Attaching a gun to a hand in Cal3d?

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Gatekeeper
Posts: 31
Joined: Fri Apr 21, 2006 12:00 am
Location: Australia

Attaching a gun to a hand in Cal3d?

Post 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
Klasker
Posts: 230
Joined: Thu May 20, 2004 8:53 am
Contact:

Post 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 ) );
}
Post Reply