POV-Ray : Newsgroups : povray.general : How to define the normal on a single triangle? (new pov-ray user) Server Time
1 Nov 2024 21:21:57 EDT (-0400)
  How to define the normal on a single triangle? (new pov-ray user) (Message 1 to 9 of 9)  
From: Impress
Subject: How to define the normal on a single triangle? (new pov-ray user)
Date: 22 Jul 2004 13:15:00
Message: <web.40fff583897c4c6f1e9c3cfd0@news.povray.org>
I have define a single triangle with two textures, one for the backface and
frontface. However, I would like to have a bit more control over it. Here
it's my povray basic source...

// ------------------------------------------------------------
camera { location  <0.0, 4.0,  0.0> look_at <0.0, 0.0,  0.0> }
global_settings { ambient_light color rgb <10,10,10> }

triangle {
  <-1,  0, -1>,  // <Vertex1>
  < 1,  0, -1>,  // <Vertex2>
  < 0,  0,  1>   // <Vertex3>
  texture { pigment {color rgb <1,1,0>}}
  interior_texture { pigment {color rgb <0,0,1>}}
}
// ------------------------------------------------------------

I wonder how POV-RAY define the back and front of my triangle!? I try with
inside_vector into a mesh statement, but as it's say in the doc... they
give unpredicted results for open-shape!

I would like to have full control by specifying a vector (normal!?). This
way, no matter what are my three vertex, I would be sure that the front
face is the one I want! I am happy with the flat-shade surface (which is
the type of shading I look for), so that's why I prefer not using
smooth_triangle.

Thank you very much in advance!
Impress


Post a reply to this message

From: Christoph Hormann
Subject: Re: How to define the normal on a single triangle? (new pov-ray user)
Date: 22 Jul 2004 13:25:02
Message: <cdot5n$305$2@chho.imagico.de>
Impress wrote:
> I have define a single triangle with two textures, one for the backface and
> frontface. However, I would like to have a bit more control over it. Here
> it's my povray basic source...

The inside/outside of a triangle is determined by the order in which the 
vertices are given.

Christoph

-- 
POV-Ray tutorials, include files, Sim-POV,
HCR-Edit and more: http://www.tu-bs.de/~y0013390/
Last updated 06 Jul. 2004 _____./\/^>_*_<^\/\.______


Post a reply to this message

From: Shay
Subject: Re: How to define the normal on a single triangle? (new pov-ray user)
Date: 22 Jul 2004 13:50:45
Message: <40fffe75$1@news.povray.org>
Christoph Hormann wrote:

> 
> The inside/outside of a triangle is determined by the order in
> which the vertices are given. 

Only works reliably for me with the triangles enclosed in a mesh. 
Comment out the "union {" in the following code and uncomment the "mesh 
{" to see the difference.

BTW, for Impress, the normal, should you still need it, can be figured 
like this:
#local Normal = vcross ( Ver2 - Ver1, Ver3 - Ver1 );

camera {
     orthographic
     location <5,5,-10>
     look_at <5,5,0>
     right 12*x
     up 12*3/4*y
}

#local r0 = seed(123);
union {
     #local c0 = 0; #while ( c0 < 10 )
         union {
         //mesh {
             triangle { <-1,-1,1>, <-1,1,-1>, <1,1,1> }
             triangle { <-1,-1,1>, <1,-1,-1>, <-1,1,-1> }
             triangle { <-1,-1,1>, <1,1,1>, <1,-1,-1> }
             triangle { <-1,1,-1>, <1,-1,-1>, <1,1,1> }
             rotate <rand(r0),rand(r0),rand(r0)>*360
             translate <rand(r0),rand(r0),rand(r0)>*10
         }
     #local c0 = c0 + 1; #end
     texture {
         pigment { rgb x }
         finish { ambient 1 }
     }
     interior_texture {
         pigment { rgb y }
         finish { ambient 1 }
     }
}

-Shay


Post a reply to this message

From: Impress
Subject: Re: How to define the normal on a single triangle? (new pov-ray user)
Date: 22 Jul 2004 16:55:00
Message: <web.410028fc20205b2d1e9c3cfd0@news.povray.org>
Well, it's surely depends of the order. But, what's the condition that
allows Pov-Ray to put interior_texture on the triangle? I mean, if by
computing the normal length and check if it's zero or greater, the surface
receive the texture, otherwise interior_texture...? Then, I would be able
to check for that in my C++ program that generate .pov file.

Right now, the vertices of the triangle is moving over time and there's a
"flip-flap" of the front/back texture in the animation.

regards,
Impress


Post a reply to this message

From: Warp
Subject: Re: How to define the normal on a single triangle? (new pov-ray user)
Date: 23 Jul 2004 08:01:48
Message: <4100fe2c@news.povray.org>
Impress <yha### [at] nospamhotmailcom> wrote:
> I mean, if by
> computing the normal length and check if it's zero or greater, the surface
> receive the texture, otherwise interior_texture...?

  AFAIK, triangles are assigned a normal vector at parse time.
  At render time it's enough to check the sign of the dot-product of the
incoming ray and the normal vector to see if the incoming ray hit the
inner or the outer side of the triangle.

-- 
plane{-x+y,-1pigment{bozo color_map{[0rgb x][1rgb x+y]}turbulence 1}}
sphere{0,2pigment{rgbt 1}interior{media{emission 1density{spherical
density_map{[0rgb 0][.5rgb<1,.5>][1rgb 1]}turbulence.9}}}scale
<1,1,3>hollow}text{ttf"timrom""Warp".1,0translate<-1,-.1,2>}//  - Warp -


Post a reply to this message

From: Shay
Subject: Re: How to define the normal on a single triangle? (new pov-ray user)
Date: 23 Jul 2004 09:24:16
Message: <41011180@news.povray.org>
Impress wrote:
> 
> Right now, the vertices of the triangle is moving over time and
> there's a "flip-flap" of the front/back texture in the animation.

try writing your single triangle as:
mesh { triangle { p0, p1, p2 } }

  -Shay


Post a reply to this message

From: Impress
Subject: Re: How to define the normal on a single triangle? (new pov-ray user)
Date: 23 Jul 2004 13:15:01
Message: <web.4101469520205b2df3cbb6c30@news.povray.org>
The problem I've got it's that I compute my points in a C++ program that I
made. In fact, my program always output p1, p2, p3... in the same order.
The vertices got always the same distances in each other.. but, there is
two vertices that rotate around the third one. When it reach certain
degree.. the texture flip. However, because I output always p1, p2, p3...
in the same order for a specific triangle... I thought it should be
okay..!?

sprintf(strPovRay, "triangle {<%.4f, %.4f, %.4f>, <%.4f, %.4f, %.4f>, <%.4f,
%.4f, %.4f> texture{pigment{color rgb <%.4f, %.4f, %.4f>}}
interior_texture{pigment{color rgb <%.4f, %.4f, %.4f>}} transform {rotate
<%.4f, %.4f, %.4f> translate <%.4f, %.4f, %.4f>} }n",
x[i1], y[i1], z[i1],
x[i2], y[i2], z[i2],
x[i3], y[i3], z[i3],
m_dColorRedC[0+i/2], m_dColorGreenC[0+i/2], m_dColorBlueC[0+i/2],
m_dColorRedC[6+i/2], m_dColorGreenC[6+i/2], m_dColorBlueC[6+i/2], m_rotX,
m_rotY, m_rotZ, m_transX, m_transY, m_transZ);

The solution I saw to my problem.. would be to create in my C++ program..
triangles with always the same coordinate and then use POV-RAY
transformation to place it in space. I wanted to avoid that because I
wanted to avoid having too much transformation in my .pov file... Right
now, the transformation output by my program allow each object to move in
the 3D space.

regards,
Impress


Post a reply to this message

From: Warp
Subject: Re: How to define the normal on a single triangle? (new pov-ray user)
Date: 23 Jul 2004 13:37:00
Message: <41014cbb@news.povray.org>
Impress <yha### [at] nospamhotmailcom> wrote:
> The problem I've got it's that I compute my points in a C++ program that I
> made. In fact, my program always output p1, p2, p3... in the same order.
> The vertices got always the same distances in each other.. but, there is
> two vertices that rotate around the third one. When it reach certain
> degree.. the texture flip. However, because I output always p1, p2, p3...
> in the same order for a specific triangle... I thought it should be
> okay..!?

  No, you shouldn't output the points always in the same order. You should
output them always counter-clockwise with regard to the desired outwards
direction (or clockwise if you want the other direction).
  You need to compute the correct order of the two last points before
outputting them.

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: Impress
Subject: Re: How to define the normal on a single triangle? (new pov-ray user)
Date: 24 Jul 2004 14:15:00
Message: <web.4102a71320205b2db9c6e2600@news.povray.org>
Warp:

Dawm... you're absolutely right! Well, I'm very glad it's my mistake! :) I
just give an example on paper to see my mistake. Great.. then, I can fix it
easily and output another preview to see the results!

Thanks Warp for your patience! :)

Impress

btw, very nice signature.


Post a reply to this message

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