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
Attaching a gun to a hand in Cal3d?
-
- Posts: 31
- Joined: Fri Apr 21, 2006 12:00 am
- Location: Australia
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:
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 ) );
}