mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 21:16:00 +02:00
working out avatar touch stuff
This commit is contained in:
parent
0e9d9dccaf
commit
9fc56a6230
4 changed files with 34 additions and 32 deletions
|
@ -297,7 +297,6 @@ void Avatar::UpdateGyros(float frametime, SerialInterface* serialInterface, glm:
|
|||
if ((_headYaw < MAX_YAW) && (_headYaw > MIN_YAW)) {
|
||||
addHeadYaw(_head.yawRate * HEAD_ROTATION_SCALE * frametime);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
float Avatar::getAbsoluteHeadYaw() const {
|
||||
|
@ -322,12 +321,10 @@ void Avatar::setMousePressed(bool d) {
|
|||
_mousePressed = d;
|
||||
}
|
||||
|
||||
|
||||
bool Avatar::getIsNearInteractingOther() {
|
||||
return _avatarTouch.getAbleToReachOtherAvatar();
|
||||
}
|
||||
|
||||
|
||||
void Avatar::simulate(float deltaTime) {
|
||||
|
||||
|
||||
|
@ -454,7 +451,7 @@ void Avatar::updateHandMovementAndTouching(float deltaTime) {
|
|||
_avatarTouch.setMyBodyPosition(_position);
|
||||
|
||||
Avatar * _interactingOther = NULL;
|
||||
float closestDistance = 10000.0f;
|
||||
float closestDistance = std::numeric_limits<float>::max();;
|
||||
|
||||
//loop through all the other avatars for potential interactions...
|
||||
AgentList* agentList = AgentList::getInstance();
|
||||
|
@ -473,7 +470,8 @@ void Avatar::updateHandMovementAndTouching(float deltaTime) {
|
|||
}
|
||||
|
||||
if (_interactingOther) {
|
||||
_avatarTouch.setYourHandPosition(_interactingOther->_position);
|
||||
_avatarTouch.setYourBodyPosition(_interactingOther->_position);
|
||||
_avatarTouch.setYourHandPosition(_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].springyPosition);
|
||||
}
|
||||
|
||||
}//if (_isMine)
|
||||
|
@ -486,10 +484,14 @@ void Avatar::updateHandMovementAndTouching(float deltaTime) {
|
|||
//Set the vector we send for hand position to other people to be our right hand
|
||||
setHandPosition(_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position);
|
||||
_handState = _mousePressed;
|
||||
|
||||
_avatarTouch.setMyHandState(_handState);
|
||||
|
||||
if (_handState == 1) {
|
||||
_avatarTouch.setMyHandPosition(_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].springyPosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Avatar::updateHead(float deltaTime) {
|
||||
|
|
|
@ -61,23 +61,12 @@ void AvatarTouch::setReachableRadius( float r ) {
|
|||
|
||||
void AvatarTouch::render() {
|
||||
|
||||
if (_canReachToOtherAvatar) {
|
||||
if (_canReachToOtherAvatar) {
|
||||
glPushMatrix();
|
||||
glTranslatef(_myBodyPosition.x, _myBodyPosition.y, _myBodyPosition.z);
|
||||
glTranslatef(_yourBodyPosition.x, _yourBodyPosition.y, _yourBodyPosition.z);
|
||||
glColor4f( 0.3, 0.4, 0.5, 0.3 ); glutSolidSphere( _reachableRadius, 30.0f, 30.0f );
|
||||
glPopMatrix();
|
||||
|
||||
/*
|
||||
// if my hand is grasping, show it...
|
||||
if ( _myHandState == 1 ) {
|
||||
glPushMatrix();
|
||||
glTranslatef(_myHandPosition.x, _myHandPosition.y, _myHandPosition.z);
|
||||
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();
|
||||
}
|
||||
|
||||
// if your hand is grasping, show it...
|
||||
if ( _yourHandState == 1 ) {
|
||||
glPushMatrix();
|
||||
|
@ -87,7 +76,16 @@ if (_canReachToOtherAvatar) {
|
|||
glColor4f( 1.0, 1.0, 0.2, 0.1 ); glutSolidSphere( 0.030f, 10.0f, 10.0f );
|
||||
glPopMatrix();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
// if my hand is grasping, show it...
|
||||
if ( _myHandState == 1 ) {
|
||||
glPushMatrix();
|
||||
glTranslatef(_myHandPosition.x, _myHandPosition.y, _myHandPosition.z);
|
||||
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();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -123,7 +121,7 @@ void AvatarTouch::simulate (float deltaTime) {
|
|||
|
||||
float distance = glm::length(v);
|
||||
|
||||
if (distance < _reachableRadius * 2.0f ) {
|
||||
if (distance < _reachableRadius * 2.3f ) {
|
||||
_canReachToOtherAvatar = true;
|
||||
} else {
|
||||
_canReachToOtherAvatar = false;
|
||||
|
|
|
@ -25,12 +25,11 @@ public:
|
|||
void setYourHandPosition(glm::vec3 position);
|
||||
void setMyBodyPosition (glm::vec3 position);
|
||||
void setYourBodyPosition(glm::vec3 position);
|
||||
void setMyHandState (int state );
|
||||
void setYourHandState (int state );
|
||||
void setMyHandState (int state);
|
||||
void setYourHandState (int state);
|
||||
void setReachableRadius (float r);
|
||||
|
||||
void setAbleToReachOtherAvatar (bool a) { _canReachToOtherAvatar = a;}
|
||||
void setHandsCloseEnoughToGrasp(bool h) { _handsCloseEnoughToGrasp = h;}
|
||||
void setAbleToReachOtherAvatar (bool a) {_canReachToOtherAvatar = a;}
|
||||
void setHandsCloseEnoughToGrasp(bool h) {_handsCloseEnoughToGrasp = h;}
|
||||
|
||||
bool getAbleToReachOtherAvatar () {return _canReachToOtherAvatar;}
|
||||
bool getHandsCloseEnoughToGrasp() {return _handsCloseEnoughToGrasp;}
|
||||
|
|
|
@ -1671,11 +1671,14 @@ void idle(void) {
|
|||
myAvatar.setHandMovementValues( handControl.getValues() );
|
||||
|
||||
// tell my avatar if the mouse is being pressed...
|
||||
myAvatar.setMousePressed(mousePressed);
|
||||
/*
|
||||
if ( mousePressed == 1 ) {
|
||||
myAvatar.setMousePressed( true );
|
||||
} else {
|
||||
myAvatar.setMousePressed( false );
|
||||
myAvatar.setMousePressed( false );
|
||||
}
|
||||
*/
|
||||
|
||||
// walking triggers the handControl to stop
|
||||
if ( myAvatar.getMode() == AVATAR_MODE_WALKING ) {
|
||||
|
|
Loading…
Reference in a new issue