Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Jeffrey Ventrella 2013-04-17 15:34:00 -07:00
commit 5595bb8cf6
5 changed files with 38 additions and 31 deletions

View file

@ -48,7 +48,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();
@ -62,6 +62,7 @@ Head::Head() {
_bodyYawDelta = 0.0;
_triggeringAction = false;
_mode = AVATAR_MODE_STANDING;
_isMine = isMine;
initializeSkeleton();
@ -211,7 +212,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;
@ -468,8 +469,6 @@ void Head::simulate(float deltaTime) {
}
}
const float DEGREES_BETWEEN_VIEWER_EYES = 3;
const float DEGREES_TO_VIEWER_MOUTH = 7;
@ -556,7 +555,7 @@ void Head::render(int faceToFace, int isMine) {
//---------------------------------------------------
// render head
//---------------------------------------------------
renderHead( faceToFace, isMine );
renderHead(faceToFace);
//---------------------------------------------------
// render other avatars (DEBUG TEST)
@ -616,7 +615,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);
@ -662,6 +661,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
@ -1023,10 +1023,6 @@ void Head::updateBodySprings( float deltaTime ) {
}
}
float Head::getBodyYaw() {
return _bodyYaw;
}
glm::vec3 Head::getHeadLookatDirection() {
return glm::vec3
(
@ -1073,8 +1069,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 ) {
@ -1156,6 +1152,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);
}

View file

@ -102,13 +102,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; }
@ -129,7 +129,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();
@ -140,10 +142,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);
@ -175,6 +177,7 @@ class Head : public AvatarData {
float getTransmitterHz() { return transmitterHz; };
private:
bool _isMine;
float noise;
float Pitch;
float Yaw;

View file

@ -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();
@ -1316,7 +1311,7 @@ void *networkReceive(void *args)
AgentList::getInstance()->processBulkAgentData(&senderAddress,
incomingPacket,
bytesReceived,
(sizeof(float) * 3) + (sizeof(uint16_t) * 2));
(sizeof(float) * 3) + (sizeof(uint16_t) * 3));
break;
default:
AgentList::getInstance()->processAgentData(&senderAddress, incomingPacket, bytesReceived);
@ -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));
}
}

View file

@ -43,14 +43,13 @@ AvatarData* AvatarData::clone() const {
return new AvatarData(*this);
}
// transmit data to agents requesting it
// called on me just prior to sending data to others (continuasly called)
int AvatarData::getBroadcastData(unsigned char* destinationBuffer) {
unsigned char* bufferStart = 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;
@ -75,6 +74,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() {
@ -87,6 +90,10 @@ void AvatarData::setBodyPosition(glm::vec3 bodyPosition) {
_bodyPosition = bodyPosition;
}
void AvatarData::setHandPosition(glm::vec3 handPosition) {
_handPosition = handPosition;
}
float AvatarData::getBodyYaw() {
return _bodyYaw;
}

View file

@ -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;