mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 22:16:58 +02:00
Merge branch 'master' of https://github.com/worklist/hifi into view_frustum_work
This commit is contained in:
commit
429ba8c729
9 changed files with 142 additions and 119 deletions
|
@ -60,7 +60,6 @@ int main(int argc, const char* argv[])
|
||||||
|
|
||||||
agentList->startDomainServerCheckInThread();
|
agentList->startDomainServerCheckInThread();
|
||||||
agentList->startSilentAgentRemovalThread();
|
agentList->startSilentAgentRemovalThread();
|
||||||
agentList->startPingUnknownAgentsThread();
|
|
||||||
|
|
||||||
sockaddr *agentAddress = new sockaddr;
|
sockaddr *agentAddress = new sockaddr;
|
||||||
unsigned char *packetData = new unsigned char[MAX_PACKET_SIZE];
|
unsigned char *packetData = new unsigned char[MAX_PACKET_SIZE];
|
||||||
|
@ -70,34 +69,36 @@ int main(int argc, const char* argv[])
|
||||||
*broadcastPacket = PACKET_HEADER_BULK_AVATAR_DATA;
|
*broadcastPacket = PACKET_HEADER_BULK_AVATAR_DATA;
|
||||||
|
|
||||||
unsigned char* currentBufferPosition = NULL;
|
unsigned char* currentBufferPosition = NULL;
|
||||||
int agentIndex = 0;
|
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (agentList->getAgentSocket().receive(agentAddress, packetData, &receivedBytes)) {
|
if (agentList->getAgentSocket().receive(agentAddress, packetData, &receivedBytes)) {
|
||||||
switch (packetData[0]) {
|
switch (packetData[0]) {
|
||||||
case PACKET_HEADER_HEAD_DATA:
|
case PACKET_HEADER_HEAD_DATA:
|
||||||
|
// add this agent if we don't have them yet
|
||||||
|
if (agentList->addOrUpdateAgent(agentAddress, agentAddress, AGENT_TYPE_AVATAR, agentList->getLastAgentId())) {
|
||||||
|
agentList->increaseAgentId();
|
||||||
|
}
|
||||||
|
|
||||||
// this is positional data from an agent
|
// this is positional data from an agent
|
||||||
agentList->updateAgentWithData(agentAddress, packetData, receivedBytes);
|
agentList->updateAgentWithData(agentAddress, packetData, receivedBytes);
|
||||||
|
|
||||||
currentBufferPosition = broadcastPacket + 1;
|
currentBufferPosition = broadcastPacket + 1;
|
||||||
agentIndex = 0;
|
|
||||||
|
|
||||||
// send back a packet with other active agent data to this agent
|
// send back a packet with other active agent data to this agent
|
||||||
for (AgentList::iterator avatarAgent = agentList->begin();
|
for (AgentList::iterator agent = agentList->begin(); agent != agentList->end(); agent++) {
|
||||||
avatarAgent != agentList->end();
|
if (agent->getLinkedData() != NULL
|
||||||
avatarAgent++) {
|
&& !socketMatch(agentAddress, agent->getActiveSocket())) {
|
||||||
if (avatarAgent->getLinkedData() != NULL
|
currentBufferPosition = addAgentToBroadcastPacket(currentBufferPosition, &*agent);
|
||||||
&& !socketMatch(agentAddress, avatarAgent->getActiveSocket())) {
|
|
||||||
currentBufferPosition = addAgentToBroadcastPacket(currentBufferPosition, &*avatarAgent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
agentIndex++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
agentList->getAgentSocket().send(agentAddress,
|
agentList->getAgentSocket().send(agentAddress,
|
||||||
broadcastPacket,
|
broadcastPacket,
|
||||||
currentBufferPosition - broadcastPacket);
|
currentBufferPosition - broadcastPacket);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case PACKET_HEADER_DOMAIN:
|
||||||
|
// ignore the DS packet, for now agents are added only when they communicate directly with us
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// hand this off to the AgentList
|
// hand this off to the AgentList
|
||||||
|
@ -107,9 +108,8 @@ int main(int argc, const char* argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
agentList->stopDomainServerCheckInThread();
|
|
||||||
agentList->stopSilentAgentRemovalThread();
|
agentList->stopSilentAgentRemovalThread();
|
||||||
agentList->stopPingUnknownAgentsThread();
|
agentList->stopDomainServerCheckInThread();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
BIN
eve/resources/audio/eve.raw
Normal file
BIN
eve/resources/audio/eve.raw
Normal file
Binary file not shown.
|
@ -116,10 +116,7 @@ Avatar::Avatar(bool isMine) {
|
||||||
_sphere = NULL;
|
_sphere = NULL;
|
||||||
_interactingOther = NULL;
|
_interactingOther = NULL;
|
||||||
_interactingOtherIsNearby = false;
|
_interactingOtherIsNearby = false;
|
||||||
|
_handHoldingPosition = 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.force = 10.0f;
|
|
||||||
|
|
||||||
initializeSkeleton();
|
initializeSkeleton();
|
||||||
|
|
||||||
|
@ -309,8 +306,7 @@ void Avatar::simulate(float deltaTime) {
|
||||||
|
|
||||||
if ( !_interactingOtherIsNearby ) {
|
if ( !_interactingOtherIsNearby ) {
|
||||||
//initialize _handHolding
|
//initialize _handHolding
|
||||||
_handHolding.position = _bone[ AVATAR_BONE_RIGHT_HAND ].position;
|
_handHoldingPosition = _bone[ AVATAR_BONE_RIGHT_HAND ].position;
|
||||||
_handHolding.velocity = glm::vec3( 0.0, 0.0, 0.0 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_interactingOtherIsNearby = false;
|
_interactingOtherIsNearby = false;
|
||||||
|
@ -337,27 +333,20 @@ void Avatar::simulate(float deltaTime) {
|
||||||
float distance = glm::length( v );
|
float distance = glm::length( v );
|
||||||
if ( distance < _maxArmLength + _maxArmLength ) {
|
if ( distance < _maxArmLength + _maxArmLength ) {
|
||||||
|
|
||||||
//if ( distance < closestDistance ) { // perhaps I don't need this if we want to allow multi-avatar interactions
|
closestDistance = distance;
|
||||||
{
|
_interactingOther = otherAvatar;
|
||||||
closestDistance = distance;
|
_interactingOtherIsNearby = true;
|
||||||
_interactingOther = otherAvatar;
|
|
||||||
_interactingOtherIsNearby = true;
|
|
||||||
|
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_avatarTouch.setMyHandPosition( _bone[ AVATAR_BONE_RIGHT_HAND ].position );
|
// if I am holding hands with another avatar, a force is applied
|
||||||
_avatarTouch.setYourPosition( otherAvatar->getBonePosition( AVATAR_BONE_RIGHT_HAND ) );
|
if (( _handState == 1 ) || ( _interactingOther->_handState == 1 )) {
|
||||||
|
glm::vec3 vectorToOtherHand = _interactingOther->_handPosition - _handHoldingPosition;
|
||||||
|
glm::vec3 vectorToMyHand = _bone[ AVATAR_BONE_RIGHT_HAND ].position - _handHoldingPosition;
|
||||||
|
_handHoldingPosition += vectorToOtherHand * YOUR_HAND_HOLDING_PULL;
|
||||||
|
_handHoldingPosition += vectorToMyHand * MY_HAND_HOLDING_PULL;
|
||||||
|
_bone[ AVATAR_BONE_RIGHT_HAND ].position = _handHoldingPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
_avatarTouch.setYourHandPosition( _interactingOther->_handPosition );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -370,8 +359,13 @@ void Avatar::simulate(float deltaTime) {
|
||||||
|
|
||||||
}//if ( _isMine )
|
}//if ( _isMine )
|
||||||
|
|
||||||
|
//constrain right arm length and re-adjust elbow position as it bends
|
||||||
updateArmIKAndConstraints( deltaTime );
|
updateArmIKAndConstraints( deltaTime );
|
||||||
|
|
||||||
|
if (_isMine) {
|
||||||
|
_avatarTouch.setMyHandPosition( _bone[ AVATAR_BONE_RIGHT_HAND ].position );
|
||||||
|
}
|
||||||
|
|
||||||
if (!_interactingOtherIsNearby) {
|
if (!_interactingOtherIsNearby) {
|
||||||
_interactingOther = NULL;
|
_interactingOther = NULL;
|
||||||
}
|
}
|
||||||
|
@ -545,21 +539,23 @@ void Avatar::updateCollisionWithSphere( glm::vec3 position, float radius, float
|
||||||
float distanceToBigSphere = glm::length(vectorFromMyBodyToBigSphere);
|
float distanceToBigSphere = glm::length(vectorFromMyBodyToBigSphere);
|
||||||
if ( distanceToBigSphere < myBodyApproximateBoundingRadius + radius ) {
|
if ( distanceToBigSphere < myBodyApproximateBoundingRadius + radius ) {
|
||||||
for (int b = 0; b < NUM_AVATAR_BONES; b++) {
|
for (int b = 0; b < NUM_AVATAR_BONES; b++) {
|
||||||
glm::vec3 vectorFromJointToBigSphereCenter(_bone[b].springyPosition - position);
|
if ( _bone[b].isCollidable ) {
|
||||||
float distanceToBigSphereCenter = glm::length(vectorFromJointToBigSphereCenter);
|
glm::vec3 vectorFromJointToBigSphereCenter(_bone[b].springyPosition - position);
|
||||||
float combinedRadius = _bone[b].radius + radius;
|
float distanceToBigSphereCenter = glm::length(vectorFromJointToBigSphereCenter);
|
||||||
|
float combinedRadius = _bone[b].radius + radius;
|
||||||
if ( distanceToBigSphereCenter < combinedRadius ) {
|
|
||||||
jointCollision = true;
|
if ( distanceToBigSphereCenter < combinedRadius ) {
|
||||||
if (distanceToBigSphereCenter > 0.0) {
|
jointCollision = true;
|
||||||
glm::vec3 directionVector = vectorFromJointToBigSphereCenter / distanceToBigSphereCenter;
|
if (distanceToBigSphereCenter > 0.0) {
|
||||||
|
glm::vec3 directionVector = vectorFromJointToBigSphereCenter / distanceToBigSphereCenter;
|
||||||
float penetration = 1.0 - (distanceToBigSphereCenter / combinedRadius);
|
|
||||||
glm::vec3 collisionForce = vectorFromJointToBigSphereCenter * penetration;
|
float penetration = 1.0 - (distanceToBigSphereCenter / combinedRadius);
|
||||||
|
glm::vec3 collisionForce = vectorFromJointToBigSphereCenter * penetration;
|
||||||
_bone[b].springyVelocity += collisionForce * 30.0f * deltaTime;
|
|
||||||
_velocity += collisionForce * 100.0f * deltaTime;
|
_bone[b].springyVelocity += collisionForce * 30.0f * deltaTime;
|
||||||
_bone[b].springyPosition = position + directionVector * combinedRadius;
|
_velocity += collisionForce * 100.0f * deltaTime;
|
||||||
|
_bone[b].springyPosition = position + directionVector * combinedRadius;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -583,27 +579,32 @@ void Avatar::updateCollisionWithOtherAvatar( Avatar * otherAvatar, float deltaTi
|
||||||
|
|
||||||
// loop through the bones of each avatar to check for every possible collision
|
// loop through the bones of each avatar to check for every possible collision
|
||||||
for (int b=1; b<NUM_AVATAR_BONES; b++) {
|
for (int b=1; b<NUM_AVATAR_BONES; b++) {
|
||||||
for (int o=b+1; o<NUM_AVATAR_BONES; o++) {
|
if ( _bone[b].isCollidable ) {
|
||||||
|
|
||||||
|
for (int o=b+1; o<NUM_AVATAR_BONES; o++) {
|
||||||
|
if ( _bone[o].isCollidable ) {
|
||||||
|
|
||||||
|
glm::vec3 vectorBetweenJoints(_bone[b].springyPosition - otherAvatar->_bone[o].springyPosition);
|
||||||
|
float distanceBetweenJoints = glm::length(vectorBetweenJoints);
|
||||||
|
|
||||||
glm::vec3 vectorBetweenJoints(_bone[b].springyPosition - otherAvatar->_bone[o].springyPosition);
|
// to avoid divide by zero
|
||||||
float distanceBetweenJoints = glm::length(vectorBetweenJoints);
|
if ( distanceBetweenJoints > 0.0 ) {
|
||||||
|
float combinedRadius = _bone[b].radius + otherAvatar->_bone[o].radius;
|
||||||
// to avoid divide by zero
|
|
||||||
if ( distanceBetweenJoints > 0.0 ) {
|
|
||||||
float combinedRadius = _bone[b].radius + otherAvatar->_bone[o].radius;
|
|
||||||
|
|
||||||
// check for collision
|
// check for collision
|
||||||
if ( distanceBetweenJoints < combinedRadius * COLLISION_RADIUS_SCALAR) {
|
if ( distanceBetweenJoints < combinedRadius * COLLISION_RADIUS_SCALAR) {
|
||||||
glm::vec3 directionVector = vectorBetweenJoints / distanceBetweenJoints;
|
glm::vec3 directionVector = vectorBetweenJoints / distanceBetweenJoints;
|
||||||
|
|
||||||
// push ball away from colliding other ball and puch avatar body (_velocity) as well
|
// push ball away from colliding other ball and puch avatar body (_velocity) as well
|
||||||
_bone[b].springyVelocity += directionVector * COLLISION_BALL_FORCE * deltaTime;
|
_bone[b].springyVelocity += directionVector * COLLISION_BALL_FORCE * deltaTime;
|
||||||
_velocity += directionVector * COLLISION_BODY_FORCE * deltaTime;
|
_velocity += directionVector * COLLISION_BODY_FORCE * deltaTime;
|
||||||
|
|
||||||
// apply fruction to _velocity
|
// apply fruction to _velocity
|
||||||
float momentum = 1.0 - COLLISION_FRICTION * deltaTime;
|
float momentum = 1.0 - COLLISION_FRICTION * deltaTime;
|
||||||
if ( momentum < 0.0 ) { momentum = 0.0;}
|
if ( momentum < 0.0 ) { momentum = 0.0;}
|
||||||
_velocity *= momentum;
|
_velocity *= momentum;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -867,19 +868,6 @@ void Avatar::renderHead(bool lookingInMirror) {
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Avatar::startHandMovement() {
|
|
||||||
|
|
||||||
if (!_usingBodySprings) {
|
|
||||||
initializeBodySprings();
|
|
||||||
_usingBodySprings = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Avatar::stopHandMovement() {
|
|
||||||
//_usingBodySprings = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Avatar::setHandMovementValues( glm::vec3 handOffset ) {
|
void Avatar::setHandMovementValues( glm::vec3 handOffset ) {
|
||||||
_movedHandOffset = handOffset;
|
_movedHandOffset = handOffset;
|
||||||
}
|
}
|
||||||
|
@ -891,6 +879,7 @@ AvatarMode Avatar::getMode() {
|
||||||
void Avatar::initializeSkeleton() {
|
void Avatar::initializeSkeleton() {
|
||||||
|
|
||||||
for (int b=0; b<NUM_AVATAR_BONES; b++) {
|
for (int b=0; b<NUM_AVATAR_BONES; b++) {
|
||||||
|
_bone[b].isCollidable = true;
|
||||||
_bone[b].parent = AVATAR_BONE_NULL;
|
_bone[b].parent = AVATAR_BONE_NULL;
|
||||||
_bone[b].position = glm::vec3( 0.0, 0.0, 0.0 );
|
_bone[b].position = glm::vec3( 0.0, 0.0, 0.0 );
|
||||||
_bone[b].defaultPosePosition = glm::vec3( 0.0, 0.0, 0.0 );
|
_bone[b].defaultPosePosition = glm::vec3( 0.0, 0.0, 0.0 );
|
||||||
|
@ -906,9 +895,7 @@ void Avatar::initializeSkeleton() {
|
||||||
_bone[b].orientation.setToIdentity();
|
_bone[b].orientation.setToIdentity();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
// specify the parental hierarchy
|
||||||
// parental hierarchy
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
_bone[ AVATAR_BONE_PELVIS_SPINE ].parent = AVATAR_BONE_NULL;
|
_bone[ AVATAR_BONE_PELVIS_SPINE ].parent = AVATAR_BONE_NULL;
|
||||||
_bone[ AVATAR_BONE_MID_SPINE ].parent = AVATAR_BONE_PELVIS_SPINE;
|
_bone[ AVATAR_BONE_MID_SPINE ].parent = AVATAR_BONE_PELVIS_SPINE;
|
||||||
_bone[ AVATAR_BONE_CHEST_SPINE ].parent = AVATAR_BONE_MID_SPINE;
|
_bone[ AVATAR_BONE_CHEST_SPINE ].parent = AVATAR_BONE_MID_SPINE;
|
||||||
|
@ -958,7 +945,7 @@ void Avatar::initializeSkeleton() {
|
||||||
_bone[ AVATAR_BONE_RIGHT_SHIN ].defaultPosePosition = glm::vec3( 0.0, -0.15, 0.0 );
|
_bone[ AVATAR_BONE_RIGHT_SHIN ].defaultPosePosition = glm::vec3( 0.0, -0.15, 0.0 );
|
||||||
_bone[ AVATAR_BONE_RIGHT_FOOT ].defaultPosePosition = glm::vec3( 0.0, 0.0, 0.04 );
|
_bone[ AVATAR_BONE_RIGHT_FOOT ].defaultPosePosition = glm::vec3( 0.0, 0.0, 0.04 );
|
||||||
|
|
||||||
|
// specify the radii of the bone positions
|
||||||
_bone[ AVATAR_BONE_PELVIS_SPINE ].radius = 0.05;
|
_bone[ AVATAR_BONE_PELVIS_SPINE ].radius = 0.05;
|
||||||
_bone[ AVATAR_BONE_MID_SPINE ].radius = 0.06;
|
_bone[ AVATAR_BONE_MID_SPINE ].radius = 0.06;
|
||||||
_bone[ AVATAR_BONE_CHEST_SPINE ].radius = 0.03;
|
_bone[ AVATAR_BONE_CHEST_SPINE ].radius = 0.03;
|
||||||
|
@ -982,7 +969,12 @@ void Avatar::initializeSkeleton() {
|
||||||
_bone[ AVATAR_BONE_RIGHT_THIGH ].radius = 0.02;
|
_bone[ AVATAR_BONE_RIGHT_THIGH ].radius = 0.02;
|
||||||
_bone[ AVATAR_BONE_RIGHT_SHIN ].radius = 0.015;
|
_bone[ AVATAR_BONE_RIGHT_SHIN ].radius = 0.015;
|
||||||
_bone[ AVATAR_BONE_RIGHT_FOOT ].radius = 0.02;
|
_bone[ AVATAR_BONE_RIGHT_FOOT ].radius = 0.02;
|
||||||
|
|
||||||
|
// to aid in hand-shaking and hand-holding, the right hand is not collidable
|
||||||
|
_bone[ AVATAR_BONE_RIGHT_UPPER_ARM ].isCollidable = false;
|
||||||
|
_bone[ AVATAR_BONE_RIGHT_FOREARM ].isCollidable = false;
|
||||||
|
_bone[ AVATAR_BONE_RIGHT_HAND ].isCollidable = false;
|
||||||
|
|
||||||
// calculate bone length
|
// calculate bone length
|
||||||
calculateBoneLengths();
|
calculateBoneLengths();
|
||||||
|
|
||||||
|
@ -1135,7 +1127,7 @@ void Avatar::updateArmIKAndConstraints( float deltaTime ) {
|
||||||
// test to see if right hand is being dragged beyond maximum arm length
|
// test to see if right hand is being dragged beyond maximum arm length
|
||||||
float distance = glm::length( armVector );
|
float distance = glm::length( armVector );
|
||||||
|
|
||||||
// if right hand is being dragged beyond maximum arm length...
|
// don't let right hand get dragged beyond maximum arm length...
|
||||||
if ( distance > _maxArmLength ) {
|
if ( distance > _maxArmLength ) {
|
||||||
// reset right hand to be constrained to maximum arm length
|
// reset right hand to be constrained to maximum arm length
|
||||||
_bone[ AVATAR_BONE_RIGHT_HAND ].position = _bone[ AVATAR_BONE_RIGHT_SHOULDER ].position;
|
_bone[ AVATAR_BONE_RIGHT_HAND ].position = _bone[ AVATAR_BONE_RIGHT_SHOULDER ].position;
|
||||||
|
|
|
@ -36,10 +36,11 @@ const float COLLISION_RADIUS_SCALAR = 1.8;
|
||||||
const float COLLISION_BALL_FORCE = 0.1;
|
const float COLLISION_BALL_FORCE = 0.1;
|
||||||
const float COLLISION_BODY_FORCE = 3.0;
|
const float COLLISION_BODY_FORCE = 3.0;
|
||||||
|
|
||||||
|
const float MY_HAND_HOLDING_PULL = 0.2;
|
||||||
|
const float YOUR_HAND_HOLDING_PULL = 1.0;
|
||||||
|
|
||||||
enum eyeContactTargets {LEFT_EYE, RIGHT_EYE, MOUTH};
|
enum eyeContactTargets {LEFT_EYE, RIGHT_EYE, MOUTH};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
enum DriveKeys
|
enum DriveKeys
|
||||||
{
|
{
|
||||||
FWD = 0,
|
FWD = 0,
|
||||||
|
@ -107,18 +108,10 @@ enum AvatarBoneID
|
||||||
NUM_AVATAR_BONES
|
NUM_AVATAR_BONES
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct AvatarHandHolding //think of this as one half of a distributed spring :)
|
|
||||||
{
|
|
||||||
glm::vec3 position;
|
|
||||||
glm::vec3 velocity;
|
|
||||||
float force;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct AvatarBone
|
struct AvatarBone
|
||||||
{
|
{
|
||||||
AvatarBoneID parent; // which bone is this bone connected to?
|
AvatarBoneID parent; // which bone is this bone connected to?
|
||||||
glm::vec3 position; // the position at the "end" of the bone
|
glm::vec3 position; // the position at the "end" of the bone - in global space
|
||||||
glm::vec3 defaultPosePosition; // the parent relative position when the avatar is in the "T-pose"
|
glm::vec3 defaultPosePosition; // the parent relative position when the avatar is in the "T-pose"
|
||||||
glm::vec3 springyPosition; // used for special effects (a 'flexible' variant of position)
|
glm::vec3 springyPosition; // used for special effects (a 'flexible' variant of position)
|
||||||
glm::vec3 springyVelocity; // used for special effects ( the velocity of the springy position)
|
glm::vec3 springyVelocity; // used for special effects ( the velocity of the springy position)
|
||||||
|
@ -130,6 +123,7 @@ struct AvatarBone
|
||||||
Orientation orientation; // three orthogonal normals determined by yaw, pitch, roll
|
Orientation orientation; // three orthogonal normals determined by yaw, pitch, roll
|
||||||
float length; // the length of the bone
|
float length; // the length of the bone
|
||||||
float radius; // used for detecting collisions for certain physical effects
|
float radius; // used for detecting collisions for certain physical effects
|
||||||
|
bool isCollidable; // when false, the bone position will not register a collision
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AvatarHead
|
struct AvatarHead
|
||||||
|
@ -215,8 +209,6 @@ public:
|
||||||
void renderBody();
|
void renderBody();
|
||||||
void renderHead(bool lookingInMirror);
|
void renderHead(bool lookingInMirror);
|
||||||
void simulate(float);
|
void simulate(float);
|
||||||
void startHandMovement();
|
|
||||||
void stopHandMovement();
|
|
||||||
void setHandMovementValues( glm::vec3 movement );
|
void setHandMovementValues( glm::vec3 movement );
|
||||||
void updateHandMovement( float deltaTime );
|
void updateHandMovement( float deltaTime );
|
||||||
void updateArmIKAndConstraints( float deltaTime );
|
void updateArmIKAndConstraints( float deltaTime );
|
||||||
|
@ -257,7 +249,7 @@ private:
|
||||||
glm::quat _rotation; // the rotation of the avatar body as a whole expressed as a quaternion
|
glm::quat _rotation; // the rotation of the avatar body as a whole expressed as a quaternion
|
||||||
AvatarBone _bone[ NUM_AVATAR_BONES ];
|
AvatarBone _bone[ NUM_AVATAR_BONES ];
|
||||||
AvatarMode _mode;
|
AvatarMode _mode;
|
||||||
AvatarHandHolding _handHolding;
|
glm::vec3 _handHoldingPosition;
|
||||||
glm::vec3 _velocity;
|
glm::vec3 _velocity;
|
||||||
glm::vec3 _thrust;
|
glm::vec3 _thrust;
|
||||||
float _speed;
|
float _speed;
|
||||||
|
|
|
@ -3,41 +3,61 @@
|
||||||
// interface
|
// interface
|
||||||
//
|
//
|
||||||
// Created by Jeffrey Ventrella
|
// Created by Jeffrey Ventrella
|
||||||
// Copyright (c) 2012 High Fidelity, Inc. All rights reserved.
|
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
#include <SharedUtil.h>
|
||||||
#include "AvatarTouch.h"
|
#include "AvatarTouch.h"
|
||||||
#include "InterfaceConfig.h"
|
#include "InterfaceConfig.h"
|
||||||
|
|
||||||
|
|
||||||
AvatarTouch::AvatarTouch() {
|
AvatarTouch::AvatarTouch() {
|
||||||
|
|
||||||
_myHandPosition = glm::vec3( 0.0f, 0.0f, 0.0f );
|
_myHandPosition = glm::vec3( 0.0f, 0.0f, 0.0f );
|
||||||
_yourHandPosition = glm::vec3( 0.0f, 0.0f, 0.0f );
|
_yourHandPosition = glm::vec3( 0.0f, 0.0f, 0.0f );
|
||||||
|
|
||||||
|
for (int p=0; p<NUM_POINTS; p++) {
|
||||||
|
_point[p] = glm::vec3( 0.0, 0.0, 0.0 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarTouch::setMyHandPosition( glm::vec3 position ) {
|
void AvatarTouch::setMyHandPosition( glm::vec3 position ) {
|
||||||
_myHandPosition = position;
|
_myHandPosition = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarTouch::setYourPosition( glm::vec3 position ) {
|
void AvatarTouch::setYourHandPosition( glm::vec3 position ) {
|
||||||
_yourHandPosition = position;
|
_yourHandPosition = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AvatarTouch::render() {
|
void AvatarTouch::render() {
|
||||||
|
|
||||||
glm::vec3 v1( _myHandPosition );
|
glm::vec3 v1( _myHandPosition );
|
||||||
glm::vec3 v2( _yourHandPosition );
|
glm::vec3 v2( _yourHandPosition );
|
||||||
|
|
||||||
glLineWidth( 8.0 );
|
glLineWidth( 2.0 );
|
||||||
glColor4f( 0.7f, 0.4f, 0.1f, 0.6 );
|
glColor4f( 0.7f, 0.4f, 0.1f, 0.3 );
|
||||||
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();
|
||||||
|
|
||||||
|
glColor4f( 1.0f, 1.0f, 0.0f, 0.8 );
|
||||||
|
|
||||||
|
for (int p=0; p<NUM_POINTS; p++) {
|
||||||
|
glBegin(GL_POINTS);
|
||||||
|
glVertex3f(_point[p].x, _point[p].y, _point[p].z);
|
||||||
|
glEnd();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarTouch::simulate (float deltaTime) {
|
void AvatarTouch::simulate (float deltaTime) {
|
||||||
|
|
||||||
|
glm::vec3 v = _yourHandPosition - _myHandPosition;
|
||||||
|
for (int p=0; p<NUM_POINTS; p++) {
|
||||||
|
_point[p] = _myHandPosition + v * ( (float)p / (float)NUM_POINTS );
|
||||||
|
_point[p].x += randFloatInRange( -0.007, 0.007 );
|
||||||
|
_point[p].y += randFloatInRange( -0.007, 0.007 );
|
||||||
|
_point[p].z += randFloatInRange( -0.007, 0.007 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,12 +15,16 @@ class AvatarTouch {
|
||||||
public:
|
public:
|
||||||
AvatarTouch();
|
AvatarTouch();
|
||||||
|
|
||||||
void setMyHandPosition( glm::vec3 position );
|
void setMyHandPosition ( glm::vec3 position );
|
||||||
void setYourPosition ( glm::vec3 position );
|
void setYourHandPosition( glm::vec3 position );
|
||||||
void simulate(float deltaTime);
|
void simulate(float deltaTime);
|
||||||
void render();
|
void render();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
static const int NUM_POINTS = 100;
|
||||||
|
|
||||||
|
glm::vec3 _point [NUM_POINTS];
|
||||||
glm::vec3 _myHandPosition;
|
glm::vec3 _myHandPosition;
|
||||||
glm::vec3 _yourHandPosition;
|
glm::vec3 _yourHandPosition;
|
||||||
};
|
};
|
||||||
|
|
|
@ -868,12 +868,14 @@ void display(void)
|
||||||
|
|
||||||
// Render avatars of other agents
|
// Render avatars of other agents
|
||||||
AgentList* agentList = AgentList::getInstance();
|
AgentList* agentList = AgentList::getInstance();
|
||||||
|
agentList->lock();
|
||||||
for (AgentList::iterator agent = agentList->begin(); agent != agentList->end(); agent++) {
|
for (AgentList::iterator agent = agentList->begin(); agent != agentList->end(); agent++) {
|
||||||
if (agent->getLinkedData() != NULL && agent->getType() == AGENT_TYPE_AVATAR) {
|
if (agent->getLinkedData() != NULL && agent->getType() == AGENT_TYPE_AVATAR) {
|
||||||
Avatar *avatar = (Avatar *)agent->getLinkedData();
|
Avatar *avatar = (Avatar *)agent->getLinkedData();
|
||||||
avatar->render(0);
|
avatar->render(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
agentList->unlock();
|
||||||
|
|
||||||
// Render the world box
|
// Render the world box
|
||||||
if (!::lookingInMirror && ::statsOn) { render_world_box(); }
|
if (!::lookingInMirror && ::statsOn) { render_world_box(); }
|
||||||
|
@ -1465,8 +1467,7 @@ void idle(void) {
|
||||||
// tell my avatar if the mouse is being pressed...
|
// tell my avatar if the mouse is being pressed...
|
||||||
if ( mousePressed == 1 ) {
|
if ( mousePressed == 1 ) {
|
||||||
myAvatar.setMousePressed( true );
|
myAvatar.setMousePressed( true );
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
myAvatar.setMousePressed( false );
|
myAvatar.setMousePressed( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1485,14 +1486,16 @@ void idle(void) {
|
||||||
networkReceive(0);
|
networkReceive(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//loop through all the other avatars and simulate them...
|
//loop through all the remote avatars and simulate them...
|
||||||
AgentList* agentList = AgentList::getInstance();
|
AgentList* agentList = AgentList::getInstance();
|
||||||
|
agentList->lock();
|
||||||
for(AgentList::iterator agent = agentList->begin(); agent != agentList->end(); agent++) {
|
for(AgentList::iterator agent = agentList->begin(); agent != agentList->end(); agent++) {
|
||||||
if (agent->getLinkedData() != NULL) {
|
if (agent->getLinkedData() != NULL) {
|
||||||
Avatar *avatar = (Avatar *)agent->getLinkedData();
|
Avatar *avatar = (Avatar *)agent->getLinkedData();
|
||||||
avatar->simulate(deltaTime);
|
avatar->simulate(deltaTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
agentList->unlock();
|
||||||
|
|
||||||
myAvatar.simulate(deltaTime);
|
myAvatar.simulate(deltaTime);
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ AgentList::AgentList(char newOwnerType, unsigned int newSocketListenPort) :
|
||||||
socketListenPort(newSocketListenPort),
|
socketListenPort(newSocketListenPort),
|
||||||
lastAgentId(0)
|
lastAgentId(0)
|
||||||
{
|
{
|
||||||
|
pthread_mutex_init(&mutex, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
AgentList::~AgentList() {
|
AgentList::~AgentList() {
|
||||||
|
@ -74,6 +74,8 @@ AgentList::~AgentList() {
|
||||||
stopSilentAgentRemovalThread();
|
stopSilentAgentRemovalThread();
|
||||||
stopDomainServerCheckInThread();
|
stopDomainServerCheckInThread();
|
||||||
stopPingUnknownAgentsThread();
|
stopPingUnknownAgentsThread();
|
||||||
|
|
||||||
|
pthread_mutex_destroy(&mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
UDPSocket& AgentList::getAgentSocket() {
|
UDPSocket& AgentList::getAgentSocket() {
|
||||||
|
@ -106,6 +108,8 @@ void AgentList::processAgentData(sockaddr *senderAddress, unsigned char *packetD
|
||||||
}
|
}
|
||||||
|
|
||||||
void AgentList::processBulkAgentData(sockaddr *senderAddress, unsigned char *packetData, int numTotalBytes) {
|
void AgentList::processBulkAgentData(sockaddr *senderAddress, unsigned char *packetData, int numTotalBytes) {
|
||||||
|
lock();
|
||||||
|
|
||||||
// find the avatar mixer in our agent list and update the lastRecvTime from it
|
// find the avatar mixer in our agent list and update the lastRecvTime from it
|
||||||
Agent* bulkSendAgent = agentWithAddress(senderAddress);
|
Agent* bulkSendAgent = agentWithAddress(senderAddress);
|
||||||
|
|
||||||
|
@ -141,6 +145,8 @@ void AgentList::processBulkAgentData(sockaddr *senderAddress, unsigned char *pac
|
||||||
packetHolder,
|
packetHolder,
|
||||||
numTotalBytes - (currentPosition - startPosition));
|
numTotalBytes - (currentPosition - startPosition));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
int AgentList::updateAgentWithData(sockaddr *senderAddress, unsigned char *packetData, size_t dataBytes) {
|
int AgentList::updateAgentWithData(sockaddr *senderAddress, unsigned char *packetData, size_t dataBytes) {
|
||||||
|
@ -253,7 +259,9 @@ bool AgentList::addOrUpdateAgent(sockaddr *publicSocket, sockaddr *localSocket,
|
||||||
// to use the local socket information the domain server gave us
|
// to use the local socket information the domain server gave us
|
||||||
sockaddr_in *publicSocketIn = (sockaddr_in *)publicSocket;
|
sockaddr_in *publicSocketIn = (sockaddr_in *)publicSocket;
|
||||||
audioMixerSocketUpdate(publicSocketIn->sin_addr.s_addr, publicSocketIn->sin_port);
|
audioMixerSocketUpdate(publicSocketIn->sin_addr.s_addr, publicSocketIn->sin_port);
|
||||||
} else if (newAgent->getType() == AGENT_TYPE_VOXEL) {
|
} else if (newAgent->getType() == AGENT_TYPE_VOXEL || newAgent->getType() == AGENT_TYPE_AVATAR_MIXER) {
|
||||||
|
// this is currently the cheat we use to talk directly to our test servers on EC2
|
||||||
|
// to be removed when we have a proper identification strategy
|
||||||
newAgent->activatePublicSocket();
|
newAgent->activatePublicSocket();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,9 @@ public:
|
||||||
uint16_t getLastAgentId();
|
uint16_t getLastAgentId();
|
||||||
void increaseAgentId();
|
void increaseAgentId();
|
||||||
|
|
||||||
|
void lock() { pthread_mutex_lock(&mutex); }
|
||||||
|
void unlock() { pthread_mutex_unlock(&mutex); }
|
||||||
|
|
||||||
int updateList(unsigned char *packetData, size_t dataBytes);
|
int updateList(unsigned char *packetData, size_t dataBytes);
|
||||||
|
|
||||||
Agent* agentWithAddress(sockaddr *senderAddress);
|
Agent* agentWithAddress(sockaddr *senderAddress);
|
||||||
|
@ -99,6 +102,7 @@ private:
|
||||||
pthread_t removeSilentAgentsThread;
|
pthread_t removeSilentAgentsThread;
|
||||||
pthread_t checkInWithDomainServerThread;
|
pthread_t checkInWithDomainServerThread;
|
||||||
pthread_t pingUnknownAgentsThread;
|
pthread_t pingUnknownAgentsThread;
|
||||||
|
pthread_mutex_t mutex;
|
||||||
|
|
||||||
void handlePingReply(sockaddr *agentAddress);
|
void handlePingReply(sockaddr *agentAddress);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue