mirror of
https://github.com/overte-org/overte.git
synced 2025-08-05 18:38:24 +02:00
adjusted the ordering of porcessed in camera update method
This commit is contained in:
parent
dcd6aafb77
commit
f766843b7a
1 changed files with 22 additions and 9 deletions
|
@ -9,8 +9,7 @@
|
||||||
|
|
||||||
#include "Camera.h"
|
#include "Camera.h"
|
||||||
|
|
||||||
Camera::Camera()
|
Camera::Camera() {
|
||||||
{
|
|
||||||
_mode = CAMERA_MODE_THIRD_PERSON;
|
_mode = CAMERA_MODE_THIRD_PERSON;
|
||||||
_tightness = DEFAULT_CAMERA_TIGHTNESS;
|
_tightness = DEFAULT_CAMERA_TIGHTNESS;
|
||||||
_fieldOfView = 60.0; // default
|
_fieldOfView = 60.0; // default
|
||||||
|
@ -28,26 +27,40 @@ Camera::Camera()
|
||||||
_orientation.setToIdentity();
|
_orientation.setToIdentity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Camera::update( float deltaTime )
|
void Camera::update( float deltaTime )
|
||||||
{
|
{
|
||||||
float radian = ( _yaw / 180.0 ) * PIE;
|
//----------------------------------------
|
||||||
|
// derive t from tightness
|
||||||
//these need to be checked to make sure they correspond to the coordinate system.
|
//----------------------------------------
|
||||||
double x = _distance * -sin( radian );
|
|
||||||
double z = _distance * cos( radian );
|
|
||||||
double y = _up;
|
|
||||||
|
|
||||||
_idealPosition = _targetPosition + glm::vec3( x, y, z );
|
|
||||||
float t = _tightness * deltaTime;
|
float t = _tightness * deltaTime;
|
||||||
|
|
||||||
if ( t > 1.0 ){
|
if ( t > 1.0 ){
|
||||||
t = 1.0;
|
t = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
_position += ( _idealPosition - _position ) * t;
|
//----------------------------------------
|
||||||
_yaw += ( _idealYaw - _yaw ) * t;
|
// update _yaw (before position!)
|
||||||
|
//----------------------------------------
|
||||||
|
_yaw += ( _idealYaw - _yaw ) * t;
|
||||||
|
float radian = ( _yaw / 180.0 ) * PIE;
|
||||||
|
|
||||||
|
//----------------------------------------
|
||||||
|
// update _position
|
||||||
|
//----------------------------------------
|
||||||
|
//these need to be checked to make sure they correspond to the coordinate system.
|
||||||
|
double x = _distance * -sin( radian );
|
||||||
|
double z = _distance * cos( radian );
|
||||||
|
double y = _up;
|
||||||
|
|
||||||
|
_idealPosition = _targetPosition + glm::vec3( x, y, z );
|
||||||
|
|
||||||
|
_position += ( _idealPosition - _position ) * t;
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
// generate the ortho-normals for the orientation based on the Euler angles
|
// generate the ortho-normals for the orientation based on the Euler angles
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
_orientation.setToIdentity();
|
_orientation.setToIdentity();
|
||||||
_orientation.yaw ( _yaw );
|
_orientation.yaw ( _yaw );
|
||||||
_orientation.pitch ( _pitch );
|
_orientation.pitch ( _pitch );
|
||||||
|
|
Loading…
Reference in a new issue