Delgine 3D Tools & Content DeleD Community Edition
Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Exporting triangle meshes

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    DeleD Community Edition Forum Index -> DeleD Plugins
View previous topic :: View next topic  
Author Message
Grandmaster B
DeleD PRO user


Joined: 03 Jul 2007
Posts: 218

PostPosted: Tue Feb 12, 2008 9:05 pm    Post subject: Exporting triangle meshes Reply with quote

Im writing a exporter that needs triangulated polygons.
I want the plugin do the triangulation.

I thought of using these vertex indices:
0-1-2
0-2-3
0-3-4
0-4-5
...

Does that work or do i need a more complex algorithm?
Back to top
View user's profile Send private message
Mr.Fletcher
DeleD PRO user


Joined: 07 Aug 2004
Posts: 1772
Location: Germany

PostPosted: Tue Feb 12, 2008 9:10 pm    Post subject: Reply with quote

It will work if the polygon is convex, which would need the modeler to pay attention to, but generally is being avoided anyway.
//edit
Non-convex polygons are being avoided, I mean.
_________________
Behold! The DeleD Wiki! Please help us expanding it Smile
DeleD on IRC
Back to top
View user's profile Send private message
Jeroen
Site Admin


Joined: 07 Aug 2004
Posts: 5332
Location: The Netherlands

PostPosted: Tue Feb 12, 2008 9:41 pm    Post subject: Reply with quote

A modeler could use the Optimize routine which will make sure concave polygons are broken into convex ones.

@Grandmaster B: are you using ear-clipping triangulation? If so, you won't need to worry about concave polygons as ear-clipping will work with those also.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Grandmaster B
DeleD PRO user


Joined: 03 Jul 2007
Posts: 218

PostPosted: Wed Feb 13, 2008 10:28 am    Post subject: Reply with quote

Thanks for your answers!

I did not know the ear-clipping triangulation but it looks interesting.
Back to top
View user's profile Send private message
Paul-Jan
Site Admin


Joined: 08 Aug 2004
Posts: 3066
Location: Lage Zwaluwe

PostPosted: Wed Feb 13, 2008 11:13 am    Post subject: Reply with quote

In additional to what the others said, what you were originally doing is often referred to as "fan triangulation". Hope that helps while googling. Very Happy
Back to top
View user's profile Send private message Visit poster's website
Grandmaster B
DeleD PRO user


Joined: 03 Jul 2007
Posts: 218

PostPosted: Wed Feb 13, 2008 10:13 pm    Post subject: Reply with quote

Thanks! Im currently going with the fan triangulation. But i will eventually try a triangulation that removes redunant vertices produced by CSG (vertices that visually share the same edge).
Back to top
View user's profile Send private message
Grandmaster B
DeleD PRO user


Joined: 03 Jul 2007
Posts: 218

PostPosted: Sat Feb 16, 2008 1:25 pm    Post subject: Reply with quote

Hi, ive made a simple plugin that merges redundant edges. The goal was to archive a better triangulation afterwards. It works by merging edges that share the same vector (on a polygon basis) (see example 2).

Example 1: CSG united geometry triangulated (Standard):


The same geometry but with merged edges and then triangulated:


Example 2: A single polygon with many redundant edges/vertices:


After using the plugin:


You may not see the result before you triangulate your model! Also note that the plugin has no effect on already triangulated primitives, but you may "Optimize" beforehand.

The plugin destroys some connectivity on the meshes polygons what may have side effects for modelling. Also you may loose some non uniform UV mapping, but this is rare. Anyway i recommend to save a backup first.

Heres the plugin:
http://www.odagames.de/EdgeMerge.dll

This is the XML parser DLL i used, put the file into your C:\Windows\System\ folder:
http://www.odagames.de/libexpat.dll
Back to top
View user's profile Send private message
Mr.Fletcher
DeleD PRO user


Joined: 07 Aug 2004
Posts: 1772
Location: Germany

PostPosted: Sat Feb 16, 2008 1:48 pm    Post subject: Reply with quote

But doesn't optimize do this too?
_________________
Behold! The DeleD Wiki! Please help us expanding it Smile
DeleD on IRC
Back to top
View user's profile Send private message
Grandmaster B
DeleD PRO user


Joined: 03 Jul 2007
Posts: 218

PostPosted: Sat Feb 16, 2008 2:02 pm    Post subject: Reply with quote

No. Theres no easy way to do this in DeleD. Optimize merges polygons but does not remove or merge edges in these polygons (it only seems so!).

When you export for a game you always need trianglulated meshes but the current implementation produces more triangles because there may be redunant edges (for games!) in the polygons. These edges keep the geometry "solid" but may have no usage for finished work.

Example 3: A level once triangulated normally and once after using the plugin. What would you prefer in your game engine?


Back to top
View user's profile Send private message
Daaark
DeleD PRO user


Joined: 01 Sep 2004
Posts: 2696
Location: Ottawa, Canada

PostPosted: Sat Feb 16, 2008 2:29 pm    Post subject: Reply with quote

Your shots looks cool, but the shots you use as DeleD's results don't even resemble DeleD's results. Deled turns a quad into 2 triangles, not the strange results you show off in this shot:



How the hell did DeleD turn that floor into so many triangles?
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Jeroen
Site Admin


Joined: 07 Aug 2004
Posts: 5332
Location: The Netherlands

PostPosted: Sat Feb 16, 2008 2:53 pm    Post subject: Reply with quote

Grandmaster B wrote:
No. Theres no easy way to do this in DeleD. Optimize merges polygons but does not remove or merge edges in these polygons (it only seems so!).

When you export for a game you always need trianglulated meshes but the current implementation produces more triangles because there may be redunant edges (for games!) in the polygons. These edges keep the geometry "solid" but may have no usage for finished work.


I like your plugin, good work!

A few random comments that come to my mind:

The Optimize command definately removes redundant vertices. You can test this by creating a simple cube, selecting a few edges and splitting them, and then use the Optimize command. You'll end up with your original cube again.

Your triangulation routine actually doesn't create triangles in all cases. It creates triangular polygons. That is, polygons that can have more than 3 vertices but are shaped in a triangular form. I wonder what graphics cards and/or game engines do with these polygons. My guess is that they will still be triangulated to real triangles (thus having only 3 vertices). But even if such polygons are triangulated by the game engine after all, the person that's doing the modeling will benefit still. I rather work with one triangular polygon than with lots and lots of little real triangles. So good job! Smile

@Daaark: that screenshot seems OK to me. Every vertex in that floor polygon has to be accounted for and as DeleD creates real triangles (3 vertices per polygon), you can get results like that. To test this, simply create a polyline, split up a few of its edges and use Normal Triangulation.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Grandmaster B
DeleD PRO user


Joined: 03 Jul 2007
Posts: 218

PostPosted: Sat Feb 16, 2008 5:00 pm    Post subject: Reply with quote

Quote:
How the hell did DeleD turn that floor into so many triangles?

CSG!

Thanks for your comments. I must say that the plugin itself does not triangulate, it only removes edges from polygons. Thats, it only prepares for good triangulation. The triangulation in all images are made with the build-in tool!

Also the plugin is in no way meant as a replacement for Optimize, in fact its works best when Optimize is used before and maybe after it.

Ive tried and seen that Optimize will also removes edges like in example 2. But its not intended to break up connection between polys and thus will not produce the result like in example 1 and 3. Optimize preserves CSG and thus cannot remove these edges.


Last edited by Grandmaster B on Sat Feb 16, 2008 5:07 pm; edited 1 time in total
Back to top
View user's profile Send private message
Daaark
DeleD PRO user


Joined: 01 Sep 2004
Posts: 2696
Location: Ottawa, Canada

PostPosted: Sat Feb 16, 2008 5:06 pm    Post subject: Reply with quote

Jeroen wrote:
@Daaark: that screenshot seems OK to me. Every vertex in that floor polygon has to be accounted for and as DeleD creates real triangles (3 vertices per polygon), you can get results like that. To test this, simply create a polyline, split up a few of its edges and use Normal Triangulation.
My answer to that is improper modeling technique.



This has to be one of the biggest wastes I've ever seen. This should have been made with 3 rectangles. One for the main floor, and 2 more for the parts that come off. As is, it's an abuse of the polyline tool.
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
jwatte
DeleD PRO user


Joined: 26 Apr 2006
Posts: 513

PostPosted: Sat Feb 16, 2008 8:47 pm    Post subject: Reply with quote

I would totally prefer the upper image. The lower image is chock full of T junctions, which can cause all kinds of render artifacts, including flying pixels, bad stencil shadows, etc.
Artists should keep meshes manifold! I'm glad that that's what DeleD does.
Back to top
View user's profile Send private message
Grandmaster B
DeleD PRO user


Joined: 03 Jul 2007
Posts: 218

PostPosted: Sat Feb 16, 2008 10:25 pm    Post subject: Reply with quote

Thanks for pointing that out. True, you may not use stencil shadows with this geometry. But the edges still line up the same!

For me the second this is a optimal mesh because it saves a few polygons and is cheaper for collision detection and ray tracing. I dont need the extra triangles that keep the level meshes manifolded.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    DeleD Community Edition Forum Index -> DeleD Plugins All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum