mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-08 06:32:35 +02:00
added quaternions to avatar body and bone structure (but not using them yet)
This commit is contained in:
parent
851b833d35
commit
4f0ca2f33e
3 changed files with 43 additions and 46 deletions
|
@ -48,26 +48,20 @@ unsigned int iris_texture_height = 256;
|
|||
Head::Head() {
|
||||
initializeAvatar();
|
||||
|
||||
|
||||
avatar.orientation.setToIdentity();
|
||||
avatar.velocity = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
avatar.thrust = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
avatar.orientation.setToIdentity();
|
||||
|
||||
closestOtherAvatar = 0;
|
||||
|
||||
_bodyYaw = -90.0;
|
||||
_bodyPitch = 0.0;
|
||||
_bodyRoll = 0.0;
|
||||
|
||||
bodyYawDelta = 0.0;
|
||||
|
||||
triggeringAction = false;
|
||||
|
||||
mode = AVATAR_MODE_STANDING;
|
||||
rotation = glm::quat( 0.0f, 0.0f, 0.0f, 0.0f );
|
||||
closestOtherAvatar = 0;
|
||||
_bodyYaw = -90.0;
|
||||
_bodyPitch = 0.0;
|
||||
_bodyRoll = 0.0;
|
||||
bodyYawDelta = 0.0;
|
||||
triggeringAction = false;
|
||||
mode = AVATAR_MODE_STANDING;
|
||||
|
||||
initializeSkeleton();
|
||||
|
||||
|
||||
for (int i = 0; i < MAX_DRIVE_KEYS; i++) driveKeys[i] = false;
|
||||
|
||||
PupilSize = 0.10;
|
||||
|
@ -102,17 +96,15 @@ Head::Head() {
|
|||
browAudioLift = 0.0;
|
||||
noise = 0;
|
||||
|
||||
handBeingMoved = false;
|
||||
previousHandBeingMoved = false;
|
||||
movedHandOffset = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
handBeingMoved = false;
|
||||
previousHandBeingMoved = false;
|
||||
movedHandOffset = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
usingSprings = false;
|
||||
springForce = 6.0f;
|
||||
springVelocityDecay = 16.0f;
|
||||
|
||||
sphere = NULL;
|
||||
|
||||
usingSprings = false;
|
||||
|
||||
springForce = 6.0f;
|
||||
springVelocityDecay = 16.0f;
|
||||
|
||||
if (iris_texture.size() == 0) {
|
||||
switchToResourcesIfRequired();
|
||||
unsigned error = lodepng::decode(iris_texture, iris_texture_width, iris_texture_height, iris_texture_file);
|
||||
|
@ -137,30 +129,23 @@ Head::Head() {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Head::Head(const Head &otherHead) {
|
||||
initializeAvatar();
|
||||
|
||||
avatar.orientation.set( otherHead.avatar.orientation );
|
||||
avatar.velocity = otherHead.avatar.velocity;
|
||||
avatar.thrust = otherHead.avatar.thrust;
|
||||
avatar.orientation.set( otherHead.avatar.orientation );
|
||||
|
||||
closestOtherAvatar = otherHead.closestOtherAvatar;
|
||||
|
||||
_bodyYaw = otherHead._bodyYaw;
|
||||
_bodyPitch = otherHead._bodyPitch;
|
||||
_bodyRoll = otherHead._bodyRoll;
|
||||
|
||||
bodyYawDelta = otherHead.bodyYawDelta;
|
||||
|
||||
triggeringAction = otherHead.triggeringAction;
|
||||
|
||||
mode = otherHead.mode;
|
||||
rotation = otherHead.rotation;
|
||||
closestOtherAvatar = otherHead.closestOtherAvatar;
|
||||
_bodyYaw = otherHead._bodyYaw;
|
||||
_bodyPitch = otherHead._bodyPitch;
|
||||
_bodyRoll = otherHead._bodyRoll;
|
||||
bodyYawDelta = otherHead.bodyYawDelta;
|
||||
triggeringAction = otherHead.triggeringAction;
|
||||
mode = otherHead.mode;
|
||||
|
||||
initializeSkeleton();
|
||||
|
||||
|
||||
for (int i = 0; i < MAX_DRIVE_KEYS; i++) driveKeys[i] = otherHead.driveKeys[i];
|
||||
|
||||
PupilSize = otherHead.PupilSize;
|
||||
|
@ -833,14 +818,19 @@ void Head::initializeAvatar() {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Head::initializeSkeleton() {
|
||||
|
||||
for (int b=0; b<NUM_AVATAR_BONES; b++) {
|
||||
bone[b].parent = AVATAR_BONE_NULL;
|
||||
bone[b].position = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
bone[b].springyPosition = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
bone[b].springyVelocity = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
bone[b].defaultPosePosition = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
bone[b].springyPosition = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
bone[b].springyVelocity = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
bone[b].rotation = glm::quat( 0.0f, 0.0f, 0.0f, 0.0f );
|
||||
bone[b].yaw = 0.0;
|
||||
bone[b].pitch = 0.0;
|
||||
bone[b].roll = 0.0;
|
||||
bone[b].length = 0.0;
|
||||
bone[b].springBodyTightness = 4.0;
|
||||
bone[b].orientation.setToIdentity();
|
||||
}
|
||||
|
|
|
@ -20,6 +20,11 @@
|
|||
#include "InterfaceConfig.h"
|
||||
#include "SerialInterface.h"
|
||||
|
||||
//#include <glm/glm.hpp>
|
||||
|
||||
#include <glm/gtc/quaternion.hpp> and <glm/gtx/quaternion.hpp>
|
||||
|
||||
|
||||
enum eyeContactTargets {LEFT_EYE, RIGHT_EYE, MOUTH};
|
||||
|
||||
#define FWD 0
|
||||
|
@ -80,6 +85,7 @@ struct AvatarBone
|
|||
glm::vec3 springyPosition; // used for special effects (a 'flexible' variant of position)
|
||||
glm::dvec3 springyVelocity; // used for special effects ( the velocity of the springy position)
|
||||
float springBodyTightness; // how tightly the springy position tries to stay on the position
|
||||
glm::quat rotation; // this will eventually replace yaw, pitch and roll (and maybe orienttion)
|
||||
float yaw; // the yaw Euler angle of the bone rotation off the parent
|
||||
float pitch; // the pitch Euler angle of the bone rotation off the parent
|
||||
float roll; // the roll Euler angle of the bone rotation off the parent
|
||||
|
@ -231,7 +237,9 @@ class Head : public AvatarData {
|
|||
|
||||
GLUquadric *sphere;
|
||||
Avatar avatar;
|
||||
|
||||
|
||||
glm::quat rotation; // the rotation of the avatar body as a whole
|
||||
|
||||
AvatarBone bone[ NUM_AVATAR_BONES ];
|
||||
|
||||
AvatarMode mode;
|
||||
|
|
|
@ -22,7 +22,6 @@ void Orientation::setToIdentity() {
|
|||
front = glm::vec3( 0.0, 0.0, 1.0 );
|
||||
}
|
||||
|
||||
|
||||
void Orientation::set( Orientation o ) {
|
||||
right = o.right;
|
||||
up = o.up;
|
||||
|
@ -125,7 +124,7 @@ void Orientation::testForOrthogonalAndNormalizedVectors( float epsilon ) {
|
|||
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// make sure vectors are orthoginal (or close enough)
|
||||
// make sure vectors are orthogonal (or close enough)
|
||||
//----------------------------------------------------------------
|
||||
glm::vec3 rightCross = glm::cross( up, front );
|
||||
glm::vec3 upCross = glm::cross( front, right );
|
||||
|
|
Loading…
Reference in a new issue