POV-Ray : Newsgroups : povray.programming : Help me pls! Turning list of points into triangle mesh? Server Time
28 Jul 2024 16:31:21 EDT (-0400)
  Help me pls! Turning list of points into triangle mesh? (Message 1 to 10 of 28)  
Goto Latest 10 Messages Next 10 Messages >>>
From: Cliff Bowman
Subject: Help me pls! Turning list of points into triangle mesh?
Date: 28 Aug 1999 20:35:38
Message: <37c87e27.11046292@news.povray.org>
Hi - I'm trying to write a converter for Wavefront .OBJ file to uvPOV.
It's going quite well so far but... there are a few oddities to some
OBJ files which I've yet to find "the best" solution to.

For example.

Some .OBJ faces comprise more than 4 points. I've successfully tested
turning 4 points into 2 triangles, and this seems to work well. Does
anyone know how to reliably turn faces with more points into triangle
meshes? Or has anyone happened on a procedure which "happens to work"
(like my 1,2,3 - 3,4,1 procedure for 4-point faces)?

Other issues revolve around .OBJ files containing degenerate triangles
(sorted. Silly, but sorted) and having normals for only SOME of the
verteces of a triangle - at the moment I'm fudging this by using a
standard triangle (instead of a smooth triangle) for any triangle
which doesn't have a full set of normals.

Any help would be greatly appreciate :)


Cheers,

Cliff Bowman
Why not pay my 3D Dr Who site a visit at http://www.who3d.cwc.net/


Post a reply to this message

From: Ken
Subject: Re: Help me pls! Turning list of points into triangle mesh?
Date: 28 Aug 1999 21:42:54
Message: <37C88FE3.A217287D@pacbell.net>
Cliff Bowman wrote:
> 
> Hi - I'm trying to write a converter for Wavefront .OBJ file to uvPOV.
> It's going quite well so far but... there are a few oddities to some
> OBJ files which I've yet to find "the best" solution to.
> 
> For example.
> 
> Some .OBJ faces comprise more than 4 points. I've successfully tested
> turning 4 points into 2 triangles, and this seems to work well. Does
> anyone know how to reliably turn faces with more points into triangle
> meshes? Or has anyone happened on a procedure which "happens to work"
> (like my 1,2,3 - 3,4,1 procedure for 4-point faces)?
> 
> Other issues revolve around .OBJ files containing degenerate triangles
> (sorted. Silly, but sorted) and having normals for only SOME of the
> verteces of a triangle - at the moment I'm fudging this by using a
> standard triangle (instead of a smooth triangle) for any triangle
> which doesn't have a full set of normals.
> 
> Any help would be greatly appreciate :)
> 
> Cheers,
> 
> Cliff Bowman
> Why not pay my 3D Dr Who site a visit at http://www.who3d.cwc.net/

I wonder if Thomas has had similar problems. I have noticed that when converting
some models with 3DWin that no matter what the smoothing angle specified there
are some times a few to several triangles that are still represented as simple
triangles instead of as smooth triangles.

-- 
Ken Tyler

See my 850+ Povray and 3D Rendering and Raytracing Links at:
http://home.pacbell.net/tylereng/index.html


Post a reply to this message

From: Mark Gordon
Subject: Re: Help me pls! Turning list of points into triangle mesh?
Date: 29 Aug 1999 00:22:52
Message: <37C8B5CD.73D0B940@mailbag.com>
Cliff Bowman wrote:
> 
> Some .OBJ faces comprise more than 4 points. I've successfully tested
> turning 4 points into 2 triangles, and this seems to work well. Does
> anyone know how to reliably turn faces with more points into triangle
> meshes? Or has anyone happened on a procedure which "happens to work"
> (like my 1,2,3 - 3,4,1 procedure for 4-point faces)?

Polygon triangulation is a pretty well-studied problem in computational
geometry.  Any textbook on computational geometry ought to have a
lengthy discussion of the topic.  Most of that is overkill, though.

If the polygons are convex, the simplest approach I know of is: 

-pick a point arbitrarily and call it 1
-number the rest of the points around the edge of the polygon as you did
previously, but keep going beyond 4
-divide the face up so it looks rather like a clamshell, with an edge
running from 1 to each of the other vertices
-triangles are <1,2,3>, <3,4,1>, <1, 4, 5>, <5, 6, 1> ...

If the polygons are not convex, recursively lop off pointy bits as
triangles until they are.  There's a bit of hand-waving there, but I'm
trying to wave my hand in the direction of the literature if you need
that kind of detail (not sure you do).

There are some efficiency concerns that are addressed in the literature,
but they are mostly of use to 2-D graphics, where polygons with large
numbers of vertices are used to approximate 2-D curves.  In 3-D
graphics, one seldom sees more N-gons with N>6 (except when the big 2-D
curve approximations get ducted, but that's an isolated case).

-- 
Mark Gordon
mtg### [at] povrayorg


Post a reply to this message

From: Remco de Korte
Subject: Re: Help me pls! Turning list of points into triangle mesh?
Date: 29 Aug 1999 04:51:36
Message: <37C8F591.DE8779F6@xs4all.nl>
Cliff Bowman wrote:
> 
> Hi - I'm trying to write a converter for Wavefront .OBJ file to uvPOV.
> It's going quite well so far but... there are a few oddities to some
> OBJ files which I've yet to find "the best" solution to.
> 
> For example.
> 
> Some .OBJ faces comprise more than 4 points. I've successfully tested
> turning 4 points into 2 triangles, and this seems to work well. Does
> anyone know how to reliably turn faces with more points into triangle
> meshes? Or has anyone happened on a procedure which "happens to work"
> (like my 1,2,3 - 3,4,1 procedure for 4-point faces)?
> 
> Other issues revolve around .OBJ files containing degenerate triangles
> (sorted. Silly, but sorted) and having normals for only SOME of the
> verteces of a triangle - at the moment I'm fudging this by using a
> standard triangle (instead of a smooth triangle) for any triangle
> which doesn't have a full set of normals.
> 
> Any help would be greatly appreciate :)
> 
> Cheers,
> 
> Cliff Bowman
> Why not pay my 3D Dr Who site a visit at http://www.who3d.cwc.net/

I don't know if this'll alway work but I would calculate a 'middle'-point (M)
(adding up aal points in the object and dividing them by the amount of points)
then step through the row of points connecting two consecutive points to this M
(creating a triangle. 
Sounds like a fun experimenting thing...

Remco


Post a reply to this message

From: Margus Ramst
Subject: Re: Help me pls! Turning list of points into triangle mesh?
Date: 29 Aug 1999 09:58:49
Message: <37C93C8B.71645AF0@peak.edu.ee>
This will not always work if the polygon is not convex. M could end up outside
the polygon.

Margus

Remco de Korte wrote:
> 
> I don't know if this'll alway work but I would calculate a 'middle'-point (M)
> (adding up aal points in the object and dividing them by the amount of points)
> then step through the row of points connecting two consecutive points to this M
> (creating a triangle.
> Sounds like a fun experimenting thing...
> 
> Remco


Post a reply to this message

From: Mark Gordon
Subject: Re: Help me pls! Turning list of points into triangle mesh?
Date: 29 Aug 1999 10:18:03
Message: <37C9414C.AA299D4E@mailbag.com>
Remco de Korte wrote:
> 
> I don't know if this'll alway work but I would calculate a 'middle'-point (M)
> (adding up aal points in the object and dividing them by the amount of points)
> then step through the row of points connecting two consecutive points to this M
> (creating a triangle.

If the polygon is planar, there is no benefit to this approach.  If the
polygons are approximations of curved surfaces or the vertices are
points on a curved surface, picking a point in the middle and
reevaluating the surface function at that point does make some sense. 
If adding points isn't necessary, then adding points will increase the
number of triangles and thereby decrease performance.  If the polygon is
planar, just pick an existing vertex and draw edges to all the other
points. If all the narrow angles cause acne or something due to loss of
precision, though, your idea may be worth a shot.  I haven't actually
tried it.

-- 
Mark Gordon
mtg### [at] povrayorg


Post a reply to this message

From: Remco de Korte
Subject: Re: Help me pls! Turning list of points into triangle mesh?
Date: 29 Aug 1999 11:21:45
Message: <37C9513A.D01076A7@xs4all.nl>
Margus Ramst wrote:
> 
> This will not always work if the polygon is not convex. M could end up outside
> the polygon.
> 
> Margus
> 

I know, that's why I mentioned that I didn't know it will always work. By that I
didn't mean in general but in this particular situation. I was also assuming
that a polygone would be defined by points neatly arranged around the edge. In
the latter case I think you have a real problem. With a convex polygon the
solution is not very difficult but it'll result in even more triangles. 

Remco


Post a reply to this message

From: Cliff Bowman
Subject: Re: Help me pls! Turning list of points into triangle mesh?
Date: 29 Aug 1999 13:09:14
Message: <37c9693b.1676953@news.povray.org>
On Sat, 28 Aug 1999 18:41:55 -0700, Ken <tyl### [at] pacbellnet> wrote:

[snip]
>I wonder if Thomas has had similar problems. I have noticed that when converting
>some models with 3DWin that no matter what the smoothing angle specified there
>are some times a few to several triangles that are still represented as simple
>triangles instead of as smooth triangles.
>
>-- 
It wouldn't surprise me. I'm finding that the contents of .OBJ files
are, at times, incredibly erm... disorganised.

BTW check your e-mail :)


Cheers,

Cliff Bowman
Why not pay my 3D Dr Who site a visit at http://www.who3d.cwc.net/


Post a reply to this message

From: Cliff Bowman
Subject: Re: Help me pls! Turning list of points into triangle mesh?
Date: 29 Aug 1999 13:12:39
Message: <37c969e1.1842283@news.povray.org>
On Sun, 29 Aug 1999 09:18:52 -0500, Mark Gordon <mtg### [at] mailbagcom>
wrote:

>Remco de Korte wrote:
>> 
>> I don't know if this'll alway work but I would calculate a 'middle'-point (M)
>> (adding up aal points in the object and dividing them by the amount of points)
>> then step through the row of points connecting two consecutive points to this M
>> (creating a triangle.
>
>If the polygon is planar, there is no benefit to this approach.  If the
>polygons are approximations of curved surfaces or the vertices are
>points on a curved surface, picking a point in the middle and
>reevaluating the surface function at that point does make some sense. 
>If adding points isn't necessary, then adding points will increase the
>number of triangles and thereby decrease performance.  If the polygon is
>planar, just pick an existing vertex and draw edges to all the other
>points. If all the narrow angles cause acne or something due to loss of
>precision, though, your idea may be worth a shot.  I haven't actually
>tried it.
>
I think what I'm going to ahve to do is write a "face preview"
facility in OBJuvPOV I think. So that I can *see* what the program's
encountering to help me evaluate which tack might work (I'm not good
at math - I've not the first idea how to work out if a face is planar
given just the verteces - unless they happen to lie along one of the
axes, of course!).


Cheers,

Cliff Bowman
Why not pay my 3D Dr Who site a visit at http://www.who3d.cwc.net/


Post a reply to this message

From: Mark Gordon
Subject: Re: Help me pls! Turning list of points into triangle mesh?
Date: 29 Aug 1999 21:07:56
Message: <37C9D99F.CAB834ED@mailbag.com>
Cliff Bowman wrote:
> 

> I think what I'm going to ahve to do is write a "face preview"
> facility in OBJuvPOV I think. So that I can *see* what the program's
> encountering to help me evaluate which tack might work (I'm not good
> at math - I've not the first idea how to work out if a face is planar
> given just the verteces - unless they happen to lie along one of the
> axes, of course!).

Any three points define a plane.  Derive an equation of that plane from
the vertices, and test the other points to see whether they lie on that
plane.  Actually, you should expect a little deviation from the plane on
account of finite precision, so test whether the point is within some
small distance epsilon of the plane.

-- 
Mark Gordon
mtg### [at] povrayorg


Post a reply to this message

Goto Latest 10 Messages Next 10 Messages >>>

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