mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 16:36:54 +02:00
Merge pull request #138 from Ventrella/master
major changes to hand holding logic (ordering mostly)
This commit is contained in:
commit
b8054790b0
4 changed files with 187 additions and 183 deletions
|
@ -27,6 +27,7 @@ const float MAX_ITERATIONS_BETWEEN_AUDIO_SENDS = (MAX_AUDIO_SEND_INTERVAL_SECS *
|
||||||
|
|
||||||
bool stopReceiveAgentDataThread;
|
bool stopReceiveAgentDataThread;
|
||||||
bool injectAudioThreadRunning = false;
|
bool injectAudioThreadRunning = false;
|
||||||
|
int handStateTimer = 0;
|
||||||
|
|
||||||
int TEMP_AUDIO_LISTEN_PORT = 55439;
|
int TEMP_AUDIO_LISTEN_PORT = 55439;
|
||||||
// UDPSocket audioSocket(TEMP_AUDIO_LISTEN_PORT);
|
// UDPSocket audioSocket(TEMP_AUDIO_LISTEN_PORT);
|
||||||
|
@ -124,6 +125,18 @@ int main(int argc, const char* argv[]) {
|
||||||
eve.setHandPosition(glm::vec3(eve.getPosition()[0] - 0.2,
|
eve.setHandPosition(glm::vec3(eve.getPosition()[0] - 0.2,
|
||||||
0.25,
|
0.25,
|
||||||
eve.getPosition()[2] + 0.1));
|
eve.getPosition()[2] + 0.1));
|
||||||
|
|
||||||
|
// simulate the effect of pressing and un-pressing the mouse button/pad
|
||||||
|
handStateTimer ++;
|
||||||
|
if ( handStateTimer == 100 ) {
|
||||||
|
eve.setHandState(1);
|
||||||
|
}
|
||||||
|
if ( handStateTimer == 150 ) {
|
||||||
|
eve.setHandState(0);
|
||||||
|
}
|
||||||
|
if ( handStateTimer >= 200 ) {
|
||||||
|
handStateTimer = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// read eve's audio data
|
// read eve's audio data
|
||||||
AudioInjector eveAudioInjector("eve.raw");
|
AudioInjector eveAudioInjector("eve.raw");
|
||||||
|
|
|
@ -91,7 +91,7 @@ bool processParameters(int parameterCount, char* parameterData[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};_Position
|
};
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main(int argc, const char* argv[]) {
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,6 @@ Head::Head(bool isMine) {
|
||||||
_velocity = glm::vec3( 0.0, 0.0, 0.0 );
|
_velocity = glm::vec3( 0.0, 0.0, 0.0 );
|
||||||
_thrust = 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 );
|
_rotation = glm::quat( 0.0f, 0.0f, 0.0f, 0.0f );
|
||||||
_nearOtherAvatar = false;
|
|
||||||
_bodyYaw = -90.0;
|
_bodyYaw = -90.0;
|
||||||
_bodyPitch = 0.0;
|
_bodyPitch = 0.0;
|
||||||
_bodyRoll = 0.0;
|
_bodyRoll = 0.0;
|
||||||
|
@ -60,7 +59,6 @@ Head::Head(bool isMine) {
|
||||||
//_transmitterTimer = 0;
|
//_transmitterTimer = 0;
|
||||||
_transmitterHz = 0.0;
|
_transmitterHz = 0.0;
|
||||||
_transmitterPackets = 0;
|
_transmitterPackets = 0;
|
||||||
//_numOtherAvatars = 0;
|
|
||||||
|
|
||||||
initializeSkeleton();
|
initializeSkeleton();
|
||||||
|
|
||||||
|
@ -69,54 +67,51 @@ Head::Head(bool isMine) {
|
||||||
|
|
||||||
for (int i = 0; i < MAX_DRIVE_KEYS; i++) _driveKeys[i] = false;
|
for (int i = 0; i < MAX_DRIVE_KEYS; i++) _driveKeys[i] = false;
|
||||||
|
|
||||||
_head.pupilSize = 0.10;
|
_head.pupilSize = 0.10;
|
||||||
_head.interPupilDistance = 0.6;
|
_head.interPupilDistance = 0.6;
|
||||||
_head.interBrowDistance = 0.75;
|
_head.interBrowDistance = 0.75;
|
||||||
_head.nominalPupilSize = 0.10;
|
_head.nominalPupilSize = 0.10;
|
||||||
//_head.yaw = 0.0;
|
_head.pitchRate = 0.0;
|
||||||
//_head.pitch = 0.0;
|
_head.yawRate = 0.0;
|
||||||
//_head.roll = 0.0;
|
_head.rollRate = 0.0;
|
||||||
_head.pitchRate = 0.0;
|
_head.eyebrowPitch[0] = -30;
|
||||||
_head.yawRate = 0.0;
|
_head.eyebrowPitch[1] = -30;
|
||||||
_head.rollRate = 0.0;
|
_head.eyebrowRoll [0] = 20;
|
||||||
_head.eyebrowPitch[0] = -30;
|
_head.eyebrowRoll [1] = -20;
|
||||||
_head.eyebrowPitch[1] = -30;
|
_head.mouthPitch = 0;
|
||||||
_head.eyebrowRoll [0] = 20;
|
_head.mouthYaw = 0;
|
||||||
_head.eyebrowRoll [1] = -20;
|
_head.mouthWidth = 1.0;
|
||||||
_head.mouthPitch = 0;
|
_head.mouthHeight = 0.2;
|
||||||
_head.mouthYaw = 0;
|
_head.eyeballPitch[0] = 0;
|
||||||
_head.mouthWidth = 1.0;
|
_head.eyeballPitch[1] = 0;
|
||||||
_head.mouthHeight = 0.2;
|
_head.eyeballScaleX = 1.2;
|
||||||
_head.eyeballPitch[0] = 0;
|
_head.eyeballScaleY = 1.5;
|
||||||
_head.eyeballPitch[1] = 0;
|
_head.eyeballScaleZ = 1.0;
|
||||||
_head.eyeballScaleX = 1.2;
|
_head.eyeballYaw[0] = 0;
|
||||||
_head.eyeballScaleY = 1.5;
|
_head.eyeballYaw[1] = 0;
|
||||||
_head.eyeballScaleZ = 1.0;
|
_head.pitchTarget = 0;
|
||||||
_head.eyeballYaw[0] = 0;
|
_head.yawTarget = 0;
|
||||||
_head.eyeballYaw[1] = 0;
|
_head.noiseEnvelope = 1.0;
|
||||||
_head.pitchTarget = 0;
|
_head.pupilConverge = 10.0;
|
||||||
_head.yawTarget = 0;
|
_head.leanForward = 0.0;
|
||||||
_head.noiseEnvelope = 1.0;
|
_head.leanSideways = 0.0;
|
||||||
_head.pupilConverge = 10.0;
|
_head.eyeContact = 1;
|
||||||
_head.leanForward = 0.0;
|
_head.eyeContactTarget = LEFT_EYE;
|
||||||
_head.leanSideways = 0.0;
|
_head.scale = 1.0;
|
||||||
_head.eyeContact = 1;
|
_head.audioAttack = 0.0;
|
||||||
_head.eyeContactTarget = LEFT_EYE;
|
_head.averageLoudness = 0.0;
|
||||||
_head.scale = 1.0;
|
_head.lastLoudness = 0.0;
|
||||||
_head.audioAttack = 0.0;
|
_head.browAudioLift = 0.0;
|
||||||
_head.averageLoudness = 0.0;
|
_head.noise = 0;
|
||||||
_head.lastLoudness = 0.0;
|
_movedHandOffset = glm::vec3( 0.0, 0.0, 0.0 );
|
||||||
_head.browAudioLift = 0.0;
|
_usingBodySprings = true;
|
||||||
_head.noise = 0;
|
_springForce = 6.0f;
|
||||||
|
_springVelocityDecay = 16.0f;
|
||||||
_movedHandOffset = glm::vec3( 0.0, 0.0, 0.0 );
|
_renderYaw = 0.0;
|
||||||
_usingBodySprings = true;
|
_renderPitch = 0.0;
|
||||||
_springForce = 6.0f;
|
_sphere = NULL;
|
||||||
_springVelocityDecay = 16.0f;
|
_interactingOther = NULL;
|
||||||
_renderYaw = 0.0;
|
_interactingOtherIsNearby = false;
|
||||||
_renderPitch = 0.0;
|
|
||||||
|
|
||||||
_sphere = NULL;
|
|
||||||
|
|
||||||
_handHolding.position = glm::vec3( 0.0, 0.0, 0.0 );
|
_handHolding.position = glm::vec3( 0.0, 0.0, 0.0 );
|
||||||
_handHolding.velocity = glm::vec3( 0.0, 0.0, 0.0 );
|
_handHolding.velocity = glm::vec3( 0.0, 0.0, 0.0 );
|
||||||
|
@ -129,38 +124,35 @@ Head::Head(bool isMine) {
|
||||||
printLog("error %u: %s\n", error, lodepng_error_text(error));
|
printLog("error %u: %s\n", error, lodepng_error_text(error));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_otherAvatar.handPosition = glm::vec3( 0.0f, 0.0f, 0.0f );
|
|
||||||
_otherAvatar.handState = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Head::Head(const Head &otherAvatar) {
|
Head::Head(const Head &otherAvatar) {
|
||||||
|
|
||||||
_velocity = otherAvatar._velocity;
|
_velocity = otherAvatar._velocity;
|
||||||
_thrust = otherAvatar._thrust;
|
_thrust = otherAvatar._thrust;
|
||||||
_rotation = otherAvatar._rotation;
|
_rotation = otherAvatar._rotation;
|
||||||
_nearOtherAvatar = otherAvatar._nearOtherAvatar;
|
_interactingOtherIsNearby = otherAvatar._interactingOtherIsNearby;
|
||||||
_bodyYaw = otherAvatar._bodyYaw;
|
_bodyYaw = otherAvatar._bodyYaw;
|
||||||
_bodyPitch = otherAvatar._bodyPitch;
|
_bodyPitch = otherAvatar._bodyPitch;
|
||||||
_bodyRoll = otherAvatar._bodyRoll;
|
_bodyRoll = otherAvatar._bodyRoll;
|
||||||
_bodyYawDelta = otherAvatar._bodyYawDelta;
|
_bodyYawDelta = otherAvatar._bodyYawDelta;
|
||||||
_mousePressed = otherAvatar._mousePressed;
|
_mousePressed = otherAvatar._mousePressed;
|
||||||
_mode = otherAvatar._mode;
|
_mode = otherAvatar._mode;
|
||||||
_isMine = otherAvatar._isMine;
|
_isMine = otherAvatar._isMine;
|
||||||
_renderYaw = otherAvatar._renderYaw;
|
_renderYaw = otherAvatar._renderYaw;
|
||||||
_renderPitch = otherAvatar._renderPitch;
|
_renderPitch = otherAvatar._renderPitch;
|
||||||
_maxArmLength = otherAvatar._maxArmLength;
|
_maxArmLength = otherAvatar._maxArmLength;
|
||||||
_transmitterTimer = otherAvatar._transmitterTimer;
|
_transmitterTimer = otherAvatar._transmitterTimer;
|
||||||
_transmitterHz = otherAvatar._transmitterHz;
|
_transmitterHz = otherAvatar._transmitterHz;
|
||||||
_transmitterPackets = otherAvatar._transmitterPackets;
|
_transmitterPackets = otherAvatar._transmitterPackets;
|
||||||
_TEST_bigSphereRadius = otherAvatar._TEST_bigSphereRadius;
|
_TEST_bigSphereRadius = otherAvatar._TEST_bigSphereRadius;
|
||||||
_TEST_bigSpherePosition = otherAvatar._TEST_bigSpherePosition;
|
_TEST_bigSpherePosition = otherAvatar._TEST_bigSpherePosition;
|
||||||
_movedHandOffset = otherAvatar._movedHandOffset;
|
_movedHandOffset = otherAvatar._movedHandOffset;
|
||||||
_usingBodySprings = otherAvatar._usingBodySprings;
|
_usingBodySprings = otherAvatar._usingBodySprings;
|
||||||
_springForce = otherAvatar._springForce;
|
_springForce = otherAvatar._springForce;
|
||||||
_springVelocityDecay = otherAvatar._springVelocityDecay;
|
_springVelocityDecay = otherAvatar._springVelocityDecay;
|
||||||
_orientation.set( otherAvatar._orientation );
|
_orientation.set( otherAvatar._orientation );
|
||||||
|
|
||||||
_sphere = NULL;
|
_sphere = NULL;
|
||||||
|
@ -173,9 +165,6 @@ Head::Head(const Head &otherAvatar) {
|
||||||
_head.interPupilDistance = otherAvatar._head.interPupilDistance;
|
_head.interPupilDistance = otherAvatar._head.interPupilDistance;
|
||||||
_head.interBrowDistance = otherAvatar._head.interBrowDistance;
|
_head.interBrowDistance = otherAvatar._head.interBrowDistance;
|
||||||
_head.nominalPupilSize = otherAvatar._head.nominalPupilSize;
|
_head.nominalPupilSize = otherAvatar._head.nominalPupilSize;
|
||||||
//_head.yaw = otherAvatar._head.yaw;
|
|
||||||
//_head.pitch = otherAvatar._head.pitch;
|
|
||||||
//_head.roll = otherAvatar._head.roll;
|
|
||||||
_head.yawRate = otherAvatar._head.yawRate;
|
_head.yawRate = otherAvatar._head.yawRate;
|
||||||
_head.pitchRate = otherAvatar._head.pitchRate;
|
_head.pitchRate = otherAvatar._head.pitchRate;
|
||||||
_head.rollRate = otherAvatar._head.rollRate;
|
_head.rollRate = otherAvatar._head.rollRate;
|
||||||
|
@ -209,7 +198,6 @@ Head::Head(const Head &otherAvatar) {
|
||||||
_head.browAudioLift = otherAvatar._head.browAudioLift;
|
_head.browAudioLift = otherAvatar._head.browAudioLift;
|
||||||
_head.noise = otherAvatar._head.noise;
|
_head.noise = otherAvatar._head.noise;
|
||||||
|
|
||||||
|
|
||||||
if (iris_texture.size() == 0) {
|
if (iris_texture.size() == 0) {
|
||||||
switchToResourcesParentIfRequired();
|
switchToResourcesParentIfRequired();
|
||||||
unsigned error = lodepng::decode(iris_texture, iris_texture_width, iris_texture_height, iris_texture_file);
|
unsigned error = lodepng::decode(iris_texture, iris_texture_width, iris_texture_height, iris_texture_file);
|
||||||
|
@ -296,19 +284,34 @@ void Head::setMousePressed( bool d ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Head::simulate(float deltaTime) {
|
void Head::simulate(float deltaTime) {
|
||||||
|
|
||||||
|
//------------------------
|
||||||
|
// update avatar skeleton
|
||||||
|
//------------------------
|
||||||
|
updateSkeleton();
|
||||||
|
|
||||||
|
//------------------------------------------------------------
|
||||||
|
// reset hand and arm positions according to hand movement
|
||||||
|
//------------------------------------------------------------
|
||||||
|
updateHandMovement( deltaTime );
|
||||||
|
|
||||||
|
if ( !_interactingOtherIsNearby ) {
|
||||||
|
//initialize _handHolding
|
||||||
|
_handHolding.position = _bone[ AVATAR_BONE_RIGHT_HAND ].position;
|
||||||
|
_handHolding.velocity = glm::vec3( 0.0, 0.0, 0.0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
_interactingOtherIsNearby = false;
|
||||||
|
|
||||||
//-------------------------------------------------------------
|
//-------------------------------------------------------------
|
||||||
// if the avatar being simulated is mine, then loop through
|
// if the avatar being simulated is mine, then loop through
|
||||||
// all the other avatars to get information about them...
|
// all the other avatars for potential interactions...
|
||||||
//-------------------------------------------------------------
|
//-------------------------------------------------------------
|
||||||
if ( _isMine )
|
if ( _isMine )
|
||||||
{
|
{
|
||||||
_nearOtherAvatar = false;
|
|
||||||
float closestDistance = 10000.0f;
|
float closestDistance = 10000.0f;
|
||||||
|
|
||||||
AgentList * agentList = AgentList::getInstance();
|
AgentList * agentList = AgentList::getInstance();
|
||||||
|
|
||||||
//_numOtherAvatars = 0;
|
|
||||||
|
|
||||||
for(std::vector<Agent>::iterator agent = agentList->getAgents().begin();
|
for(std::vector<Agent>::iterator agent = agentList->getAgents().begin();
|
||||||
agent != agentList->getAgents().end();
|
agent != agentList->getAgents().end();
|
||||||
|
@ -316,42 +319,64 @@ void Head::simulate(float deltaTime) {
|
||||||
if (( agent->getLinkedData() != NULL && ( agent->getType() == AGENT_TYPE_AVATAR ) )) {
|
if (( agent->getLinkedData() != NULL && ( agent->getType() == AGENT_TYPE_AVATAR ) )) {
|
||||||
Head *otherAvatar = (Head *)agent->getLinkedData();
|
Head *otherAvatar = (Head *)agent->getLinkedData();
|
||||||
|
|
||||||
// if ( _numOtherAvatars < MAX_OTHER_AVATARS )
|
//------------------------------------------------------
|
||||||
{
|
// check for collisions with other avatars and respond
|
||||||
|
//------------------------------------------------------
|
||||||
//------------------------------------------------------
|
updateAvatarCollisionDetectionAndResponse
|
||||||
// check for collisions with other avatars and respond
|
(
|
||||||
//------------------------------------------------------
|
otherAvatar->getPosition(),
|
||||||
updateAvatarCollisionDetectionAndResponse
|
otherAvatar->getGirth(),
|
||||||
(
|
otherAvatar->getHeight(),
|
||||||
otherAvatar->getPosition(),
|
otherAvatar->getBodyUpDirection(),
|
||||||
otherAvatar->getGirth(),
|
deltaTime
|
||||||
otherAvatar->getHeight(),
|
);
|
||||||
otherAvatar->getBodyUpDirection(),
|
|
||||||
deltaTime
|
//-------------------------------------------------
|
||||||
);
|
// test other avatar hand position for proximity
|
||||||
|
//------------------------------------------------
|
||||||
//-------------------------------------------------
|
glm::vec3 v( _bone[ AVATAR_BONE_RIGHT_SHOULDER ].position );
|
||||||
// test other avatar hand position for proximity
|
v -= otherAvatar->getBonePosition( AVATAR_BONE_RIGHT_HAND );
|
||||||
//------------------------------------------------
|
|
||||||
glm::vec3 v( _bone[ AVATAR_BONE_RIGHT_SHOULDER ].position );
|
float distance = glm::length( v );
|
||||||
v -= otherAvatar->getBonePosition( AVATAR_BONE_RIGHT_HAND );
|
if ( distance < _maxArmLength ) {
|
||||||
|
|
||||||
float distance = glm::length( v );
|
//if ( distance < closestDistance ) { // perhaps I don't need this if we want to allow multi-avatar interactions
|
||||||
if ( distance < _maxArmLength ) {
|
{
|
||||||
if ( distance < closestDistance ) {
|
closestDistance = distance;
|
||||||
closestDistance = distance;
|
_interactingOther = otherAvatar;
|
||||||
_nearOtherAvatar = true;
|
_interactingOtherIsNearby = true;
|
||||||
_otherAvatar.handPosition = otherAvatar->getBonePosition( AVATAR_BONE_RIGHT_HAND );
|
|
||||||
_otherAvatar.handState = (int)otherAvatar->getHandState();
|
//---------------------------------------------------------------------
|
||||||
}
|
// if I am holding hands with another avatar, a force is applied
|
||||||
|
//---------------------------------------------------------------------
|
||||||
|
if (( _handState == 1 )
|
||||||
|
|| ( _interactingOther->_handState == 1 )) {
|
||||||
|
glm::vec3 vectorToOtherHand = _interactingOther->_handPosition - _handHolding.position;
|
||||||
|
glm::vec3 vectorToMyHand = _bone[ AVATAR_BONE_RIGHT_HAND ].position - _handHolding.position;
|
||||||
|
|
||||||
|
_handHolding.velocity *= 0.7;
|
||||||
|
_handHolding.velocity += ( vectorToOtherHand + vectorToMyHand ) * _handHolding.force * deltaTime;
|
||||||
|
_handHolding.position += _handHolding.velocity;
|
||||||
|
|
||||||
|
_bone[ AVATAR_BONE_RIGHT_HAND ].position = _handHolding.position;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}//if ( _isMine )
|
// Set the vector we send for hand position to other people to be our right hand
|
||||||
|
setHandPosition(_bone[ AVATAR_BONE_RIGHT_HAND ].position);
|
||||||
|
|
||||||
|
}//if ( _isMine )
|
||||||
|
|
||||||
|
|
||||||
|
updateArmIKAndConstraints( deltaTime );
|
||||||
|
|
||||||
|
if ( ! _interactingOtherIsNearby ) {
|
||||||
|
_interactingOther = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if ( usingBigSphereCollisionTest ) {
|
if ( usingBigSphereCollisionTest ) {
|
||||||
//--------------------------------------------------------------
|
//--------------------------------------------------------------
|
||||||
// test for avatar collision response (using a big sphere :)
|
// test for avatar collision response (using a big sphere :)
|
||||||
|
@ -378,19 +403,10 @@ void Head::simulate(float deltaTime) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------
|
// update body springs
|
||||||
// update avatar skeleton
|
updateBodySprings( deltaTime );
|
||||||
//------------------------
|
|
||||||
updateSkeleton();
|
|
||||||
|
|
||||||
//------------------------------------------------------------
|
|
||||||
// reset hand and arm positions according to hand movement
|
|
||||||
//------------------------------------------------------------
|
|
||||||
if (_usingBodySprings) {
|
|
||||||
updateHandMovement( deltaTime );
|
|
||||||
updateBodySprings( deltaTime );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( _isMine ) { // driving the avatar around should only apply if this is my avatar (as opposed to an avatar being driven remotely)
|
if ( _isMine ) { // driving the avatar around should only apply if this is my avatar (as opposed to an avatar being driven remotely)
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
// this handles the avatar being driven around...
|
// this handles the avatar being driven around...
|
||||||
|
@ -449,7 +465,6 @@ void Head::simulate(float deltaTime) {
|
||||||
_bodyYaw += _bodyYawDelta * deltaTime;
|
_bodyYaw += _bodyYawDelta * deltaTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------
|
//----------------------------------------------------------
|
||||||
// decay body yaw delta
|
// decay body yaw delta
|
||||||
//----------------------------------------------------------
|
//----------------------------------------------------------
|
||||||
|
@ -632,8 +647,6 @@ void Head::updateAvatarCollisionDetectionAndResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Head::render(bool lookingInMirror) {
|
void Head::render(bool lookingInMirror) {
|
||||||
|
|
||||||
//---------------------------------------------------
|
//---------------------------------------------------
|
||||||
|
@ -658,9 +671,9 @@ void Head::render(bool lookingInMirror) {
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------
|
//---------------
|
||||||
// render body
|
// render body
|
||||||
//---------------------------------------------------
|
//---------------
|
||||||
renderBody();
|
renderBody();
|
||||||
|
|
||||||
//---------------------------------------------------
|
//---------------------------------------------------
|
||||||
|
@ -669,28 +682,25 @@ void Head::render(bool lookingInMirror) {
|
||||||
renderHead(lookingInMirror);
|
renderHead(lookingInMirror);
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
// if this is my avatar, then render my interactions with the other avatars
|
// if this is my avatar, then render my interactions with the other avatar
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
if ( _isMine )
|
if ( _isMine )
|
||||||
{
|
{
|
||||||
if (_usingBodySprings) {
|
if ( _interactingOtherIsNearby ) {
|
||||||
if ( _nearOtherAvatar ) {
|
|
||||||
|
|
||||||
glm::vec3 v1( _bone[ AVATAR_BONE_RIGHT_HAND ].position );
|
glm::vec3 v1( _bone[ AVATAR_BONE_RIGHT_HAND ].position );
|
||||||
glm::vec3 v2( _otherAvatar.handPosition );
|
glm::vec3 v2( _interactingOther->_handPosition );
|
||||||
|
|
||||||
glLineWidth( 8.0 );
|
glLineWidth( 8.0 );
|
||||||
glColor4f( 0.7f, 0.4f, 0.1f, 0.6 );
|
glColor4f( 0.7f, 0.4f, 0.1f, 0.6 );
|
||||||
glBegin( GL_LINE_STRIP );
|
glBegin( GL_LINE_STRIP );
|
||||||
glVertex3f( v1.x, v1.y, v1.z );
|
glVertex3f( v1.x, v1.y, v1.z );
|
||||||
glVertex3f( v2.x, v2.y, v2.z );
|
glVertex3f( v2.x, v2.y, v2.z );
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Head::renderHead(bool lookingInMirror) {
|
void Head::renderHead(bool lookingInMirror) {
|
||||||
int side = 0;
|
int side = 0;
|
||||||
|
@ -978,9 +988,9 @@ void Head::initializeSkeleton() {
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
calculateBoneLengths();
|
calculateBoneLengths();
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//---------------------------
|
||||||
// generate world positions
|
// generate world positions
|
||||||
//----------------------------------------------------------------------------
|
//---------------------------
|
||||||
updateSkeleton();
|
updateSkeleton();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1140,29 +1150,11 @@ void Head::updateHandMovement( float deltaTime ) {
|
||||||
if (_isMine) {
|
if (_isMine) {
|
||||||
_handState = _mousePressed;
|
_handState = _mousePressed;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
//---------------------------------------------------------------------
|
|
||||||
// if holding hands with another avatar, add a force to the hand...
|
|
||||||
//---------------------------------------------------------------------
|
void Head::updateArmIKAndConstraints( float deltaTime ) {
|
||||||
if (( getHandState() == 1 )
|
|
||||||
|| ( _otherAvatar.handState == 1 )) {
|
|
||||||
if ( _nearOtherAvatar ) {
|
|
||||||
|
|
||||||
glm::vec3 vectorToOtherHand = _otherAvatar.handPosition - _handHolding.position;
|
|
||||||
glm::vec3 vectorToMyHand = _bone[ AVATAR_BONE_RIGHT_HAND ].position - _handHolding.position;
|
|
||||||
|
|
||||||
_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
|
// determine the arm vector
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
|
@ -1207,14 +1199,11 @@ void Head::updateHandMovement( float deltaTime ) {
|
||||||
glm::vec3 newWristPosition = _bone[ AVATAR_BONE_RIGHT_UPPER_ARM ].position;
|
glm::vec3 newWristPosition = _bone[ AVATAR_BONE_RIGHT_UPPER_ARM ].position;
|
||||||
newWristPosition += vv * 0.7f;
|
newWristPosition += vv * 0.7f;
|
||||||
_bone[ AVATAR_BONE_RIGHT_FOREARM ].position = newWristPosition;
|
_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);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Head::renderBody() {
|
void Head::renderBody() {
|
||||||
//-----------------------------------------
|
//-----------------------------------------
|
||||||
// Render bone positions as spheres
|
// Render bone positions as spheres
|
||||||
|
|
|
@ -100,12 +100,14 @@ struct AvatarHandHolding
|
||||||
float force;
|
float force;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
struct OtherAvatar
|
struct OtherAvatar
|
||||||
{
|
{
|
||||||
glm::vec3 handPosition;
|
bool nearby;
|
||||||
int handState;
|
//glm::vec3 handPosition;
|
||||||
|
//int handState;
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
struct AvatarBone
|
struct AvatarBone
|
||||||
{
|
{
|
||||||
|
@ -191,7 +193,6 @@ class Head : public AvatarData {
|
||||||
glm::vec3 getHeadPosition();
|
glm::vec3 getHeadPosition();
|
||||||
glm::vec3 getBonePosition( AvatarBoneID b );
|
glm::vec3 getBonePosition( AvatarBoneID b );
|
||||||
glm::vec3 getBodyUpDirection();
|
glm::vec3 getBodyUpDirection();
|
||||||
//int getHandState();
|
|
||||||
float getGirth();
|
float getGirth();
|
||||||
float getHeight();
|
float getHeight();
|
||||||
|
|
||||||
|
@ -206,6 +207,7 @@ class Head : public AvatarData {
|
||||||
void stopHandMovement();
|
void stopHandMovement();
|
||||||
void setHandMovementValues( glm::vec3 movement );
|
void setHandMovementValues( glm::vec3 movement );
|
||||||
void updateHandMovement( float deltaTime );
|
void updateHandMovement( float deltaTime );
|
||||||
|
void updateArmIKAndConstraints( float deltaTime );
|
||||||
|
|
||||||
float getAverageLoudness() {return _head.averageLoudness;};
|
float getAverageLoudness() {return _head.averageLoudness;};
|
||||||
void setAverageLoudness(float al) {_head.averageLoudness = al;};
|
void setAverageLoudness(float al) {_head.averageLoudness = al;};
|
||||||
|
@ -230,10 +232,8 @@ class Head : public AvatarData {
|
||||||
bool _isMine;
|
bool _isMine;
|
||||||
glm::vec3 _TEST_bigSpherePosition;
|
glm::vec3 _TEST_bigSpherePosition;
|
||||||
float _TEST_bigSphereRadius;
|
float _TEST_bigSphereRadius;
|
||||||
OtherAvatar _otherAvatar;
|
|
||||||
bool _mousePressed;
|
bool _mousePressed;
|
||||||
float _bodyYawDelta;
|
float _bodyYawDelta;
|
||||||
bool _nearOtherAvatar;
|
|
||||||
bool _usingBodySprings;
|
bool _usingBodySprings;
|
||||||
glm::vec3 _movedHandOffset;
|
glm::vec3 _movedHandOffset;
|
||||||
float _springVelocityDecay;
|
float _springVelocityDecay;
|
||||||
|
@ -253,6 +253,8 @@ class Head : public AvatarData {
|
||||||
timeval _transmitterTimer;
|
timeval _transmitterTimer;
|
||||||
float _transmitterHz;
|
float _transmitterHz;
|
||||||
int _transmitterPackets;
|
int _transmitterPackets;
|
||||||
|
Head* _interactingOther;
|
||||||
|
bool _interactingOtherIsNearby;
|
||||||
|
|
||||||
//-----------------------------
|
//-----------------------------
|
||||||
// private methods...
|
// private methods...
|
||||||
|
|
Loading…
Reference in a new issue