help me add weapons to md2 [screenshot]

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
ozrinaut
Posts: 28
Joined: Tue Sep 13, 2005 5:09 pm

help me add weapons to md2 [screenshot]

Post by ozrinaut »

How can i add a wepon into my md2 guy?
i have the weapon.md2 file...

Image
Dances
Posts: 454
Joined: Sat Jul 02, 2005 1:45 am
Location: Canada
Contact:

Post by Dances »

The best way to do it is convert him to a .x file then get the ID of the bone for his hand and then attach the weapon model to that bone via the bone's matrix.
ozrinaut
Posts: 28
Joined: Tue Sep 13, 2005 5:09 pm

Post by ozrinaut »

doesn't Irrlicht fetch them during the "scene::IAnimatedMesh* mesh = smgr->getMesh("model.md2");" ? or no?

this only retrives oplygon info? no bone data?
Masdus
Posts: 186
Joined: Tue Aug 26, 2003 1:13 pm
Location: Australia

Post by Masdus »

I didn't think md2 had bones, which is probably why dances suggest using .x files instead
Foole
Posts: 87
Joined: Mon Aug 29, 2005 10:08 am

Post by Foole »

I'm curious about this too. There must be some way of correctly adding the weapon because Quake 2 can do it. Is there some chunk of data for this in the md2 file that isn't handled by irrlicht?
Armen138
Posts: 298
Joined: Mon Feb 23, 2004 3:38 am

Post by Armen138 »

usually the weapon 'animation' is synced with the character, so simply adding the weapon.md2 at the same position and rotation as the character would do the trick.. cant hurt to try
if you're looking for me, start looking on irc, i'm probably there.
Foole
Posts: 87
Joined: Mon Aug 29, 2005 10:08 am

Post by Foole »

Except that it wouldn't move around with the arm/hand when the model animates.

If it did, then any child node would do the same.. including my 3rd person camera.
Armen138
Posts: 298
Joined: Mon Feb 23, 2004 3:38 am

Post by Armen138 »

i might be wrong, but i think the weapon.md2's usually have the same animations as the character, thus following the arm when it moves.
if you're looking for me, start looking on irc, i'm probably there.
ozrinaut
Posts: 28
Joined: Tue Sep 13, 2005 5:09 pm

Post by ozrinaut »

Armen138 wrote:usually the weapon 'animation' is synced with the character, so simply adding the weapon.md2 at the same position and rotation as the character would do the trick.. cant hurt to try
That would require an immense amount of animations... it's not practical. especially if [ehich i do] you plan on using many different guns

BESIDES, animation flags like this work (see screen below) which makes me believe there should be some access to these bones after loading the mesh:
node->setMD2Animation(scene::EMAT_SALUTE);
Image
Masdus
Posts: 186
Joined: Tue Aug 26, 2003 1:13 pm
Location: Australia

Post by Masdus »

stop refering to bones and md2 together. When you create a md2 in an animation package there are NO bones. It workes purely on key frame animation from a deformed mesh.

Each animation has been created in the animation package and is stored as part of the file. These animations define the vertex position at key frames of the animation and the rest is interprolated.

For bone animation formats like .x, each vertex is affect by one or more bones. This information is stored in the file. The animations define the position of the bones, again at key frames. The position of each vertex can then be determined using the stored bone->vertex info.

As no bone as such exist in md2 you can't just attach the weapon to a bone and have it completly animated in sync with the model. Two possible methods are the one Armen138 stated, or it might be possible to fake a bone, by looking at the postion of certain vertices on the arm/hand and using these to determine the position of you weapon.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

I was going to need this for my project but i think i may not bother now. What i did early on was load a md2 and then add it's weapon as a child. The md2 was of one of those things from the new Star Wars trilogy, the robots that curl themselves up and roll around... The weapon.md2 that came with it when added as a child aligned into the proper position but its animation was out of time i think.. It didn't move in exactly the same way..

Also when i added a bfg to a Johnny 5 (Short Circuit films) it was positioned on his shoulder, which is where it should have been, but again it was out of time with the animation.
Image Image Image
Post Reply