Attach stuff to a model.. ( weapons, armor etc..)
Attach stuff to a model.. ( weapons, armor etc..)
Hi,
i want to attach different stuff to my models (at this point only weapons... i dont want to try clothing yet.. ) and i want to use skeletal animation, but i am not sure which modelformat i should use.
What experiences do you have with the different modelformats ?
i want to attach different stuff to my models (at this point only weapons... i dont want to try clothing yet.. ) and i want to use skeletal animation, but i am not sure which modelformat i should use.
What experiences do you have with the different modelformats ?
-
- Posts: 23
- Joined: Fri Aug 06, 2004 12:28 pm
-
- Posts: 23
- Joined: Fri Aug 06, 2004 12:28 pm
okay, as I said, "AFAIK" .. remembered just a thing like getXJoint.. but as you're saying, i begin remembering there was something about Milkshape files, too... Hm... anyhow it would be good if there would be support to attach things to vertices, so that the move like the vertices do... have to think about a implementation for my project..
-
- Posts: 23
- Joined: Fri Aug 06, 2004 12:28 pm
First you load an x or an ms3d file:
That's it. This should work (i didn't test it). For detailed documentation visit the Irrlicht Docu. i.e. this page: click
\edit:
As I discovered, it seems to work just with MILKSHAPE files. Or the getMS3DJointNode() method of the IAnimatedMeshSceneNode returns also joints from X files...
Code: Select all
// the player model
IAnimatedMesh* pPlayerMesh = pSmgr->getMesh("./data/player.ms3d");
// the weapon model
IAnimatedMesh* pWeaponMesh = pSmgr->getMesh("./data/weapon.3ds");
// insert two scene nodes for weapon and player
IAnimatedMeshSceneNode* pnPlayer = pSmgr->addAnimatedMeshSceneNode( pPlayerMesh );
pPlayerMesh->drop();
IAnimatedMeshSceneNode* pnWeapon = pSmgr->addAnimatedMeshSceneNode( pWeaponMesh );
pWeaponMesh->drop();
// this is a scene node where we can attach things to joints
ISceneNode* pJointNode = pnPlayer->getMS3DJointNode("weapon_attach");
if(pJointNode)
{
pJointNode->addChild( pnWeapon );
}
\edit:
As I discovered, it seems to work just with MILKSHAPE files. Or the getMS3DJointNode() method of the IAnimatedMeshSceneNode returns also joints from X files...
Thanks a lot !!! After spending several hours with Milkshape i now have a model to try that... i'll post my progress with this...
btw. : this is my first model :
http://sh1t.kicks-ass.org/dummy_skel2.jpg
... yes, its ugly ...
btw. : this is my first model :
http://sh1t.kicks-ass.org/dummy_skel2.jpg
... yes, its ugly ...
-
- Posts: 23
- Joined: Fri Aug 06, 2004 12:28 pm
Joints are the connections between the bones... every model has a root joint. So you have a hierarchy like this:
So i think if you name a bone, you name the joint that is facing away from the Root joint. But so the root joint would have no name... hm.. looks like you have to do some trial & error with blender
Code: Select all
o--o
/
o--o
\
o--o
- = bone
o = joint
I have added the function getXJointNode(0 see here http://irrlicht.sourceforge.net/phpBB2/ ... 66e2573262As I discovered, it seems to work just with MILKSHAPE files. Or the getMS3DJointNode() method of the IAnimatedMeshSceneNode returns also joints from X files...
Unfortunately, according to this thread http://irrlicht.sourceforge.net/phpBB2/ ... 0044#20044
getMatrixOfJoint(used in internally for both ms3d and x joint child nodes) returns an incorrect position for joints not at the bottom of the hierarchy. I haven't tested that myself, and I'm surprised niko wouldn't have noticed a large bug like that, but regardless of whether you chose .x or .ms3d, if you try to attach something to a joint and it seems to be coming out wrong, keep that in mind.
You do a lot of programming? Really? I try to get some in, but the debugging keeps me pretty busy.
Crucible of Stars
Crucible of Stars
Not sure if I understand this right. Niko only has a method for .ms3d models. I added one for .X that works exactly the same way, presuming getMatrixOfJoint is working correctly for bothIs this method actual for *.x models or is only for MS3D models?
I have not myself confirmed that a bug even exists. The call to getMatrixOfJoint for .x models returns the Combined animation matrix which the engine uses internally for skinning the mesh after skeletal aimation has been performed. If the CombinedAnimationMatrix was incorrect I believe the models would show up incorrectly on the screen (though I took only a very cursory look at the code in CXAnimationPlayer.cpp).electron: is there a work-around for this bug?
One thing to note is that while the getMatrixOfJoint accepts both the joint number and the frame as parameters, as far as I can tell the frame parameter is actually ignored and the joint transformation returned is that of the joint at the curent frame. For ms3d meshes the frame parameter is actually taken into account.
When I get a chance I will test things myself and try to find a fix if there is in fact a bug.
BLAST IT: I just read the bug thread again and buhatkj just replied with a pic of transformations gone wrong. I guess there is a problem. I'll look into, though complicated matrix transformations are not an area where I'm totally comfortable
You do a lot of programming? Really? I try to get some in, but the debugging keeps me pretty busy.
Crucible of Stars
Crucible of Stars
found this in CXanimationPlayer::animateSkeleton. It might have something to do with our problem. Unfortunately my mathematical skills are not exactly up to the tsk of fixing niko's spherical linear interpolations
Code: Select all
// animate it
switch(currentSet.Animations[i].keyType)
{
case 0: // rotation
{
// with this code, rotations are not 100% ok, they are
// mirrored.
core::quaternion q;
q.Slerp(currentSet.Animations[i].Quaternions[idx1],
currentSet.Animations[i].Quaternions[idx2], factor);
joint.LocalAnimatedMatrix *= q.getMatrix();
joint.WasAnimatedThisFrame = true;
}
break;
You do a lot of programming? Really? I try to get some in, but the debugging keeps me pretty busy.
Crucible of Stars
Crucible of Stars
found this quaternion thread. Might be useful, though I think the dates are from before 0.6 so the fixes given there might already be in the engine
http://irrlicht.sourceforge.net/phpBB2 ... rp&start=0
http://irrlicht.sourceforge.net/phpBB2 ... rp&start=0
You do a lot of programming? Really? I try to get some in, but the debugging keeps me pretty busy.
Crucible of Stars
Crucible of Stars