mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 11:39:41 +02:00
Set/get lean to/from network data.
This commit is contained in:
parent
82f03ffd8e
commit
7ef2a2c5d9
1 changed files with 7 additions and 5 deletions
|
@ -289,11 +289,9 @@ void Avatar::updateHeadFromGyros(float deltaTime, SerialInterface* serialInterfa
|
||||||
// Update torso lean distance based on accelerometer data
|
// Update torso lean distance based on accelerometer data
|
||||||
glm::vec3 estimatedPosition = serialInterface->getEstimatedPosition();
|
glm::vec3 estimatedPosition = serialInterface->getEstimatedPosition();
|
||||||
const float TORSO_LENGTH = 0.5f;
|
const float TORSO_LENGTH = 0.5f;
|
||||||
const float MAX_LEAN_RADIANS = PIf / 4;
|
const float MAX_LEAN = 45.0f;
|
||||||
_skeleton.joint[AVATAR_JOINT_TORSO].rotation = glm::quat(glm::vec3(
|
_head.setLeanSideways(glm::clamp(glm::degrees(atanf(-estimatedPosition.x / TORSO_LENGTH)), -MAX_LEAN, MAX_LEAN));
|
||||||
glm::clamp(atanf(estimatedPosition.z / TORSO_LENGTH), -MAX_LEAN_RADIANS, MAX_LEAN_RADIANS),
|
_head.setLeanForward(glm::clamp(glm::degrees(atanf(estimatedPosition.z / TORSO_LENGTH)), -MAX_LEAN, MAX_LEAN));
|
||||||
0.0f,
|
|
||||||
glm::clamp(atanf(-estimatedPosition.x / TORSO_LENGTH), -MAX_LEAN_RADIANS, MAX_LEAN_RADIANS)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float Avatar::getAbsoluteHeadYaw() const {
|
float Avatar::getAbsoluteHeadYaw() const {
|
||||||
|
@ -355,6 +353,10 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
||||||
// update balls
|
// update balls
|
||||||
if (_balls) { _balls->simulate(deltaTime); }
|
if (_balls) { _balls->simulate(deltaTime); }
|
||||||
|
|
||||||
|
// update torso rotation based on head lean
|
||||||
|
_skeleton.joint[AVATAR_JOINT_TORSO].rotation = glm::quat(glm::radians(glm::vec3(
|
||||||
|
_head.getLeanForward(), 0.0f, _head.getLeanSideways())));
|
||||||
|
|
||||||
// update avatar skeleton
|
// update avatar skeleton
|
||||||
_skeleton.update(deltaTime, getOrientation(), _position);
|
_skeleton.update(deltaTime, getOrientation(), _position);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue