示例#1
0
void ofxGameCamera::setAnglesFromOrientation(){
	ofVec3f rotation = getOrientationEuler();
	rotationX = targetXRot = -rotation.y;
	rotationY = targetYRot = -rotation.z;
	rotationZ = targetZRot = -rotation.x;
//	cout << "rotation is " << ofVec3f(rotationX,rotationY,rotationZ) << endl;;
	justResetAngles = true;
}
示例#2
0
void WaypointCamera::updateCam(){
    
    // If the camera is in free mode, do not update its position
    if(camState == WAYPOINT_CAM_STATE_FREE){
        return;
    }
    
    // Calculate deltas between current position and target positoin
    ofVec3f posDelta = curTarNode.getPosition() - getPosition();
    ofVec3f oriDelta = curTarNode.getOrientationEuler() - getOrientationEuler();
    
    // Update pos if camera is too far from target
    if(posDelta.length() > CAM_VEL_RATE){
        isMoving = true;
        
        // Update positoin
        ofVec3f vel = posDelta.normalize();
        vel *= CAM_VEL_RATE;
        setPosition(getPosition() + vel);
        
        // Calculate fraction of distance from previous node
        float fromPreNodeDistFrac = (getPosition() - preTarNode.getPosition()).length()/(curTarNode.getPosition() - preTarNode.getPosition()).length();
        
        // Lerp between old and new orientations
        ofQuaternion newOri = quaternionLerp(preTarNode.getOrientationQuat(),
                                             curTarNode.getOrientationQuat(),
                                             fromPreNodeDistFrac);
        setOrientation(newOri);
        
        // Rotate 180 on Y axis so camera faces pos Z direction
        pan(180);
    }else{
        // Free the cam once we have reached our target
        camState =  WAYPOINT_CAM_STATE_FREE;
        isMoving = false;
        
        // We have arrived at target
        arrivedAtTarget = true; 
    }
}
示例#3
0
//--------------------------------------------------------------
void ofxPhysicalNode::updatePhysics() {
    float nowMillis = ofGetElapsedTimeMillis();
    float deltaTime = (nowMillis - lastUpdateMillis)/1000.0f;
    lastUpdateMillis = ofGetElapsedTimeMillis();
    
    ofVec3f pos(getPosition());
    if(maxPosVel.x > 0) posVel.x = ofClamp(posVel.x, -maxPosVel.x, maxPosVel.x);
    if(maxPosVel.y > 0) posVel.y = ofClamp(posVel.y, -maxPosVel.y, maxPosVel.y);
    if(maxPosVel.z > 0) posVel.z = ofClamp(posVel.z, -maxPosVel.z, maxPosVel.z);
    pos += posVel * deltaTime;
    setPosition(pos);
    posVel -= posVel * posDrag; // TODO: how to make this fps independent?
    if(posVel.lengthSquared() < 0.00001) posVel.set(0, 0, 0);
    
    ofVec3f rot(getOrientationEuler());
    if(maxRotVel.x > 0) rotVel.x = ofClamp(rotVel.x, -maxRotVel.x, maxRotVel.x);
    if(maxRotVel.y > 0) rotVel.y = ofClamp(rotVel.y, -maxRotVel.y, maxRotVel.y);
    if(maxRotVel.z > 0) rotVel.z = ofClamp(rotVel.z, -maxRotVel.z, maxRotVel.z);
    rot += rotVel * deltaTime;
    setOrientation(rot);
    rotVel -= rotVel * rotDrag; // TODO: how to make this fps independent?
    if(rotVel.lengthSquared() < 0.00001) rotVel.set(0, 0, 0);
}
示例#4
0
//----------------------------------------
float ofNode::getRoll() const {
    return getOrientationEuler().z;
}
示例#5
0
//----------------------------------------
float ofNode::getHeading() const {
    return getOrientationEuler().y;
}
示例#6
0
//----------------------------------------
float ofNode::getPitch() const {
    return getOrientationEuler().x;
}
ofVec3f BasicScreenObject::getOrientationAngles() const{
	ofVec3f euler = getOrientationEuler();
	return euler;	
}