mirror of
https://github.com/overte-org/overte.git
synced 2025-07-16 10:16:44 +02:00
Merge remote-tracking branch 'upstream/master' into agentlist-array
This commit is contained in:
commit
e6d278ea12
6 changed files with 211 additions and 112 deletions
|
@ -113,9 +113,8 @@ int main(int argc, const char* argv[]) {
|
||||||
// move eve away from the origin
|
// move eve away from the origin
|
||||||
// pick a random point inside a 10x10 grid
|
// pick a random point inside a 10x10 grid
|
||||||
|
|
||||||
eve.setPosition(glm::vec3(randFloatInRange(-RANDOM_POSITION_MAX_DIMENSION, RANDOM_POSITION_MAX_DIMENSION),
|
eve.setPosition(glm::vec3(randFloatInRange(-RANDOM_POSITION_MAX_DIMENSION, RANDOM_POSITION_MAX_DIMENSION), 0.4,
|
||||||
0,
|
randFloatInRange(-RANDOM_POSITION_MAX_DIMENSION, RANDOM_POSITION_MAX_DIMENSION)));
|
||||||
randFloatInRange(-RANDOM_POSITION_MAX_DIMENSION, RANDOM_POSITION_MAX_DIMENSION)));
|
|
||||||
|
|
||||||
// face any instance of eve down the z-axis
|
// face any instance of eve down the z-axis
|
||||||
eve.setBodyYaw(0);
|
eve.setBodyYaw(0);
|
||||||
|
|
|
@ -117,6 +117,8 @@ Avatar::Avatar(bool isMine) {
|
||||||
_handHolding.velocity = glm::vec3( 0.0, 0.0, 0.0 );
|
_handHolding.velocity = glm::vec3( 0.0, 0.0, 0.0 );
|
||||||
_handHolding.force = 10.0f;
|
_handHolding.force = 10.0f;
|
||||||
|
|
||||||
|
initializeSkeleton();
|
||||||
|
|
||||||
if (iris_texture.size() == 0) {
|
if (iris_texture.size() == 0) {
|
||||||
switchToResourcesParentIfRequired();
|
switchToResourcesParentIfRequired();
|
||||||
unsigned error = lodepng::decode(iris_texture, iris_texture_width, iris_texture_height, iris_texture_file);
|
unsigned error = lodepng::decode(iris_texture, iris_texture_width, iris_texture_height, iris_texture_file);
|
||||||
|
@ -127,7 +129,6 @@ Avatar::Avatar(bool isMine) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Avatar::Avatar(const Avatar &otherAvatar) {
|
Avatar::Avatar(const Avatar &otherAvatar) {
|
||||||
|
|
||||||
_velocity = otherAvatar._velocity;
|
_velocity = otherAvatar._velocity;
|
||||||
|
@ -198,6 +199,9 @@ Avatar::Avatar(const Avatar &otherAvatar) {
|
||||||
_head.browAudioLift = otherAvatar._head.browAudioLift;
|
_head.browAudioLift = otherAvatar._head.browAudioLift;
|
||||||
_head.noise = otherAvatar._head.noise;
|
_head.noise = otherAvatar._head.noise;
|
||||||
|
|
||||||
|
|
||||||
|
initializeSkeleton();
|
||||||
|
|
||||||
if (iris_texture.size() == 0) {
|
if (iris_texture.size() == 0) {
|
||||||
switchToResourcesParentIfRequired();
|
switchToResourcesParentIfRequired();
|
||||||
unsigned error = lodepng::decode(iris_texture, iris_texture_width, iris_texture_height, iris_texture_file);
|
unsigned error = lodepng::decode(iris_texture, iris_texture_width, iris_texture_height, iris_texture_file);
|
||||||
|
@ -366,6 +370,19 @@ void Avatar::simulate(float deltaTime) {
|
||||||
deltaTime);
|
deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( AVATAR_GRAVITY ) {
|
||||||
|
if ( _position.y > _pelvisStandingHeight + 0.01 ) {
|
||||||
|
_velocity += glm::dvec3( 0.0, -1.0, 0.0 ) * ( 6.0 * deltaTime );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ( _position.y < _pelvisStandingHeight ) {
|
||||||
|
_position.y = _pelvisStandingHeight;
|
||||||
|
_velocity.y = 0.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
if ( AVATAR_GRAVITY ) {
|
if ( AVATAR_GRAVITY ) {
|
||||||
if ( _position.y > _bone[ AVATAR_BONE_RIGHT_FOOT ].radius * 2.0 ) {
|
if ( _position.y > _bone[ AVATAR_BONE_RIGHT_FOOT ].radius * 2.0 ) {
|
||||||
_velocity += glm::dvec3(getGravity(getPosition())) * ( 6.0 * deltaTime );
|
_velocity += glm::dvec3(getGravity(getPosition())) * ( 6.0 * deltaTime );
|
||||||
|
@ -374,6 +391,8 @@ void Avatar::simulate(float deltaTime) {
|
||||||
_velocity.y = 0.0;
|
_velocity.y = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
// update body springs
|
// update body springs
|
||||||
updateBodySprings( deltaTime );
|
updateBodySprings( deltaTime );
|
||||||
|
@ -533,6 +552,22 @@ void Avatar::simulate(float deltaTime) {
|
||||||
const float AUDIO_AVERAGING_SECS = 0.05;
|
const float AUDIO_AVERAGING_SECS = 0.05;
|
||||||
_head.averageLoudness = (1.f - deltaTime / AUDIO_AVERAGING_SECS) * _head.averageLoudness +
|
_head.averageLoudness = (1.f - deltaTime / AUDIO_AVERAGING_SECS) * _head.averageLoudness +
|
||||||
(deltaTime / AUDIO_AVERAGING_SECS) * _audioLoudness;
|
(deltaTime / AUDIO_AVERAGING_SECS) * _audioLoudness;
|
||||||
|
|
||||||
|
_speed = glm::length( _velocity );
|
||||||
|
float rotationalSpeed = fabs( _bodyYawDelta );
|
||||||
|
if ( _speed + rotationalSpeed > 0.2 )
|
||||||
|
{
|
||||||
|
_mode = AVATAR_MODE_WALKING;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_mode = AVATAR_MODE_INTERACTING;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float Avatar::getSpeed() {
|
||||||
|
return _speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -595,6 +630,7 @@ void Avatar::render(bool lookingInMirror) {
|
||||||
glScalef( 0.03, 0.03, 0.03 );
|
glScalef( 0.03, 0.03, 0.03 );
|
||||||
glutSolidSphere( 1, 10, 10 );
|
glutSolidSphere( 1, 10, 10 );
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
*/
|
||||||
|
|
||||||
if ( usingBigSphereCollisionTest ) {
|
if ( usingBigSphereCollisionTest ) {
|
||||||
|
|
||||||
|
@ -860,7 +896,7 @@ void Avatar::initializeSkeleton() {
|
||||||
_bone[ AVATAR_BONE_RIGHT_FOOT ].parent = AVATAR_BONE_RIGHT_SHIN;
|
_bone[ AVATAR_BONE_RIGHT_FOOT ].parent = AVATAR_BONE_RIGHT_SHIN;
|
||||||
|
|
||||||
// specify the default pose position
|
// specify the default pose position
|
||||||
_bone[ AVATAR_BONE_PELVIS_SPINE ].defaultPosePosition = glm::vec3( 0.0, 0.3, 0.0 );
|
_bone[ AVATAR_BONE_PELVIS_SPINE ].defaultPosePosition = glm::vec3( 0.0, 0.0, 0.0 );
|
||||||
_bone[ AVATAR_BONE_MID_SPINE ].defaultPosePosition = glm::vec3( 0.0, 0.1, 0.0 );
|
_bone[ AVATAR_BONE_MID_SPINE ].defaultPosePosition = glm::vec3( 0.0, 0.1, 0.0 );
|
||||||
_bone[ AVATAR_BONE_CHEST_SPINE ].defaultPosePosition = glm::vec3( 0.0, 0.06, 0.0 );
|
_bone[ AVATAR_BONE_CHEST_SPINE ].defaultPosePosition = glm::vec3( 0.0, 0.06, 0.0 );
|
||||||
_bone[ AVATAR_BONE_NECK ].defaultPosePosition = glm::vec3( 0.0, 0.06, 0.0 );
|
_bone[ AVATAR_BONE_NECK ].defaultPosePosition = glm::vec3( 0.0, 0.06, 0.0 );
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
const bool AVATAR_GRAVITY = true;
|
const bool AVATAR_GRAVITY = true;
|
||||||
const float DECAY = 0.1;
|
const float DECAY = 0.1;
|
||||||
const float THRUST_MAG = 10.0;
|
const float THRUST_MAG = 10.0;
|
||||||
const float YAW_MAG = 300.0;
|
const float YAW_MAG = 500.0; //JJV - changed from 300.0;
|
||||||
const float TEST_YAW_DECAY = 5.0;
|
const float TEST_YAW_DECAY = 5.0;
|
||||||
const float LIN_VEL_DECAY = 5.0;
|
const float LIN_VEL_DECAY = 5.0;
|
||||||
|
|
||||||
|
|
|
@ -11,63 +11,89 @@
|
||||||
#include "Camera.h"
|
#include "Camera.h"
|
||||||
|
|
||||||
Camera::Camera() {
|
Camera::Camera() {
|
||||||
_mode = CAMERA_MODE_THIRD_PERSON;
|
_frustumNeedsReshape = false;
|
||||||
_tightness = DEFAULT_CAMERA_TIGHTNESS;
|
_mode = CAMERA_MODE_THIRD_PERSON;
|
||||||
_fieldOfView = 60.0; // default
|
_tightness = 10.0; // default
|
||||||
_nearClip = 0.08; // default
|
_fieldOfView = 60.0; // default
|
||||||
_farClip = 50.0; // default
|
_nearClip = 0.08; // default
|
||||||
_yaw = 0.0;
|
_farClip = 50.0; // default
|
||||||
_pitch = 0.0;
|
_modeShift = 0.0;
|
||||||
_roll = 0.0;
|
_yaw = 0.0;
|
||||||
_up = 0.0;
|
_pitch = 0.0;
|
||||||
_distance = 0.0;
|
_roll = 0.0;
|
||||||
_idealYaw = 0.0;
|
_upShift = 0.0;
|
||||||
_targetPosition = glm::vec3( 0.0, 0.0, 0.0 );
|
_rightShift = 0.0;
|
||||||
_position = glm::vec3( 0.0, 0.0, 0.0 );
|
_distance = 0.0;
|
||||||
_idealPosition = glm::vec3( 0.0, 0.0, 0.0 );
|
_idealYaw = 0.0;
|
||||||
|
_targetPosition = glm::vec3( 0.0, 0.0, 0.0 );
|
||||||
|
_position = glm::vec3( 0.0, 0.0, 0.0 );
|
||||||
|
_idealPosition = glm::vec3( 0.0, 0.0, 0.0 );
|
||||||
_orientation.setToIdentity();
|
_orientation.setToIdentity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Camera::update( float deltaTime ) {
|
||||||
|
|
||||||
void Camera::update( float deltaTime )
|
// generate the ortho-normals for the orientation based on the Euler angles
|
||||||
{
|
_orientation.setToIdentity();
|
||||||
//----------------------------------------
|
_orientation.yaw ( _yaw );
|
||||||
// derive t from tightness
|
_orientation.pitch( _pitch );
|
||||||
//----------------------------------------
|
_orientation.roll ( _roll );
|
||||||
float t = _tightness * deltaTime;
|
|
||||||
|
|
||||||
if ( t > 1.0 ){
|
if ( _mode == CAMERA_MODE_NULL ) {
|
||||||
t = 1.0;
|
_modeShift = 0.0;
|
||||||
}
|
} else {
|
||||||
|
// use iterative forces to keep the camera at the desired position and angle
|
||||||
|
updateFollowMode( deltaTime );
|
||||||
|
|
||||||
//----------------------------------------
|
if ( _modeShift < 1.0f ) {
|
||||||
// update _yaw (before position!)
|
_modeShift += MODE_SHIFT_RATE * deltaTime;
|
||||||
//----------------------------------------
|
if ( _modeShift > 1.0f ) {
|
||||||
_yaw += ( _idealYaw - _yaw ) * t;
|
_modeShift = 1.0f;
|
||||||
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
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
_orientation.setToIdentity();
|
|
||||||
|
|
||||||
_orientation.yaw ( _yaw );
|
|
||||||
_orientation.pitch ( _pitch );
|
|
||||||
_orientation.roll ( _roll );
|
|
||||||
|
|
||||||
//printLog( "orientation.front = %f, %f, %f\n", _orientation.front.x, _orientation.front.y, _orientation.front.z );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// use iterative forces to keep the camera at the desired position and angle
|
||||||
|
void Camera::updateFollowMode( float deltaTime ) {
|
||||||
|
// derive t from tightness
|
||||||
|
float t = _tightness * deltaTime;
|
||||||
|
if ( t > 1.0 ) {
|
||||||
|
t = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// update _yaw (before position!)
|
||||||
|
_yaw += ( _idealYaw - _yaw ) * t;
|
||||||
|
_orientation.yaw ( _yaw );
|
||||||
|
|
||||||
|
float radian = ( _yaw / 180.0 ) * PIE;
|
||||||
|
|
||||||
|
// update _position
|
||||||
|
//these need to be checked to make sure they correspond to the correct coordinate system.
|
||||||
|
double x = _distance * -sin( radian );
|
||||||
|
double z = _distance * cos( radian );
|
||||||
|
double y = _upShift;
|
||||||
|
|
||||||
|
_idealPosition = _targetPosition + glm::vec3( x, y, z );
|
||||||
|
//_idealPosition += _orientation.getRight() * _rightShift;
|
||||||
|
//_idealPosition += _orientation.getUp () * _upShift;
|
||||||
|
|
||||||
|
// pull position towards ideal position
|
||||||
|
_position += ( _idealPosition - _position ) * t;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// call to find out if the view frustum needs to be reshaped
|
||||||
|
bool Camera::getFrustumNeedsReshape() {
|
||||||
|
return _frustumNeedsReshape;
|
||||||
|
}
|
||||||
|
|
||||||
|
// call this after reshaping the view frustum
|
||||||
|
void Camera::setFrustumWasReshaped() {
|
||||||
|
_frustumNeedsReshape = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,13 +14,13 @@
|
||||||
enum CameraMode
|
enum CameraMode
|
||||||
{
|
{
|
||||||
CAMERA_MODE_NULL = -1,
|
CAMERA_MODE_NULL = -1,
|
||||||
CAMERA_MODE_FIRST_PERSON,
|
|
||||||
CAMERA_MODE_THIRD_PERSON,
|
CAMERA_MODE_THIRD_PERSON,
|
||||||
|
CAMERA_MODE_FIRST_PERSON,
|
||||||
CAMERA_MODE_MY_OWN_FACE,
|
CAMERA_MODE_MY_OWN_FACE,
|
||||||
NUM_CAMERA_MODES
|
NUM_CAMERA_MODES
|
||||||
};
|
};
|
||||||
|
|
||||||
static const float DEFAULT_CAMERA_TIGHTNESS = 10.0f;
|
const float MODE_SHIFT_RATE = 2.0f;
|
||||||
|
|
||||||
class Camera
|
class Camera
|
||||||
{
|
{
|
||||||
|
@ -29,35 +29,42 @@ public:
|
||||||
|
|
||||||
void update( float deltaTime );
|
void update( float deltaTime );
|
||||||
|
|
||||||
void setMode ( CameraMode m ) { _mode = m; }
|
void setMode ( CameraMode m ) { _mode = m; _modeShift = 0.0f; }
|
||||||
void setYaw ( float y ) { _idealYaw = y; }
|
void setYaw ( float y ) { _yaw = y; }
|
||||||
void setPitch ( float p ) { _pitch = p; }
|
void setPitch ( float p ) { _pitch = p; }
|
||||||
void setRoll ( float r ) { _roll = r; }
|
void setRoll ( float r ) { _roll = r; }
|
||||||
void setUp ( float u ) { _up = u; }
|
void setUpShift ( float u ) { _upShift = u; }
|
||||||
void setDistance ( float d ) { _distance = d; }
|
void setRightShift ( float r ) { _rightShift = r; }
|
||||||
void setTargetPosition ( glm::vec3 t ) { _targetPosition = t; };
|
void setDistance ( float d ) { _distance = d; }
|
||||||
void setPosition ( glm::vec3 p ) { _position = p; };
|
void setTargetPosition( glm::vec3 t ) { _targetPosition = t; }
|
||||||
void setOrientation ( Orientation o ) { _orientation.set(o); }
|
void setTargetYaw ( float y ) { _idealYaw = y; }
|
||||||
void setTightness ( float t ) { _tightness = t; }
|
void setPosition ( glm::vec3 p ) { _position = p; }
|
||||||
void setFieldOfView ( float f ) { _fieldOfView = f; }
|
void setOrientation ( Orientation o ) { _orientation.set(o); }
|
||||||
void setAspectRatio ( float a ) { _aspectRatio = a; }
|
void setTightness ( float t ) { _tightness = t; }
|
||||||
void setNearClip ( float n ) { _nearClip = n; }
|
void setFieldOfView ( float f ) { _fieldOfView = f; _frustumNeedsReshape = true; }
|
||||||
void setFarClip ( float f ) { _farClip = f; }
|
void setAspectRatio ( float a ) { _aspectRatio = a; _frustumNeedsReshape = true; }
|
||||||
|
void setNearClip ( float n ) { _nearClip = n; _frustumNeedsReshape = true; }
|
||||||
|
void setFarClip ( float f ) { _farClip = f; _frustumNeedsReshape = true; }
|
||||||
|
|
||||||
float getYaw () { return _yaw; }
|
float getYaw () { return _yaw; }
|
||||||
float getPitch () { return _pitch; }
|
float getPitch () { return _pitch; }
|
||||||
float getRoll () { return _roll; }
|
float getRoll () { return _roll; }
|
||||||
glm::vec3 getPosition () { return _position; }
|
glm::vec3 getPosition () { return _position; }
|
||||||
Orientation getOrientation () { return _orientation; }
|
Orientation getOrientation() { return _orientation; }
|
||||||
CameraMode getMode () { return _mode; }
|
CameraMode getMode () { return _mode; }
|
||||||
float getFieldOfView () { return _fieldOfView; }
|
float getModeShift () { return _modeShift; }
|
||||||
float getAspectRatio () { return _aspectRatio; }
|
float getFieldOfView() { return _fieldOfView; }
|
||||||
float getNearClip () { return _nearClip; }
|
float getAspectRatio() { return _aspectRatio; }
|
||||||
float getFarClip () { return _farClip; }
|
float getNearClip () { return _nearClip; }
|
||||||
|
float getFarClip () { return _farClip; }
|
||||||
|
bool getFrustumNeedsReshape(); // call to find out if the view frustum needs to be reshaped
|
||||||
|
void setFrustumWasReshaped(); // call this after reshaping the view frustum.
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
CameraMode _mode;
|
CameraMode _mode;
|
||||||
|
float _modeShift; // 0.0 to 1.0
|
||||||
|
bool _frustumNeedsReshape;
|
||||||
glm::vec3 _position;
|
glm::vec3 _position;
|
||||||
glm::vec3 _idealPosition;
|
glm::vec3 _idealPosition;
|
||||||
glm::vec3 _targetPosition;
|
glm::vec3 _targetPosition;
|
||||||
|
@ -68,11 +75,14 @@ private:
|
||||||
float _yaw;
|
float _yaw;
|
||||||
float _pitch;
|
float _pitch;
|
||||||
float _roll;
|
float _roll;
|
||||||
float _up;
|
float _upShift;
|
||||||
|
float _rightShift;
|
||||||
float _idealYaw;
|
float _idealYaw;
|
||||||
float _distance;
|
float _distance;
|
||||||
float _tightness;
|
float _tightness;
|
||||||
Orientation _orientation;
|
Orientation _orientation;
|
||||||
|
|
||||||
|
void updateFollowMode( float deltaTime );
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -240,8 +240,6 @@ void updateHandController( int x, int y ) {
|
||||||
handController.startX = WIDTH / 2;
|
handController.startX = WIDTH / 2;
|
||||||
handController.startY = HEIGHT / 2;
|
handController.startY = HEIGHT / 2;
|
||||||
handController.envelope = 0.0;
|
handController.envelope = 0.0;
|
||||||
//prototype
|
|
||||||
//myAvatar.stopHandMovement();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -800,35 +798,67 @@ void display(void)
|
||||||
glMaterialfv(GL_FRONT, GL_SPECULAR, specular_color);
|
glMaterialfv(GL_FRONT, GL_SPECULAR, specular_color);
|
||||||
glMateriali(GL_FRONT, GL_SHININESS, 96);
|
glMateriali(GL_FRONT, GL_SHININESS, 96);
|
||||||
|
|
||||||
//--------------------------------------------------------
|
|
||||||
// camera settings
|
// camera settings
|
||||||
//--------------------------------------------------------
|
|
||||||
if ( ::lookingInMirror ) {
|
if ( ::lookingInMirror ) {
|
||||||
//-----------------------------------------------
|
|
||||||
// set the camera to looking at my own face
|
// set the camera to looking at my own face
|
||||||
//-----------------------------------------------
|
|
||||||
myCamera.setTargetPosition ( myAvatar.getHeadPosition() );
|
myCamera.setTargetPosition ( myAvatar.getHeadPosition() );
|
||||||
myCamera.setYaw ( - myAvatar.getBodyYaw() );
|
myCamera.setTargetYaw ( - myAvatar.getBodyYaw() );
|
||||||
myCamera.setPitch ( 0.0 );
|
myCamera.setPitch ( 0.0 );
|
||||||
myCamera.setRoll ( 0.0 );
|
myCamera.setRoll ( 0.0 );
|
||||||
myCamera.setUp ( 0.0 );
|
myCamera.setUpShift ( 0.0 );
|
||||||
myCamera.setDistance ( 0.2 );
|
myCamera.setDistance ( 0.2 );
|
||||||
myCamera.setTightness ( 100.0f );
|
myCamera.setTightness ( 100.0f );
|
||||||
myCamera.update ( 1.f/FPS );
|
|
||||||
} else {
|
} else {
|
||||||
//----------------------------------------------------
|
|
||||||
// set the camera to third-person view behind my av
|
float firstPersonPitch = 20.0f;
|
||||||
//----------------------------------------------------
|
float firstPersonUpShift = 0.1f;
|
||||||
myCamera.setTargetPosition ( myAvatar.getPosition() );
|
float firstPersonDistance = 0.0f;
|
||||||
myCamera.setYaw ( 180.0 - myAvatar.getBodyYaw() );
|
float firstPersonTightness = 100.0f;
|
||||||
myCamera.setPitch ( 0.0 ); // temporarily, this must be 0.0 or else bad juju
|
|
||||||
myCamera.setRoll ( 0.0 );
|
float thirdPersonPitch = 0.0f;
|
||||||
myCamera.setUp ( 0.45 );
|
float thirdPersonUpShift = -0.1f;
|
||||||
myCamera.setDistance ( 1.0 );
|
float thirdPersonDistance = 1.f;
|
||||||
myCamera.setTightness ( 8.0f );
|
float thirdPersonTightness = 8.0f;
|
||||||
myCamera.update ( 1.f/FPS);
|
|
||||||
|
myCamera.setPitch (thirdPersonPitch );
|
||||||
|
myCamera.setUpShift (thirdPersonUpShift );
|
||||||
|
myCamera.setDistance (thirdPersonDistance );
|
||||||
|
myCamera.setTightness(thirdPersonTightness);
|
||||||
|
|
||||||
|
/*
|
||||||
|
if ( myAvatar.getSpeed() < 0.02 ) {
|
||||||
|
if (myCamera.getMode() != CAMERA_MODE_FIRST_PERSON ) {
|
||||||
|
myCamera.setMode(CAMERA_MODE_FIRST_PERSON);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf( "myCamera.getModeShift() = %f\n", myCamera.getModeShift());
|
||||||
|
|
||||||
|
myCamera.setPitch ( thirdPersonPitch + myCamera.getModeShift() * ( firstPersonPitch - thirdPersonPitch ));
|
||||||
|
myCamera.setUpShift ( thirdPersonUpShift + myCamera.getModeShift() * ( firstPersonUpShift - thirdPersonUpShift ));
|
||||||
|
myCamera.setDistance ( thirdPersonDistance + myCamera.getModeShift() * ( firstPersonDistance - thirdPersonDistance ));
|
||||||
|
myCamera.setTightness ( thirdPersonTightness + myCamera.getModeShift() * ( firstPersonTightness - thirdPersonTightness ));
|
||||||
|
} else {
|
||||||
|
if (myCamera.getMode() != CAMERA_MODE_THIRD_PERSON ) {
|
||||||
|
myCamera.setMode(CAMERA_MODE_THIRD_PERSON);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf( "myCamera.getModeShift() = %f\n", myCamera.getModeShift());
|
||||||
|
|
||||||
|
myCamera.setPitch ( firstPersonPitch + myCamera.getModeShift() * ( thirdPersonPitch - firstPersonPitch ));
|
||||||
|
myCamera.setUpShift ( firstPersonUpShift + myCamera.getModeShift() * ( thirdPersonUpShift - firstPersonUpShift ));
|
||||||
|
myCamera.setDistance ( firstPersonDistance + myCamera.getModeShift() * ( thirdPersonDistance - firstPersonDistance ));
|
||||||
|
myCamera.setTightness ( firstPersonTightness + myCamera.getModeShift() * ( thirdPersonTightness - firstPersonTightness ));
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
myCamera.setTargetPosition( myAvatar.getHeadPosition() );
|
||||||
|
myCamera.setTargetYaw ( 180.0 - myAvatar.getBodyYaw() );
|
||||||
|
myCamera.setRoll ( 0.0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// important...
|
||||||
|
myCamera.update( 1.f/FPS );
|
||||||
|
|
||||||
// Note: whichCamera is used to pick between the normal camera myCamera for our
|
// Note: whichCamera is used to pick between the normal camera myCamera for our
|
||||||
// main camera, vs, an alternate camera. The alternate camera we support right now
|
// main camera, vs, an alternate camera. The alternate camera we support right now
|
||||||
// is the viewFrustumOffsetCamera. But theoretically, we could use this same mechanism
|
// is the viewFrustumOffsetCamera. But theoretically, we could use this same mechanism
|
||||||
|
@ -843,10 +873,10 @@ void display(void)
|
||||||
if (::viewFrustumFromOffset && ::frustumOn) {
|
if (::viewFrustumFromOffset && ::frustumOn) {
|
||||||
|
|
||||||
// set the camera to third-person view but offset so we can see the frustum
|
// set the camera to third-person view but offset so we can see the frustum
|
||||||
viewFrustumOffsetCamera.setYaw ( 180.0 - myAvatar.getBodyYaw() + ::viewFrustumOffsetYaw );
|
viewFrustumOffsetCamera.setTargetYaw( 180.0 - myAvatar.getBodyYaw() + ::viewFrustumOffsetYaw );
|
||||||
viewFrustumOffsetCamera.setPitch ( ::viewFrustumOffsetPitch );
|
viewFrustumOffsetCamera.setPitch ( ::viewFrustumOffsetPitch );
|
||||||
viewFrustumOffsetCamera.setRoll ( ::viewFrustumOffsetRoll );
|
viewFrustumOffsetCamera.setRoll ( ::viewFrustumOffsetRoll );
|
||||||
viewFrustumOffsetCamera.setUp ( ::viewFrustumOffsetUp );
|
viewFrustumOffsetCamera.setUpShift ( ::viewFrustumOffsetUp );
|
||||||
viewFrustumOffsetCamera.setDistance ( ::viewFrustumOffsetDistance );
|
viewFrustumOffsetCamera.setDistance ( ::viewFrustumOffsetDistance );
|
||||||
viewFrustumOffsetCamera.update(1.f/FPS);
|
viewFrustumOffsetCamera.update(1.f/FPS);
|
||||||
whichCamera = viewFrustumOffsetCamera;
|
whichCamera = viewFrustumOffsetCamera;
|
||||||
|
@ -864,10 +894,8 @@ void display(void)
|
||||||
if (::starsOn) {
|
if (::starsOn) {
|
||||||
// should be the first rendering pass - w/o depth buffer / lighting
|
// should be the first rendering pass - w/o depth buffer / lighting
|
||||||
|
|
||||||
|
|
||||||
// finally render the starfield
|
// finally render the starfield
|
||||||
stars.render(whichCamera.getFieldOfView(), aspectRatio, whichCamera.getNearClip());
|
stars.render(whichCamera.getFieldOfView(), aspectRatio, whichCamera.getNearClip());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glEnable(GL_LIGHTING);
|
glEnable(GL_LIGHTING);
|
||||||
|
|
Loading…
Reference in a new issue