Quaternion rotate problem

Hello

Im playing with ofxNI2 and trying to apply the quaternion coming from a skeleton joint to a 3d model, but im not able to make the model rotate, i know that the quaternion contain data as im able to print the angles of that joint.

Maybe im making some dumb mistake in my code

for (int i = 0; i < tracker.getNumUser(); i++)
    {
        ofxNiTE2::User::Ref user = tracker.getUser(i);
        const ofxNiTE2::Joint &joint = user->getJoint(nite::JOINT_HEAD);

        ofPushMatrix();
        ofEnableDepthTest();
        ofTranslate(user->head);

        auto rot = joint.getOrientationQuat();
        float angle = glm::angle(rot);
        glm::vec3 axis = glm::axis(rot);
 
        
        ofRotate(angle, axis.x, axis.y, axis.z);
        
        ofNoFill();
        
        
        model.drawFaces();
        ofDrawBox(0, 0, 0, 200);
        ofDisableDepthTest();
        ofPopMatrix();
}

Also i know that that joint have data because if i do, it works but i do not want to have the translation of that because im drawing over the rgb frame in 2d

        joint.transformGL();
        ofDrawBox(300);
        joint.restoreTransformGL();

Thank you!

using ofTranslate, rotate… is probably not the best idea but in any case the angle you get from glm::angle is in radians while ofRotate works in degrees by default, you are probably even getting a warning about it cause since 0.10 there’s now ofRotateDeg and ofRotateRad to rotate in degrees and radians

Thank you Arturo

I tried ofRotateRad but still do not work… Obviously im doing more things wrong but i do not understand what can be the cause

Also tried, but none work

        ofNode n;
        
        n.setGlobalOrientation(joint.getOrientationQuat());
        n.setGlobalPosition(user->head.x, user->head.y, 0);
        
        n.transformGL();
        ofDrawBox(0, 0, 0, 200);
        
        n.restoreTransformGL();

This worked!!

        for (int i = 0; i < tracker.getNumUser(); i++)
        {
            ofxNiTE2::User::Ref user = tracker.getUser(i);
            const ofxNiTE2::Joint &joint = user->getJoint(nite::JOINT_HEAD);
            
            ofNode n = joint;
            n.setGlobalPosition(user->head.x, user->head.y, 0);
            
            n.transformGL();
            model.drawFaces();
            n.restoreTransformGL();
        }

But X and Z axis are reversed… how can i reverse those two axis?