POV-Ray : Newsgroups : povray.advanced-users : Re: ..triangle? For Tim, ABX, Christopher : Re: ..triangle? For Tim, ABX, Christopher Server Time
29 Jul 2024 00:29:45 EDT (-0400)
  Re: ..triangle? For Tim, ABX, Christopher  
From: Christopher James Huff
Date: 8 Jul 2003 15:27:33
Message: <cjameshuff-317238.14250208072003@netplex.aussie.org>
In article <3f0b090d@news.povray.org>, "Jaap Frank" <jjf### [at] xs4allnl> 
wrote:

> I am working with a closed mesh() and wanted to see if there were 
> holes in it (I think there are) and used 'interior_texture'. It gave 
> many triangles with the 'interior_texture'. If I altered the sequence 
> of the vertices of some triangles, it didn't matter much. Some did 
> change, but other didn't.

    It is known to work in meshes. The height field macros, for example, 
were designed to give triangles with the correct ordering, so 
interior_texture works with the resulting meshes. It should work with 
plain triangles as well, the normal is computed internally as:

  VSub(V1, Triangle->P1, Triangle->P2);
  VSub(V2, Triangle->P3, Triangle->P2);

  VCross(Triangle->Normal_Vector, V1, V2);

    However, part of the code in Compute_Triangle() changes the ordering 
of the points (after the normal has been computed). Transforming the 
triangle causes this function to be called again, this time using the 
swapped around vertices to compute the normal, so the original winding 
is lost. This could be considered a bug, but never mattered before the 
inside_texture feature. The best solution would be to call the 
Compute_Triangle() function just once, after all the changes to the 
triangle have been made, but this would take a fairly large amount of 
work. It should have no effect on triangles in meshes, as the 
transformation is applied to the entire mesh. (the mesh data can not be 
transformed, because it may be used by other mesh objects)
    As a workaround, you could simply transform the triangle vertices 
instead of the entire triangle.

#macro TransformedTriangle(P1, P2, P3, Trans)
    #local TransFn = function {transform {Trans}}
    triangle {TransFn(P1.x, P1.y, P1.z),
              TransFn(P1.x, P1.y, P1.z),
              TransFn(P1.x, P1.y, P1.z)
    }
#end

    This could also be useful in meshes, where you can't apply 
transforms to individual triangles.


> I did remember something about 'clock wise' or 'counter clock wise' but
> my example file told me something different. That's why I asked.
> I will try the 'inside_vector' and see if it helps.

    The inside_vector feature only affects solidity, it will have no 
effect here.

-- 
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.