mirror of
https://github.com/JulianGro/overte.git
synced 2025-08-04 20:37:11 +02:00
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:
parent
a73ea8c255
commit
eb631e2ef6
6 changed files with 29 additions and 29 deletions
|
@ -157,7 +157,7 @@ int audioCallback (const void *inputBuffer,
|
||||||
|
|
||||||
// memcpy the three float positions
|
// memcpy the three float positions
|
||||||
for (int p = 0; p < 3; p++) {
|
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);
|
currentPacketPtr += sizeof(float);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -328,7 +328,7 @@ void Head::simulate(float deltaTime) {
|
||||||
//------------------------------------------------------
|
//------------------------------------------------------
|
||||||
updateAvatarCollisionDetectionAndResponse
|
updateAvatarCollisionDetectionAndResponse
|
||||||
(
|
(
|
||||||
otherAvatar->getBodyPosition(),
|
otherAvatar->getPosition(),
|
||||||
otherAvatar->getGirth(),
|
otherAvatar->getGirth(),
|
||||||
otherAvatar->getHeight(),
|
otherAvatar->getHeight(),
|
||||||
otherAvatar->getBodyUpDirection(),
|
otherAvatar->getBodyUpDirection(),
|
||||||
|
@ -378,12 +378,12 @@ void Head::simulate(float deltaTime) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( AVATAR_GRAVITY ) {
|
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 );
|
_velocity += glm::dvec3( 0.0, -1.0, 0.0 ) * ( 6.0 * deltaTime );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ( _bodyPosition.y < _bone[ AVATAR_BONE_RIGHT_FOOT ].radius ) {
|
if ( _position.y < _bone[ AVATAR_BONE_RIGHT_FOOT ].radius ) {
|
||||||
_bodyPosition.y = _bone[ AVATAR_BONE_RIGHT_FOOT ].radius;
|
_position.y = _bone[ AVATAR_BONE_RIGHT_FOOT ].radius;
|
||||||
_velocity.y = 0.0;
|
_velocity.y = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -474,7 +474,7 @@ void Head::simulate(float deltaTime) {
|
||||||
//----------------------------------------------------------
|
//----------------------------------------------------------
|
||||||
// update position by velocity
|
// update position by velocity
|
||||||
//----------------------------------------------------------
|
//----------------------------------------------------------
|
||||||
_bodyPosition += (glm::vec3)_velocity * deltaTime;
|
_position += (glm::vec3)_velocity * deltaTime;
|
||||||
|
|
||||||
//----------------------------------------------------------
|
//----------------------------------------------------------
|
||||||
// decay velocity
|
// decay velocity
|
||||||
|
@ -600,7 +600,7 @@ void Head::updateAvatarCollisionDetectionAndResponse
|
||||||
( glm::vec3 collisionPosition, float collisionGirth, float collisionHeight, glm::vec3 collisionUpVector, float deltaTime ) {
|
( glm::vec3 collisionPosition, float collisionGirth, float collisionHeight, glm::vec3 collisionUpVector, float deltaTime ) {
|
||||||
|
|
||||||
float myBodyApproximateBoundingRadius = 1.0f;
|
float myBodyApproximateBoundingRadius = 1.0f;
|
||||||
glm::vec3 vectorFromMyBodyToBigSphere(_bodyPosition - collisionPosition);
|
glm::vec3 vectorFromMyBodyToBigSphere(_position - collisionPosition);
|
||||||
bool jointCollision = false;
|
bool jointCollision = false;
|
||||||
|
|
||||||
float distanceToBigSphere = glm::length(vectorFromMyBodyToBigSphere);
|
float distanceToBigSphere = glm::length(vectorFromMyBodyToBigSphere);
|
||||||
|
@ -647,7 +647,7 @@ void Head::render(bool lookingInMirror) {
|
||||||
//---------------------------------------------------
|
//---------------------------------------------------
|
||||||
glColor4f( 0.5f, 0.5f, 0.5f, 0.6 );
|
glColor4f( 0.5f, 0.5f, 0.5f, 0.6 );
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(_bodyPosition.x, _bodyPosition.y, _bodyPosition.z);
|
glTranslatef(_position.x, _position.y, _position.z);
|
||||||
glScalef( 0.03, 0.03, 0.03 );
|
glScalef( 0.03, 0.03, 0.03 );
|
||||||
glutSolidSphere( 1, 10, 10 );
|
glutSolidSphere( 1, 10, 10 );
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
@ -1017,7 +1017,7 @@ void Head::updateSkeleton() {
|
||||||
for (int b=0; b<NUM_AVATAR_BONES; b++) {
|
for (int b=0; b<NUM_AVATAR_BONES; b++) {
|
||||||
if ( _bone[b].parent == AVATAR_BONE_NULL ) {
|
if ( _bone[b].parent == AVATAR_BONE_NULL ) {
|
||||||
_bone[b].orientation.set( _orientation );
|
_bone[b].orientation.set( _orientation );
|
||||||
_bone[b].position = _bodyPosition;
|
_bone[b].position = _position;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_bone[b].orientation.set( _bone[ _bone[b].parent ].orientation );
|
_bone[b].orientation.set( _bone[ _bone[b].parent ].orientation );
|
||||||
|
@ -1056,7 +1056,7 @@ void Head::updateBodySprings( float deltaTime ) {
|
||||||
glm::vec3 springVector( _bone[b].springyPosition );
|
glm::vec3 springVector( _bone[b].springyPosition );
|
||||||
|
|
||||||
if ( _bone[b].parent == AVATAR_BONE_NULL ) {
|
if ( _bone[b].parent == AVATAR_BONE_NULL ) {
|
||||||
springVector -= _bodyPosition;
|
springVector -= _position;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
springVector -= _bone[ _bone[b].parent ].springyPosition;
|
springVector -= _bone[ _bone[b].parent ].springyPosition;
|
||||||
|
|
|
@ -185,7 +185,7 @@ int VoxelSystem::treeToArrays(VoxelNode *currentNode, const glm::vec3& nodePosi
|
||||||
int voxelsAdded = 0;
|
int voxelsAdded = 0;
|
||||||
|
|
||||||
float halfUnitForVoxel = powf(0.5, *currentNode->octalCode) * (0.5 * TREE_SCALE);
|
float halfUnitForVoxel = powf(0.5, *currentNode->octalCode) * (0.5 * TREE_SCALE);
|
||||||
glm::vec3 viewerPosition = viewerHead->getBodyPosition();
|
glm::vec3 viewerPosition = viewerHead->getPosition();
|
||||||
|
|
||||||
// debug LOD code
|
// debug LOD code
|
||||||
glm::vec3 debugNodePosition;
|
glm::vec3 debugNodePosition;
|
||||||
|
|
|
@ -304,7 +304,7 @@ void displayStats(void)
|
||||||
char legend2[] = "* - toggle stars, & - toggle paint mode, '-' - send erase all, '%' - send add scene";
|
char legend2[] = "* - toggle stars, & - toggle paint mode, '-' - send erase all, '%' - send add scene";
|
||||||
drawtext(10, statsVerticalOffset + 32, 0.10f, 0, 1.0, 0, legend2);
|
drawtext(10, statsVerticalOffset + 32, 0.10f, 0, 1.0, 0, legend2);
|
||||||
|
|
||||||
glm::vec3 avatarPos = myAvatar.getBodyPosition();
|
glm::vec3 avatarPos = myAvatar.getPosition();
|
||||||
|
|
||||||
char stats[200];
|
char stats[200];
|
||||||
sprintf(stats, "FPS = %3.0f Pkts/s = %d Bytes/s = %d Head(x,y,z)= %4.2f, %4.2f, %4.2f ",
|
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) {
|
if (noiseOn) {
|
||||||
myAvatar.setNoise(noise);
|
myAvatar.setNoise(noise);
|
||||||
}
|
}
|
||||||
myAvatar.setBodyPosition(start_location);
|
myAvatar.setPosition(start_location);
|
||||||
myCamera.setPosition( start_location );
|
myCamera.setPosition(start_location);
|
||||||
|
|
||||||
|
|
||||||
#ifdef MARKER_CAPTURE
|
#ifdef MARKER_CAPTURE
|
||||||
|
@ -438,7 +438,7 @@ void reset_sensors()
|
||||||
|
|
||||||
renderYawRate = 0;
|
renderYawRate = 0;
|
||||||
renderPitchRate = 0;
|
renderPitchRate = 0;
|
||||||
myAvatar.setBodyPosition(start_location);
|
myAvatar.setPosition(start_location);
|
||||||
headMouseX = WIDTH/2;
|
headMouseX = WIDTH/2;
|
||||||
headMouseY = HEIGHT/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 I'm in paint mode, send a voxel out to VOXEL server agents.
|
||||||
if (::paintOn) {
|
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.
|
// For some reason, we don't want to flip X and Z here.
|
||||||
::paintingVoxel.x = avatarPos.x/10.0;
|
::paintingVoxel.x = avatarPos.x/10.0;
|
||||||
|
@ -833,7 +833,7 @@ void display(void)
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
// set the camera to third-person view behind my av
|
// 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.setYaw ( 180.0 - myAvatar.getBodyYaw() );
|
||||||
myCamera.setPitch ( 0.0 ); // temporarily, this must be 0.0 or else bad juju
|
myCamera.setPitch ( 0.0 ); // temporarily, this must be 0.0 or else bad juju
|
||||||
myCamera.setRoll ( 0.0 );
|
myCamera.setRoll ( 0.0 );
|
||||||
|
@ -1265,7 +1265,7 @@ void shiftPaintingColor()
|
||||||
}
|
}
|
||||||
|
|
||||||
void setupPaintingVoxel() {
|
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.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
|
::paintingVoxel.y = avatarPos.y/-10.0; // voxel space y is negative y head space
|
||||||
|
|
|
@ -69,7 +69,7 @@ int AvatarData::getBroadcastData(unsigned char* destinationBuffer) {
|
||||||
// and return the number of bytes to push the pointer
|
// and return the number of bytes to push the pointer
|
||||||
|
|
||||||
// Body world position
|
// Body world position
|
||||||
memcpy(destinationBuffer, &_bodyPosition, sizeof(float) * 3);
|
memcpy(destinationBuffer, &_position, sizeof(float) * 3);
|
||||||
destinationBuffer += sizeof(float) * 3;
|
destinationBuffer += sizeof(float) * 3;
|
||||||
|
|
||||||
// Body rotation (NOTE: This needs to become a quaternion to save two bytes)
|
// 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;
|
unsigned char* startPosition = sourceBuffer;
|
||||||
|
|
||||||
// Body world position
|
// Body world position
|
||||||
memcpy(&_bodyPosition, sourceBuffer, sizeof(float) * 3);
|
memcpy(&_position, sourceBuffer, sizeof(float) * 3);
|
||||||
sourceBuffer += sizeof(float) * 3;
|
sourceBuffer += sizeof(float) * 3;
|
||||||
|
|
||||||
// Body rotation (NOTE: This needs to become a quaternion to save two bytes)
|
// 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;
|
return sourceBuffer - startPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 AvatarData::getBodyPosition() {
|
glm::vec3 AvatarData::getPosition() {
|
||||||
return glm::vec3(_bodyPosition.x,
|
return glm::vec3(_position.x,
|
||||||
_bodyPosition.y,
|
_position.y,
|
||||||
_bodyPosition.z);
|
_position.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarData::setBodyPosition(glm::vec3 bodyPosition) {
|
void AvatarData::setPosition(glm::vec3 position) {
|
||||||
_bodyPosition = bodyPosition;
|
_position = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarData::setHandPosition(glm::vec3 handPosition) {
|
void AvatarData::setHandPosition(glm::vec3 handPosition) {
|
||||||
|
|
|
@ -20,8 +20,8 @@ public:
|
||||||
|
|
||||||
AvatarData* clone() const;
|
AvatarData* clone() const;
|
||||||
|
|
||||||
glm::vec3 getBodyPosition();
|
glm::vec3 getPosition();
|
||||||
void setBodyPosition(glm::vec3 bodyPosition);
|
void setPosition(glm::vec3 position);
|
||||||
void setHandPosition(glm::vec3 handPosition);
|
void setHandPosition(glm::vec3 handPosition);
|
||||||
|
|
||||||
int getBroadcastData(unsigned char* destinationBuffer);
|
int getBroadcastData(unsigned char* destinationBuffer);
|
||||||
|
@ -75,7 +75,7 @@ public:
|
||||||
void setCameraFarClip(float farClip) { _cameraFarClip = farClip; }
|
void setCameraFarClip(float farClip) { _cameraFarClip = farClip; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
glm::vec3 _bodyPosition;
|
glm::vec3 _position;
|
||||||
glm::vec3 _handPosition;
|
glm::vec3 _handPosition;
|
||||||
|
|
||||||
// Body rotation
|
// Body rotation
|
||||||
|
|
Loading…
Reference in a new issue