Clamp bone rotation

Hi !
I still work on my avatar project for puppet show. Urho3D is a great Engine, I become in love with it :smiley:
For those who doesnt know what I’m talking about :
The head rotation works nice now, I made an ‘Avatar’ LogicComponent with it. I found a lot of help in samples, almost Vehicle Sample. We’ll have some differents ‘Avatars’ to use, and I though I can save some attributes in XML format (maybe a UI, if I have enough time…) so as to work easily with puppeteer and art director on stage.

I’ld like to know how I can clamp bones rotations. I tried some stuff with Urho3D::Clamp function, but I think I don’t really understand how it works. :blush:
I saw, in Vehicle sample , another way by adding constraints with the physic engine. But I’m not sure I need to code with physics for this project.

What do you think about it ?

Thanks to all, have a nice day (or night, I think there’s poeple from all over the world here…)

Did you have a look at the ragdoll sample?

I had a project with a plane and used bones to control the flaps:

    Urho3D::Node* node_flap_l;
    Urho3D::Node* node_plane;
    float flaps=0;
    AnimatedModel* plane=node_plane->CreateComponent<AnimatedModel>();
    node_flap_l=node_plane->GetChild("flap.L",true);    // the bone is called flap.L
    // if you are using animations you may want to disable them for the
    // manually controlled bones:
    // in the update function:
    flaps=Clamp(flaps,0.0,60.0);             // keep the flap angle between 0 and 60
    node_flap_l->SetRotation(Quaternion());             // reset the rotation
    node_flap_l->Yaw(flaps);                            // yaw the bone

I don’t know if there’s an automatic way to keep a bone in a certain angle range. If you move them manually though like I did there pretty straight forward.