mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 14:33:31 +02:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
a440570cb4
7 changed files with 164 additions and 139 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ Head::Head(bool isMine) {
|
|||
_velocity = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
_thrust = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
_rotation = glm::quat( 0.0f, 0.0f, 0.0f, 0.0f );
|
||||
_closestOtherAvatar = 0;
|
||||
_nearOtherAvatar = false;
|
||||
_bodyYaw = -90.0;
|
||||
_bodyPitch = 0.0;
|
||||
_bodyRoll = 0.0;
|
||||
|
@ -60,7 +60,7 @@ Head::Head(bool isMine) {
|
|||
//_transmitterTimer = 0;
|
||||
_transmitterHz = 0.0;
|
||||
_transmitterPackets = 0;
|
||||
_numOtherAvatarsInView = 0;
|
||||
//_numOtherAvatars = 0;
|
||||
|
||||
initializeSkeleton();
|
||||
|
||||
|
@ -117,13 +117,11 @@ Head::Head(bool isMine) {
|
|||
_renderPitch = 0.0;
|
||||
|
||||
_sphere = NULL;
|
||||
|
||||
_collisionElipsoid.colliding = false;
|
||||
_collisionElipsoid.position = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
_collisionElipsoid.upVector = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
_collisionElipsoid.girth = 0.0;
|
||||
_collisionElipsoid.height = 0.0;
|
||||
|
||||
|
||||
_handHolding.position = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
_handHolding.velocity = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
_handHolding.force = 10.0f;
|
||||
|
||||
if (iris_texture.size() == 0) {
|
||||
switchToResourcesParentIfRequired();
|
||||
unsigned error = lodepng::decode(iris_texture, iris_texture_width, iris_texture_height, iris_texture_file);
|
||||
|
@ -131,19 +129,19 @@ Head::Head(bool isMine) {
|
|||
printLog("error %u: %s\n", error, lodepng_error_text(error));
|
||||
}
|
||||
}
|
||||
|
||||
for (int o=0; o<MAX_OTHER_AVATARS; o++) {
|
||||
_otherAvatarHandPosition[o] = glm::vec3( 0.0f, 0.0f, 0.0f );
|
||||
}
|
||||
|
||||
_otherAvatar.handPosition = glm::vec3( 0.0f, 0.0f, 0.0f );
|
||||
_otherAvatar.handState = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Head::Head(const Head &otherAvatar) {
|
||||
|
||||
_velocity = otherAvatar._velocity;
|
||||
_thrust = otherAvatar._thrust;
|
||||
_rotation = otherAvatar._rotation;
|
||||
_closestOtherAvatar = otherAvatar._closestOtherAvatar;
|
||||
_nearOtherAvatar = otherAvatar._nearOtherAvatar;
|
||||
_bodyYaw = otherAvatar._bodyYaw;
|
||||
_bodyPitch = otherAvatar._bodyPitch;
|
||||
_bodyRoll = otherAvatar._bodyRoll;
|
||||
|
@ -305,12 +303,12 @@ void Head::simulate(float deltaTime) {
|
|||
//-------------------------------------------------------------
|
||||
if ( _isMine )
|
||||
{
|
||||
_closestOtherAvatar = -1;
|
||||
_nearOtherAvatar = false;
|
||||
float closestDistance = 10000.0f;
|
||||
|
||||
AgentList * agentList = AgentList::getInstance();
|
||||
|
||||
_numOtherAvatarsInView =0;
|
||||
//_numOtherAvatars = 0;
|
||||
|
||||
for(std::vector<Agent>::iterator agent = agentList->getAgents().begin();
|
||||
agent != agentList->getAgents().end();
|
||||
|
@ -318,21 +316,34 @@ void Head::simulate(float deltaTime) {
|
|||
if (( agent->getLinkedData() != NULL && ( agent->getType() == AGENT_TYPE_AVATAR ) )) {
|
||||
Head *otherAvatar = (Head *)agent->getLinkedData();
|
||||
|
||||
if ( _numOtherAvatarsInView < MAX_OTHER_AVATARS ) {
|
||||
// if ( _numOtherAvatars < MAX_OTHER_AVATARS )
|
||||
{
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// test other avatar hand position for proximity...
|
||||
//-----------------------------------------------------------
|
||||
_otherAvatarHandPosition[ _numOtherAvatarsInView ] = otherAvatar->getBonePosition( AVATAR_BONE_RIGHT_HAND );
|
||||
//------------------------------------------------------
|
||||
// check for collisions with other avatars and respond
|
||||
//------------------------------------------------------
|
||||
updateAvatarCollisionDetectionAndResponse
|
||||
(
|
||||
otherAvatar->getPosition(),
|
||||
otherAvatar->getGirth(),
|
||||
otherAvatar->getHeight(),
|
||||
otherAvatar->getBodyUpDirection(),
|
||||
deltaTime
|
||||
);
|
||||
|
||||
//-------------------------------------------------
|
||||
// test other avatar hand position for proximity
|
||||
//------------------------------------------------
|
||||
glm::vec3 v( _bone[ AVATAR_BONE_RIGHT_SHOULDER ].position );
|
||||
v -= _otherAvatarHandPosition[ _numOtherAvatarsInView ];
|
||||
v -= otherAvatar->getBonePosition( AVATAR_BONE_RIGHT_HAND );
|
||||
|
||||
float distance = glm::length( v );
|
||||
if ( distance < _maxArmLength ) {
|
||||
if ( distance < closestDistance ) {
|
||||
closestDistance = distance;
|
||||
_closestOtherAvatar = _numOtherAvatarsInView;
|
||||
_numOtherAvatarsInView++;
|
||||
_nearOtherAvatar = true;
|
||||
_otherAvatar.handPosition = otherAvatar->getBonePosition( AVATAR_BONE_RIGHT_HAND );
|
||||
_otherAvatar.handState = (int)otherAvatar->getHandState();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -345,16 +356,23 @@ void Head::simulate(float deltaTime) {
|
|||
//--------------------------------------------------------------
|
||||
// test for avatar collision response (using a big sphere :)
|
||||
//--------------------------------------------------------------
|
||||
updateAvatarCollisionDetectionAndResponse(_TEST_bigSpherePosition, _TEST_bigSphereRadius, deltaTime);
|
||||
updateAvatarCollisionDetectionAndResponse
|
||||
(
|
||||
_TEST_bigSpherePosition,
|
||||
_TEST_bigSphereRadius,
|
||||
_TEST_bigSphereRadius,
|
||||
glm::vec3( 0.0, 1.0, 0.0 ),
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -369,7 +387,7 @@ void Head::simulate(float deltaTime) {
|
|||
// reset hand and arm positions according to hand movement
|
||||
//------------------------------------------------------------
|
||||
if (_usingBodySprings) {
|
||||
updateHandMovement();
|
||||
updateHandMovement( deltaTime );
|
||||
updateBodySprings( deltaTime );
|
||||
}
|
||||
|
||||
|
@ -445,7 +463,7 @@ void Head::simulate(float deltaTime) {
|
|||
//----------------------------------------------------------
|
||||
// update position by velocity
|
||||
//----------------------------------------------------------
|
||||
_bodyPosition += (glm::vec3)_velocity * deltaTime;
|
||||
_position += (glm::vec3)_velocity * deltaTime;
|
||||
|
||||
//----------------------------------------------------------
|
||||
// decay velocity
|
||||
|
@ -563,37 +581,25 @@ float Head::getHeight() {
|
|||
glm::vec3 Head::getBodyUpDirection() {
|
||||
return _orientation.getUp();
|
||||
}
|
||||
|
||||
|
||||
bool Head::testForCollision( glm::vec3 collisionPosition, float collisionGirth, float collisionHeight, glm::vec3 collisionUpVector ) {
|
||||
_collisionElipsoid.colliding = false;
|
||||
_collisionElipsoid.position = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
_collisionElipsoid.upVector = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
_collisionElipsoid.girth = 0.0;
|
||||
_collisionElipsoid.height = 0.0;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// This is a workspace for testing avatar body collision detection and response
|
||||
//--------------------------------------------------------------------------------
|
||||
void Head::updateAvatarCollisionDetectionAndResponse( glm::vec3 collisionPosition, float collisionRadius, float deltaTime ) {
|
||||
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);
|
||||
if ( distanceToBigSphere < myBodyApproximateBoundingRadius + collisionRadius )
|
||||
if ( distanceToBigSphere < myBodyApproximateBoundingRadius + collisionGirth )
|
||||
{
|
||||
for (int b=0; b<NUM_AVATAR_BONES; b++)
|
||||
{
|
||||
glm::vec3 vectorFromJointToBigSphereCenter(_bone[b].springyPosition - collisionPosition);
|
||||
float distanceToBigSphereCenter = glm::length(vectorFromJointToBigSphereCenter);
|
||||
float combinedRadius = _bone[b].radius + collisionRadius;
|
||||
float combinedRadius = _bone[b].radius + collisionGirth;
|
||||
if ( distanceToBigSphereCenter < combinedRadius )
|
||||
{
|
||||
jointCollision = true;
|
||||
|
@ -630,12 +636,11 @@ 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();
|
||||
|
||||
|
||||
if ( usingBigSphereCollisionTest ) {
|
||||
//---------------------------------------------------
|
||||
// show TEST big sphere
|
||||
|
@ -664,10 +669,10 @@ void Head::render(bool lookingInMirror) {
|
|||
if ( _isMine )
|
||||
{
|
||||
if (_usingBodySprings) {
|
||||
if ( _closestOtherAvatar != -1 ) {
|
||||
if ( _nearOtherAvatar ) {
|
||||
|
||||
glm::vec3 v1( _bone[ AVATAR_BONE_RIGHT_HAND ].position );
|
||||
glm::vec3 v2( _otherAvatarHandPosition[ _closestOtherAvatar ] );
|
||||
glm::vec3 v2( _otherAvatar.handPosition );
|
||||
|
||||
glLineWidth( 8.0 );
|
||||
glColor4f( 0.7f, 0.4f, 0.1f, 0.6 );
|
||||
|
@ -970,9 +975,6 @@ void Head::initializeSkeleton() {
|
|||
updateSkeleton();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Head::calculateBoneLengths() {
|
||||
for (int b=0; b<NUM_AVATAR_BONES; b++) {
|
||||
_bone[b].length = glm::length( _bone[b].defaultPosePosition );
|
||||
|
@ -997,7 +999,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 );
|
||||
|
@ -1036,7 +1038,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;
|
||||
|
@ -1114,7 +1116,7 @@ glm::vec3 Head::getBonePosition( AvatarBoneID b ) {
|
|||
|
||||
|
||||
|
||||
void Head::updateHandMovement() {
|
||||
void Head::updateHandMovement( float deltaTime ) {
|
||||
glm::vec3 transformedHandMovement;
|
||||
|
||||
transformedHandMovement
|
||||
|
@ -1126,19 +1128,31 @@ void Head::updateHandMovement() {
|
|||
|
||||
setHandState(_mousePressed);
|
||||
|
||||
//if holding hands, add a pull to the hand...
|
||||
if ( _usingBodySprings ) {
|
||||
if ( _closestOtherAvatar != -1 ) {
|
||||
if ( _mousePressed ) {
|
||||
|
||||
glm::vec3 handToHandVector( _otherAvatarHandPosition[ _closestOtherAvatar ]);
|
||||
handToHandVector -= _bone[ AVATAR_BONE_RIGHT_HAND ].position;
|
||||
//---------------------------------------------------------------------
|
||||
// if holding hands with another avatar, add a force to the hand...
|
||||
//---------------------------------------------------------------------
|
||||
if (( getHandState() == 1 )
|
||||
|| ( _otherAvatar.handState == 1 )) {
|
||||
//if ( _usingBodySprings )
|
||||
{
|
||||
if ( _nearOtherAvatar ) {
|
||||
|
||||
glm::vec3 vectorToOtherHand = _otherAvatar.handPosition - _handHolding.position;
|
||||
glm::vec3 vectorToMyHand = _bone[ AVATAR_BONE_RIGHT_HAND ].position - _handHolding.position;
|
||||
|
||||
_bone[ AVATAR_BONE_RIGHT_HAND ].position = _otherAvatarHandPosition[ _closestOtherAvatar ];
|
||||
_handHolding.velocity *= 0.7;
|
||||
_handHolding.velocity += ( vectorToOtherHand + vectorToMyHand ) * _handHolding.force * deltaTime;
|
||||
_handHolding.position += _handHolding.velocity;
|
||||
|
||||
_bone[ AVATAR_BONE_RIGHT_HAND ].position = _handHolding.position;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
_handHolding.position = _bone[ AVATAR_BONE_RIGHT_HAND ].position;
|
||||
_handHolding.velocity = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// determine the arm vector
|
||||
//-------------------------------------------------------------------------------
|
||||
|
@ -1247,8 +1261,10 @@ void Head::renderBody() {
|
|||
}
|
||||
}
|
||||
|
||||
if (( _usingBodySprings ) && ( getHandState() )) {
|
||||
glColor4f( 1.0, 1.0, 0.5, 0.5 );
|
||||
//---------------------------------------------------------
|
||||
// if the hand is grasping, show it...
|
||||
//---------------------------------------------------------
|
||||
if (( _usingBodySprings ) && ( getHandState() == 1 )) {
|
||||
glPushMatrix();
|
||||
glTranslatef
|
||||
(
|
||||
|
@ -1256,7 +1272,10 @@ void Head::renderBody() {
|
|||
_bone[ AVATAR_BONE_RIGHT_HAND ].springyPosition.y,
|
||||
_bone[ AVATAR_BONE_RIGHT_HAND ].springyPosition.z
|
||||
);
|
||||
glutSolidSphere( 0.03f, 10.0f, 5.0f );
|
||||
glColor4f( 1.0, 1.0, 0.8, 0.3 ); glutSolidSphere( 0.020f, 10.0f, 10.0f );
|
||||
glColor4f( 1.0, 1.0, 0.4, 0.2 ); glutSolidSphere( 0.025f, 10.0f, 10.0f );
|
||||
glColor4f( 1.0, 1.0, 0.2, 0.1 ); glutSolidSphere( 0.030f, 10.0f, 10.0f );
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ const float YAW_MAG = 300.0;
|
|||
const float TEST_YAW_DECAY = 5.0;
|
||||
const float LIN_VEL_DECAY = 5.0;
|
||||
|
||||
const float COLLISION_BODY_RADIUS = 0.3;
|
||||
const float COLLISION_BODY_RADIUS = 0.1;
|
||||
const float COLLISION_HEIGHT = 1.5;
|
||||
|
||||
enum eyeContactTargets {LEFT_EYE, RIGHT_EYE, MOUTH};
|
||||
|
@ -93,6 +93,20 @@ struct AvatarCollisionElipsoid
|
|||
glm::vec3 upVector;
|
||||
};
|
||||
|
||||
struct AvatarHandHolding
|
||||
{
|
||||
glm::vec3 position;
|
||||
glm::vec3 velocity;
|
||||
float force;
|
||||
};
|
||||
|
||||
struct OtherAvatar
|
||||
{
|
||||
glm::vec3 handPosition;
|
||||
int handState;
|
||||
};
|
||||
|
||||
|
||||
struct AvatarBone
|
||||
{
|
||||
AvatarBoneID parent; // which bone is this bone connected to?
|
||||
|
@ -177,6 +191,7 @@ class Head : public AvatarData {
|
|||
glm::vec3 getHeadPosition();
|
||||
glm::vec3 getBonePosition( AvatarBoneID b );
|
||||
glm::vec3 getBodyUpDirection();
|
||||
//int getHandState();
|
||||
float getGirth();
|
||||
float getHeight();
|
||||
|
||||
|
@ -190,13 +205,11 @@ class Head : public AvatarData {
|
|||
void startHandMovement();
|
||||
void stopHandMovement();
|
||||
void setHandMovementValues( glm::vec3 movement );
|
||||
void updateHandMovement();
|
||||
void updateHandMovement( float deltaTime );
|
||||
|
||||
float getAverageLoudness() {return _head.averageLoudness;};
|
||||
void setAverageLoudness(float al) {_head.averageLoudness = al;};
|
||||
|
||||
bool testForCollision( glm::vec3 collisionPosition, float collisionGirth, float collisionHeight, glm::vec3 collisionUpVector );
|
||||
|
||||
|
||||
void SetNewHeadTarget(float, float);
|
||||
|
||||
// Set what driving keys are being pressed to control thrust levels
|
||||
|
@ -208,47 +221,38 @@ class Head : public AvatarData {
|
|||
void addThrust(glm::vec3 newThrust) { _thrust += newThrust; };
|
||||
glm::vec3 getThrust() { return _thrust; };
|
||||
|
||||
//
|
||||
// Related to getting transmitter UDP data used to animate the avatar hand
|
||||
//
|
||||
|
||||
void processTransmitterData(unsigned char * packetData, int numBytes);
|
||||
float getTransmitterHz() { return _transmitterHz; };
|
||||
|
||||
private:
|
||||
AvatarHead _head;
|
||||
bool _isMine;
|
||||
glm::vec3 _TEST_bigSpherePosition;
|
||||
float _TEST_bigSphereRadius;
|
||||
glm::vec3 _otherAvatarHandPosition[ MAX_OTHER_AVATARS ];
|
||||
bool _mousePressed;
|
||||
float _bodyYawDelta;
|
||||
int _closestOtherAvatar;
|
||||
bool _usingBodySprings;
|
||||
glm::vec3 _movedHandOffset;
|
||||
float _springVelocityDecay;
|
||||
float _springForce;
|
||||
glm::quat _rotation; // the rotation of the avatar body as a whole expressed as a quaternion
|
||||
AvatarBone _bone[ NUM_AVATAR_BONES ];
|
||||
AvatarMode _mode;
|
||||
glm::dvec3 _velocity;
|
||||
glm::vec3 _thrust;
|
||||
float _maxArmLength;
|
||||
Orientation _orientation;
|
||||
int _numOtherAvatarsInView;
|
||||
int _driveKeys[MAX_DRIVE_KEYS];
|
||||
GLUquadric* _sphere;
|
||||
float _renderYaw;
|
||||
float _renderPitch; // Pitch from view frustum when this is own head
|
||||
|
||||
AvatarCollisionElipsoid _collisionElipsoid;
|
||||
|
||||
//
|
||||
// Related to getting transmitter UDP data used to animate the avatar hand
|
||||
//
|
||||
timeval _transmitterTimer;
|
||||
float _transmitterHz;
|
||||
int _transmitterPackets;
|
||||
AvatarHead _head;
|
||||
bool _isMine;
|
||||
glm::vec3 _TEST_bigSpherePosition;
|
||||
float _TEST_bigSphereRadius;
|
||||
OtherAvatar _otherAvatar;
|
||||
bool _mousePressed;
|
||||
float _bodyYawDelta;
|
||||
bool _nearOtherAvatar;
|
||||
bool _usingBodySprings;
|
||||
glm::vec3 _movedHandOffset;
|
||||
float _springVelocityDecay;
|
||||
float _springForce;
|
||||
glm::quat _rotation; // the rotation of the avatar body as a whole expressed as a quaternion
|
||||
AvatarBone _bone[ NUM_AVATAR_BONES ];
|
||||
AvatarMode _mode;
|
||||
AvatarHandHolding _handHolding;
|
||||
glm::dvec3 _velocity;
|
||||
glm::vec3 _thrust;
|
||||
float _maxArmLength;
|
||||
Orientation _orientation;
|
||||
int _driveKeys[MAX_DRIVE_KEYS];
|
||||
GLUquadric* _sphere;
|
||||
float _renderYaw;
|
||||
float _renderPitch; // Pitch from view frustum when this is own head
|
||||
timeval _transmitterTimer;
|
||||
float _transmitterHz;
|
||||
int _transmitterPackets;
|
||||
|
||||
//-----------------------------
|
||||
// private methods...
|
||||
|
@ -258,10 +262,16 @@ class Head : public AvatarData {
|
|||
void initializeBodySprings();
|
||||
void updateBodySprings( float deltaTime );
|
||||
void calculateBoneLengths();
|
||||
void updateAvatarCollisionDetectionAndResponse( glm::vec3, float radius, float deltaTime );
|
||||
void readSensors();
|
||||
void renderBoneAsBlock( AvatarBoneID b );
|
||||
|
||||
void updateAvatarCollisionDetectionAndResponse
|
||||
(
|
||||
glm::vec3 collisionPosition,
|
||||
float collisionGirth,
|
||||
float collisionHeight,
|
||||
glm::vec3 collisionUpVector,
|
||||
float deltaTime
|
||||
);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -306,7 +306,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 ",
|
||||
|
@ -398,8 +398,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
|
||||
|
@ -440,7 +440,7 @@ void reset_sensors()
|
|||
|
||||
renderYawRate = 0;
|
||||
renderPitchRate = 0;
|
||||
myAvatar.setBodyPosition(start_location);
|
||||
myAvatar.setPosition(start_location);
|
||||
headMouseX = WIDTH/2;
|
||||
headMouseY = HEIGHT/2;
|
||||
|
||||
|
@ -540,7 +540,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;
|
||||
|
@ -822,7 +822,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 );
|
||||
|
@ -1264,7 +1264,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
|
||||
|
@ -1493,7 +1493,7 @@ void idle(void) {
|
|||
//
|
||||
updateAvatar(deltaTime);
|
||||
|
||||
//loop through all the other avatars and simulate them.
|
||||
//loop through all the other avatars and simulate them...
|
||||
AgentList * agentList = AgentList::getInstance();
|
||||
for(std::vector<Agent>::iterator agent = agentList->getAgents().begin(); agent != agentList->getAgents().end(); agent++)
|
||||
{
|
||||
|
@ -1501,9 +1501,6 @@ void idle(void) {
|
|||
{
|
||||
Head *avatar = (Head *)agent->getLinkedData();
|
||||
avatar->simulate(deltaTime);
|
||||
|
||||
//not ready yet...
|
||||
//myAvatar.testForCollision( avatar->getBodyPosition(), avatar->getGirth(), avatar->getHeight(), avatar->getBodyUpDirection() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1514,7 +1511,6 @@ void idle(void) {
|
|||
|
||||
glutPostRedisplay();
|
||||
lastTimeIdle = check;
|
||||
|
||||
}
|
||||
|
||||
// Read serial data
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
@ -48,7 +48,7 @@ public:
|
|||
|
||||
// Hand State
|
||||
void setHandState(char s) { _handState = s; };
|
||||
const float getHandState() const {return _handState; };
|
||||
const float getHandState() const {return _handState; }; //@Philip - shouldn't this be an int or a char?
|
||||
|
||||
// Instantaneous audio loudness to drive mouth/facial animation
|
||||
void setLoudness(float l) { _audioLoudness = l; };
|
||||
|
@ -75,7 +75,7 @@ public:
|
|||
void setCameraFarClip(float farClip) { _cameraFarClip = farClip; }
|
||||
|
||||
protected:
|
||||
glm::vec3 _bodyPosition;
|
||||
glm::vec3 _position;
|
||||
glm::vec3 _handPosition;
|
||||
|
||||
// Body rotation
|
||||
|
|
Loading…
Reference in a new issue