mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 17:14:59 +02:00
cleaning up look at code - Stephen helped find a transmission bug - fixed.
This commit is contained in:
parent
f7b101b4aa
commit
3c3a3fc82e
6 changed files with 54 additions and 49 deletions
|
@ -20,10 +20,6 @@
|
|||
#include <PacketHeaders.h>
|
||||
#include <OculusManager.h>
|
||||
|
||||
//test
|
||||
static glm::vec3 headLean(0.0f, 0.0f, 0.0f);
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
const bool BALLS_ON = false;
|
||||
|
@ -395,13 +391,14 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
|||
}
|
||||
|
||||
// set head lookat position
|
||||
if ((_interactingOther)
|
||||
&& (_isMine)) {
|
||||
_head.setLookAtPosition(_interactingOther->getSpringyHeadPosition());
|
||||
} else {
|
||||
_head.setLookAtPosition(glm::vec3(0.0f, 0.0f, 0.0f));
|
||||
if (_isMine) {
|
||||
if (_interactingOther) {
|
||||
_head.setLookAtPosition(_interactingOther->getApproximateEyePosition());
|
||||
} else {
|
||||
_head.setLookAtPosition(glm::vec3(0.0f, 0.0f, 0.0f));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
_head.setBodyRotation (glm::vec3(_bodyPitch, _bodyYaw, _bodyRoll));
|
||||
_head.setPosition(_joint[ AVATAR_JOINT_HEAD_BASE ].springyPosition);
|
||||
_head.setScale (_joint[ AVATAR_JOINT_HEAD_BASE ].radius);
|
||||
|
@ -417,6 +414,11 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
|||
}
|
||||
}
|
||||
|
||||
glm::vec3 Avatar::getApproximateEyePosition() {
|
||||
|
||||
return _head.getApproximateEyePosition();
|
||||
}
|
||||
|
||||
void Avatar::checkForMouseRayTouching() {
|
||||
|
||||
for (int b = 0; b < NUM_AVATAR_JOINTS; b++) {
|
||||
|
@ -722,7 +724,7 @@ void Avatar::render(bool lookingInMirror, glm::vec3 cameraPosition) {
|
|||
|
||||
//render body
|
||||
renderBody(lookingInMirror);
|
||||
|
||||
|
||||
// if this is my avatar, then render my interactions with the other avatar
|
||||
if (_isMine) {
|
||||
_avatarTouch.render(_cameraPosition);
|
||||
|
|
|
@ -37,18 +37,25 @@ Camera::Camera() {
|
|||
_idealPosition = glm::vec3(0.0, 0.0, 0.0);
|
||||
_orientation.setToIdentity();
|
||||
|
||||
for (int m = 0; m < NUM_CAMERA_MODES; m ++) {
|
||||
_attributes[m].upShift = 0.0f;
|
||||
_attributes[m].distance = 0.0f;
|
||||
_attributes[m].tightness = 0.0f;
|
||||
_attributes[CAMERA_MODE_FIRST_PERSON].upShift = CAMERA_DEFAULT_FIRST_PERSON_MODE_UP_SHIFT;
|
||||
_attributes[CAMERA_MODE_FIRST_PERSON].distance = CAMERA_DEFAULT_FIRST_PERSON_MODE_DISTANCE;
|
||||
_attributes[CAMERA_MODE_FIRST_PERSON].tightness = CAMERA_DEFAULT_FIRST_PERSON_MODE_TIGHTNESS;
|
||||
|
||||
_attributes[CAMERA_MODE_THIRD_PERSON].upShift = CAMERA_DEFAULT_THIRD_PERSON_MODE_UP_SHIFT;
|
||||
_attributes[CAMERA_MODE_THIRD_PERSON].distance = CAMERA_DEFAULT_THIRD_PERSON_MODE_DISTANCE;
|
||||
_attributes[CAMERA_MODE_THIRD_PERSON].tightness = CAMERA_DEFAULT_THIRD_PERSON_MODE_TIGHTNESS;
|
||||
|
||||
_attributes[CAMERA_MODE_MIRROR ].upShift = CAMERA_DEFAULT_MIRROR_MODE_UP_SHIFT;
|
||||
_attributes[CAMERA_MODE_MIRROR ].distance = CAMERA_DEFAULT_MIRROR_MODE_DISTANCE;
|
||||
_attributes[CAMERA_MODE_MIRROR ].tightness = CAMERA_DEFAULT_MIRROR_MODE_TIGHTNESS;
|
||||
|
||||
for (int m = 0; m < NUM_CAMERA_MODES; m ++) {
|
||||
_previousAttributes[m].upShift = 0.0f;
|
||||
_previousAttributes[m].distance = 0.0f;
|
||||
_previousAttributes[m].tightness = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Camera::update(float deltaTime) {
|
||||
|
||||
if (_mode != CAMERA_MODE_NULL) {
|
||||
|
|
|
@ -21,6 +21,19 @@ enum CameraMode
|
|||
NUM_CAMERA_MODES
|
||||
};
|
||||
|
||||
|
||||
const float CAMERA_DEFAULT_FIRST_PERSON_MODE_UP_SHIFT = 0.0f;
|
||||
const float CAMERA_DEFAULT_FIRST_PERSON_MODE_DISTANCE = 0.0f;
|
||||
const float CAMERA_DEFAULT_FIRST_PERSON_MODE_TIGHTNESS = 100.0f;
|
||||
|
||||
const float CAMERA_DEFAULT_THIRD_PERSON_MODE_UP_SHIFT = -0.2f;
|
||||
const float CAMERA_DEFAULT_THIRD_PERSON_MODE_DISTANCE = 1.5f;
|
||||
const float CAMERA_DEFAULT_THIRD_PERSON_MODE_TIGHTNESS = 8.0f;
|
||||
|
||||
const float CAMERA_DEFAULT_MIRROR_MODE_UP_SHIFT = 0.0f;
|
||||
const float CAMERA_DEFAULT_MIRROR_MODE_DISTANCE = 0.2f;
|
||||
const float CAMERA_DEFAULT_MIRROR_MODE_TIGHTNESS = 100.0f;
|
||||
|
||||
class Camera
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -104,7 +104,11 @@ void Head::simulate(float deltaTime, bool isMine) {
|
|||
float clamp = 0.01;
|
||||
if (_browAudioLift > clamp) { _browAudioLift = clamp; }
|
||||
|
||||
_browAudioLift *= 0.7f;
|
||||
_browAudioLift *= 0.7f;
|
||||
|
||||
//add comment when done...
|
||||
processLookat();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -124,33 +128,9 @@ void Head::setLooking(bool looking) {
|
|||
*/
|
||||
|
||||
|
||||
void Head::setLookAtPosition(const glm::vec3& lookAtPosition) {
|
||||
void Head::processLookat() {
|
||||
|
||||
_lookAtPosition = lookAtPosition;
|
||||
|
||||
_lookingAtSomething = true;
|
||||
|
||||
/*
|
||||
if ( fabs(lookAtPosition.x + lookAtPosition.y + lookAtPosition.z) == 0.0 ) { // a lookatPosition of 0,0,0 signifies NOT looking
|
||||
_lookingAtSomething = false;
|
||||
} else {
|
||||
_lookingAtSomething = true;
|
||||
}
|
||||
|
||||
glm::vec3 averageEyePosition = _leftEyePosition + (_rightEyePosition - _leftEyePosition ) * ONE_HALF;
|
||||
glm::vec3 targetLookatAxis = glm::normalize(_lookAtPosition - averageEyePosition);
|
||||
float dot = glm::dot(targetLookatAxis, _orientation.getFront());
|
||||
if (dot < MINIMUM_EYE_ROTATION) {
|
||||
_lookingAtSomething = false;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
_lookingAtSomething = true;
|
||||
|
||||
/*
|
||||
if ( fabs(lookAtPosition.x + lookAtPosition.y + lookAtPosition.z) == 0.0 ) { // a lookatPosition of 0,0,0 signifies NOT looking
|
||||
if ( fabs(_lookAtPosition.x + _lookAtPosition.y + _lookAtPosition.z) == 0.0 ) { // a lookatPosition of 0,0,0 signifies NOT looking
|
||||
_lookingAtSomething = false;
|
||||
} else {
|
||||
glm::vec3 averageEyePosition = _leftEyePosition + (_rightEyePosition - _leftEyePosition ) * ONE_HALF;
|
||||
|
@ -159,12 +139,13 @@ _lookingAtSomething = true;
|
|||
if (dot < MINIMUM_EYE_ROTATION) {
|
||||
_lookingAtSomething = false;
|
||||
} else {
|
||||
_lookAtPosition = lookAtPosition;
|
||||
_lookingAtSomething = true;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
glm::vec3 Head::getApproximateEyePosition() {
|
||||
return _leftEyePosition + (_rightEyePosition - _leftEyePosition ) * ONE_HALF;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -44,10 +44,11 @@ public:
|
|||
void setAudioLoudness (float audioLoudness ) { _audioLoudness = audioLoudness; }
|
||||
void setReturnToCenter (bool returnHeadToCenter) { _returnHeadToCenter = returnHeadToCenter; }
|
||||
|
||||
void setLookAtPosition (const glm::vec3& lookAtPosition); // overrides method in HeadData
|
||||
//void setLookAtPosition (const glm::vec3& lookAtPosition); // overrides method in HeadData
|
||||
|
||||
const bool getReturnToCenter() const { return _returnHeadToCenter; } // Do you want head to try to return to center (depends on interface detected)
|
||||
float getAverageLoudness() {return _averageLoudness;};
|
||||
glm::vec3 getApproximateEyePosition();
|
||||
|
||||
float yawRate;
|
||||
float noise;
|
||||
|
@ -86,6 +87,7 @@ private:
|
|||
void renderMouth();
|
||||
void debugRenderLookatVectors(glm::vec3 leftEyePosition, glm::vec3 rightEyePosition, glm::vec3 lookatPosition);
|
||||
void calculateGeometry( bool lookingInMirror);
|
||||
void processLookat();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -97,7 +97,7 @@ int AvatarData::getBroadcastData(unsigned char* destinationBuffer) {
|
|||
// Lookat Position
|
||||
memcpy(destinationBuffer, &_headData->_lookAtPosition, sizeof(_headData->_lookAtPosition));
|
||||
destinationBuffer += sizeof(_headData->_lookAtPosition);
|
||||
|
||||
|
||||
// Hand State (0 = not grabbing, 1 = grabbing)
|
||||
memcpy(destinationBuffer, &_handState, sizeof(char));
|
||||
destinationBuffer += sizeof(char);
|
||||
|
@ -191,7 +191,7 @@ int AvatarData::parseData(unsigned char* sourceBuffer, int numBytes) {
|
|||
// Lookat Position
|
||||
memcpy(&_headData->_lookAtPosition, sourceBuffer, sizeof(_headData->_lookAtPosition));
|
||||
sourceBuffer += sizeof(_headData->_lookAtPosition);
|
||||
|
||||
|
||||
// Hand State
|
||||
memcpy(&_handState, sourceBuffer, sizeof(char));
|
||||
sourceBuffer += sizeof(char);
|
||||
|
|
Loading…
Reference in a new issue