Welcome, Guest. Please login or register.
Did you miss your activation email?
September 02, 2010, 05:57:16 pm
advanced search




Pages: [1]
  Print  
Author Topic: Subdivision surfaces  (Read 4658 times)
Tobias
Jr. Member
**
Offline Offline

Posts: 130


View Profile WWW
« on: October 30, 2006, 10:56:11 pm »

Hi, been lurking for a while. Thought I'd give something back that you might find mildly amusing if not useful.

Subdivision surfaces implementation (the Butterfly scheme) that can handle any mesh with triangular faces you throw at it (open as well as closed). Simple to use as well:

Code:
TriMesh mesh = {some trimesh};
Subdivision subdivision = new SubdivisionButterfly(mesh.getBatch(0)); // prepare for subdivision
subdivision.subdivide(); // subdivide
subdivision.apply(); // Applies the new subdivided buffers to the batch
subdivision.computeNormals(); // calculate new normals

Star:



Pyramids:



Disc:



It interpolates any buffer you'd like it to (that would probably mostly be vertex buffer, color buffer and texture buffers, but I guess you could feed it an alphamap as well)

Get it here: http://bokbloggen.com/stuff/subdivision.zip

The test program subdivides every time you press 'Z', a couple of different shapes are provided. Press 'T' as usual to take a look at the magic in wireframe mode.

Take a look at the code and feel free to suggest improvements. Mostly looking for a better way to make it fit with the structure of jME (extending TriangleBatch, perhaps?). I haven't worked too much with jME yet, so I feel like this might not be the best way.

Papers I used during development are stated in the source, interesting stuff but highly confusing rolleyes
Logged

renanse
Champion
Hero Member
*
Offline Offline

Posts: 5457



View Profile WWW
« Reply #1 on: October 30, 2006, 11:16:12 pm »

Very cool!
Logged

---
next gen Ardor3d has reached 0.6!
nymon
Project Advocate
Hero Member
*
Offline Offline

Posts: 1255



View Profile
« Reply #2 on: October 31, 2006, 12:15:48 am »

Thats neat.  wink
Logged

Scene Monitor might help!
sfera
Hero Member
*****
Offline Offline

Posts: 1244



View Profile
« Reply #3 on: October 31, 2006, 11:45:57 am »

looks very nice
Logged

Notorious lurker.
MrCoder
Champion
Hero Member
*
Offline Offline

Posts: 1530



View Profile WWW
« Reply #4 on: October 31, 2006, 12:14:37 pm »

great! lets look this through and get ready for jme inclusion...i'll see if i can find the time tonight...

PS. hur kommer det sig att en bokrecensent pillar med jme? Smiley DS
Logged

Destroy, Erase, Improve - www.ardorlabs.com / www.ardor3d.com
Tobias
Jr. Member
**
Offline Offline

Posts: 130


View Profile WWW
« Reply #5 on: October 31, 2006, 01:14:57 pm »

I'm glad you guys like it. Forgot to mention that it currently does not handle triangle strips or fans, only three indices per triangle.

PS. Jag vill bli indiespelsutvecklare smiley DS.
Logged

12
Newbie
*
Offline Offline

Posts: 21


View Profile
« Reply #6 on: June 04, 2007, 05:58:10 pm »

Tops man that is really cool!!!!
                 Thanks
                      12
Logged
12
Newbie
*
Offline Offline

Posts: 21


View Profile
« Reply #7 on: June 21, 2007, 11:42:26 am »

Any body have any luck with an obj for example, excuse my ignorance. What kinds of models can I try if any
            Thanks    12
Logged
sfera
Hero Member
*****
Offline Offline

Posts: 1244



View Profile
« Reply #8 on: June 21, 2007, 11:49:44 am »

subdividing models is tricky because you usually want to keep some of the (hard) edges. such things are best done in a dedicated 3d modelling program.

but if you just have some simple models (and are sure you want to do this), you just load them, walk the loaded tree, grab the trimeshes and apply the subdivision to them as described in tobias's post.
Logged

Notorious lurker.
12
Newbie
*
Offline Offline

Posts: 21


View Profile
« Reply #9 on: June 21, 2007, 02:21:05 pm »

Hi Sfera, I just wanted to try it on an organic shape which should be fine but how do I walk the tree...gulp sorry for my poor knowledge, I'm new but keen   can you load .objs directly or do you have to change some thing
       Thanks 12
Logged
sfera
Hero Member
*****
Offline Offline

Posts: 1244



View Profile
« Reply #10 on: June 21, 2007, 03:25:02 pm »

take a look at the source of TestObjJmeWrite to see how to load a .obj file. after loading it, you get a Savable from the BinaryImporter. that Savable is a SceneElement. then you can test with instanceof (or getType()) what kind of SceneElement you are dealing with. if it's a Trimesh you just apply the subdivision, if it's a Node, you grab the children of the node and test them the same way you tested before.
Logged

Notorious lurker.
renanse
Champion
Hero Member
*
Offline Offline

Posts: 5457



View Profile WWW
« Reply #11 on: August 03, 2007, 03:41:10 am »

PS: this is in cvs
Logged

---
next gen Ardor3d has reached 0.6!
Tags:
Pages: [1]
  Print  
 
Jump to: