renamed "bodyPosition" to "position". (This corresponds to the position of the avatar on the ground, where y=0). I will next add a new "getBodyPosition" which returns the avatar's center of gravity - is useful for certain purposes, such as setting collision volumes, etc.

This commit is contained in:
Jeffrey Ventrella 2013-04-23 14:05:23 -07:00
parent a73ea8c255
commit eb631e2ef6
6 changed files with 29 additions and 29 deletions

View file

@ -157,7 +157,7 @@ int audioCallback (const void *inputBuffer,
// memcpy the three float positions
for (int p = 0; p < 3; p++) {
memcpy(currentPacketPtr, &data->linkedHead->getBodyPosition()[p], sizeof(float));
memcpy(currentPacketPtr, &data->linkedHead->getPosition()[p], sizeof(float));
currentPacketPtr += sizeof(float);
}

View file

@ -328,7 +328,7 @@ void Head::simulate(float deltaTime) {
//------------------------------------------------------
updateAvatarCollisionDetectionAndResponse
(
otherAvatar->getBodyPosition(),
otherAvatar->getPosition(),
otherAvatar->getGirth(),
otherAvatar->getHeight(),
otherAvatar->getBodyUpDirection(),
@ -378,12 +378,12 @@ void Head::simulate(float deltaTime) {
}
if ( AVATAR_GRAVITY ) {
if ( _bodyPosition.y > _bone[ AVATAR_BONE_RIGHT_FOOT ].radius * 2.0 ) {
if ( _position.y > _bone[ AVATAR_BONE_RIGHT_FOOT ].radius * 2.0 ) {
_velocity += glm::dvec3( 0.0, -1.0, 0.0 ) * ( 6.0 * deltaTime );
}
else {
if ( _bodyPosition.y < _bone[ AVATAR_BONE_RIGHT_FOOT ].radius ) {
_bodyPosition.y = _bone[ AVATAR_BONE_RIGHT_FOOT ].radius;
if ( _position.y < _bone[ AVATAR_BONE_RIGHT_FOOT ].radius ) {
_position.y = _bone[ AVATAR_BONE_RIGHT_FOOT ].radius;
_velocity.y = 0.0;
}
}
@ -474,7 +474,7 @@ void Head::simulate(float deltaTime) {
//----------------------------------------------------------
// update position by velocity
//----------------------------------------------------------
_bodyPosition += (glm::vec3)_velocity * deltaTime;
_position += (glm::vec3)_velocity * deltaTime;
//----------------------------------------------------------
// decay velocity
@ -600,7 +600,7 @@ void Head::updateAvatarCollisionDetectionAndResponse
( glm::vec3 collisionPosition, float collisionGirth, float collisionHeight, glm::vec3 collisionUpVector, float deltaTime ) {
float myBodyApproximateBoundingRadius = 1.0f;
glm::vec3 vectorFromMyBodyToBigSphere(_bodyPosition - collisionPosition);
glm::vec3 vectorFromMyBodyToBigSphere(_position - collisionPosition);
bool jointCollision = false;
float distanceToBigSphere = glm::length(vectorFromMyBodyToBigSphere);
@ -647,7 +647,7 @@ void Head::render(bool lookingInMirror) {
//---------------------------------------------------
glColor4f( 0.5f, 0.5f, 0.5f, 0.6 );
glPushMatrix();
glTranslatef(_bodyPosition.x, _bodyPosition.y, _bodyPosition.z);
glTranslatef(_position.x, _position.y, _position.z);
glScalef( 0.03, 0.03, 0.03 );
glutSolidSphere( 1, 10, 10 );
glPopMatrix();
@ -1017,7 +1017,7 @@ void Head::updateSkeleton() {
for (int b=0; b<NUM_AVATAR_BONES; b++) {
if ( _bone[b].parent == AVATAR_BONE_NULL ) {
_bone[b].orientation.set( _orientation );
_bone[b].position = _bodyPosition;
_bone[b].position = _position;
}
else {
_bone[b].orientation.set( _bone[ _bone[b].parent ].orientation );
@ -1056,7 +1056,7 @@ void Head::updateBodySprings( float deltaTime ) {
glm::vec3 springVector( _bone[b].springyPosition );
if ( _bone[b].parent == AVATAR_BONE_NULL ) {
springVector -= _bodyPosition;
springVector -= _position;
}
else {
springVector -= _bone[ _bone[b].parent ].springyPosition;

View file

@ -185,7 +185,7 @@ int VoxelSystem::treeToArrays(VoxelNode *currentNode, const glm::vec3& nodePosi
int voxelsAdded = 0;
float halfUnitForVoxel = powf(0.5, *currentNode->octalCode) * (0.5 * TREE_SCALE);
glm::vec3 viewerPosition = viewerHead->getBodyPosition();
glm::vec3 viewerPosition = viewerHead->getPosition();
// debug LOD code
glm::vec3 debugNodePosition;

View file

@ -304,7 +304,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.getBodyPosition();
glm::vec3 avatarPos = myAvatar.getPosition();
char stats[200];
sprintf(stats, "FPS = %3.0f Pkts/s = %d Bytes/s = %d Head(x,y,z)= %4.2f, %4.2f, %4.2f ",
@ -396,8 +396,8 @@ void init(void)
if (noiseOn) {
myAvatar.setNoise(noise);
}
myAvatar.setBodyPosition(start_location);
myCamera.setPosition( start_location );
myAvatar.setPosition(start_location);
myCamera.setPosition(start_location);
#ifdef MARKER_CAPTURE
@ -438,7 +438,7 @@ void reset_sensors()
renderYawRate = 0;
renderPitchRate = 0;
myAvatar.setBodyPosition(start_location);
myAvatar.setPosition(start_location);
headMouseX = WIDTH/2;
headMouseY = HEIGHT/2;
@ -551,7 +551,7 @@ void updateAvatar(float frametime)
// If I'm in paint mode, send a voxel out to VOXEL server agents.
if (::paintOn) {
glm::vec3 avatarPos = myAvatar.getBodyPosition();
glm::vec3 avatarPos = myAvatar.getPosition();
// For some reason, we don't want to flip X and Z here.
::paintingVoxel.x = avatarPos.x/10.0;
@ -833,7 +833,7 @@ void display(void)
//----------------------------------------------------
// set the camera to third-person view behind my av
//----------------------------------------------------
myCamera.setTargetPosition ( myAvatar.getBodyPosition() );
myCamera.setTargetPosition ( myAvatar.getPosition() );
myCamera.setYaw ( 180.0 - myAvatar.getBodyYaw() );
myCamera.setPitch ( 0.0 ); // temporarily, this must be 0.0 or else bad juju
myCamera.setRoll ( 0.0 );
@ -1265,7 +1265,7 @@ void shiftPaintingColor()
}
void setupPaintingVoxel() {
glm::vec3 avatarPos = myAvatar.getBodyPosition();
glm::vec3 avatarPos = myAvatar.getPosition();
::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

View file

@ -69,7 +69,7 @@ int AvatarData::getBroadcastData(unsigned char* destinationBuffer) {
// and return the number of bytes to push the pointer
// Body world position
memcpy(destinationBuffer, &_bodyPosition, sizeof(float) * 3);
memcpy(destinationBuffer, &_position, sizeof(float) * 3);
destinationBuffer += sizeof(float) * 3;
// Body rotation (NOTE: This needs to become a quaternion to save two bytes)
@ -125,7 +125,7 @@ int AvatarData::parseData(unsigned char* sourceBuffer, int numBytes) {
unsigned char* startPosition = sourceBuffer;
// Body world position
memcpy(&_bodyPosition, sourceBuffer, sizeof(float) * 3);
memcpy(&_position, sourceBuffer, sizeof(float) * 3);
sourceBuffer += sizeof(float) * 3;
// Body rotation (NOTE: This needs to become a quaternion to save two bytes)
@ -171,14 +171,14 @@ int AvatarData::parseData(unsigned char* sourceBuffer, int numBytes) {
return sourceBuffer - startPosition;
}
glm::vec3 AvatarData::getBodyPosition() {
return glm::vec3(_bodyPosition.x,
_bodyPosition.y,
_bodyPosition.z);
glm::vec3 AvatarData::getPosition() {
return glm::vec3(_position.x,
_position.y,
_position.z);
}
void AvatarData::setBodyPosition(glm::vec3 bodyPosition) {
_bodyPosition = bodyPosition;
void AvatarData::setPosition(glm::vec3 position) {
_position = position;
}
void AvatarData::setHandPosition(glm::vec3 handPosition) {

View file

@ -20,8 +20,8 @@ public:
AvatarData* clone() const;
glm::vec3 getBodyPosition();
void setBodyPosition(glm::vec3 bodyPosition);
glm::vec3 getPosition();
void setPosition(glm::vec3 position);
void setHandPosition(glm::vec3 handPosition);
int getBroadcastData(unsigned char* destinationBuffer);
@ -75,7 +75,7 @@ public:
void setCameraFarClip(float farClip) { _cameraFarClip = farClip; }
protected:
glm::vec3 _bodyPosition;
glm::vec3 _position;
glm::vec3 _handPosition;
// Body rotation