mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 11:37:58 +02:00
Merge pull request #97 from Ventrella/master
added - and then removed - some tests related to orientation
This commit is contained in:
commit
1c6048e2e9
3 changed files with 43 additions and 25 deletions
|
@ -47,7 +47,8 @@ unsigned int iris_texture_height = 256;
|
||||||
|
|
||||||
Head::Head(bool isMine) {
|
Head::Head(bool isMine) {
|
||||||
|
|
||||||
_orientation.setToIdentity();
|
_orientation.setToIdentity();
|
||||||
|
|
||||||
_velocity = glm::vec3( 0.0, 0.0, 0.0 );
|
_velocity = glm::vec3( 0.0, 0.0, 0.0 );
|
||||||
_thrust = glm::vec3( 0.0, 0.0, 0.0 );
|
_thrust = glm::vec3( 0.0, 0.0, 0.0 );
|
||||||
_rotation = glm::quat( 0.0f, 0.0f, 0.0f, 0.0f );
|
_rotation = glm::quat( 0.0f, 0.0f, 0.0f, 0.0f );
|
||||||
|
@ -163,8 +164,7 @@ Head::Head(const Head &otherAvatar) {
|
||||||
_movedHandOffset = otherAvatar._movedHandOffset;
|
_movedHandOffset = otherAvatar._movedHandOffset;
|
||||||
_usingBodySprings = otherAvatar._usingBodySprings;
|
_usingBodySprings = otherAvatar._usingBodySprings;
|
||||||
_springForce = otherAvatar._springForce;
|
_springForce = otherAvatar._springForce;
|
||||||
_springVelocityDecay = otherAvatar._springVelocityDecay;
|
_springVelocityDecay = otherAvatar._springVelocityDecay;
|
||||||
|
|
||||||
_orientation.set( otherAvatar._orientation );
|
_orientation.set( otherAvatar._orientation );
|
||||||
|
|
||||||
//for (int o=0;o<NUM_OTHER_AVATARS; o++) {
|
//for (int o=0;o<NUM_OTHER_AVATARS; o++) {
|
||||||
|
@ -385,7 +385,7 @@ void Head::simulate(float deltaTime) {
|
||||||
// this handles the avatar being driven around...
|
// this handles the avatar being driven around...
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
_thrust = glm::vec3( 0.0, 0.0, 0.0 );
|
_thrust = glm::vec3( 0.0, 0.0, 0.0 );
|
||||||
|
|
||||||
if (_driveKeys[FWD]) {
|
if (_driveKeys[FWD]) {
|
||||||
glm::vec3 front( _orientation.getFront().x, _orientation.getFront().y, _orientation.getFront().z );
|
glm::vec3 front( _orientation.getFront().x, _orientation.getFront().y, _orientation.getFront().z );
|
||||||
_thrust += front * THRUST_MAG;
|
_thrust += front * THRUST_MAG;
|
||||||
|
@ -1005,19 +1005,35 @@ void Head::updateSkeleton() {
|
||||||
//----------------------------------
|
//----------------------------------
|
||||||
_orientation.setToIdentity();
|
_orientation.setToIdentity();
|
||||||
_orientation.yaw( _bodyYaw );
|
_orientation.yaw( _bodyYaw );
|
||||||
|
|
||||||
//test! - make sure this does what expected: st rotation to be identity PLUS _bodyYaw
|
/*
|
||||||
//_rotation = glm::angleAxis( _bodyYaw, _orientation.up );
|
glm::quat quaternion
|
||||||
|
(
|
||||||
//glm::quat yaw_rotation = glm::angleAxis( _bodyYaw, _orientation.up );
|
glm::vec3
|
||||||
|
(
|
||||||
|
_bodyPitch * PI_OVER_180,
|
||||||
|
_bodyYaw * PI_OVER_180,
|
||||||
|
_bodyRoll * PI_OVER_180
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
glm::mat4 rotationMatrix = glm::mat4_cast( quaternion );
|
||||||
|
|
||||||
|
glm::vec4 right( 1.0, 0.0, 0.0, 0.0 );
|
||||||
|
glm::vec4 up ( 0.0, 1.0, 0.0, 0.0 );
|
||||||
|
glm::vec4 front( 0.0, 0.0, 1.0, 0.0 );
|
||||||
|
|
||||||
|
rightDirection = glm::vec3( right * rotationMatrix );
|
||||||
|
upDirection = glm::vec3( up * rotationMatrix );
|
||||||
|
frontDirection = glm::vec3( front * rotationMatrix );
|
||||||
|
*/
|
||||||
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// calculate positions of all bones by traversing the skeleton tree:
|
// calculate positions of all bones by traversing the skeleton tree:
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
for (int b=0; b<NUM_AVATAR_BONES; b++) {
|
for (int b=0; b<NUM_AVATAR_BONES; b++) {
|
||||||
if ( _bone[b].parent == AVATAR_BONE_NULL ) {
|
if ( _bone[b].parent == AVATAR_BONE_NULL ) {
|
||||||
_bone[b].orientation.set( _orientation );
|
_bone[b].orientation.set( _orientation );
|
||||||
_bone[b].position = _bodyPosition;
|
_bone[b].position = _bodyPosition;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1095,27 +1111,27 @@ void Head::updateBodySprings( float deltaTime ) {
|
||||||
glm::vec3 Head::getHeadLookatDirection() {
|
glm::vec3 Head::getHeadLookatDirection() {
|
||||||
return glm::vec3
|
return glm::vec3
|
||||||
(
|
(
|
||||||
_orientation.getFront().x,
|
_orientation.getFront().x,
|
||||||
_orientation.getFront().y,
|
_orientation.getFront().y,
|
||||||
_orientation.getFront().z
|
_orientation.getFront().z
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 Head::getHeadLookatDirectionUp() {
|
glm::vec3 Head::getHeadLookatDirectionUp() {
|
||||||
return glm::vec3
|
return glm::vec3
|
||||||
(
|
(
|
||||||
_orientation.getUp().x,
|
_orientation.getUp().x,
|
||||||
_orientation.getUp().y,
|
_orientation.getUp().y,
|
||||||
_orientation.getUp().z
|
_orientation.getUp().z
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 Head::getHeadLookatDirectionRight() {
|
glm::vec3 Head::getHeadLookatDirectionRight() {
|
||||||
return glm::vec3
|
return glm::vec3
|
||||||
(
|
(
|
||||||
_orientation.getRight().x,
|
_orientation.getRight().x,
|
||||||
_orientation.getRight().y,
|
_orientation.getRight().y,
|
||||||
_orientation.getRight().z
|
_orientation.getRight().z
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1132,12 +1148,13 @@ glm::vec3 Head::getHeadPosition() {
|
||||||
|
|
||||||
void Head::updateHandMovement() {
|
void Head::updateHandMovement() {
|
||||||
glm::vec3 transformedHandMovement;
|
glm::vec3 transformedHandMovement;
|
||||||
|
|
||||||
transformedHandMovement
|
transformedHandMovement
|
||||||
= _orientation.getRight() * _movedHandOffset.x
|
= _orientation.getRight() * _movedHandOffset.x
|
||||||
+ _orientation.getUp() * -_movedHandOffset.y * 0.5f
|
+ _orientation.getUp() * -_movedHandOffset.y * 0.5f
|
||||||
+ _orientation.getFront() * -_movedHandOffset.y;
|
+ _orientation.getFront() * -_movedHandOffset.y;
|
||||||
|
|
||||||
|
|
||||||
_bone[ AVATAR_BONE_RIGHT_HAND ].position += transformedHandMovement;
|
_bone[ AVATAR_BONE_RIGHT_HAND ].position += transformedHandMovement;
|
||||||
|
|
||||||
//if holding hands, add a pull to the hand...
|
//if holding hands, add a pull to the hand...
|
||||||
|
@ -1207,6 +1224,7 @@ void Head::updateHandMovement() {
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
glm::vec3 newElbowPosition = _bone[ AVATAR_BONE_RIGHT_SHOULDER ].position;
|
glm::vec3 newElbowPosition = _bone[ AVATAR_BONE_RIGHT_SHOULDER ].position;
|
||||||
newElbowPosition += armVector * ONE_HALF;
|
newElbowPosition += armVector * ONE_HALF;
|
||||||
|
//glm::vec3 perpendicular = glm::cross( frontDirection, armVector );
|
||||||
glm::vec3 perpendicular = glm::cross( _orientation.getFront(), armVector );
|
glm::vec3 perpendicular = glm::cross( _orientation.getFront(), armVector );
|
||||||
|
|
||||||
newElbowPosition += perpendicular * ( 1.0f - ( _maxArmLength / distance ) ) * ONE_HALF;
|
newElbowPosition += perpendicular * ( 1.0f - ( _maxArmLength / distance ) ) * ONE_HALF;
|
||||||
|
|
|
@ -223,18 +223,20 @@ class Head : public AvatarData {
|
||||||
glm::vec3 _movedHandOffset;
|
glm::vec3 _movedHandOffset;
|
||||||
float _springVelocityDecay;
|
float _springVelocityDecay;
|
||||||
float _springForce;
|
float _springForce;
|
||||||
glm::quat _rotation; // the rotation of the avatar body as a whole
|
glm::quat _rotation; // the rotation of the avatar body as a whole expressed as a quaternion
|
||||||
AvatarBone _bone[ NUM_AVATAR_BONES ];
|
AvatarBone _bone[ NUM_AVATAR_BONES ];
|
||||||
AvatarMode _mode;
|
AvatarMode _mode;
|
||||||
glm::dvec3 _velocity;
|
glm::dvec3 _velocity;
|
||||||
glm::vec3 _thrust;
|
glm::vec3 _thrust;
|
||||||
float _maxArmLength;
|
float _maxArmLength;
|
||||||
Orientation _orientation;
|
Orientation _orientation;
|
||||||
|
|
||||||
int _driveKeys[MAX_DRIVE_KEYS];
|
int _driveKeys[MAX_DRIVE_KEYS];
|
||||||
GLUquadric* _sphere;
|
GLUquadric* _sphere;
|
||||||
float _renderYaw;
|
float _renderYaw;
|
||||||
float _renderPitch; // Pitch from view frustum when this is own head.
|
float _renderPitch; // Pitch from view frustum when this is own head.
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Related to getting transmitter UDP data used to animate the avatar hand
|
// Related to getting transmitter UDP data used to animate the avatar hand
|
||||||
//
|
//
|
||||||
|
|
|
@ -1606,8 +1606,6 @@ void mouseoverFunc( int x, int y)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void attachNewHeadToAgent(Agent *newAgent) {
|
void attachNewHeadToAgent(Agent *newAgent) {
|
||||||
if (newAgent->getLinkedData() == NULL) {
|
if (newAgent->getLinkedData() == NULL) {
|
||||||
newAgent->setLinkedData(new Head(false));
|
newAgent->setLinkedData(new Head(false));
|
||||||
|
|
Loading…
Reference in a new issue