mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-08 06:32:35 +02:00
Merge pull request #69 from PhilipRosedale/master
Added hand position to transmission
This commit is contained in:
commit
754856227d
5 changed files with 43 additions and 29 deletions
|
@ -45,7 +45,7 @@ vector<unsigned char> iris_texture;
|
|||
unsigned int iris_texture_width = 512;
|
||||
unsigned int iris_texture_height = 256;
|
||||
|
||||
Head::Head() {
|
||||
Head::Head(bool isMine) {
|
||||
initializeAvatar();
|
||||
|
||||
_avatar.orientation.setToIdentity();
|
||||
|
@ -59,6 +59,7 @@ Head::Head() {
|
|||
_bodyYawDelta = 0.0;
|
||||
_triggeringAction = false;
|
||||
_mode = AVATAR_MODE_STANDING;
|
||||
_isMine = isMine;
|
||||
|
||||
initializeSkeleton();
|
||||
|
||||
|
@ -208,7 +209,7 @@ void Head::reset() {
|
|||
|
||||
//this pertains to moving the head with the glasses
|
||||
//---------------------------------------------------
|
||||
void Head::UpdatePos(float frametime, SerialInterface * serialInterface, int head_mirror, glm::vec3 * gravity)
|
||||
void Head::UpdateGyros(float frametime, SerialInterface * serialInterface, int head_mirror, glm::vec3 * gravity)
|
||||
// Using serial data, update avatar/render position and angles
|
||||
{
|
||||
const float PITCH_ACCEL_COUPLING = 0.5;
|
||||
|
@ -465,8 +466,6 @@ void Head::simulate(float deltaTime) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
const float DEGREES_BETWEEN_VIEWER_EYES = 3;
|
||||
const float DEGREES_TO_VIEWER_MOUTH = 7;
|
||||
|
||||
|
@ -531,7 +530,7 @@ void Head::simulate(float deltaTime) {
|
|||
|
||||
|
||||
|
||||
void Head::render(int faceToFace, int isMine) {
|
||||
void Head::render(int faceToFace) {
|
||||
|
||||
//---------------------------------------------------
|
||||
// show avatar position
|
||||
|
@ -555,7 +554,7 @@ void Head::render(int faceToFace, int isMine) {
|
|||
//---------------------------------------------------
|
||||
// render head
|
||||
//---------------------------------------------------
|
||||
renderHead( faceToFace, isMine );
|
||||
renderHead(faceToFace);
|
||||
|
||||
//---------------------------------------------------
|
||||
// render other avatars (DEBUG TEST)
|
||||
|
@ -615,7 +614,7 @@ void Head::renderOrientationDirections( glm::vec3 position, Orientation orientat
|
|||
|
||||
|
||||
|
||||
void Head::renderHead( int faceToFace, int isMine ) {
|
||||
void Head::renderHead( int faceToFace) {
|
||||
int side = 0;
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
@ -661,6 +660,7 @@ void Head::renderHead( int faceToFace, int isMine ) {
|
|||
glColor3fv(skinColor);
|
||||
|
||||
// Head
|
||||
if (!_isMine) glColor3f(0,0,1); // Temp: Other people are BLUE
|
||||
glutSolidSphere(1, 30, 30);
|
||||
|
||||
// Ears
|
||||
|
@ -1017,10 +1017,6 @@ void Head::updateBodySprings( float deltaTime ) {
|
|||
}
|
||||
}
|
||||
|
||||
float Head::getBodyYaw() {
|
||||
return _bodyYaw;
|
||||
}
|
||||
|
||||
glm::vec3 Head::getHeadLookatDirection() {
|
||||
return glm::vec3
|
||||
(
|
||||
|
@ -1065,8 +1061,8 @@ void Head::updateHandMovement() {
|
|||
+ _avatar.orientation.getUp() * -_movedHandOffset.y * 0.5f
|
||||
+ _avatar.orientation.getFront() * -_movedHandOffset.y;
|
||||
|
||||
_bone[ AVATAR_BONE_RIGHT_HAND ].position += transformedHandMovement;
|
||||
|
||||
_bone[ AVATAR_BONE_RIGHT_HAND ].position += transformedHandMovement;
|
||||
|
||||
//if holding hands, add a pull to the hand...
|
||||
if ( _usingSprings ) {
|
||||
if ( _closestOtherAvatar != -1 ) {
|
||||
|
@ -1148,6 +1144,10 @@ void Head::updateHandMovement() {
|
|||
glm::vec3 newWristPosition = _bone[ AVATAR_BONE_RIGHT_UPPER_ARM ].position;
|
||||
newWristPosition += vv * 0.7f;
|
||||
_bone[ AVATAR_BONE_RIGHT_FOREARM ].position = newWristPosition;
|
||||
|
||||
// Set the vector we send for hand position to other people to be our right hand
|
||||
setHandPosition(_bone[ AVATAR_BONE_RIGHT_HAND ].position);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -103,13 +103,13 @@ struct Avatar
|
|||
|
||||
class Head : public AvatarData {
|
||||
public:
|
||||
Head();
|
||||
Head(bool isMine);
|
||||
~Head();
|
||||
Head(const Head &otherHead);
|
||||
Head* clone() const;
|
||||
|
||||
void reset();
|
||||
void UpdatePos(float frametime, SerialInterface * serialInterface, int head_mirror, glm::vec3 * gravity);
|
||||
void UpdateGyros(float frametime, SerialInterface * serialInterface, int head_mirror, glm::vec3 * gravity);
|
||||
void setNoise (float mag) { noise = mag; }
|
||||
void setPitch(float p) {Pitch = p; }
|
||||
void setYaw(float y) {Yaw = y; }
|
||||
|
@ -130,7 +130,9 @@ class Head : public AvatarData {
|
|||
float getYaw() {return Yaw;}
|
||||
float getLastMeasuredYaw() {return YawRate;}
|
||||
|
||||
float getBodyYaw();
|
||||
float getBodyYaw() {return _bodyYaw;};
|
||||
void addBodyYaw(float y) {_bodyYaw += y;};
|
||||
|
||||
glm::vec3 getHeadLookatDirection();
|
||||
glm::vec3 getHeadLookatDirectionUp();
|
||||
glm::vec3 getHeadLookatDirectionRight();
|
||||
|
@ -141,10 +143,10 @@ class Head : public AvatarData {
|
|||
|
||||
void setTriggeringAction( bool trigger );
|
||||
|
||||
void render(int faceToFace, int isMine);
|
||||
void render(int faceToFace);
|
||||
|
||||
void renderBody();
|
||||
void renderHead( int faceToFace, int isMine );
|
||||
void renderHead( int faceToFace);
|
||||
//void renderOrientationDirections( glm::vec3 position, Orientation orientation, float size );
|
||||
|
||||
void simulate(float);
|
||||
|
@ -176,6 +178,7 @@ class Head : public AvatarData {
|
|||
float getTransmitterHz() { return transmitterHz; };
|
||||
|
||||
private:
|
||||
bool _isMine;
|
||||
float noise;
|
||||
float Pitch;
|
||||
float Yaw;
|
||||
|
|
|
@ -102,7 +102,7 @@ Oscilloscope audioScope(256,200,true);
|
|||
|
||||
ViewFrustum viewFrustum; // current state of view frustum, perspective, orientation, etc.
|
||||
|
||||
Head myAvatar; // The rendered avatar of oneself
|
||||
Head myAvatar(true); // The rendered avatar of oneself
|
||||
Camera myCamera; // My view onto the world (sometimes on myself :)
|
||||
Camera viewFrustumOffsetCamera; // The camera we use to sometimes show the view frustum from an offset mode
|
||||
|
||||
|
@ -233,12 +233,7 @@ void displayStats(void)
|
|||
char stats[200];
|
||||
sprintf(stats, "FPS = %3.0f Pkts/s = %d Bytes/s = %d Head(x,y,z)= %4.2f, %4.2f, %4.2f ",
|
||||
FPS, packetsPerSecond, bytesPerSecond, avatarPos.x,avatarPos.y,avatarPos.z);
|
||||
drawtext(10, statsVerticalOffset + 49, 0.10f, 0, 1.0, 0, stats);
|
||||
if (serialPort.active) {
|
||||
sprintf(stats, "ADC samples = %d, LED = %d",
|
||||
serialPort.getNumSamples(), serialPort.getLED());
|
||||
drawtext(300, statsVerticalOffset + 30, 0.10f, 0, 1.0, 0, stats);
|
||||
}
|
||||
drawtext(10, statsVerticalOffset + 49, 0.10f, 0, 1.0, 0, stats);
|
||||
|
||||
std::stringstream voxelStats;
|
||||
voxelStats << "Voxels Rendered: " << voxels.getVoxelsRendered();
|
||||
|
@ -389,7 +384,7 @@ void updateAvatar(float frametime)
|
|||
float gyroPitchRate = serialPort.getRelativeValue(PITCH_RATE);
|
||||
float gyroYawRate = serialPort.getRelativeValue(YAW_RATE);
|
||||
|
||||
myAvatar.UpdatePos(frametime, &serialPort, headMirror, &gravity);
|
||||
myAvatar.UpdateGyros(frametime, &serialPort, headMirror, &gravity);
|
||||
|
||||
//
|
||||
// Update gyro-based mouse (X,Y on screen)
|
||||
|
@ -831,7 +826,7 @@ void display(void)
|
|||
glPushMatrix();
|
||||
glm::vec3 pos = agentHead->getBodyPosition();
|
||||
glTranslatef(-pos.x, -pos.y, -pos.z);
|
||||
agentHead->render(0, 0);
|
||||
agentHead->render(0);
|
||||
glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
@ -846,7 +841,7 @@ void display(void)
|
|||
|
||||
|
||||
//Render my own avatar
|
||||
myAvatar.render( true, 1 );
|
||||
myAvatar.render(true);
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
|
@ -1499,7 +1494,7 @@ void mouseoverFunc( int x, int y)
|
|||
|
||||
void attachNewHeadToAgent(Agent *newAgent) {
|
||||
if (newAgent->getLinkedData() == NULL) {
|
||||
newAgent->setLinkedData(new Head());
|
||||
newAgent->setLinkedData(new Head(false));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ int AvatarData::getBroadcastData(unsigned char* destinationBuffer) {
|
|||
// 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(destinationBuffer, &_bodyPosition, sizeof(float) * 3);
|
||||
destinationBuffer += sizeof(float) * 3;
|
||||
|
||||
|
@ -56,6 +57,11 @@ int AvatarData::getBroadcastData(unsigned char* destinationBuffer) {
|
|||
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _bodyPitch);
|
||||
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _bodyRoll);
|
||||
|
||||
memcpy(destinationBuffer, &_handPosition, sizeof(float) * 3);
|
||||
destinationBuffer += sizeof(float) * 3;
|
||||
|
||||
//std::cout << _handPosition.x << ", " << _handPosition.y << ", " << _handPosition.z << "\n";
|
||||
|
||||
return destinationBuffer - bufferStart;
|
||||
}
|
||||
|
||||
|
@ -71,6 +77,10 @@ void AvatarData::parseData(unsigned char* sourceBuffer, int numBytes) {
|
|||
sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t *)sourceBuffer, &_bodyYaw);
|
||||
sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t *)sourceBuffer, &_bodyPitch);
|
||||
sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t *)sourceBuffer, &_bodyRoll);
|
||||
|
||||
memcpy(&_handPosition, sourceBuffer, sizeof(float) * 3);
|
||||
sourceBuffer += sizeof(float) * 3;
|
||||
|
||||
}
|
||||
|
||||
glm::vec3 AvatarData::getBodyPosition() {
|
||||
|
@ -83,6 +93,10 @@ void AvatarData::setBodyPosition(glm::vec3 bodyPosition) {
|
|||
_bodyPosition = bodyPosition;
|
||||
}
|
||||
|
||||
void AvatarData::setHandPosition(glm::vec3 handPosition) {
|
||||
_handPosition = handPosition;
|
||||
}
|
||||
|
||||
float AvatarData::getBodyYaw() {
|
||||
return _bodyYaw;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ public:
|
|||
|
||||
glm::vec3 getBodyPosition();
|
||||
void setBodyPosition(glm::vec3 bodyPosition);
|
||||
void setHandPosition(glm::vec3 handPosition);
|
||||
|
||||
int getBroadcastData(unsigned char* destinationBuffer);
|
||||
void parseData(unsigned char* sourceBuffer, int numBytes);
|
||||
|
@ -39,6 +40,7 @@ public:
|
|||
|
||||
protected:
|
||||
glm::vec3 _bodyPosition;
|
||||
glm::vec3 _handPosition;
|
||||
|
||||
float _bodyYaw;
|
||||
float _bodyPitch;
|
||||
|
|
Loading…
Reference in a new issue