void Camera::setLookAtPoint(QVector3D _lookAtPoint) { lookAtDirection = _lookAtPoint - position; lookAtDirection.normalize(); lookAtPoint = position + lookAtDirection; updateLookAt(); }
void GameCamera::update( const glm::vec3 & position, const glm::vec3 & direction, float seconds, float normalizedCaveDistance) { updateRotationProgress(seconds); updateLookAt(position, direction, normalizedCaveDistance); }
void Camera::mouseMoveEvent(int dX, int dY) { QVector3D rightVector = lookAtDirection.crossProduct(lookAtDirection, up); rightVector.normalize(); rotationMatrix.setToIdentity(); rotationMatrix.rotate(pitchSpeed*dY*mouseSensitivity, rightVector); rotationMatrix.rotate(yawSpeed*dX*mouseSensitivity, up); lookAtDirection = rotationMatrix*lookAtDirection; up = rotationMatrix*up; lookAtPoint = position + lookAtDirection; updateLookAt(); }
void TrackToConstraint::onTargetPositionChanged(ObjectEventArgs& obj) { updateLookAt(); }
void TrackToConstraint::onPositionChanged() { updateLookAt(); }
void Camera::updatePosition() { elapsedTime = timer.elapsed(); timer.restart(); elapsedSeconds = (float)elapsedTime/1000; QVector3D rightVector = lookAtDirection.crossProduct(lookAtDirection, up); rightVector.normalize(); QVector3D velocityVector(0,0,0); if(keyMap[Qt::Key_W]){ velocityVector += lookAtDirection; } if(keyMap[Qt::Key_A]){ velocityVector -= rightVector; } if(keyMap[Qt::Key_S]){ velocityVector -= lookAtDirection; } if(keyMap[Qt::Key_D]){ velocityVector += rightVector; } if(keyMap[Qt::Key_Up]){ rotationMatrix.setToIdentity(); rotationMatrix.rotate(pitchSpeed*elapsedSeconds, rightVector); lookAtDirection = rotationMatrix*lookAtDirection; up = rotationMatrix*up; lookAtPoint = position + lookAtDirection; } if(keyMap[Qt::Key_Left]){ rotationMatrix.setToIdentity(); rotationMatrix.rotate(yawSpeed*elapsedSeconds, up); lookAtDirection = rotationMatrix*lookAtDirection; lookAtPoint = position + lookAtDirection; } if(keyMap[Qt::Key_Down]){ rotationMatrix.setToIdentity(); rotationMatrix.rotate(-pitchSpeed*elapsedSeconds, rightVector); lookAtDirection = rotationMatrix*lookAtDirection; up = rotationMatrix*up; lookAtPoint = position + lookAtDirection; } if(keyMap[Qt::Key_Right]){ rotationMatrix.setToIdentity(); rotationMatrix.rotate(-yawSpeed*elapsedSeconds, up); lookAtDirection = rotationMatrix*lookAtDirection; lookAtPoint = position + lookAtDirection; } if(keyMap[Qt::Key_Q]){ rotationMatrix.setToIdentity(); rotationMatrix.rotate(-rollSpeed*elapsedSeconds, lookAtDirection); up = rotationMatrix*up; } if(keyMap[Qt::Key_E]){ rotationMatrix.setToIdentity(); rotationMatrix.rotate(rollSpeed*elapsedSeconds, lookAtDirection); up = rotationMatrix*up; } if(keyMap[Qt::Key_Space]){ velocityVector += up; } if(keyMap[Qt::Key_Control]){ velocityVector -= up; } velocityVector.normalize(); position += velocityVector*translationSpeed*elapsedSeconds; lookAtPoint += velocityVector*translationSpeed*elapsedSeconds; qDebug() << "------------------"; qDebug() << "position" << position; qDebug() << "lookAtPoint" << lookAtPoint; updateLookAt(); }
void Camera::setUp(QVector3D _up) { up = _up; up.normalize(); updateLookAt(); }
void Camera::setPosition(QVector3D _position) { position = _position; lookAtDirection = lookAtPoint - position; updateLookAt(); }
void ofxFBXCamera::setFrame(u_int frame){ ofxFBXNode::setFrame(frame); ((ofNode&)*this) = getNode(); updateLookAt(); }
void ofxFBXCamera::setTime(u_long ms){ ofxFBXNode::setTime(ms); ((ofNode&)*this) = getNode(); updateLookAt(); }
bool HexMapTest::UpdateKey() { CIwMat rotation; CIwVec3 lookFrom(0,0,0); if (KeyPressed(s3eKeyPageUp)) { if (KeyAltDown()) { rotation.SetAxisAngle( s_viewMatrix.RotateVec(s_left), IW_ANGLE_FROM_DEGREES(0)); lookFrom = (s_viewMatrix * rotation).RotateVec( s_cameraPos); updateLookAt(lookFrom); } else { s_viewMatrix.t[2] -= 0x010; if (s_cameraPos.z<-0x40) s_cameraPos.z += 0x40; } } if (KeyPressed(s3eKeyPageDown)) { if (KeyAltDown()) { s_cameraPos.z -= 0x40; rotation.SetAxisAngle( s_viewMatrix.RotateVec(s_left), IW_ANGLE_FROM_DEGREES(0)); lookFrom = (s_viewMatrix * rotation).RotateVec( s_cameraPos); updateLookAt(lookFrom); } else { s_viewMatrix.t[2] += 0x010; } } // Up, Down, Left, Right keys // if (KeyPressed(s3eKeyUp)) { if (KeyAltDown()) { rotation.SetAxisAngle( s_viewMatrix.RotateVec(s_left), IW_ANGLE_FROM_DEGREES(-5)); lookFrom = (s_viewMatrix * rotation).RotateVec( s_cameraPos); updateLookAt(lookFrom); } else { s_viewMatrix.t[1] -= 0x010; } } if (KeyPressed(s3eKeyDown)) { if (KeyAltDown()) { rotation.SetAxisAngle( s_viewMatrix.RotateVec(s_left), IW_ANGLE_FROM_DEGREES(5)); lookFrom = (s_viewMatrix * rotation).RotateVec( s_cameraPos); updateLookAt(lookFrom); } else { s_viewMatrix.t[1] += 0x010; } } if (KeyPressed(s3eKeyRight)) { if (KeyAltDown()) { rotation.SetAxisAngle( s_viewMatrix.TransformVec(s_up), IW_ANGLE_FROM_DEGREES(5)); lookFrom = (s_viewMatrix * rotation).RotateVec( s_cameraPos); updateLookAt(lookFrom); } else { s_viewMatrix.t[0] += 0x010; } } if (KeyPressed(s3eKeyLeft)) { if (KeyAltDown()) { rotation.SetAxisAngle( s_viewMatrix.TransformVec(s_up), IW_ANGLE_FROM_DEGREES(-5)); lookFrom = (s_viewMatrix * rotation).RotateVec( s_cameraPos); updateLookAt(lookFrom); } else { s_viewMatrix.t[0] -= 0x010; } } return true; }