mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 14:03:55 +02:00
fixed merge problem
This commit is contained in:
parent
1e6ba9cc34
commit
35a8066bd6
4 changed files with 134 additions and 104 deletions
|
@ -20,11 +20,15 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
/*
|
||||
const bool BALLS_ON = false;
|
||||
|
||||
const bool AVATAR_GRAVITY = true;
|
||||
const float DECAY = 0.1;
|
||||
const float THRUST_MAG = 1200.0;
|
||||
|
||||
//const float THRUST_MAG = 1200.0;
|
||||
const float THRUST_MAG = 0.0;
|
||||
|
||||
const float YAW_MAG = 500.0; //JJV - changed from 300.0;
|
||||
const float TEST_YAW_DECAY = 5.0;
|
||||
const float LIN_VEL_DECAY = 5.0;
|
||||
|
@ -37,7 +41,8 @@ const float COLLISION_BALL_FORCE = 0.6;
|
|||
const float COLLISION_BODY_FORCE = 6.0;
|
||||
const float COLLISION_BALL_FRICTION = 200.0;
|
||||
const float COLLISION_BODY_FRICTION = 0.5;
|
||||
|
||||
*/
|
||||
|
||||
float skinColor[] = {1.0, 0.84, 0.66};
|
||||
float lightBlue[] = { 0.7, 0.8, 1.0 };
|
||||
float browColor[] = {210.0/255.0, 105.0/255.0, 30.0/255.0};
|
||||
|
@ -135,7 +140,7 @@ Avatar::Avatar(bool isMine) {
|
|||
_renderPitch = 0.0;
|
||||
_sphere = NULL;
|
||||
_interactingOther = NULL;
|
||||
_canReachToOtherAvatar = false;
|
||||
//_canReachToOtherAvatar = false;
|
||||
_handHoldingPosition = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
|
||||
initializeSkeleton();
|
||||
|
@ -157,7 +162,7 @@ Avatar::Avatar(const Avatar &otherAvatar) {
|
|||
_velocity = otherAvatar._velocity;
|
||||
_thrust = otherAvatar._thrust;
|
||||
_rotation = otherAvatar._rotation;
|
||||
_canReachToOtherAvatar = otherAvatar._canReachToOtherAvatar;
|
||||
//_canReachToOtherAvatar = otherAvatar._canReachToOtherAvatar;
|
||||
_bodyYaw = otherAvatar._bodyYaw;
|
||||
_bodyPitch = otherAvatar._bodyPitch;
|
||||
_bodyRoll = otherAvatar._bodyRoll;
|
||||
|
@ -316,6 +321,11 @@ void Avatar::setMousePressed( bool d ) {
|
|||
}
|
||||
|
||||
|
||||
bool Avatar::getIsNearInteractingOther() {
|
||||
return _avatarTouch.getAbleToReachOtherAvatar();
|
||||
}
|
||||
|
||||
|
||||
void Avatar::simulate(float deltaTime) {
|
||||
|
||||
//keep this - I'm still using it to test things....
|
||||
|
@ -336,13 +346,14 @@ _head.leanForward = 0.02 * sin( tt * 0.8 );
|
|||
// reset hand and arm positions according to hand movement
|
||||
updateHandMovement( deltaTime );
|
||||
|
||||
if ( !_canReachToOtherAvatar ) {
|
||||
if ( !_avatarTouch.getAbleToReachOtherAvatar() ) {
|
||||
//initialize _handHolding
|
||||
_handHoldingPosition = _bone[ AVATAR_BONE_RIGHT_HAND ].position;
|
||||
}
|
||||
|
||||
_handsCloseEnoughToGrasp = false; // reset for the next go-round
|
||||
_canReachToOtherAvatar = false; // reset for the next go-round
|
||||
//reset these for the next go-round
|
||||
_avatarTouch.setAbleToReachOtherAvatar (false);
|
||||
_avatarTouch.setHandsCloseEnoughToGrasp(false);
|
||||
|
||||
// if the avatar being simulated is mine, then loop through
|
||||
// all the other avatars for potential interactions...
|
||||
|
@ -364,21 +375,23 @@ _head.leanForward = 0.02 * sin( tt * 0.8 );
|
|||
if ( distance < _maxArmLength + _maxArmLength ) {
|
||||
|
||||
_interactingOther = otherAvatar;
|
||||
_canReachToOtherAvatar = true;
|
||||
_avatarTouch.setAbleToReachOtherAvatar(true);
|
||||
|
||||
glm::vec3 vectorBetweenHands( _bone[ AVATAR_BONE_RIGHT_HAND ].position );
|
||||
vectorBetweenHands -= otherAvatar->getBonePosition( AVATAR_BONE_RIGHT_HAND );
|
||||
float distanceBetweenHands = glm::length(vectorBetweenHands);
|
||||
|
||||
if (distanceBetweenHands < _avatarTouch.HANDS_CLOSE_ENOUGH_TO_GRASP) {
|
||||
_avatarTouch.setHandsCloseEnoughToGrasp(true);
|
||||
}
|
||||
|
||||
// if I am holding hands with another avatar, a force is applied
|
||||
if (( _handState == 1 ) || ( _interactingOther->_handState == 1 )) {
|
||||
|
||||
glm::vec3 vectorBetweenHands( _bone[ AVATAR_BONE_RIGHT_HAND ].position );
|
||||
vectorBetweenHands -= otherAvatar->getBonePosition( AVATAR_BONE_RIGHT_HAND );
|
||||
|
||||
float distanceBetweenHands = glm::length(vectorBetweenHands);
|
||||
|
||||
// if the hands are close enough to grasp...
|
||||
if (distanceBetweenHands < 0.1)
|
||||
if (distanceBetweenHands < _avatarTouch.HANDS_CLOSE_ENOUGH_TO_GRASP)
|
||||
{
|
||||
_handsCloseEnoughToGrasp = true;
|
||||
|
||||
// apply the forces...
|
||||
glm::vec3 vectorToOtherHand = _interactingOther->_handPosition - _handHoldingPosition;
|
||||
glm::vec3 vectorToMyHand = _bone[ AVATAR_BONE_RIGHT_HAND ].position - _handHoldingPosition;
|
||||
|
||||
|
@ -386,6 +399,7 @@ _head.leanForward = 0.02 * sin( tt * 0.8 );
|
|||
_handHoldingPosition += vectorToMyHand * MY_HAND_HOLDING_PULL;
|
||||
_bone[ AVATAR_BONE_RIGHT_HAND ].position = _handHoldingPosition;
|
||||
|
||||
// apply a force to the avatar body
|
||||
if ( glm::length(vectorToOtherHand) > _maxArmLength * 0.9 ) {
|
||||
_velocity += vectorToOtherHand;
|
||||
}
|
||||
|
@ -404,18 +418,17 @@ _head.leanForward = 0.02 * sin( tt * 0.8 );
|
|||
updateArmIKAndConstraints( deltaTime );
|
||||
|
||||
// set hand positions for _avatarTouch.setMyHandPosition AFTER calling updateArmIKAndConstraints
|
||||
//if ( _interactingOther != NULL ) {
|
||||
if ( _interactingOther ) { // Brad recommended I use this method pof checking that a pointer is valid
|
||||
if ( _interactingOther ) {
|
||||
if (_isMine) {
|
||||
_avatarTouch.setMyHandPosition ( _bone[ AVATAR_BONE_RIGHT_HAND ].position );
|
||||
_avatarTouch.setYourHandPosition( _interactingOther->_handPosition );
|
||||
_avatarTouch.setYourHandPosition( _interactingOther->_bone[ AVATAR_BONE_RIGHT_HAND ].position );
|
||||
_avatarTouch.setMyHandState ( _handState );
|
||||
_avatarTouch.setYourHandState ( _interactingOther->_handState );
|
||||
_avatarTouch.simulate(deltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
if (!_canReachToOtherAvatar) {
|
||||
if (!_avatarTouch.getAbleToReachOtherAvatar() ) {
|
||||
_interactingOther = NULL;
|
||||
}
|
||||
|
||||
|
@ -720,7 +733,6 @@ void Avatar::render(bool lookingInMirror) {
|
|||
*/
|
||||
|
||||
if ( usingBigSphereCollisionTest ) {
|
||||
|
||||
// show TEST big sphere
|
||||
glColor4f( 0.5f, 0.6f, 0.8f, 0.7 );
|
||||
glPushMatrix();
|
||||
|
@ -730,7 +742,7 @@ void Avatar::render(bool lookingInMirror) {
|
|||
glPopMatrix();
|
||||
}
|
||||
|
||||
// render body
|
||||
//render body
|
||||
renderBody();
|
||||
|
||||
// render head
|
||||
|
@ -739,12 +751,11 @@ void Avatar::render(bool lookingInMirror) {
|
|||
}
|
||||
|
||||
// if this is my avatar, then render my interactions with the other avatar
|
||||
if (( _isMine ) && ( _handsCloseEnoughToGrasp )) {
|
||||
if ( _isMine ) {
|
||||
_avatarTouch.render();
|
||||
}
|
||||
|
||||
// Render the balls
|
||||
|
||||
if (_balls) {
|
||||
glPushMatrix();
|
||||
glTranslatef(_position.x, _position.y, _position.z);
|
||||
|
@ -1145,7 +1156,7 @@ void Avatar::updateSkeleton() {
|
|||
_bone[ AVATAR_BONE_RIGHT_HAND ].position = _handPosition;
|
||||
}
|
||||
|
||||
// the following will be replaced by a proper rotation...
|
||||
// the following will be replaced by a proper rotation...close
|
||||
float xx = glm::dot( _bone[b].defaultPosePosition, _bone[b].orientation.getRight() );
|
||||
float yy = glm::dot( _bone[b].defaultPosePosition, _bone[b].orientation.getUp () );
|
||||
float zz = glm::dot( _bone[b].defaultPosePosition, _bone[b].orientation.getFront() );
|
||||
|
|
|
@ -92,8 +92,8 @@ public:
|
|||
float getBodyYaw() {return _bodyYaw;};
|
||||
void addBodyYaw(float y) {_bodyYaw += y;};
|
||||
|
||||
bool getIsNearInteractingOther() { return _canReachToOtherAvatar; }
|
||||
|
||||
bool getIsNearInteractingOther();
|
||||
|
||||
float getAbsoluteHeadYaw() const;
|
||||
void setLeanForward(float dist);
|
||||
void setLeanSideways(float dist);
|
||||
|
@ -144,6 +144,7 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
const bool BALLS_ON = false;
|
||||
const bool AVATAR_GRAVITY = true;
|
||||
const float DECAY = 0.1;
|
||||
const float THRUST_MAG = 1200.0;
|
||||
|
@ -226,46 +227,43 @@ private:
|
|||
float returnSpringScale;
|
||||
};
|
||||
|
||||
AvatarHead _head;
|
||||
bool _isMine;
|
||||
glm::vec3 _TEST_bigSpherePosition;
|
||||
float _TEST_bigSphereRadius;
|
||||
bool _mousePressed;
|
||||
float _bodyPitchDelta;
|
||||
float _bodyYawDelta;
|
||||
float _bodyRollDelta;
|
||||
bool _usingBodySprings;
|
||||
glm::vec3 _movedHandOffset;
|
||||
glm::quat _rotation; // the rotation of the avatar body as a whole expressed as a quaternion
|
||||
AvatarBone _bone[ NUM_AVATAR_BONES ];
|
||||
AvatarMode _mode;
|
||||
glm::vec3 _handHoldingPosition;
|
||||
glm::vec3 _velocity;
|
||||
glm::vec3 _thrust;
|
||||
float _speed;
|
||||
float _maxArmLength;
|
||||
Orientation _orientation;
|
||||
int _driveKeys[MAX_DRIVE_KEYS];
|
||||
GLUquadric* _sphere;
|
||||
float _renderYaw;
|
||||
float _renderPitch; // Pitch from view frustum when this is own head
|
||||
bool _transmitterIsFirstData;
|
||||
timeval _transmitterTimeLastReceived;
|
||||
timeval _transmitterTimer;
|
||||
float _transmitterHz;
|
||||
int _transmitterPackets;
|
||||
glm::vec3 _transmitterInitialReading;
|
||||
Avatar* _interactingOther;
|
||||
bool _canReachToOtherAvatar;
|
||||
bool _handsCloseEnoughToGrasp;
|
||||
float _pelvisStandingHeight;
|
||||
float _height;
|
||||
Balls* _balls;
|
||||
AvatarTouch _avatarTouch;
|
||||
bool _displayingHead; // should be false if in first-person view
|
||||
bool _returnHeadToCenter;
|
||||
AvatarHead _head;
|
||||
bool _isMine;
|
||||
glm::vec3 _TEST_bigSpherePosition;
|
||||
float _TEST_bigSphereRadius;
|
||||
bool _mousePressed;
|
||||
float _bodyPitchDelta;
|
||||
float _bodyYawDelta;
|
||||
float _bodyRollDelta;
|
||||
bool _usingBodySprings;
|
||||
glm::vec3 _movedHandOffset;
|
||||
glm::quat _rotation; // the rotation of the avatar body as a whole expressed as a quaternion
|
||||
AvatarBone _bone[ NUM_AVATAR_BONES ];
|
||||
AvatarMode _mode;
|
||||
glm::vec3 _handHoldingPosition;
|
||||
glm::vec3 _velocity;
|
||||
glm::vec3 _thrust;
|
||||
float _speed;
|
||||
float _maxArmLength;
|
||||
Orientation _orientation;
|
||||
int _driveKeys[MAX_DRIVE_KEYS];
|
||||
GLUquadric* _sphere;
|
||||
float _renderYaw;
|
||||
float _renderPitch; // Pitch from view frustum when this is own head
|
||||
bool _transmitterIsFirstData;
|
||||
timeval _transmitterTimeLastReceived;
|
||||
timeval _transmitterTimer;
|
||||
float _transmitterHz;
|
||||
int _transmitterPackets;
|
||||
glm::vec3 _transmitterInitialReading;
|
||||
Avatar* _interactingOther;
|
||||
float _pelvisStandingHeight;
|
||||
float _height;
|
||||
Balls* _balls;
|
||||
AvatarTouch _avatarTouch;
|
||||
bool _displayingHead; // should be false if in first-person view
|
||||
bool _returnHeadToCenter;
|
||||
|
||||
|
||||
// private methods...
|
||||
void initializeSkeleton();
|
||||
void updateSkeleton();
|
||||
|
|
|
@ -11,15 +11,18 @@
|
|||
#include "AvatarTouch.h"
|
||||
#include "InterfaceConfig.h"
|
||||
|
||||
const float THREAD_RADIUS = 0.007;
|
||||
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 );
|
||||
_myHandState = 0;
|
||||
_yourHandState = 0;
|
||||
_yourHandState = 0;
|
||||
|
||||
_canReachToOtherAvatar = false;
|
||||
_handsCloseEnoughToGrasp = false;
|
||||
|
||||
for (int p=0; p<NUM_POINTS; p++) {
|
||||
_point[p] = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
}
|
||||
|
@ -45,43 +48,49 @@ void AvatarTouch::render() {
|
|||
|
||||
glm::vec3 v1( _myHandPosition );
|
||||
glm::vec3 v2( _yourHandPosition );
|
||||
|
||||
if (_canReachToOtherAvatar) {
|
||||
// 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();
|
||||
glTranslatef(_yourHandPosition.x, _yourHandPosition.y, _yourHandPosition.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 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();
|
||||
glTranslatef(_yourHandPosition.x, _yourHandPosition.y, _yourHandPosition.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();
|
||||
}
|
||||
|
||||
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);
|
||||
//show beam
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AvatarTouch::simulate (float deltaTime) {
|
||||
|
||||
glm::vec3 v = _yourHandPosition - _myHandPosition;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
// interface
|
||||
//
|
||||
// Created by Jeffrey Ventrella
|
||||
// Copyright (c) 2012 High Fidelity, Inc. All rights reserved.
|
||||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef __interface__AvatarTouch__
|
||||
|
@ -13,15 +13,25 @@
|
|||
|
||||
class AvatarTouch {
|
||||
public:
|
||||
|
||||
const float HANDS_CLOSE_ENOUGH_TO_GRASP = 0.1;
|
||||
|
||||
AvatarTouch();
|
||||
|
||||
void simulate(float deltaTime);
|
||||
void render();
|
||||
|
||||
void setMyHandPosition ( glm::vec3 position );
|
||||
void setYourHandPosition( glm::vec3 position );
|
||||
void setMyHandState ( int state );
|
||||
void setYourHandState ( int state );
|
||||
void simulate (float deltaTime);
|
||||
void render();
|
||||
|
||||
void setAbleToReachOtherAvatar ( bool a ) { _canReachToOtherAvatar = a; }
|
||||
void setHandsCloseEnoughToGrasp( bool h ) { _handsCloseEnoughToGrasp = h; }
|
||||
|
||||
bool getAbleToReachOtherAvatar () { return _canReachToOtherAvatar; }
|
||||
bool getHandsCloseEnoughToGrasp() { return _handsCloseEnoughToGrasp; }
|
||||
|
||||
private:
|
||||
|
||||
static const int NUM_POINTS = 100;
|
||||
|
@ -31,6 +41,8 @@ private:
|
|||
glm::vec3 _yourHandPosition;
|
||||
int _myHandState;
|
||||
int _yourHandState;
|
||||
bool _canReachToOtherAvatar;
|
||||
bool _handsCloseEnoughToGrasp;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue