Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (480)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (547)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  md3 question  (Read 1233 times)
0 Members and 1 Guest are viewing this topic.
Offline weston

Junior Member





« Posted 2005-09-01 01:27:03 »

Not really sure where to put this, I think we need a general 3d graphics or opengl forum... well this will do for now.

I'm writing an md3 loader/renderer and I've come to a problem when it comes to attaching separate model pieces. I'm hoping someone who has used md3s before can help me, but first some review on the issue: md3s use something called 'tags' to attach separate model pieces, generally the pieces are: head, torso, and legs but could be anything I assume. Each model part has a set of tags, each of which has a name that specifies what model part the tag effects. The tag itself stores a position and orientation (as a 3x3 matrix). Its my understanding that if a model part has a tag with a name specifying another piece, than that other piece's position and orientation are always dependant on the piece with the tag.

The part I'm having trouble with is keeping the pieces synced together. I know how to transform the pieces according to the matrix and translate them into place, but I don't understand how I can update the pieces when the 'controller' piece animates. For example, there is a 'torso' model part with a tag: tag_weapon and there is a weapon model part. When the torso (which actually makes up the midsection and both arms of the model) animates, the arms move up and down and the gun should stay oriented relative to the position of the right hand. I don't understand how I can detect the change in the torso's position and orientation in order to update the pieces which are dependant on it. The problem seems even more complex since the gun should really be positioned relative to the hand (which is a part of the torso), but the weapon is only attached to the torso piece, the file itself says nothing about the model's hand.

This is the sort of problem that makes me think I'm missing something big because I just see no solution. Is there some other part to the md3 format that gives more info about how these various pieces are connected? or maybe I'm supposed to calculate the change in position and orientation of model parts in order to apply it to its dependancies? I have seen this model animated correctly with another program, so the file itself (or files rather) is valid. Hopefully someone can give me some insight Smiley thanks.

for(int i = 1; i > 0; i++)
{
System.out.println(i+" cups of java downed");
}
Offline Jeff

JGO Coder




Got any cats?


« Reply #1 - Posted 2005-09-01 04:11:26 »

Well, you need some kind of hashtable for the tags that points to the right objects.

If this is Java3D you can look at what I did for NWN mdl files which are very similar, at least in concept, to what you described.

Thats all in the JNWN codebase. If your curious abt various parts I can answer questions...

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline weston

Junior Member





« Reply #2 - Posted 2005-09-01 07:28:07 »

I've already got the hashtable bit taken care of Smiley the problem I'm having is detecting the change in orientation and position of the controller model part so that I can apply it to dependant model parts. When the md3 animates, its just switching between complete sets of vertices, I don't see how I can derive the transformation thats taking place. I also think it may not be possible to do that... the torso is dependant on the position and orientation of the legs for example, but there can be no single transformation that takes place from frame to frame because the legs move independantly of one another, one leg may bend a bit forward and the other a bit backward in a single frame. Perhaps I'm missing something so fundamental that my question isn't quite making sense  Embarrassed

for(int i = 1; i > 0; i++)
{
System.out.println(i+" cups of java downed");
}
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline kevglass

JGO Kernel


Medals: 152
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #3 - Posted 2005-09-01 07:49:59 »

I believe in the MD3 format there are actually multiple transforms/matricies per tag, i.e. as the key frame changes so does the transform for a tag (which you'd have to interpolate between as well).

Just checking my own Java3D loader code....

Yep - the tags segment is built up of:

F * T * Tag

Where F is the number of frames, T is the number of tags in the model and Tag is the tag structure.

So you've got say your 3 parts.. when a a remote part is updated you pick out the transform you need for the current animation frame. This means of course that your weapon model and torso model for instance need to be synced.

Kev

Offline weston

Junior Member





« Reply #4 - Posted 2005-09-01 08:11:49 »

problem solved on irc, thanks to kev Smiley

the problem was that tags for every frame are indeed stored in the file, I just didn't notice it before because there is a field in the header that says NUM_TAGS which is equal to 3, but there are really 3 for every frame. So I was only reading in 3 and then skipping to the next section of the file Sad

for(int i = 1; i > 0; i++)
{
System.out.println(i+" cups of java downed");
}
Offline Jeff

JGO Coder




Got any cats?


« Reply #5 - Posted 2005-09-01 22:43:16 »

I've already got the hashtable bit taken care of Smiley the problem I'm having is detecting the change in orientation and position of the controller model part so that I can apply it to dependant model parts. When the md3 animates, its just switching between complete sets of vertices, I don't see how I can derive the transformation thats taking place.

Oh its THAT kind of animation.

The answer is you dont do it with transforms.  These are effectively morphs.

You might want to look at the MorphBehavior in J3D.  basically it takes 2 seperate models that have the same number of verticies and interpolates a third model that also has the same point count  between the point positions of the two targets

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline kevglass

JGO Kernel


Medals: 152
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #6 - Posted 2005-09-02 10:03:07 »

I see what you mean, but in this case it really is transforms.

You have a series of models - gun - body - head, each is a mesh that has a series of keyframes that you are morphing between (thats how I did it in the Java3D loader too Smiley). However, the relationship between the parts is decribed in the model format as transforms.. i.e. if the body has changed to the keyframe where the arm is at angle X the gun model should be at this angle/transform to the body.

Kev

Offline Jeff

JGO Coder




Got any cats?


« Reply #7 - Posted 2005-09-04 03:47:37 »

I see what you mean, but in this case it really is transforms.

You have a series of models - gun - body - head, each is a mesh that has a series of keyframes that you are morphing between (thats how I did it in the Java3D loader too Smiley). However, the relationship between the parts is decribed in the model format as transforms.. i.e. if the body has changed to the keyframe where the arm is at angle X the gun model should be at this angle/transform to the body.

Kev

Okay, well he said it wasnt.

So I was right answering hsi question, he was just wrong about his data (or describing it in a very confused manner)  Grin

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline kevglass

JGO Kernel


Medals: 152
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #8 - Posted 2005-09-04 07:07:17 »

LOL! Absolutely - dead on. Smiley

Kev

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

atombrot (24 views)
2014-08-19 09:29:53

Tekkerue (23 views)
2014-08-16 06:45:27

Tekkerue (23 views)
2014-08-16 06:22:17

Tekkerue (13 views)
2014-08-16 06:20:21

Tekkerue (20 views)
2014-08-16 06:12:11

Rayexar (58 views)
2014-08-11 02:49:23

BurntPizza (38 views)
2014-08-09 21:09:32

BurntPizza (30 views)
2014-08-08 02:01:56

Norakomi (37 views)
2014-08-06 19:49:38

BurntPizza (67 views)
2014-08-03 02:57:17
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!