Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

11991 Posts in 1587 Topics- by 3509 Members - Latest Member: lioneltenel

26. May 2012, 09:33:49 pm
Xith3D CommunityGeneral CategoryGeneral Discussion (Moderators: Marvin Fröhlich, 'n ddrylliog)Quick Question - Using Xith for just the SceneGraph functionality.. How??
Pages: [1]
Print
Author Topic: Quick Question - Using Xith for just the SceneGraph functionality.. How??  (Read 1937 times)
Richard Hefner
Just dropped in

Offline Offline

Posts: 3

1913502 RichAKABrassman richhefner
View Profile
« on: 16. December 2006, 11:12:53 pm »

Hi all,

I have to implement my own game loop in a class that I'm taking, but he's letting us borrow a scenegraph implementation.  So, I have a md2 model I've loaded and I want to be able to get it's geometry information without using the Xith3D rendering portion.. 

Is this possible...?  If so, how?  Sorry for the stupid post, i've been looking at it for a while and just can't find out.
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #1 on: 17. December 2006, 12:13:58 am »

Hi, Richard

First of all: Welcome to Xith3D and this board Smiley.

I have to implement my own game loop in a class that I'm taking, but he's letting us borrow a scenegraph implementation.  So, I have a md2 model I've loaded and I want to be able to get it's geometry information without using the Xith3D rendering portion.. 

Is this possible...?  If so, how?  Sorry for the stupid post, i've been looking at it for a while and just can't find out.

I think, you'll have to explain a little more...

Who is "he", who is letting you borrow a scenegraph implementation? Your teacher?
Are you working on a school project, where your job is to implement a RenderLoop? We have a class called RenderLoop. You can either use it or copy it and tell your teacher, it's yours Wink.

What do you want to know about the Geometry?

Based on a guess you can use this:
Code:
List<Shape3D> shapes = org.xith3d.scenegraph.traversal.impl.ShapeFinder.findAllShapes( model );
Please be aware, that I added this method just a minute ago. So please do a fresh SVN checkout.

This will return a List filled with all the Shape3Ds in the model. A Shape3D provides method to everything going on in it. e.g. invoke getGeometry() to retrieve the geometry, your model is built of. Or invoke getAppearance() to retrieve the Appearance to "air-brushes" you model.

Please tell me, if I guessed right or if I missed your point.

Marvin
Logged
Richard Hefner
Just dropped in

Offline Offline

Posts: 3

1913502 RichAKABrassman richhefner
View Profile
« Reply #2 on: 17. December 2006, 08:18:14 am »

Hi Marvin,

Thanks for the welcome.  Smiley  Yes, my teacher is letting us borrow the scenegraph structure and model loader, so I tried out Java3D and it didn't quite do what I wanted..  I don't know if Xith can or can't.

Basically, my teacher said it's not a good idea to use Java3D for what we are doing in the class, but Xith may be a good option..  So, what I need to do is load in an MD2 model into the Xith scenegraph and then manipulate the scenegraph (with the model and such) in my own program..  like, pull out the geometry, texture coordinates, etc..  But, I wanted to use the scenegraph's built-in animation features (we're going to use keyframe animation), collision detection, etc.

So, the function you gave me may work just fine for what I need..  but, if there's a different way to go about it, lemme know.  OR, if there's a better alternative to Xith I'm open to all ears..  I just don't know enough about *game* programming to tell if it's the best option or not.

Thanks!!
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #3 on: 17. December 2006, 01:11:29 pm »

So, the function you gave me may work just fine for what I need..  but, if there's a different way to go about it, lemme know.  OR, if there's a better alternative to Xith I'm open to all ears..  I just don't know enough about *game* programming to tell if it's the best option or not.

Well, of course, there's no better option than Xith3D Grin Grin Grin. There's jmonkey-engine. I've never used it... There may be some differences... But I tell you, that Xith3D will be fine for you. If there's anything missing, just tell us, and we will see, if we can add it Wink.

For the keyframe animation and collision detection thing: I've never used keyframe animation. Well, if it is, what the MD2Model does when its own animations are used, then I have. Anyway MDS supports animations, our loader supports them, too. And they're displayed in a xith3d scenegraph.
We also have a collision system built in in xith3d. But it's quite slow and doesn't alsways work. We're currently discussing, how to go to better way. This better way, which is already working very well, is to use JOODE. It is a full featured physics lib, which of course has a collision system.

So you don't need to check all the vertices, normals, etc. from the geometry on your own. JOODE does everything for you Smiley.

Marvin
Logged
Richard Hefner
Just dropped in

Offline Offline

Posts: 3

1913502 RichAKABrassman richhefner
View Profile
« Reply #4 on: 18. December 2006, 05:39:06 am »

Hehehe...  Ok.  Well, I'm giving it another try.  I went and did some research and found out that the support for Java3D "keyframe" animation is little to none with the file formats I wanted to use.  First, I wanted to use OBJ's, but there's no animation support of course.  Then, I tried out MD2's to run into a snag that you may just have fixed for me.  So, I looked at lightwave files and the Java3D loader for that isn't loading my newer LWS files correctly (I guess you have to use lightwave scene's that are version 5 or below?) ...  Yah, what a mess.  Heheh.

Anywho, I have to turn in my project on Friday, so we'll see how far I get.  Score -1 for starting late and getting sick before the projects due. 

Thanks for all your help and I'll let you know how it all works for me.
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #5 on: 18. December 2006, 04:40:37 pm »

Wow they have a Lightwave loader in Java3D. Maybe we should see, if we can port it to Xith. I found so nice models on may sites on the internet. Well, I hope they are not all newer than 5 Wink.

Marvin
Logged
'n ddrylliog
Moderator
Guru
*****
Offline Offline

Posts: 1188



View Profile WWW Email
« Reply #6 on: 18. December 2006, 05:57:26 pm »

Hi Richard Hefner (are you Hugh's cousin or what ?  Grin ) Welcome to Xith3D boards !

Well, of course, there's no better option than Xith3D Grin Grin Grin.
As he says..

Here's the API I think you will use (mostly) :
Code:
// Load
MD2Model model = new MD2Loader().loadModel( modelName, skin );

// Get anim names
List<String> anims = model.getAnimationNames();

// Choose an anim
model.setCurrentAnimation( anims.get( currentAnim ) );

// Interpolate the anim
model.interpolateAnimation( (float)frameTime / 100.0f );

// Get the Shape3D of the MD2 model
Shape3D shape = ShapeFinder.findFirstShape(model);

// Get the Appearance of the Shape
Appearance app = shape.getAppearance();

// Get the Texture of it (note that you won't get the file
Texture tex = app.getTexture();

// Get the Geometry of the Shape
Geometry geom = shape.getGeometry();

// 99% of the time it will be a TriangleArray
TriangleArray ta = (TriangleArray) geom;

// Get all we can
Point3f[] coords = new Point3f[ta.getVertexCount()];
ta.getCoordinates(0, coords);
float[] uv = new float[ta.getVertexCout()];
ta.getTextureCoordinates(0, 0, uv);

Note : code not proof-tested. Ask any questions..
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #7 on: 19. December 2006, 04:19:22 am »

There's a method getShapeNodes() in all loaded models and scenes (inherited from LoadedGraph->Model/Scene). It returns a List<Shape3D> containing all the Shape3Ds in the loaded model. In MD2Model and AseModel/AseScene they were not filled so far. This is done now and you don't need to use the ShapeFinder for this task, since the shapes can be simply retrieved from this prefilled list Smiley.

And an MD2 model seems to always contain two shapes. So the findFirstShape method wouldn't anyway be the right method. There's findAllShapes(), that does the job. Well, if you only need the first shape, the findFirstShape() method is faster. But none of them is faster than using the prefilled List Wink.

Marvin
« Last Edit: 19. December 2006, 04:22:24 am by Marvin Fröhlich » Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic