i am using the easycam to look around and in my 3d space.
how would i be able to slowly move from one saved transformation matrix to an other one?
should i use Nodes some how?
thx,
stephan.
i am using the easycam to look around and in my 3d space.
how would i be able to slowly move from one saved transformation matrix to an other one?
should i use Nodes some how?
thx,
stephan.
i guess it is always best to answer your own questions.
i ended up using ofLerp to move from one camera view to an other and added my code to the grabCam example.
bool bDoLerp;
float lerpStep;
ofMatrix4x4 lerpMatrix;
ofMatrix4x4 startMatrix, endMatrix;
float s_x,s_y,s_z;
float s_angle;
ofVec3f s_translateVec;
float e_x,e_y,e_z;
float e_angle;
ofVec3f e_translateVec;
void testApp::update(){
if(bDoLerp == true){
ofMatrix4x4 temp_rot;
ofMatrix4x4 temp_transl;
float l_x = ofLerp(s_x, e_x, lerpStep);
float l_y = ofLerp(s_y, e_y, lerpStep);
float l_z = ofLerp(s_z, e_z, lerpStep);
float l_angle = ofLerpDegrees(s_angle, e_angle, lerpStep);
temp_rot.makeRotationMatrix(l_angle, l_x,l_y,l_z);
ofVec3f l_translateVec;
l_translateVec.x = ofLerp(s_translateVec.x, e_translateVec.x, lerpStep);
l_translateVec.y = ofLerp(s_translateVec.y, e_translateVec.y, lerpStep);
l_translateVec.z = ofLerp(s_translateVec.z, e_translateVec.z, lerpStep);
temp_transl.makeTranslationMatrix(l_translateVec);
lerpMatrix = temp_rot * temp_transl;
camera.setTransformMatrix(lerpMatrix);
lerpStep += 0.01;
if(lerpStep > 1) bDoLerp = false;
}
}
void testApp::keyPressed(int key){
if (key=='s')
savedPose = camera.getGlobalTransformMatrix();
if (key=='l')
camera.setTransformMatrix(savedPose);
if(key == 'x'){
startMatrix = camera.getGlobalTransformMatrix();
endMatrix = savedPose;
ofQuaternion s_mP = startMatrix.getRotate();
s_mP.getRotate(s_angle,s_x,s_y,s_z);
s_translateVec = startMatrix.getTranslation();
ofQuaternion e_mP = endMatrix.getRotate();
e_mP.getRotate(e_angle,e_x,e_y,e_z);
e_translateVec = endMatrix.getTranslation();
bDoLerp = true;
lerpStep = 0;
}
}