POV-Ray : Newsgroups : povray.general : mesh question Server Time
5 Nov 2024 14:20:20 EST (-0500)
  mesh question (Message 1 to 9 of 9)  
From: Alf Peake
Subject: mesh question
Date: 4 Feb 2005 15:40:22
Message: <4203ddb6$1@news.povray.org>
How do I select which diagonal to use when converting quads to 2
triangles? I need to use information from 2 adjacent quads? I can't
figure it out :(  Any online suggestions?

The vertices are stored in an array
  #declare Verts = array[N][NPoints+1];

and the quads are extracted (clockwise) in nested loops
  #declare Tp1 = Verts[Count][VPt];
  #declare Tp2 = Verts[Count][VPt+1];
  #declare Tp3 = Verts[Count+1][VPt+1];
  #declare Tp4 = Verts[Count+1][VPt];

TIA

Alf


Post a reply to this message

From: Sascha Ledinsky
Subject: Re: mesh question
Date: 4 Feb 2005 17:41:05
Message: <4203fa01$1@news.povray.org>
> How do I select which diagonal to use when converting quads to 2
> triangles? 

It should not matter...

-Sascha


Post a reply to this message

From: Tim Nikias
Subject: Re: mesh question
Date: 4 Feb 2005 18:17:55
Message: <420402a3$1@news.povray.org>
> > How do I select which diagonal to use when converting quads to 2
> > triangles?
>
> It should not matter...

It does. A general solution is to connect using the shortest diagonal. If
you don't, you can get very stretched triangles, which don't look too good
for texture/phong-interpolation. This might not be that big an issue in most
cases, but in extreme cases, you want to have a fairly even triangle instead
of long and sharp ones.

Regards,
Tim
-- 
"Tim Nikias v2.0"
Homepage: <http://www.nolights.de>


Post a reply to this message

From: Warp
Subject: Re: mesh question
Date: 5 Feb 2005 05:41:15
Message: <4204a2cb@news.povray.org>
Sascha Ledinsky <sas### [at] userssourceforgenet> wrote:
> > How do I select which diagonal to use when converting quads to 2
> > triangles? 

> It should not matter...

  Actually it matters when you use uv-mapping. This graphic illustrates
the problem in question:

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

  (Let's see who is the first to wrongly answer something related to
perspective... ;) )

-- 
#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: Alf Peake
Subject: Re: mesh question
Date: 5 Feb 2005 09:32:50
Message: <4204d912$1@news.povray.org>
"Sascha Ledinsky" wrote:
>> How do I select which diagonal to use when converting quads to 2
>> triangles?
>
> It should not matter...

This image of the leading edge of an aircraft wing using large 
triangles, shows the problem:

http://www.peake42.freeserve.co.uk/pix2/mesh1.jpg  13K

It looked like the shadow line artifact but if I flip the diagonals 
the surface looks OK. Unfortunately, the problem re-appears elsewhere 
:c(


Post a reply to this message

From: Alf Peake
Subject: Re: mesh question
Date: 5 Feb 2005 09:32:54
Message: <4204d916@news.povray.org>
"Tim Nikias" wrote:
>
> A general solution is to connect using the shortest diagonal.

Ahhh...  Thank you. There's always a simple answer. I'll try that.

> If you don't, you can get very stretched triangles, which don't
> look too good for texture/phong-interpolation.

Thanks again. See the link in my reply to Sascha.

> This might not be that big an issue in most cases, but in extreme
> cases, you want to have a fairly even triangle instead of long and
> sharp ones.

This is easily sorted. The wing rib outlines are stored in an array of 
splines so I only need to interpolate between splines. Unfortunately 
this will increase the triangle count. Oh well - I've got 1G ram now 
so press on :c)

Note: I started this WIP around 3 years ago, and it has been abandoned 
many times ;) See
http://news.povray.org/povray.binaries.images/thread/%3C3c6d9fde@news.povray.org%3E/?ttop=189070&toff=3000

Subject: Framed, an X-WIP (34k)
Date: 15 Feb 2002 23:55:10

Alf


Post a reply to this message

From: Sascha Ledinsky
Subject: Re: mesh question
Date: 5 Feb 2005 15:44:14
Message: <4205301e$1@news.povray.org>
Oops... of course you're right!

Tim Nikias wrote:
>>>How do I select which diagonal to use when converting quads to 2
>>>triangles?
>>
>>It should not matter...
> 
> 
> It does. A general solution is to connect using the shortest diagonal. If
> you don't, you can get very stretched triangles, which don't look too good
> for texture/phong-interpolation. This might not be that big an issue in most
> cases, but in extreme cases, you want to have a fairly even triangle instead
> of long and sharp ones.
> 
> Regards,
> Tim


Post a reply to this message

From: Sascha Ledinsky
Subject: Re: mesh question
Date: 5 Feb 2005 16:19:42
Message: <4205386e$1@news.povray.org>
>   Actually it matters when you use uv-mapping.

Thats interesting, I never thought about that...

This leads to the question: Does splitting along the shorter diagonal 
also give better results concerning u/v mapping? I drew a few irregular 
quads and by taking a look at how they would be u/v mapped I got the 
impression that splitting along the longer diagonal might be slightly 
"better"...

Is there anything that can be done about it (e.g. are OpenGL quads meant 
to somehow overcome this kind of problem)?

-Sascha


Post a reply to this message

From: Warp
Subject: Re: mesh question
Date: 5 Feb 2005 18:57:00
Message: <42055d4c@news.povray.org>
Sascha Ledinsky <sas### [at] userssourceforgenet> wrote:
> Is there anything that can be done about it (e.g. are OpenGL quads meant 
> to somehow overcome this kind of problem)?

  OpenGL quads show this exact problem when the quad is not rectangular
nor rhomboidal (ie opposite sides are not parallel). This (d)effect
can be clearly seen in many cases, for example if you tesselate a
torus with quads (the quads at the upper and lower side of the torus
will exhibit this problem).

  Theoretically there exists a method for avoiding this problem, but
I have not heard any 3D hardware (nor even software) using it:
Render quads as quads, not two triangles, and scale the texture
non-uniformly to adjust to the shape of the quad (as in the
to-be-expected illustration in the image I gave a link to).
  In fact, you can even render the quad as two triangles given
that there's a proper correction factor applied to the texture
of the triangles.
  However, as I said, I have never heard of any 3D hardware
supporting this (nor know of any software which would support it).

  Often you can avoid the problem with better modelling. For example,
in the case of tesselating a torus, you could use triangles placed
so that this effect does not present itself (ie. in a kind of
hexagonal grid on the surface of the torus). However, I'm sure there
are instances where there's no good workaround.

  (Btw, one could hastily think that dividing the quad into four
triangles could solve or at least alleviate the problem, but if you
think about how it would be textured you will realize it will not
help too much.)

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

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