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