mirror of
https://github.com/overte-org/overte.git
synced 2025-04-26 07:16:25 +02:00
Merge pull request #1339 from PhilipRosedale/remove_avatar_touch
Removed _avatarTouch class
This commit is contained in:
commit
65c21105ae
7 changed files with 11 additions and 137 deletions
|
@ -370,6 +370,7 @@ void Application::paintGL() {
|
||||||
_myCamera.setTargetRotation(_myAvatar.getHead().getCameraOrientation());
|
_myCamera.setTargetRotation(_myAvatar.getHead().getCameraOrientation());
|
||||||
|
|
||||||
} else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
|
} else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
|
||||||
|
_myCamera.setTightness (0.0f); // Camera is directly connected to head without smoothing
|
||||||
_myCamera.setTargetPosition(_myAvatar.getUprightHeadPosition());
|
_myCamera.setTargetPosition(_myAvatar.getUprightHeadPosition());
|
||||||
_myCamera.setTargetRotation(_myAvatar.getHead().getCameraOrientation());
|
_myCamera.setTargetRotation(_myAvatar.getHead().getCameraOrientation());
|
||||||
|
|
||||||
|
|
|
@ -519,33 +519,6 @@ void renderNudgeGuide(float voxelX, float voxelY, float voxelZ, float voxelS) {
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
void renderDiskShadow(glm::vec3 position, glm::vec3 upDirection, float radius, float darkness) {
|
|
||||||
|
|
||||||
glColor4f(0.0f, 0.0f, 0.0f, darkness);
|
|
||||||
|
|
||||||
int num = 20;
|
|
||||||
float y = 0.001f;
|
|
||||||
float x2 = 0.0f;
|
|
||||||
float z2 = radius;
|
|
||||||
float x1;
|
|
||||||
float z1;
|
|
||||||
|
|
||||||
glBegin(GL_TRIANGLES);
|
|
||||||
|
|
||||||
for (int i=1; i<num+1; i++) {
|
|
||||||
x1 = x2;
|
|
||||||
z1 = z2;
|
|
||||||
float r = ((float)i / (float)num) * PIf * 2.0;
|
|
||||||
x2 = radius * sin(r);
|
|
||||||
z2 = radius * cos(r);
|
|
||||||
|
|
||||||
glVertex3f(position.x, y, position.z );
|
|
||||||
glVertex3f(position.x + x1, y, position.z + z1);
|
|
||||||
glVertex3f(position.x + x2, y, position.z + z2);
|
|
||||||
}
|
|
||||||
|
|
||||||
glEnd();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -77,8 +77,6 @@ void renderNudgeGuide(float voxelX, float voxelY, float voxelZ, float voxelS);
|
||||||
|
|
||||||
void renderCollisionOverlay(int width, int height, float magnitude);
|
void renderCollisionOverlay(int width, int height, float magnitude);
|
||||||
|
|
||||||
void renderDiskShadow(glm::vec3 position, glm::vec3 upDirection, float radius, float darkness);
|
|
||||||
|
|
||||||
void renderOrientationDirections( glm::vec3 position, const glm::quat& orientation, float size );
|
void renderOrientationDirections( glm::vec3 position, const glm::quat& orientation, float size );
|
||||||
|
|
||||||
void renderSphereOutline(glm::vec3 position, float radius, int numSides, glm::vec3 cameraPosition);
|
void renderSphereOutline(glm::vec3 position, float radius, int numSides, glm::vec3 cameraPosition);
|
||||||
|
|
|
@ -48,7 +48,6 @@ const float HEAD_MAX_PITCH = 45;
|
||||||
const float HEAD_MIN_PITCH = -45;
|
const float HEAD_MIN_PITCH = -45;
|
||||||
const float HEAD_MAX_YAW = 85;
|
const float HEAD_MAX_YAW = 85;
|
||||||
const float HEAD_MIN_YAW = -85;
|
const float HEAD_MIN_YAW = -85;
|
||||||
const float PERIPERSONAL_RADIUS = 1.0f;
|
|
||||||
const float AVATAR_BRAKING_STRENGTH = 40.0f;
|
const float AVATAR_BRAKING_STRENGTH = 40.0f;
|
||||||
const float MOUSE_RAY_TOUCH_RANGE = 0.01f;
|
const float MOUSE_RAY_TOUCH_RANGE = 0.01f;
|
||||||
const float FLOATING_HEIGHT = 0.13f;
|
const float FLOATING_HEIGHT = 0.13f;
|
||||||
|
@ -122,8 +121,6 @@ Avatar::Avatar(Node* owningNode) :
|
||||||
_pelvisFloatingHeight = _skeleton.getPelvisFloatingHeight() + _bodyBall[BODY_BALL_LEFT_HEEL].radius;
|
_pelvisFloatingHeight = _skeleton.getPelvisFloatingHeight() + _bodyBall[BODY_BALL_LEFT_HEEL].radius;
|
||||||
_pelvisToHeadLength = _skeleton.getPelvisToHeadLength();
|
_pelvisToHeadLength = _skeleton.getPelvisToHeadLength();
|
||||||
|
|
||||||
_avatarTouch.setReachableRadius(PERIPERSONAL_RADIUS);
|
|
||||||
|
|
||||||
if (BALLS_ON) {
|
if (BALLS_ON) {
|
||||||
_balls = new Balls(100);
|
_balls = new Balls(100);
|
||||||
} else {
|
} else {
|
||||||
|
@ -362,7 +359,6 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
||||||
|
|
||||||
//update the movement of the hand and process handshaking with other avatars...
|
//update the movement of the hand and process handshaking with other avatars...
|
||||||
updateHandMovementAndTouching(deltaTime, enableHandMovement);
|
updateHandMovementAndTouching(deltaTime, enableHandMovement);
|
||||||
_avatarTouch.simulate(deltaTime);
|
|
||||||
|
|
||||||
// update body balls
|
// update body balls
|
||||||
updateBodyBalls(deltaTime);
|
updateBodyBalls(deltaTime);
|
||||||
|
@ -444,9 +440,6 @@ static TextRenderer* textRenderer() {
|
||||||
|
|
||||||
void Avatar::render(bool forceRenderHead) {
|
void Avatar::render(bool forceRenderHead) {
|
||||||
|
|
||||||
// render a simple round on the ground projected down from the avatar's position
|
|
||||||
renderDiskShadow(_position, glm::vec3(0.0f, 1.0f, 0.0f), _scale * 0.1f, 0.2f);
|
|
||||||
|
|
||||||
{
|
{
|
||||||
// glow when moving in the distance
|
// glow when moving in the distance
|
||||||
glm::vec3 toTarget = _position - Application::getInstance()->getAvatar()->getPosition();
|
glm::vec3 toTarget = _position - Application::getInstance()->getAvatar()->getPosition();
|
||||||
|
@ -960,6 +953,5 @@ void Avatar::setScale(const float scale) {
|
||||||
_pelvisStandingHeight = _skeleton.getPelvisStandingHeight() + _bodyBall[BODY_BALL_LEFT_HEEL].radius;
|
_pelvisStandingHeight = _skeleton.getPelvisStandingHeight() + _bodyBall[BODY_BALL_LEFT_HEEL].radius;
|
||||||
_pelvisFloatingHeight = _skeleton.getPelvisFloatingHeight() + _bodyBall[BODY_BALL_LEFT_HEEL].radius;
|
_pelvisFloatingHeight = _skeleton.getPelvisFloatingHeight() + _bodyBall[BODY_BALL_LEFT_HEEL].radius;
|
||||||
_pelvisToHeadLength = _skeleton.getPelvisToHeadLength();
|
_pelvisToHeadLength = _skeleton.getPelvisToHeadLength();
|
||||||
_avatarTouch.setReachableRadius(_scale * PERIPERSONAL_RADIUS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
|
|
||||||
#include <AvatarData.h>
|
#include <AvatarData.h>
|
||||||
|
|
||||||
#include "AvatarTouch.h"
|
|
||||||
#include "AvatarVoxelSystem.h"
|
#include "AvatarVoxelSystem.h"
|
||||||
#include "Balls.h"
|
#include "Balls.h"
|
||||||
#include "Hand.h"
|
#include "Hand.h"
|
||||||
|
@ -229,7 +228,6 @@ protected:
|
||||||
float _scale;
|
float _scale;
|
||||||
float _height;
|
float _height;
|
||||||
Balls* _balls;
|
Balls* _balls;
|
||||||
AvatarTouch _avatarTouch;
|
|
||||||
glm::vec3 _worldUpDirection;
|
glm::vec3 _worldUpDirection;
|
||||||
glm::vec3 _mouseRayOrigin;
|
glm::vec3 _mouseRayOrigin;
|
||||||
glm::vec3 _mouseRayDirection;
|
glm::vec3 _mouseRayDirection;
|
||||||
|
|
|
@ -32,7 +32,6 @@ const float COLLISION_RADIUS_SCALAR = 1.2; // pertains to avatar-to-avatar colli
|
||||||
const float COLLISION_BALL_FORCE = 200.0; // pertains to avatar-to-avatar collisions
|
const float COLLISION_BALL_FORCE = 200.0; // pertains to avatar-to-avatar collisions
|
||||||
const float COLLISION_BODY_FORCE = 30.0; // pertains to avatar-to-avatar collisions
|
const float COLLISION_BODY_FORCE = 30.0; // pertains to avatar-to-avatar collisions
|
||||||
const float COLLISION_RADIUS_SCALE = 0.125f;
|
const float COLLISION_RADIUS_SCALE = 0.125f;
|
||||||
const float PERIPERSONAL_RADIUS = 1.0f;
|
|
||||||
const float MOUSE_RAY_TOUCH_RANGE = 0.01f;
|
const float MOUSE_RAY_TOUCH_RANGE = 0.01f;
|
||||||
const bool USING_HEAD_LEAN = false;
|
const bool USING_HEAD_LEAN = false;
|
||||||
const float SKIN_COLOR[] = {1.0, 0.84, 0.66};
|
const float SKIN_COLOR[] = {1.0, 0.84, 0.66};
|
||||||
|
@ -46,7 +45,6 @@ MyAvatar::MyAvatar(Node* owningNode) :
|
||||||
_shouldJump(false),
|
_shouldJump(false),
|
||||||
_gravity(0.0f, -1.0f, 0.0f),
|
_gravity(0.0f, -1.0f, 0.0f),
|
||||||
_distanceToNearestAvatar(std::numeric_limits<float>::max()),
|
_distanceToNearestAvatar(std::numeric_limits<float>::max()),
|
||||||
_interactingOther(NULL),
|
|
||||||
_elapsedTimeMoving(0.0f),
|
_elapsedTimeMoving(0.0f),
|
||||||
_elapsedTimeStopped(0.0f),
|
_elapsedTimeStopped(0.0f),
|
||||||
_elapsedTimeSinceCollision(0.0f),
|
_elapsedTimeSinceCollision(0.0f),
|
||||||
|
@ -166,7 +164,6 @@ void MyAvatar::simulate(float deltaTime, Transmitter* transmitter) {
|
||||||
|
|
||||||
// update the movement of the hand and process handshaking with other avatars...
|
// update the movement of the hand and process handshaking with other avatars...
|
||||||
updateHandMovementAndTouching(deltaTime, enableHandMovement);
|
updateHandMovementAndTouching(deltaTime, enableHandMovement);
|
||||||
_avatarTouch.simulate(deltaTime);
|
|
||||||
|
|
||||||
// apply gravity
|
// apply gravity
|
||||||
// For gravity, always move the avatar by the amount driven by gravity, so that the collision
|
// For gravity, always move the avatar by the amount driven by gravity, so that the collision
|
||||||
|
@ -499,15 +496,9 @@ static TextRenderer* textRenderer() {
|
||||||
|
|
||||||
void MyAvatar::render(bool forceRenderHead) {
|
void MyAvatar::render(bool forceRenderHead) {
|
||||||
|
|
||||||
// render a simple round on the ground projected down from the avatar's position
|
|
||||||
renderDiskShadow(_position, glm::vec3(0.0f, 1.0f, 0.0f), _scale * 0.1f, 0.2f);
|
|
||||||
|
|
||||||
// render body
|
// render body
|
||||||
renderBody(forceRenderHead);
|
renderBody(forceRenderHead);
|
||||||
|
|
||||||
// if this is my avatar, then render my interactions with the other avatar
|
|
||||||
_avatarTouch.render(Application::getInstance()->getCamera()->getPosition());
|
|
||||||
|
|
||||||
// Render the balls
|
// Render the balls
|
||||||
if (_balls) {
|
if (_balls) {
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
@ -882,90 +873,6 @@ void MyAvatar::updateHandMovementAndTouching(float deltaTime, bool enableHandMov
|
||||||
pointing = true;
|
pointing = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
_avatarTouch.setMyBodyPosition(_position);
|
|
||||||
_avatarTouch.setMyOrientation(orientation);
|
|
||||||
|
|
||||||
float closestDistance = std::numeric_limits<float>::max();
|
|
||||||
|
|
||||||
_interactingOther = NULL;
|
|
||||||
|
|
||||||
//loop through all the other avatars for potential interactions...
|
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
|
||||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
|
||||||
if (node->getLinkedData() && node->getType() == NODE_TYPE_AGENT) {
|
|
||||||
Avatar *otherAvatar = (Avatar *)node->getLinkedData();
|
|
||||||
|
|
||||||
// test whether shoulders are close enough to allow for reaching to touch hands
|
|
||||||
glm::vec3 v(_position - otherAvatar->_position);
|
|
||||||
float distance = glm::length(v);
|
|
||||||
if (distance < closestDistance) {
|
|
||||||
closestDistance = distance;
|
|
||||||
|
|
||||||
if (distance < _scale * PERIPERSONAL_RADIUS) {
|
|
||||||
_interactingOther = otherAvatar;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_interactingOther) {
|
|
||||||
|
|
||||||
_avatarTouch.setHasInteractingOther(true);
|
|
||||||
_avatarTouch.setYourBodyPosition(_interactingOther->_position);
|
|
||||||
_avatarTouch.setYourHandPosition(_interactingOther->_bodyBall[ BODY_BALL_RIGHT_FINGERTIPS ].position);
|
|
||||||
_avatarTouch.setYourOrientation (_interactingOther->getOrientation());
|
|
||||||
_avatarTouch.setYourHandState(_interactingOther->_handState);
|
|
||||||
|
|
||||||
//if hand-holding is initiated by either avatar, turn on hand-holding...
|
|
||||||
if (_avatarTouch.getHandsCloseEnoughToGrasp()) {
|
|
||||||
if ((_handState == HAND_STATE_GRASPING ) || (_interactingOther->_handState == HAND_STATE_GRASPING)) {
|
|
||||||
if (!_avatarTouch.getHoldingHands())
|
|
||||||
{
|
|
||||||
_avatarTouch.setHoldingHands(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
glm::vec3 vectorFromMyHandToYourHand
|
|
||||||
(
|
|
||||||
_interactingOther->_skeleton.joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position -
|
|
||||||
_skeleton.joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position
|
|
||||||
);
|
|
||||||
|
|
||||||
float distanceBetweenOurHands = glm::length(vectorFromMyHandToYourHand);
|
|
||||||
|
|
||||||
// if neither of us are grasping, turn off hand-holding
|
|
||||||
if ((_handState != HAND_STATE_GRASPING ) && (_interactingOther->_handState != HAND_STATE_GRASPING)) {
|
|
||||||
_avatarTouch.setHoldingHands(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
//if holding hands, apply the appropriate forces
|
|
||||||
if (_avatarTouch.getHoldingHands()) {
|
|
||||||
_skeleton.joint[AVATAR_JOINT_RIGHT_FINGERTIPS ].position +=
|
|
||||||
(_interactingOther->_skeleton.joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position
|
|
||||||
- _skeleton.joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position) * 0.5f;
|
|
||||||
|
|
||||||
const float MAX_FORCE = 1.0f;
|
|
||||||
const float FORCE_RATIO = 10.0f;
|
|
||||||
|
|
||||||
if (distanceBetweenOurHands > 0.3) {
|
|
||||||
float force = min(MAX_FORCE, FORCE_RATIO * deltaTime);
|
|
||||||
_velocity += vectorFromMyHandToYourHand * force;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
_avatarTouch.setHasInteractingOther(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
enableHandMovement |= updateLeapHandPositions();
|
|
||||||
|
|
||||||
//constrain right arm length and re-adjust elbow position as it bends
|
|
||||||
// NOTE - the following must be called on all avatars - not just _isMine
|
|
||||||
if (enableHandMovement) {
|
|
||||||
updateArmIKAndConstraints(deltaTime, AVATAR_JOINT_RIGHT_FINGERTIPS);
|
|
||||||
updateArmIKAndConstraints(deltaTime, AVATAR_JOINT_LEFT_FINGERTIPS);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Set right hand position and state to be transmitted, and also tell AvatarTouch about it
|
//Set right hand position and state to be transmitted, and also tell AvatarTouch about it
|
||||||
setHandPosition(_skeleton.joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position);
|
setHandPosition(_skeleton.joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position);
|
||||||
|
|
||||||
|
@ -976,9 +883,6 @@ void MyAvatar::updateHandMovementAndTouching(float deltaTime, bool enableHandMov
|
||||||
} else {
|
} else {
|
||||||
_handState = HAND_STATE_NULL;
|
_handState = HAND_STATE_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
_avatarTouch.setMyHandState(_handState);
|
|
||||||
_avatarTouch.setMyHandPosition(_bodyBall[ BODY_BALL_RIGHT_FINGERTIPS ].position);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyAvatar::updateCollisionWithEnvironment(float deltaTime) {
|
void MyAvatar::updateCollisionWithEnvironment(float deltaTime) {
|
||||||
|
|
|
@ -13,6 +13,15 @@
|
||||||
|
|
||||||
#include "Avatar.h"
|
#include "Avatar.h"
|
||||||
|
|
||||||
|
enum AvatarHandState
|
||||||
|
{
|
||||||
|
HAND_STATE_NULL = 0,
|
||||||
|
HAND_STATE_OPEN,
|
||||||
|
HAND_STATE_GRASPING,
|
||||||
|
HAND_STATE_POINTING,
|
||||||
|
NUM_HAND_STATES
|
||||||
|
};
|
||||||
|
|
||||||
class MyAvatar : public Avatar {
|
class MyAvatar : public Avatar {
|
||||||
public:
|
public:
|
||||||
MyAvatar(Node* owningNode = NULL);
|
MyAvatar(Node* owningNode = NULL);
|
||||||
|
@ -67,7 +76,6 @@ private:
|
||||||
float _driveKeys[MAX_DRIVE_KEYS];
|
float _driveKeys[MAX_DRIVE_KEYS];
|
||||||
glm::vec3 _gravity;
|
glm::vec3 _gravity;
|
||||||
float _distanceToNearestAvatar; // How close is the nearest avatar?
|
float _distanceToNearestAvatar; // How close is the nearest avatar?
|
||||||
Avatar* _interactingOther;
|
|
||||||
float _elapsedTimeMoving; // Timers to drive camera transitions when moving
|
float _elapsedTimeMoving; // Timers to drive camera transitions when moving
|
||||||
float _elapsedTimeStopped;
|
float _elapsedTimeStopped;
|
||||||
float _elapsedTimeSinceCollision;
|
float _elapsedTimeSinceCollision;
|
||||||
|
|
Loading…
Reference in a new issue