POV-Ray : Newsgroups : povray.general : from quad to triangle ...? Server Time
6 Nov 2024 14:24:53 EST (-0500)
  from quad to triangle ...? (Message 1 to 7 of 7)  
From: ingo
Subject: from quad to triangle ...?
Date: 25 May 2004 19:18:57
Message: <Xns94F5D63150A8seed7@news.povray.org>
While working on a mesh2 to *obj converter I ran into a problem. It 
seems that is important to the obj file and applications that use it how 
a quad is dividen in triangles. Or better, in what order the vertices 
should be specified, counteclockwise.

D     C
------
|   /|
|  / |
| /  |
|/   |
------
A     B

It wants <A,B,C>, <D,A,C>. Otherwise the normals get messed up, even if 
no normals are specified in the obj file. I only have to Poseray to test 
this and assume it works the right way.

Is there a consensus on how to specify quads>triangles in the CG world?

Is there a way to figure out from a list of face_indices and vertices in 
what way the faces are written?

For POV-Ray it doesn't seem to matter how the faces are arranged, as I 
noticed when writing the mesh macros. I there for no specific reason 
chose for <A,B,D><A,C,D>. This becomes a mess when converting to *obj :(


Ingo


Post a reply to this message

From: Fredrik Eriksson
Subject: Re: from quad to triangle ...?
Date: 25 May 2004 20:01:44
Message: <opr8kydfmfcs6ysw@news.povray.org>
On 25 May 2004 19:18:57 -0400, ingo <ing### [at] tagpovrayorg> wrote:
> Is there a consensus on how to specify quads>triangles in the CG world?

Usually, triangles/quads are specified with their vertices in  
counter-clockwise order.



> Is there a way to figure out from a list of face_indices and vertices in
> what way the faces are written?

In general, no.
If it's a closed mesh, I suppose you could examine one of the faces to see  
which order makes the normal point outward. You could do the same for an  
open mesh if you know which way at least one of the normals is supposed to  
point.



> For POV-Ray it doesn't seem to matter how the faces are arranged, as I
> noticed when writing the mesh macros.

It matters if you specify an interior texture.



-- 
FE


Post a reply to this message

From: andrel
Subject: Re: from quad to triangle ...?
Date: 26 May 2004 07:24:28
Message: <40B47E73.2030007@hotmail.com>
ingo wrote:
> While working on a mesh2 to *obj converter I ran into a problem. It 
> seems that is important to the obj file and applications that use it how 
> a quad is dividen in triangles. Or better, in what order the vertices 
> should be specified, counteclockwise.
> 
> D     C
> ------
> |   /|
> |  / |
> | /  |
> |/   |
> ------
> A     B

In fact it does not matter if the vertices are clockwise or
counterclockwise. You should keep the same order as in the quad.
So either <A,B,C> and <A,C,D> or <A,B,D> and <B,C,D> (or any
rotated form of these).

> It wants <A,B,C>, <D,A,C>. Otherwise the normals get messed up, even if 
> no normals are specified in the obj file. I only have to Poseray to test 
> this and assume it works the right way.
> 
> Is there a consensus on how to specify quads>triangles in the CG world?
> 
> Is there a way to figure out from a list of face_indices and vertices in 
> what way the faces are written?
No, unless you assume that the objects have finite volume and you are
willing to reconstruct the whole object and do some inside/outside
tests. Luckily there is no need to know, just keep the same orientation.

> For POV-Ray it doesn't seem to matter how the faces are arranged, as I 
> noticed when writing the mesh macros. 
It does matter. Normally you do not notice it except if you use
interior_texture. I would not be surprised if there are also problems
if you use interior media in self intersecting objects.
> I there for no specific reason 
> chose for <A,B,D><A,C,D>. This becomes a mess when converting to *obj :(
I assume a typo here, these two triangles do not fill the quad.
> 
> Ingo


Post a reply to this message

From: Warp
Subject: Re: from quad to triangle ...?
Date: 26 May 2004 10:37:27
Message: <40b4aba7@news.povray.org>
Note that converting a quad into two triangles may be the most efficient
way if the amount of triangles is concerned, but it's not the best way
if you are texturing the polygon with uv-mapping.
  This image explains why:

http://www.cs.tut.fi/~warp/images/uvproblem.gif

  (And no, that image has no perspective. I bet all my money someone would
comment something about perspective correction (which has nothing to do
with this since there's no perspective projection anywhere).)

  I don't know if there exists any solution to this problem.

-- 
#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: John VanSickle
Subject: Re: from quad to triangle ...?
Date: 26 May 2004 19:04:32
Message: <40B52279.1BA96716@hotmail.com>
ingo wrote:
> 
> While working on a mesh2 to *obj converter I ran into a problem. It
> seems that is important to the obj file and applications that use it how
> a quad is dividen in triangles. Or better, in what order the vertices
> should be specified, counteclockwise.
> 
> D     C
> ------
> |   /|
> |  / |
> | /  |
> |/   |
> ------
> A     B
> 
> It wants <A,B,C>, <D,A,C>. Otherwise the normals get messed up, even if
> no normals are specified in the obj file. I only have to Poseray to test
> this and assume it works the right way.
> 
> Is there a consensus on how to specify quads>triangles in the CG world?
> 
> Is there a way to figure out from a list of face_indices and vertices in
> what way the faces are written?

My New Surface Subdivision Suite contains code that does this.  It was
posted to p.b.scene-files a few days ago.

Basically you look at each edge, and see the way the vertices of that edge
are specified in the faces bordering on that edge.  If they are named in
opposite order, you're cool.

So if one triangle has the vertices A, B, and C, then the other triangle can
have vertices B,A,D, D,B,A, or A,D,B (assuming that A and B are the shared
vertices).

Regards,
John



Regards,
John


Post a reply to this message

From: Christopher James Huff
Subject: Re: from quad to triangle ...?
Date: 26 May 2004 23:09:00
Message: <cjameshuff-22FC6B.22092426052004@news.povray.org>
In article <40B### [at] hotmailcom>,
 andrel <a_l### [at] hotmailcom> wrote:

> I would not be surprised if there are also problems
> if you use interior media in self intersecting objects.

There are no problems with this. Since media uses intersections to 
decide which volume a ray is in, the only requirement is a "well 
behaved" object with no holes or stray internal surfaces.

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

From: andrel
Subject: Re: from quad to triangle ...?
Date: 27 May 2004 08:30:58
Message: <40B5DF8A.7000806@hotmail.com>
Christopher James Huff wrote:
> In article <40B### [at] hotmailcom>,
>  andrel <a_l### [at] hotmailcom> wrote:
> 
> 
>>I would not be surprised if there are also problems
>>if you use interior media in self intersecting objects.
> 
> 
> There are no problems with this. Since media uses intersections to 
> decide which volume a ray is in, the only requirement is a "well 
> behaved" object with no holes or stray internal surfaces.
> 
Am I correct that the 3D equivalent of the even/odd rule is used.
If I have a self intersecting object and I enter the object
again somewhere on the inside, I am supposed to be outside
again? Can I also create hollow objects by simply adding two
meshes? No need to invert the orientation of the inner surface?
That would be much faster then using differences, I guess.

I know I can simply try this myself, only with meshes you always
have a lot of boundary cases with rays exactly hitting a vertex
or a face 'horizontally', and in this case you could hit
two vertices and/or faces at the same time. So I guess asking
you is a more authoritative answer then any testing I can do myself.


Post a reply to this message

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