Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Philip Rosedale 2013-05-09 15:03:45 -07:00
commit 52337a1fae
4 changed files with 65 additions and 49 deletions

View file

@ -505,11 +505,10 @@ void Avatar::updateHandMovementAndTouching(float deltaTime) {
_avatarTouch.setYourHandPosition(_interactingOther->_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].springyPosition);
_avatarTouch.setYourHandState (_interactingOther->_handState);
_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position =
_interactingOther->_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].springyPosition;
//_handHoldingPosition
if ( _avatarTouch.getAbleToReachOtherAvatar()) {
_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position =
_interactingOther->_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].springyPosition;
}
}
}//if (_isMine)
@ -529,10 +528,7 @@ void Avatar::updateHandMovementAndTouching(float deltaTime) {
}
_avatarTouch.setMyHandState(_handState);
if (_handState == 1) {
_avatarTouch.setMyHandPosition(_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].springyPosition);
}
_avatarTouch.setMyHandPosition(_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].springyPosition);
}
}

View file

@ -16,13 +16,14 @@ const float THREAD_RADIUS = 0.012;
AvatarTouch::AvatarTouch() {
_myHandPosition = glm::vec3(0.0f, 0.0f, 0.0f);
_yourHandPosition = glm::vec3(0.0f, 0.0f, 0.0f);
_myBodyPosition = glm::vec3(0.0f, 0.0f, 0.0f);
_yourBodyPosition = glm::vec3(0.0f, 0.0f, 0.0f);
_myHandState = 0;
_yourHandState = 0;
_reachableRadius = 0.0f;
_myHandPosition = glm::vec3(0.0f, 0.0f, 0.0f);
_yourHandPosition = glm::vec3(0.0f, 0.0f, 0.0f);
_myBodyPosition = glm::vec3(0.0f, 0.0f, 0.0f);
_yourBodyPosition = glm::vec3(0.0f, 0.0f, 0.0f);
_vectorBetweenHands = glm::vec3(0.0f, 0.0f, 0.0f);
_myHandState = 0;
_yourHandState = 0;
_reachableRadius = 0.0f;
_canReachToOtherAvatar = false;
_handsCloseEnoughToGrasp = false;
@ -60,15 +61,17 @@ void AvatarTouch::setReachableRadius(float r) {
_reachableRadius = r;
}
void AvatarTouch::render(glm::vec3 cameraPosition) {
if (_canReachToOtherAvatar) {
glColor4f(0.3, 0.4, 0.5, 0.5);
glm::vec3 p(_yourBodyPosition);
p.y = 0.0005f;
renderCircle(p, _reachableRadius, glm::vec3(0.0f, 1.0f, 0.0f), 30);
renderBeamBetweenHands();
// if your hand is grasping, show it...
if (_yourHandState == 1) {
glPushMatrix();
@ -78,28 +81,7 @@ if (_canReachToOtherAvatar) {
glColor4f(1.0, 1.0, 0.2, 0.1); glutSolidSphere(0.030f, 10.0f, 10.0f);
glPopMatrix();
}
//show beam
glm::vec3 v1(_myHandPosition);
glm::vec3 v2(_yourHandPosition);
if (_handsCloseEnoughToGrasp) {
glLineWidth(2.0);
glColor4f(0.7f, 0.4f, 0.1f, 0.3);
glBegin(GL_LINE_STRIP);
glVertex3f(v1.x, v1.y, v1.z);
glVertex3f(v2.x, v2.y, v2.z);
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();
}
}
}
}
// if my hand is grasping, show it...
if (_myHandState == 1) {
@ -114,24 +96,54 @@ if (_canReachToOtherAvatar) {
void AvatarTouch::simulate (float deltaTime) {
glm::vec3 v = _yourBodyPosition - _myBodyPosition;
float distance = glm::length(v);
_vectorBetweenHands = _yourBodyPosition - _myBodyPosition;
float distance = glm::length(_vectorBetweenHands);
if (distance < _reachableRadius) {
_canReachToOtherAvatar = true;
generateBeamBetweenHands();
} else {
_canReachToOtherAvatar = false;
}
}
/*
}
void AvatarTouch::generateBeamBetweenHands() {
for (int p=0; p<NUM_POINTS; p++) {
_point[p] = _myHandPosition + v * ((float)p / (float)NUM_POINTS);
_point[p] = _myHandPosition + _vectorBetweenHands * ((float)p / (float)NUM_POINTS);
_point[p].x += randFloatInRange(-THREAD_RADIUS, THREAD_RADIUS);
_point[p].y += randFloatInRange(-THREAD_RADIUS, THREAD_RADIUS);
_point[p].z += randFloatInRange(-THREAD_RADIUS, THREAD_RADIUS);
}
*/
}
}
void AvatarTouch::renderBeamBetweenHands() {
glm::vec3 v1(_myHandPosition);
glm::vec3 v2(_yourHandPosition);
glLineWidth(2.0);
glColor4f(0.7f, 0.4f, 0.1f, 0.3);
glBegin(GL_LINE_STRIP);
glVertex3f(v1.x, v1.y, v1.z);
glVertex3f(v2.x, v2.y, v2.z);
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();
}
}

View file

@ -43,11 +43,15 @@ private:
glm::vec3 _yourBodyPosition;
glm::vec3 _myHandPosition;
glm::vec3 _yourHandPosition;
glm::vec3 _vectorBetweenHands;
int _myHandState;
int _yourHandState;
bool _canReachToOtherAvatar;
bool _handsCloseEnoughToGrasp;
float _reachableRadius;
void generateBeamBetweenHands();
void renderBeamBetweenHands();
};
#endif

View file

@ -1873,7 +1873,11 @@ glm::vec3 getGravity(glm::vec3 pos) {
}
void mouseFunc(int button, int state, int x, int y) {
if ( !menu.mouseClick(x, y)) { // if a menu item was not clicked or unclicked...
//catch mouse actiond on the menu
bool menuClickedOrUnclicked = menu.mouseClick(x, y);
if (!menuClickedOrUnclicked) {
if ( button == GLUT_LEFT_BUTTON ) {
mouseX = x;
mouseY = y;