mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-01 05:32:24 +02:00
Merge pull request #392 from birarda/oculus
fix broken head rotation set based on copy return
This commit is contained in:
commit
da39f28211
6 changed files with 42 additions and 39 deletions
|
@ -289,25 +289,22 @@ void Application::paintGL() {
|
||||||
glPushMatrix(); {
|
glPushMatrix(); {
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
|
||||||
// camera settings
|
if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
|
||||||
if (OculusManager::isConnected()) {
|
|
||||||
_myAvatar.setDisplayingHead(false);
|
|
||||||
_myCamera.setUpShift (0.0f);
|
|
||||||
_myCamera.setDistance (0.0f);
|
|
||||||
_myCamera.setTightness (100.0f);
|
|
||||||
_myCamera.setTargetPosition(_myAvatar.getHeadPosition());
|
|
||||||
_myCamera.setTargetRotation(_myAvatar.getBodyYaw() + _myAvatar.getHead().getYaw(),
|
|
||||||
-_myAvatar.getHead().getPitch(),
|
|
||||||
_myAvatar.getHead().getRoll());
|
|
||||||
|
|
||||||
} else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
|
|
||||||
_myCamera.setTightness (100.0f);
|
_myCamera.setTightness (100.0f);
|
||||||
_myCamera.setTargetPosition(_myAvatar.getSpringyHeadPosition());
|
_myCamera.setTargetPosition(_myAvatar.getSpringyHeadPosition());
|
||||||
_myCamera.setTargetRotation(_myAvatar.getBodyYaw() - 180.0f,
|
_myCamera.setTargetRotation(_myAvatar.getBodyYaw() - 180.0f,
|
||||||
0.0f,
|
0.0f,
|
||||||
0.0f);
|
0.0f);
|
||||||
} else {
|
} else if (OculusManager::isConnected()) {
|
||||||
if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) {
|
_myAvatar.setDisplayingHead(false);
|
||||||
|
_myCamera.setUpShift (0.0f);
|
||||||
|
_myCamera.setDistance (0.0f);
|
||||||
|
_myCamera.setTightness (100.0f);
|
||||||
|
_myCamera.setTargetPosition(_myAvatar.getHeadPosition());
|
||||||
|
_myCamera.setTargetRotation(_myAvatar.getAbsoluteHeadYaw(),
|
||||||
|
-_myAvatar.getHead().getPitch(),
|
||||||
|
_myAvatar.getHead().getRoll());
|
||||||
|
} else if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) {
|
||||||
_myCamera.setTargetPosition(_myAvatar.getSpringyHeadPosition());
|
_myCamera.setTargetPosition(_myAvatar.getSpringyHeadPosition());
|
||||||
_myCamera.setTargetRotation(_myAvatar.getAbsoluteHeadYaw(),
|
_myCamera.setTargetRotation(_myAvatar.getAbsoluteHeadYaw(),
|
||||||
0.0f,
|
0.0f,
|
||||||
|
@ -316,8 +313,10 @@ void Application::paintGL() {
|
||||||
// Take a look at whether we are inside head, don't render it if so.
|
// Take a look at whether we are inside head, don't render it if so.
|
||||||
const float HEAD_RENDER_DISTANCE = 0.5;
|
const float HEAD_RENDER_DISTANCE = 0.5;
|
||||||
glm::vec3 distanceToHead(_myCamera.getPosition() - _myAvatar.getSpringyHeadPosition());
|
glm::vec3 distanceToHead(_myCamera.getPosition() - _myAvatar.getSpringyHeadPosition());
|
||||||
if (glm::length(distanceToHead) < HEAD_RENDER_DISTANCE) { _myAvatar.setDisplayingHead(false); }
|
|
||||||
|
|
||||||
|
if (glm::length(distanceToHead) < HEAD_RENDER_DISTANCE) {
|
||||||
|
_myAvatar.setDisplayingHead(false);
|
||||||
|
}
|
||||||
} else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
|
} else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
|
||||||
_myCamera.setTargetPosition(_myAvatar.getHeadPosition());
|
_myCamera.setTargetPosition(_myAvatar.getHeadPosition());
|
||||||
_myCamera.setTargetRotation(_myAvatar.getBodyYaw(),
|
_myCamera.setTargetRotation(_myAvatar.getBodyYaw(),
|
||||||
|
@ -325,7 +324,6 @@ void Application::paintGL() {
|
||||||
//-_myAvatar.getAbsoluteHeadPitch(),
|
//-_myAvatar.getAbsoluteHeadPitch(),
|
||||||
0.0f);
|
0.0f);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// important...
|
// important...
|
||||||
_myCamera.update( 1.f/_fps );
|
_myCamera.update( 1.f/_fps );
|
||||||
|
@ -1345,8 +1343,7 @@ void Application::updateAvatar(float deltaTime) {
|
||||||
const float HORIZONTAL_PIXELS_PER_DEGREE = 2880.f / 45.f;
|
const float HORIZONTAL_PIXELS_PER_DEGREE = 2880.f / 45.f;
|
||||||
const float VERTICAL_PIXELS_PER_DEGREE = 1800.f / 30.f;
|
const float VERTICAL_PIXELS_PER_DEGREE = 1800.f / 30.f;
|
||||||
if (powf(measuredYawRate * measuredYawRate +
|
if (powf(measuredYawRate * measuredYawRate +
|
||||||
measuredPitchRate * measuredPitchRate, 0.5) > MIN_MOUSE_RATE)
|
measuredPitchRate * measuredPitchRate, 0.5) > MIN_MOUSE_RATE) {
|
||||||
{
|
|
||||||
_headMouseX += measuredYawRate * HORIZONTAL_PIXELS_PER_DEGREE * deltaTime;
|
_headMouseX += measuredYawRate * HORIZONTAL_PIXELS_PER_DEGREE * deltaTime;
|
||||||
_headMouseY -= measuredPitchRate * VERTICAL_PIXELS_PER_DEGREE * deltaTime;
|
_headMouseY -= measuredPitchRate * VERTICAL_PIXELS_PER_DEGREE * deltaTime;
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,6 @@ Avatar::Avatar(bool isMine) :
|
||||||
// give the pointer to our head to inherited _headData variable from AvatarData
|
// give the pointer to our head to inherited _headData variable from AvatarData
|
||||||
_headData = &_head;
|
_headData = &_head;
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < MAX_DRIVE_KEYS; i++) {
|
for (int i = 0; i < MAX_DRIVE_KEYS; i++) {
|
||||||
_driveKeys[i] = false;
|
_driveKeys[i] = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ public:
|
||||||
float getHeight() const { return _height; }
|
float getHeight() const { return _height; }
|
||||||
|
|
||||||
AvatarMode getMode() const { return _mode; }
|
AvatarMode getMode() const { return _mode; }
|
||||||
Head getHead() const { return _head; }
|
Head& getHead() { return _head; }
|
||||||
|
|
||||||
void setMousePressed(bool pressed);
|
void setMousePressed(bool pressed);
|
||||||
void render(bool lookingInMirror, glm::vec3 cameraPosition);
|
void render(bool lookingInMirror, glm::vec3 cameraPosition);
|
||||||
|
|
|
@ -52,6 +52,9 @@ public:
|
||||||
float noise;
|
float noise;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// disallow copies of the Head, copy of owning Avatar is disallowed too
|
||||||
|
Head(const Head&);
|
||||||
|
Head& operator= (const Head&);
|
||||||
|
|
||||||
bool _returnHeadToCenter;
|
bool _returnHeadToCenter;
|
||||||
float _audioLoudness;
|
float _audioLoudness;
|
||||||
|
|
|
@ -95,10 +95,6 @@ public:
|
||||||
void setHeadData(HeadData* headData) { _headData = headData; }
|
void setHeadData(HeadData* headData) { _headData = headData; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// privatize the copy constructor and assignment operator so they cannot be called
|
|
||||||
AvatarData(const AvatarData&);
|
|
||||||
AvatarData& operator= (const AvatarData&);
|
|
||||||
|
|
||||||
glm::vec3 _position;
|
glm::vec3 _position;
|
||||||
glm::vec3 _handPosition;
|
glm::vec3 _handPosition;
|
||||||
|
|
||||||
|
@ -137,6 +133,10 @@ protected:
|
||||||
bool _wantDelta;
|
bool _wantDelta;
|
||||||
|
|
||||||
HeadData* _headData;
|
HeadData* _headData;
|
||||||
|
private:
|
||||||
|
// privatize the copy constructor and assignment operator so they cannot be called
|
||||||
|
AvatarData(const AvatarData&);
|
||||||
|
AvatarData& operator= (const AvatarData&);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* defined(__hifi__AvatarData__) */
|
#endif /* defined(__hifi__AvatarData__) */
|
||||||
|
|
|
@ -55,6 +55,10 @@ protected:
|
||||||
glm::vec3 _lookAtPosition;
|
glm::vec3 _lookAtPosition;
|
||||||
float _leanSideways;
|
float _leanSideways;
|
||||||
float _leanForward;
|
float _leanForward;
|
||||||
|
private:
|
||||||
|
// privatize copy ctor and assignment operator so copies of this object cannot be made
|
||||||
|
HeadData(const HeadData&);
|
||||||
|
HeadData& operator= (const HeadData&);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* defined(__hifi__HeadData__) */
|
#endif /* defined(__hifi__HeadData__) */
|
||||||
|
|
Loading…
Reference in a new issue