OptimizeMesh() ... ?

Blitz3D Forums/Blitz3D Programming/OptimizeMesh() ... ?

jfk EO-11110(Posted 2006) [#1]
Is there a OptimizeMesh function somewhere? I have seen a Polygon Reduction in the archives. That's cool, but not exactly what I need here. OptimizeMesh will try to reduce the polycount without to alter the shape. This works especially with meshes that contain unneccessary fragmentation of planes.


b32(Posted 2006) [#2]
I found this references to a OptimizeMesh function:
http://www.blitzbasic.com/codearcs/codearcs_bb/250.bb


jfk EO-11110(Posted 2006) [#3]
Thanks. This is welding the mesh. I meant searching for an alternative set of triangles for the same shape. Like when you have a cylinder cap. In 3dsMax for example the cap will be made of as many tris as there are segments in the cylinder. Then when you choose the "Optimize" modifier, the cap will be made of less triangles, where their axis point is no longer the center of the cylinder, but one of the segment edges. Ehrm, hard to explain for me. Imagine the unoptimized cap is looking like a 2D sun with lots of rays. The optimized cap looks more like a quarter of such a sun, where all rays start in one corner and go across the entire cap to every segment edge.


Beaker(Posted 2006) [#4]
jfk - I know exactly what you mean. I've never seen anything in Blitz to do this. If someone has made a generic poly 'filler' you could adapt it by searching for attached co-planar triangles, and using the resulting poly outline.


b32(Posted 2006) [#5]
What a nice idea. Maybe you could add a parameter that controls the maximum difference between the normals of two triangles that should be treated as coplanar.


Hambone(Posted 2006) [#6]
I read an article a few years ago on mesh optimization. It presenteda method for dynamically tessalating geometry, that handled LOD similar to what you are looking for. Rather than simply descimate the geometry it calculated the best representation of a geometric surface using the fewest triangles.

Check this link, it might get you going in the right direction.

http://research.microsoft.com/~hoppe/#meshopt

Allan


John Blackledge(Posted 2006) [#7]
Some modellers I've used have a 'reduce triangles' function, but they are never that clever and always leave holes in the model.
I guess it would be a nightmare to code.


Scherererer(Posted 2006) [#8]
I would just use max and optimise your models pre-implementation, unless you want to do it dynamically or are creating a program specifically for it.

What i'd probubly do, is check a poly, then look at all adjacent polies and if it has the same or similar normal, then add the vertecies of that tri to a list, and after finding all coplanar tris, use some kind of algo to delete all points in the center of the plane and then connect the remaining vertecies accordingly.


Rroff(Posted 2006) [#9]
If your doing it for performance reasons it is far far more efficent to create a high res model in your modelling package and then create 1-2 lower LOD models using the relevant tools and hide/unhide the relevant models in game, than trying to generate appropriate LOD on the fly.

From playing with some asteroid code, I found I only needed 2 LODs 1 high-res approx 4K polys and one low res approx 200 poly and I could have several thousand in use with little slow down, I tried a 2D sprite for very distant asteroids and didn't get any speed boost.


b32(Posted 2006) [#10]
This is a translated java program written by Ian Garton. It triangulates a closed, simple polygon.



jfk EO-11110(Posted 2006) [#11]
Thanks a lot everybody. I was AFK. Thanks bram32, that is looking very interesting.

A few comments: I was not looking for a LOD system. The idea was to remove unneccessary triangulation. This would not reduce the level of details (tho LOD is a good thing, but that wasn't the idea).

I have made some tests with 3DS Max's optimation mesh modifier. Although it can reduce the Polycount to about 60%, a new problem pops up: blinking dots on the seams, seam-leaks. Where I got them in all meshes, it became much more worse when optimized.

So for now I leave the meshes unoptimized for the sake of leakless Tirangle-edges.

Those of you who think about to implement a runtime LOD system should check out the polygon reduction source from the archives. All it needs is automatic UV convertion.

Thanks for your help!


JoshK(Posted 2006) [#12]
Wouldn't it be better to make the mesh the right way to begin with?


kfprimm(Posted 2006) [#13]
MeshViewer?