Page 1 of 1

Attaching a gun to a hand in Cal3d?

Posted: Thu Jul 27, 2006 1:38 am
by Gatekeeper
Hey guys,
Does anyone know how would I go about attaching a gun (well, basically any scene node) to a specific bone in Klasker's Cal3d scene node?

I know I need to make the gun node a child of the parent node, but how do I get the node of just the hand bone so I can make it the parent?

You can get the bone position and the bone rotation from ICal3dSceneNode - does this help?

Thanks

Posted: Thu Jul 27, 2006 9:35 pm
by Klasker
Write an ISceneNodeAnimator that updates the transformation of the gun node.

Something written off the top of my head, not sure if it works, but worth a try:

Code: Select all

class CLockToBoneAnimator : public ISceneNodeAnimator
{
public:
    void animateNode( ISceneNode* node, u32 timeMs );
    CLockToBoneAnimator( ICal3DSceneNode* node, s32 boneId );
    
private:
    s32 BoneId;
    ICal3DSceneNode* CalNode;
};

//    ~ in CLockToBoneAnimator.cpp ~

CLockToBoneAnimator::CLockToBoneAnimator( ICal3DSceneNode* node, s32 boneId )
{
    CalNode = node;
    BoneId = boneId;
}

void CLockToBoneAnimator::animateNode( ISceneNode* node, u32 timeMs )
{
    node->setPosition( CalNode->getBonePosition( BoneId ) );
    node->setRotation( CalNode->getBoneRotation( BoneId ) );
}