Quantcast
Channel: beginners - openFrameworks
Viewing all articles
Browse latest Browse all 4929

Quaternion rotate problem

$
0
0

@pandereto wrote:

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!

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4929

Trending Articles