mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-08 06:32:35 +02:00
re-work AvatarData to handle body position and rotation
This commit is contained in:
parent
ed3f308a0e
commit
a5a93443c6
9 changed files with 164 additions and 243 deletions
|
@ -35,7 +35,6 @@
|
|||
#include "AvatarData.h"
|
||||
|
||||
const int AVATAR_LISTEN_PORT = 55444;
|
||||
const unsigned short BROADCAST_INTERVAL_USECS = 20 * 1000 * 1000;
|
||||
|
||||
unsigned char *addAgentToBroadcastPacket(unsigned char *currentPosition, Agent *agentToAdd) {
|
||||
currentPosition += packAgentId(currentPosition, agentToAdd->getAgentId());
|
||||
|
|
|
@ -156,7 +156,7 @@ int audioCallback (const void *inputBuffer,
|
|||
|
||||
// memcpy the three float positions
|
||||
for (int p = 0; p < 3; p++) {
|
||||
memcpy(currentPacketPtr, &data->linkedHead->getPos()[p], sizeof(float));
|
||||
memcpy(currentPacketPtr, &data->linkedHead->getBodyPosition()[p], sizeof(float));
|
||||
currentPacketPtr += sizeof(float);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "Head.h"
|
||||
#include <AgentList.h>
|
||||
#include <AgentTypes.h>
|
||||
#include <PacketHeaders.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -125,7 +126,6 @@ Head::Head() {
|
|||
Head::Head(const Head &otherHead) {
|
||||
initializeAvatar();
|
||||
|
||||
position = otherHead.position;
|
||||
//velocity = otherHead.velocity;
|
||||
//thrust = otherHead.thrust;
|
||||
for (int i = 0; i < MAX_DRIVE_KEYS; i++) driveKeys[i] = otherHead.driveKeys[i];
|
||||
|
@ -375,16 +375,16 @@ void Head::simulate(float deltaTime) {
|
|||
bodyYawDelta += YAW_MAG * deltaTime;
|
||||
}
|
||||
|
||||
bodyYaw += bodyYawDelta * deltaTime;
|
||||
_bodyYaw += bodyYawDelta * deltaTime;
|
||||
|
||||
Yaw = bodyYaw;
|
||||
Yaw = _bodyYaw;
|
||||
|
||||
const float TEST_YAW_DECAY = 5.0;
|
||||
bodyYawDelta *= ( 1.0 - TEST_YAW_DECAY * deltaTime );
|
||||
|
||||
avatar.velocity += glm::dvec3( avatar.thrust * deltaTime );
|
||||
|
||||
position += (glm::vec3)avatar.velocity * deltaTime;
|
||||
_bodyPosition += (glm::vec3)avatar.velocity * deltaTime;
|
||||
//avatar.position += (glm::vec3)avatar.velocity * deltaTime;
|
||||
//position = avatar.position;
|
||||
|
||||
|
@ -515,7 +515,7 @@ void Head::render(int faceToFace, int isMine) {
|
|||
// show avatar position
|
||||
//---------------------------------------------------
|
||||
glPushMatrix();
|
||||
glTranslatef( position.x, position.y, position.z );
|
||||
glTranslatef(_bodyPosition.x, _bodyPosition.y, _bodyPosition.z);
|
||||
glScalef( 0.03, 0.03, 0.03 );
|
||||
glutSolidSphere( 1, 10, 10 );
|
||||
glPopMatrix();
|
||||
|
@ -624,7 +624,7 @@ void Head::renderHead( int faceToFace, int isMine ) {
|
|||
|
||||
//glRotatef(Yaw, 0, 1, 0);
|
||||
|
||||
glRotatef( bodyYaw, 0, 1, 0);
|
||||
glRotatef( _bodyYaw, 0, 1, 0);
|
||||
|
||||
//hand->render(1);
|
||||
|
||||
|
@ -780,9 +780,9 @@ void Head::initializeAvatar() {
|
|||
|
||||
closestOtherAvatar = 0;
|
||||
|
||||
bodyYaw = -90.0;
|
||||
bodyPitch = 0.0;
|
||||
bodyRoll = 0.0;
|
||||
_bodyYaw = -90.0;
|
||||
_bodyPitch = 0.0;
|
||||
_bodyRoll = 0.0;
|
||||
|
||||
bodyYawDelta = 0.0;
|
||||
|
||||
|
@ -899,7 +899,7 @@ void Head::updateAvatarSkeleton() {
|
|||
// rotate...
|
||||
//----------------------------------
|
||||
avatar.orientation.setToIdentity();
|
||||
avatar.orientation.yaw( bodyYaw );
|
||||
avatar.orientation.yaw( _bodyYaw );
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// calculate positions of all bones by traversing the skeleton tree:
|
||||
|
@ -907,7 +907,7 @@ void Head::updateAvatarSkeleton() {
|
|||
for (int b=0; b<NUM_AVATAR_BONES; b++) {
|
||||
if ( avatar.bone[b].parent == AVATAR_BONE_NULL ) {
|
||||
avatar.bone[b].orientation.set( avatar.orientation );
|
||||
avatar.bone[b].position = position;
|
||||
avatar.bone[b].position = _bodyPosition;
|
||||
}
|
||||
else {
|
||||
avatar.bone[b].orientation.set( avatar.bone[ avatar.bone[b].parent ].orientation );
|
||||
|
@ -937,7 +937,7 @@ void Head::updateAvatarSprings( float deltaTime ) {
|
|||
glm::vec3 springVector( avatar.bone[b].springyPosition );
|
||||
|
||||
if ( avatar.bone[b].parent == AVATAR_BONE_NULL ) {
|
||||
springVector -= position;
|
||||
springVector -= _bodyPosition;
|
||||
}
|
||||
else {
|
||||
springVector -= avatar.bone[ avatar.bone[b].parent ].springyPosition;
|
||||
|
@ -970,7 +970,7 @@ void Head::updateAvatarSprings( float deltaTime ) {
|
|||
}
|
||||
|
||||
float Head::getBodyYaw() {
|
||||
return bodyYaw;
|
||||
return _bodyYaw;
|
||||
}
|
||||
|
||||
glm::vec3 Head::getHeadLookatDirection() {
|
||||
|
@ -1009,17 +1009,6 @@ glm::vec3 Head::getHeadPosition() {
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
glm::vec3 Head::getBodyPosition() {
|
||||
return glm::vec3
|
||||
(
|
||||
avatar.bone[ AVATAR_BONE_PELVIS_SPINE ].position.x,
|
||||
avatar.bone[ AVATAR_BONE_PELVIS_SPINE ].position.y,
|
||||
avatar.bone[ AVATAR_BONE_PELVIS_SPINE ].position.z
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void Head::updateHandMovement() {
|
||||
glm::vec3 transformedHandMovement;
|
||||
|
||||
|
@ -1137,42 +1126,6 @@ void Head::renderBody()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Transmit data to agents requesting it
|
||||
// called on me just prior to sending data to others (continuasly called)
|
||||
int Head::getBroadcastData(char* data) {
|
||||
// Copy data for transmission to the buffer, return length of data
|
||||
sprintf(data, "H%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f",
|
||||
getRenderPitch() + Pitch, -getRenderYaw() + 180 -Yaw, Roll,
|
||||
//avatar.yaw, avatar.pitch, avatar.roll,
|
||||
position.x + leanSideways, position.y, position.z + leanForward,
|
||||
loudness, averageLoudness,
|
||||
//hand->getPos().x, hand->getPos().y, hand->getPos().z); //previous to Ventrella change
|
||||
avatar.bone[ AVATAR_BONE_RIGHT_HAND ].position.x,
|
||||
avatar.bone[ AVATAR_BONE_RIGHT_HAND ].position.y,
|
||||
avatar.bone[ AVATAR_BONE_RIGHT_HAND ].position.z );
|
||||
return strlen(data);
|
||||
}
|
||||
|
||||
|
||||
//called on the other agents - assigns it to my views of the others
|
||||
void Head::parseData(void *data, int size) {
|
||||
sscanf
|
||||
(
|
||||
(char *)data, "H%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f",
|
||||
&Pitch, &Yaw, &Roll,
|
||||
//&avatar.yaw, &avatar.pitch, &avatar.roll,
|
||||
&position.x, &position.y, &position.z,
|
||||
&loudness, &averageLoudness,
|
||||
&avatar.bone[ AVATAR_BONE_RIGHT_HAND ].position.x,
|
||||
&avatar.bone[ AVATAR_BONE_RIGHT_HAND ].position.y,
|
||||
&avatar.bone[ AVATAR_BONE_RIGHT_HAND ].position.z
|
||||
);
|
||||
|
||||
handBeingMoved = true;
|
||||
}
|
||||
|
||||
void Head::SetNewHeadTarget(float pitch, float yaw) {
|
||||
PitchTarget = pitch;
|
||||
YawTarget = yaw;
|
||||
|
|
|
@ -34,6 +34,60 @@ enum eyeContactTargets {LEFT_EYE, RIGHT_EYE, MOUTH};
|
|||
|
||||
#define NUM_OTHER_AVATARS 5
|
||||
|
||||
enum AvatarBones
|
||||
{
|
||||
AVATAR_BONE_NULL = -1,
|
||||
AVATAR_BONE_PELVIS_SPINE, // connects pelvis joint with torso joint (not supposed to be rotated)
|
||||
AVATAR_BONE_MID_SPINE, // connects torso joint with chest joint
|
||||
AVATAR_BONE_CHEST_SPINE, // connects chest joint with neckBase joint (not supposed to be rotated)
|
||||
AVATAR_BONE_NECK, // connects neckBase joint with headBase joint
|
||||
AVATAR_BONE_HEAD, // connects headBase joint with headTop joint
|
||||
AVATAR_BONE_LEFT_CHEST, // connects chest joint with left clavicle joint (not supposed to be rotated)
|
||||
AVATAR_BONE_LEFT_SHOULDER, // connects left clavicle joint with left shoulder joint
|
||||
AVATAR_BONE_LEFT_UPPER_ARM, // connects left shoulder joint with left elbow joint
|
||||
AVATAR_BONE_LEFT_FOREARM, // connects left elbow joint with left wrist joint
|
||||
AVATAR_BONE_LEFT_HAND, // connects left wrist joint with left fingertips joint
|
||||
AVATAR_BONE_RIGHT_CHEST, // connects chest joint with right clavicle joint (not supposed to be rotated)
|
||||
AVATAR_BONE_RIGHT_SHOULDER, // connects right clavicle joint with right shoulder joint
|
||||
AVATAR_BONE_RIGHT_UPPER_ARM, // connects right shoulder joint with right elbow joint
|
||||
AVATAR_BONE_RIGHT_FOREARM, // connects right elbow joint with right wrist joint
|
||||
AVATAR_BONE_RIGHT_HAND, // connects right wrist joint with right fingertips joint
|
||||
AVATAR_BONE_LEFT_PELVIS, // connects pelvis joint with left hip joint (not supposed to be rotated)
|
||||
AVATAR_BONE_LEFT_THIGH, // connects left hip joint with left knee joint
|
||||
AVATAR_BONE_LEFT_SHIN, // connects left knee joint with left heel joint
|
||||
AVATAR_BONE_LEFT_FOOT, // connects left heel joint with left toes joint
|
||||
AVATAR_BONE_RIGHT_PELVIS, // connects pelvis joint with right hip joint (not supposed to be rotated)
|
||||
AVATAR_BONE_RIGHT_THIGH, // connects right hip joint with right knee joint
|
||||
AVATAR_BONE_RIGHT_SHIN, // connects right knee joint with right heel joint
|
||||
AVATAR_BONE_RIGHT_FOOT, // connects right heel joint with right toes joint
|
||||
|
||||
NUM_AVATAR_BONES
|
||||
};
|
||||
|
||||
struct AvatarBone
|
||||
{
|
||||
AvatarBones parent; // which bone is this bone connected to?
|
||||
glm::vec3 position; // the position at the "end" of the bone
|
||||
glm::vec3 defaultPosePosition; // the parent relative position when the avatar is in the "T-pose"
|
||||
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 (0 to 1) the springy position tries to stay on the position
|
||||
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
|
||||
Orientation orientation; // three orthogonal normals determined by yaw, pitch, roll
|
||||
float length; // the length of the bone
|
||||
};
|
||||
|
||||
struct Avatar
|
||||
{
|
||||
glm::dvec3 velocity;
|
||||
glm::vec3 thrust;
|
||||
float maxArmLength;
|
||||
Orientation orientation;
|
||||
AvatarBone bone[ NUM_AVATAR_BONES ];
|
||||
};
|
||||
|
||||
class Head : public AvatarData {
|
||||
public:
|
||||
Head();
|
||||
|
@ -69,7 +123,6 @@ class Head : public AvatarData {
|
|||
glm::vec3 getHeadLookatDirectionRight();
|
||||
glm::vec3 getHeadPosition();
|
||||
glm::vec3 getBonePosition( AvatarBones b );
|
||||
glm::vec3 getBodyPosition();
|
||||
|
||||
void render(int faceToFace, int isMine);
|
||||
|
||||
|
@ -82,18 +135,12 @@ class Head : public AvatarData {
|
|||
void setHandMovement( glm::vec3 movement );
|
||||
void updateHandMovement();
|
||||
|
||||
// Send and receive network data
|
||||
int getBroadcastData(char * data);
|
||||
void parseData(void *data, int size);
|
||||
|
||||
float getLoudness() {return loudness;};
|
||||
float getAverageLoudness() {return averageLoudness;};
|
||||
void setAverageLoudness(float al) {averageLoudness = al;};
|
||||
void setLoudness(float l) {loudness = l;};
|
||||
|
||||
void SetNewHeadTarget(float, float);
|
||||
glm::vec3 getPos() { return position; };
|
||||
void setPos(glm::vec3 newpos) { position = newpos; };
|
||||
|
||||
// Set what driving keys are being pressed to control thrust levels
|
||||
void setDriveKeys(int key, bool val) { driveKeys[key] = val; };
|
||||
|
@ -145,12 +192,7 @@ class Head : public AvatarData {
|
|||
float averageLoudness;
|
||||
float audioAttack;
|
||||
float browAudioLift;
|
||||
|
||||
glm::vec3 position;
|
||||
|
||||
float bodyYaw;
|
||||
float bodyPitch;
|
||||
float bodyRoll;
|
||||
float bodyYawDelta;
|
||||
|
||||
float closeEnoughToInteract;
|
||||
|
|
|
@ -184,7 +184,7 @@ int VoxelSystem::treeToArrays(VoxelNode *currentNode, float nodePosition[3]) {
|
|||
int voxelsAdded = 0;
|
||||
|
||||
float halfUnitForVoxel = powf(0.5, *currentNode->octalCode) * (0.5 * TREE_SCALE);
|
||||
glm::vec3 viewerPosition = viewerHead->getPos();
|
||||
glm::vec3 viewerPosition = viewerHead->getBodyPosition();
|
||||
|
||||
// XXXBHG - Note: It appears as if the X and Z coordinates of Head or Agent are flip-flopped relative to the
|
||||
// coords of the voxel space. This flip flop causes LOD behavior to be extremely odd. This is my temporary hack
|
||||
|
|
|
@ -222,7 +222,7 @@ void displayStats(void)
|
|||
char legend2[] = "* - toggle stars, & - toggle paint mode, '-' - send erase all, '%' - send add scene";
|
||||
drawtext(10, statsVerticalOffset + 32, 0.10f, 0, 1.0, 0, legend2);
|
||||
|
||||
glm::vec3 avatarPos = myAvatar.getPos();
|
||||
glm::vec3 avatarPos = myAvatar.getBodyPosition();
|
||||
|
||||
char stats[200];
|
||||
sprintf(stats, "FPS = %3.0f Pkts/s = %d Bytes/s = %d Head(x,y,z)= %4.2f, %4.2f, %4.2f ",
|
||||
|
@ -308,7 +308,7 @@ void init(void)
|
|||
if (noiseOn) {
|
||||
myAvatar.setNoise(noise);
|
||||
}
|
||||
myAvatar.setPos(start_location );
|
||||
myAvatar.setBodyPosition(start_location);
|
||||
myCamera.setPosition( start_location );
|
||||
|
||||
|
||||
|
@ -350,7 +350,7 @@ void reset_sensors()
|
|||
|
||||
yaw = renderYawRate = 0;
|
||||
pitch = renderPitch = renderPitchRate = 0;
|
||||
myAvatar.setPos(start_location);
|
||||
myAvatar.setBodyPosition(start_location);
|
||||
headMouseX = WIDTH/2;
|
||||
headMouseY = HEIGHT/2;
|
||||
|
||||
|
@ -461,7 +461,7 @@ void simulateHead(float frametime)
|
|||
// If I'm in paint mode, send a voxel out to VOXEL server agents.
|
||||
if (::paintOn) {
|
||||
|
||||
glm::vec3 avatarPos = myAvatar.getPos();
|
||||
glm::vec3 avatarPos = myAvatar.getBodyPosition();
|
||||
|
||||
// For some reason, we don't want to flip X and Z here.
|
||||
::paintingVoxel.x = avatarPos.x/10.0;
|
||||
|
@ -687,7 +687,7 @@ void display(void)
|
|||
//--------------------------------------------------------
|
||||
// camera settings
|
||||
//--------------------------------------------------------
|
||||
myCamera.setTargetPosition( myAvatar.getPos() );
|
||||
myCamera.setTargetPosition( myAvatar.getBodyPosition() );
|
||||
|
||||
if ( displayHead ) {
|
||||
//-----------------------------------------------
|
||||
|
@ -799,7 +799,7 @@ void display(void)
|
|||
if (agent->getLinkedData() != NULL) {
|
||||
Head *agentHead = (Head *)agent->getLinkedData();
|
||||
glPushMatrix();
|
||||
glm::vec3 pos = agentHead->getPos();
|
||||
glm::vec3 pos = agentHead->getBodyPosition();
|
||||
glTranslatef(-pos.x, -pos.y, -pos.z);
|
||||
agentHead->render(0, 0);
|
||||
glPopMatrix();
|
||||
|
@ -1083,7 +1083,7 @@ void shiftPaintingColor()
|
|||
}
|
||||
|
||||
void setupPaintingVoxel() {
|
||||
glm::vec3 avatarPos = myAvatar.getPos();
|
||||
glm::vec3 avatarPos = myAvatar.getBodyPosition();
|
||||
|
||||
::paintingVoxel.x = avatarPos.z/-10.0; // voxel space x is negative z head space
|
||||
::paintingVoxel.y = avatarPos.y/-10.0; // voxel space y is negative y head space
|
||||
|
|
|
@ -8,9 +8,28 @@
|
|||
|
||||
#include <cstdio>
|
||||
|
||||
#include <PacketHeaders.h>
|
||||
|
||||
#include "AvatarData.h"
|
||||
|
||||
AvatarData::AvatarData() {
|
||||
int packFloatAngleToTwoByte(char* buffer, float angle) {
|
||||
const float ANGLE_CONVERSION_RATIO = (std::numeric_limits<uint16_t>::max() / 360.0);
|
||||
|
||||
uint16_t angleHolder = floorf((angle + 180) * ANGLE_CONVERSION_RATIO);
|
||||
memcpy(buffer, &angleHolder, sizeof(uint16_t));
|
||||
|
||||
return sizeof(uint16_t);
|
||||
}
|
||||
|
||||
int unpackFloatAngleFromTwoByte(uint16_t *byteAnglePointer, float *destinationPointer) {
|
||||
*destinationPointer = (*byteAnglePointer / std::numeric_limits<uint16_t>::max()) * 360.0 - 180;
|
||||
return sizeof(uint16_t);
|
||||
}
|
||||
|
||||
AvatarData::AvatarData() :
|
||||
_bodyYaw(-90.0),
|
||||
_bodyPitch(0.0),
|
||||
_bodyRoll(0.0) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -22,97 +41,70 @@ AvatarData* AvatarData::clone() const {
|
|||
return new AvatarData(*this);
|
||||
}
|
||||
|
||||
void AvatarData::parseData(void *data, int size) {
|
||||
char* packetData = (char *)data + 1;
|
||||
// transmit data to agents requesting it
|
||||
// called on me just prior to sending data to others (continuasly called)
|
||||
int AvatarData::getBroadcastData(char* destinationBuffer) {
|
||||
char* bufferPointer = destinationBuffer;
|
||||
*(bufferPointer++) = PACKET_HEADER_HEAD_DATA;
|
||||
|
||||
// TODO: DRY this up to a shared method
|
||||
// that can pack any type given the number of bytes
|
||||
// and return the number of bytes to push the pointer
|
||||
memcpy(bufferPointer, &_bodyPosition, sizeof(float) * 3);
|
||||
bufferPointer += sizeof(float) * 3;
|
||||
|
||||
// // Extract data from packet
|
||||
// sscanf(packetData,
|
||||
// PACKET_FORMAT,
|
||||
// &_pitch,
|
||||
// &_yaw,
|
||||
// &_roll,
|
||||
// &_headPositionX,
|
||||
// &_headPositionY,
|
||||
// &_headPositionZ,
|
||||
// &_loudness,
|
||||
// &_averageLoudness,
|
||||
// &_handPositionX,
|
||||
// &_handPositionY,
|
||||
// &_handPositionZ);
|
||||
bufferPointer += packFloatAngleToTwoByte(bufferPointer, _bodyYaw);
|
||||
bufferPointer += packFloatAngleToTwoByte(bufferPointer, _bodyPitch);
|
||||
bufferPointer += packFloatAngleToTwoByte(bufferPointer, _bodyRoll);
|
||||
|
||||
return bufferPointer - destinationBuffer;
|
||||
}
|
||||
|
||||
float AvatarData::getPitch() {
|
||||
return _pitch;
|
||||
// called on the other agents - assigns it to my views of the others
|
||||
void AvatarData::parseData(void *sourceBuffer, int numBytes) {
|
||||
|
||||
char* bufferPointer = (char*) sourceBuffer + 1;
|
||||
|
||||
memcpy(&_bodyPosition, bufferPointer, sizeof(float) * 3);
|
||||
bufferPointer += sizeof(float) * 3;
|
||||
|
||||
bufferPointer += unpackFloatAngleFromTwoByte((uint16_t*)bufferPointer, &_bodyYaw);
|
||||
bufferPointer += unpackFloatAngleFromTwoByte((uint16_t*)bufferPointer, &_bodyPitch);
|
||||
bufferPointer += unpackFloatAngleFromTwoByte((uint16_t*)bufferPointer, &_bodyRoll);
|
||||
}
|
||||
|
||||
float AvatarData::getYaw() {
|
||||
return _yaw;
|
||||
glm::vec3 AvatarData::getBodyPosition() {
|
||||
return glm::vec3(_bodyPosition.x,
|
||||
_bodyPosition.y,
|
||||
_bodyPosition.z);
|
||||
}
|
||||
|
||||
float AvatarData::getRoll() {
|
||||
return _roll;
|
||||
void AvatarData::setBodyPosition(glm::vec3 bodyPosition) {
|
||||
_bodyPosition = bodyPosition;
|
||||
}
|
||||
|
||||
float AvatarData::getHeadPositionX() {
|
||||
return _headPositionX;
|
||||
float AvatarData::getBodyYaw() {
|
||||
return _bodyYaw;
|
||||
}
|
||||
|
||||
float AvatarData::getHeadPositionY() {
|
||||
return _headPositionY;
|
||||
void AvatarData::setBodyYaw(float bodyYaw) {
|
||||
_bodyYaw = bodyYaw;
|
||||
}
|
||||
|
||||
float AvatarData::getHeadPositionZ() {
|
||||
return _headPositionZ;
|
||||
float AvatarData::getBodyPitch() {
|
||||
return _bodyPitch;
|
||||
}
|
||||
|
||||
float AvatarData::getLoudness() {
|
||||
return _loudness;
|
||||
void AvatarData::setBodyPitch(float bodyPitch) {
|
||||
_bodyPitch = bodyPitch;
|
||||
}
|
||||
|
||||
float AvatarData::getAverageLoudness() {
|
||||
return _averageLoudness;
|
||||
float AvatarData::getBodyRoll() {
|
||||
return _bodyRoll;
|
||||
}
|
||||
|
||||
float AvatarData::getHandPositionX() {
|
||||
return _handPositionX;
|
||||
void AvatarData::setBodyRoll(float bodyRoll) {
|
||||
_bodyRoll = bodyRoll;
|
||||
}
|
||||
|
||||
float AvatarData::getHandPositionY() {
|
||||
return _handPositionY;
|
||||
}
|
||||
|
||||
float AvatarData::getHandPositionZ() {
|
||||
return _handPositionZ;
|
||||
}
|
||||
|
||||
void AvatarData::setPitch(float pitch) {
|
||||
_pitch = pitch;
|
||||
}
|
||||
|
||||
void AvatarData::setYaw(float yaw) {
|
||||
_yaw = yaw;
|
||||
}
|
||||
|
||||
void AvatarData::setRoll(float roll) {
|
||||
_roll = roll;
|
||||
}
|
||||
|
||||
void AvatarData::setHeadPosition(float x, float y, float z) {
|
||||
_headPositionX = x;
|
||||
_headPositionY = y;
|
||||
_headPositionZ = z;
|
||||
}
|
||||
|
||||
void AvatarData::setLoudness(float loudness) {
|
||||
_loudness = loudness;
|
||||
}
|
||||
|
||||
void AvatarData::setAverageLoudness(float averageLoudness) {
|
||||
_averageLoudness = averageLoudness;
|
||||
}
|
||||
|
||||
void AvatarData::setHandPosition(float x, float y, float z) {
|
||||
_handPositionX = x;
|
||||
_handPositionY = y;
|
||||
_handPositionZ = z;
|
||||
}
|
||||
|
|
|
@ -14,101 +14,35 @@
|
|||
#include <glm/glm.hpp>
|
||||
|
||||
#include <AgentData.h>
|
||||
#include "Orientation.h"
|
||||
|
||||
enum AvatarBones
|
||||
{
|
||||
AVATAR_BONE_NULL = -1,
|
||||
AVATAR_BONE_PELVIS_SPINE, // connects pelvis joint with torso joint (not supposed to be rotated)
|
||||
AVATAR_BONE_MID_SPINE, // connects torso joint with chest joint
|
||||
AVATAR_BONE_CHEST_SPINE, // connects chest joint with neckBase joint (not supposed to be rotated)
|
||||
AVATAR_BONE_NECK, // connects neckBase joint with headBase joint
|
||||
AVATAR_BONE_HEAD, // connects headBase joint with headTop joint
|
||||
AVATAR_BONE_LEFT_CHEST, // connects chest joint with left clavicle joint (not supposed to be rotated)
|
||||
AVATAR_BONE_LEFT_SHOULDER, // connects left clavicle joint with left shoulder joint
|
||||
AVATAR_BONE_LEFT_UPPER_ARM, // connects left shoulder joint with left elbow joint
|
||||
AVATAR_BONE_LEFT_FOREARM, // connects left elbow joint with left wrist joint
|
||||
AVATAR_BONE_LEFT_HAND, // connects left wrist joint with left fingertips joint
|
||||
AVATAR_BONE_RIGHT_CHEST, // connects chest joint with right clavicle joint (not supposed to be rotated)
|
||||
AVATAR_BONE_RIGHT_SHOULDER, // connects right clavicle joint with right shoulder joint
|
||||
AVATAR_BONE_RIGHT_UPPER_ARM, // connects right shoulder joint with right elbow joint
|
||||
AVATAR_BONE_RIGHT_FOREARM, // connects right elbow joint with right wrist joint
|
||||
AVATAR_BONE_RIGHT_HAND, // connects right wrist joint with right fingertips joint
|
||||
AVATAR_BONE_LEFT_PELVIS, // connects pelvis joint with left hip joint (not supposed to be rotated)
|
||||
AVATAR_BONE_LEFT_THIGH, // connects left hip joint with left knee joint
|
||||
AVATAR_BONE_LEFT_SHIN, // connects left knee joint with left heel joint
|
||||
AVATAR_BONE_LEFT_FOOT, // connects left heel joint with left toes joint
|
||||
AVATAR_BONE_RIGHT_PELVIS, // connects pelvis joint with right hip joint (not supposed to be rotated)
|
||||
AVATAR_BONE_RIGHT_THIGH, // connects right hip joint with right knee joint
|
||||
AVATAR_BONE_RIGHT_SHIN, // connects right knee joint with right heel joint
|
||||
AVATAR_BONE_RIGHT_FOOT, // connects right heel joint with right toes joint
|
||||
|
||||
NUM_AVATAR_BONES
|
||||
};
|
||||
|
||||
struct AvatarBone
|
||||
{
|
||||
AvatarBones parent; // which bone is this bone connected to?
|
||||
glm::vec3 position; // the position at the "end" of the bone
|
||||
glm::vec3 defaultPosePosition; // the parent relative position when the avatar is in the "T-pose"
|
||||
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 (0 to 1) the springy position tries to stay on the position
|
||||
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
|
||||
Orientation orientation; // three orthogonal normals determined by yaw, pitch, roll
|
||||
float length; // the length of the bone
|
||||
};
|
||||
|
||||
struct Avatar
|
||||
{
|
||||
glm::dvec3 velocity;
|
||||
glm::vec3 thrust;
|
||||
float maxArmLength;
|
||||
Orientation orientation;
|
||||
AvatarBone bone[ NUM_AVATAR_BONES ];
|
||||
};
|
||||
|
||||
class AvatarData : public AgentData {
|
||||
public:
|
||||
AvatarData();
|
||||
~AvatarData();
|
||||
|
||||
void parseData(void *data, int size);
|
||||
AvatarData* clone() const;
|
||||
|
||||
float getPitch();
|
||||
void setPitch(float pitch);
|
||||
float getYaw();
|
||||
void setYaw(float yaw);
|
||||
float getRoll();
|
||||
void setRoll(float roll);
|
||||
float getHeadPositionX();
|
||||
float getHeadPositionY();
|
||||
float getHeadPositionZ();
|
||||
void setHeadPosition(float x, float y, float z);
|
||||
float getLoudness();
|
||||
void setLoudness(float loudness);
|
||||
float getAverageLoudness();
|
||||
void setAverageLoudness(float averageLoudness);
|
||||
float getHandPositionX();
|
||||
float getHandPositionY();
|
||||
float getHandPositionZ();
|
||||
void setHandPosition(float x, float y, float z);
|
||||
|
||||
private:
|
||||
float _pitch;
|
||||
float _yaw;
|
||||
float _roll;
|
||||
float _headPositionX;
|
||||
float _headPositionY;
|
||||
float _headPositionZ;
|
||||
float _loudness;
|
||||
float _averageLoudness;
|
||||
float _handPositionX;
|
||||
float _handPositionY;
|
||||
float _handPositionZ;
|
||||
glm::vec3 getBodyPosition();
|
||||
void setBodyPosition(glm::vec3 bodyPosition);
|
||||
|
||||
int getBroadcastData(char* destinationBuffer);
|
||||
void parseData(void *sourceBuffer, int numBytes);
|
||||
|
||||
float getBodyYaw();
|
||||
void setBodyYaw(float bodyYaw);
|
||||
|
||||
float getBodyPitch();
|
||||
void setBodyPitch(float bodyPitch);
|
||||
|
||||
float getBodyRoll();
|
||||
void setBodyRoll(float bodyRoll);
|
||||
|
||||
protected:
|
||||
glm::vec3 _bodyPosition;
|
||||
|
||||
float _bodyYaw;
|
||||
float _bodyPitch;
|
||||
float _bodyRoll;
|
||||
};
|
||||
|
||||
#endif /* defined(__hifi__AvatarData__) */
|
||||
|
|
|
@ -118,8 +118,9 @@ void AgentList::processBulkAgentData(sockaddr *senderAddress, void *packetData,
|
|||
while ((currentPosition - startPosition) < numTotalBytes) {
|
||||
currentPosition += unpackAgentId(currentPosition, &agentID);
|
||||
memcpy(packetHolder + 1, currentPosition, numBytesPerAgent);
|
||||
|
||||
|
||||
int matchingAgentIndex = indexOfMatchingAgent(agentID);
|
||||
|
||||
if (matchingAgentIndex >= 0) {
|
||||
updateAgentWithData(&agents[matchingAgentIndex], packetHolder, numBytesPerAgent + 1);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue