Scaling of bones

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
alinpopescu
Posts: 5
Joined: Sat May 19, 2012 5:57 pm

Scaling of bones

Post by alinpopescu »

Hi,

I want to set the scaling to a bone and that the skinned mesh that is attached to to be scaled as well during the whole animation. The animation doesn't include any scaling. How can I do this?

Here is how I tried, but without success

Code: Select all

 
        scene::IAnimatedMeshSceneNode* model = (scene::IAnimatedMeshSceneNode*) Model;
        model->setJointMode(irr::scene::EJUOR_CONTROL);
 
        scene::IBoneSceneNode *node = model->getJointNode("Bip01_L_Thigh");
        SAFE_CALL(node)->setScale(core::vector3df(2,2,2));
        SAFE_CALL(node)->updateAbsolutePosition();
 
        model->OnAnimate(0);//animateJoints();
        model->setJointMode(irr::scene::EJUOR_READ);
 
Kind regards
alinpopescu
Posts: 5
Joined: Sat May 19, 2012 5:57 pm

Re: Scaling of bones

Post by alinpopescu »

I finally got it going:

Code: Select all

 
        scene::IAnimatedMeshSceneNode* model = (scene::IAnimatedMeshSceneNode*) Model;
        //scene::IBoneSceneNode *node = model->getJointNode("lhip");
        scene::IBoneSceneNode *node = model->getJointNode("Bip01_L_UpperArm");
                        
        if (node)
        {
                scene::ISkinnedMesh *mesh = (scene::ISkinnedMesh *) model->getMesh();
                scene::ISkinnedMesh::SJoint *joint = mesh->getAllJoints()[node->getBoneIndex()];
                scene::ISkinnedMesh::SScaleKey *key = mesh->addScaleKey(joint);
                                
                key->frame = 0;
                key->scale = core::vector3df(1,1,1)*2.5;
 
                key = mesh->addScaleKey(joint);
                                
                key->frame = mesh->getFrameCount()-1;
                key->scale = core::vector3df(1,1,1)*2.5;
        }
 
Very well written engine by the way.

Cheers
Post Reply