I have to move my ofCamera position through the 3D world. Im having an issue with stopping my movement from the starting point. When I get to the end point of my target, I want the movement to stop but I dont know why its not. The code is as follows for the main part -
the draw part -
easyCam.begin();
ofVec3f lookatPos = ofVec3f(width / 2.5, height / 2.5, 950);
easyCam.setPosition(lookatPos);
//easyCam.lookAt(node);
//easyCam.move(0, -150, 0);
//easyCam.truck(-300);
easyCam.setVFlip(true);
// ofCamera myCam;
float tweenvalue = (ofGetElapsedTimeMillis() % 20000) / 20000.f; // this will slowly change from 0.0f to 1.0f, resetting every 2 seconds
ofQuaternion startQuat;
ofQuaternion targetQuat;
ofVec3f startPos;
ofVec3f targetPos;
// we define the camer's start and end-position here:
startQuat.set(0, 0, 0, 1000);
startPos.set(0, 0, 0);
targetPos.set(-500, -300, -1000);
//easyCam.setGlobalPosition(-500, -500, -1000);
ofQuaternion tweenedCameraQuaternion; // this will be the camera's new rotation.
// calculate the interpolated orientation
tweenedCameraQuaternion.slerp(tweenvalue, startQuat, targetQuat);
ofVec3f lerpPos; //this will hold our tweened position.
// calculate the interpolated values.
lerpPos.x = ofLerp(tweenvalue, startPos.x, targetPos.x);
lerpPos.y = ofLerp(tweenvalue, startPos.y, targetPos.y);
lerpPos.z = ofLerp(tweenvalue, startPos.z, targetPos.z);
// alternative way to calculate interpolated values:
// lerpPos = startPos + ((targetPos-startPos) * tweenvalue);
// now update the camera with the calculated orientation and position.
easyCam.setOrientation(tweenedCameraQuaternion);
easyCam.setGlobalPosition(lerpPos);
if (lerpPos == ofVec3f(-500, -300, -1000)) {
easyCam.setGlobalPosition(-500, -300, -1000);
}
What am i doing wrong?