POV-Ray : Newsgroups : povray.general : How to place objects randomly in the visible area of image? Server Time
4 Aug 2024 06:13:02 EDT (-0400)
  How to place objects randomly in the visible area of image? (Message 1 to 5 of 5)  
From: Janne
Subject: How to place objects randomly in the visible area of image?
Date: 22 Jul 2003 07:26:19
Message: <3f1d1f5b$1@news.povray.org>
Hi,
How can I test if a randomly selected point is visible to my camera? I need
to place a lot of objects in my scene, but I run out of memory if I place
objects over the whole scene.

Janne


Post a reply to this message

From: Warp
Subject: Re: How to place objects randomly in the visible area of image?
Date: 22 Jul 2003 07:33:30
Message: <3f1d210a@news.povray.org>
Janne <kos### [at] kolumbusfi> wrote:
> How can I test if a randomly selected point is visible to my camera? I need
> to place a lot of objects in my scene, but I run out of memory if I place
> objects over the whole scene.

  This depends on whether you have reflections/refractions or not. If you
have them, then forget it.

  However, if you don't have them, then you only need to test whether the
object is directly visible on camera.
  Someone posted some time ago a tip for this: Using screen.inc, create
a box which completely and exactly covers the image area. For testing
whether an object is visible, you only need to call trace() from the
object location to the camera location and see if it hits the box.

  There is also a mathematical way of doing it, but the tip above might
be the easiest way.

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: ABX
Subject: Re: How to place objects randomly in the visible area of image?
Date: 22 Jul 2003 07:44:22
Message: <758qhvolh9p5a5f4crfoqjorbn20o38aes@4ax.com>
On Fri, 18 Jul 2003 15:32:24 +0300, "Janne" <kos### [at] kolumbusfi> wrote:
> Hi,
> How can I test if a randomly selected point is visible to my camera? I need
> to place a lot of objects in my scene, but I run out of memory if I place
> objects over the whole scene.


Here is simple method:

 1. Get camera location in point L
 2. Get rectangle of screen in scene coordinates - vertices at P1,P2,P3,P4
 3. Declare mesh M with triangle T1=P1-P2-P3 and T2=P1-P3-P4 to mimic screen

 loop:

    4. Get random location in point A
    5. Use trace function with ray from L to A.
    6. Check if sended ray intersected mesh M.
    7. If intersected then use point A to locate object.
    8. If not enough founded locations then repeat loop.

 9. Render
10. Show result in povray.binaries.images

ABX


Post a reply to this message

From: Gilles Tran
Subject: Re: How to place objects randomly in the visible area of image?
Date: 22 Jul 2003 09:51:05
Message: <3f1d4149$1@news.povray.org>

3f1d1f5b$1@news.povray.org...
> Hi,
> How can I test if a randomly selected point is visible to my camera? I
need
> to place a lot of objects in my scene, but I run out of memory if I place
> objects over the whole scene.

Look for the makestacks.inc file in the advanced/blocks demo scene
directory. There's a routine at the beginning that does exactly that.

G.


--

**********************
http://www.oyonale.com
**********************
- Graphic experiments
- POV-Ray and Poser computer images
- Posters


Post a reply to this message

From: Christopher James Huff
Subject: Re: How to place objects randomly in the visible area of image?
Date: 22 Jul 2003 10:36:44
Message: <cjameshuff-569470.09294622072003@netplex.aussie.org>
In article <3f1d210a@news.povray.org>, Warp <war### [at] tagpovrayorg> 
wrote:

> Janne <kos### [at] kolumbusfi> wrote:
> > How can I test if a randomly selected point is visible to my camera? I need
> > to place a lot of objects in my scene, but I run out of memory if I place
> > objects over the whole scene.
> 
>   This depends on whether you have reflections/refractions or not. If you
> have them, then forget it.

Radiosity can also make a difference. Even shadows can make an object 
out of the field of view have a significant effect. And you would have 
to test the corners of the bounding box for each object, not just one 
point...it may be visible even if that one point is out of the field of 
view.


>   There is also a mathematical way of doing it, but the tip above might
> be the easiest way.

Also note that you would have to use a different method for different 
camera types.

It might be possible to reduce the memory consumption of the scene some 
other way...using copies of meshes, for example. This might be a better 
solution than placing objects only where they are directly visible.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.