POV-Ray : Newsgroups : povray.binaries.images : placing things on mesh object ... : Re: placing things on mesh object ... Server Time
8 Aug 2024 04:08:27 EDT (-0400)
  Re: placing things on mesh object ...  
From: David El Tom
Date: 21 Sep 2005 14:27:43
Message: <4331a61f$1@news.povray.org>
Jim Charter wrote:

> I would be very interested in a conceptual description of how you did 
> this.  I know there were some "maya fur" macros written which do an even 
> distribution but I could not understand what was happening from the 
> code.  I could not use your particular script directly because I am 
> doing other things to manually control the direction and fall of hair or 
> fur.  But right now I am controlling the density and distribution 
> manually and could use a poly-based method on occasion.

I didn't looked into the part where the "maya fur"-macro process the 
mesh, but I will give a short inside look what the PERL script does.

First it parses the mesh file and stores the vertex- and normal-data as 
well the face indices for both. Then it calculates the area of each 
triangle and the total sum of these areas. With a given density of 
objects to place on the mesh it then calculates the probability how many 
objects would be on each facette of the mesh. The integer part is placed 
for sure and the broken part is placed by random (adjusted to the 
probability). In this way I make sure that the total number of placed 
objects differes only a little bit from whished value.

The placing on the facettes is done in the following manner:

For each facette find two linear independent vectors which are lying on 
the surface. You have the 3 corners of the triangle, so I just build the 
two difference vectors P2->P1 and P2->P3:

                    P1
                    ^\
                    | \
                    |  \
                    |   \
                    P2-->P3

For each object to be placed find 2 values, u and v, so that
   ((u+v) <= 1)
to make sure that any possible linear combination of the form
    P2 + (u* P2->P1) + (v* P2->P3)
is located inside the triangle.

The normal at this point can then be calculated by:
   (u*N1 + (1-u)*N2) + (v*N3 + (1-v)*N2)
and normalise the resulting vector.

The calculation for the texture-coordinates would look the same.

hope I wrote it not too confusing ...

... dave


Post a reply to this message

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