mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 18:23:54 +02:00
commit
cbb5fda410
6 changed files with 118 additions and 19 deletions
22
interface/resources/images/hifi-interface-tools-v2-pie.svg
Normal file
22
interface/resources/images/hifi-interface-tools-v2-pie.svg
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 17.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
width="152px" height="152px" viewBox="0 0 152 152" enable-background="new 0 0 152 152" xml:space="preserve">
|
||||
<path fill="#333333" d="M76,13.441C41.45,13.441,13.442,41.45,13.442,76S41.45,138.558,76,138.558S138.558,110.55,138.558,76
|
||||
S110.55,13.441,76,13.441z M76,107.279c-17.275,0-31.279-14.004-31.279-31.279S58.725,44.721,76,44.721S107.279,58.725,107.279,76
|
||||
S93.275,107.279,76,107.279z"/>
|
||||
<g id="XMLID_46_">
|
||||
<g>
|
||||
<path fill="#EAEAEA" d="M41.465,38.653c0.483-0.558-1.506-5.81-0.071-6.338c1.041-0.38,0.971,1.524,1.041,2.08
|
||||
c0.102,1.143,0.346,2.528,0.727,3.567c0.346-1.663,0.312-3.36,0.381-5.056c0.034-0.521,0.173-1.697,0.865-1.629
|
||||
c1.628,0.105-0.242,5.576,0.832,6.269c0.727-0.832,0.935-2.979,1.212-4.052c0.104-0.45,0.245-1.873,1.246-1.281
|
||||
c0.763,0.451,0.138,3.291-0.103,4.19c-0.244,0.935-0.244,1.592-0.521,2.667c-0.067,0.728-0.206,1.524,0.277,2.078
|
||||
c0.867,0,2.859-2.46,3.829-1.699c0.658,0.485,0.331,1.109-0.12,1.403c-3.326,2.149-2.808,4.815-4.402,5.126
|
||||
c0,2.73-0.165,2.833,0.11,5.551c-1.731,0.287-3.542,0.216-5.199,0.106c0-0.001,0-0.001,0-0.001
|
||||
c0.113-1.432,0.067-0.342,0.173-1.931c0.079-1.235,0.103-2.339,0.139-3.551l-0.036-0.138c-1.038-0.278-1.349-2.095-1.696-3.307
|
||||
c-0.38-1.318,0.069-2.495-0.416-3.775c-0.308-0.97-1.62-3.381-0.795-4.086c0.487-0.417,0.761-0.07,1.142,0.83
|
||||
C40.392,36.408,40.549,38.549,41.465,38.653z"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.7 KiB |
|
@ -2071,6 +2071,10 @@ void Application::init() {
|
|||
_pieMenu.init("./resources/images/hifi-interface-tools-v2-pie.svg",
|
||||
_glWidget->width(),
|
||||
_glWidget->height());
|
||||
|
||||
_followMode = new QAction(this);
|
||||
connect(_followMode, SIGNAL(triggered()), this, SLOT(toggleFollowMode()));
|
||||
_pieMenu.addAction(_followMode);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2082,7 +2086,7 @@ const float HEAD_SPHERE_RADIUS = 0.07;
|
|||
static uint16_t DEFAULT_NODE_ID_REF = 1;
|
||||
|
||||
|
||||
bool Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection,
|
||||
Avatar* Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection,
|
||||
glm::vec3& eyePosition, uint16_t& nodeID = DEFAULT_NODE_ID_REF) {
|
||||
|
||||
NodeList* nodeList = NodeList::getInstance();
|
||||
|
@ -2095,11 +2099,11 @@ bool Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& m
|
|||
_lookatIndicatorScale = avatar->getScale();
|
||||
_lookatOtherPosition = headPosition;
|
||||
nodeID = avatar->getOwningNode()->getNodeID();
|
||||
return true;
|
||||
return avatar;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void Application::renderLookatIndicator(glm::vec3 pointOfInterest, Camera& whichCamera) {
|
||||
|
@ -3526,6 +3530,22 @@ void Application::goHome() {
|
|||
_myAvatar.setPosition(START_LOCATION);
|
||||
}
|
||||
|
||||
|
||||
void Application::toggleFollowMode() {
|
||||
glm::vec3 mouseRayOrigin, mouseRayDirection;
|
||||
_viewFrustum.computePickRay(_pieMenu.getX() / (float)_glWidget->width(),
|
||||
_pieMenu.getY() / (float)_glWidget->height(),
|
||||
mouseRayOrigin, mouseRayDirection);
|
||||
glm::vec3 eyePositionIgnored;
|
||||
uint16_t nodeIDIgnored;
|
||||
Avatar* leadingAvatar = isLookingAtOtherAvatar(mouseRayOrigin,
|
||||
mouseRayDirection,
|
||||
eyePositionIgnored,
|
||||
nodeIDIgnored);
|
||||
|
||||
_myAvatar.follow(leadingAvatar);
|
||||
}
|
||||
|
||||
void Application::resetSensors() {
|
||||
_headMouseX = _mouseX = _glWidget->width() / 2;
|
||||
_headMouseY = _mouseY = _glWidget->height() / 2;
|
||||
|
|
|
@ -187,6 +187,8 @@ private slots:
|
|||
glm::vec2 getScaledScreenPoint(glm::vec2 projectedPoint);
|
||||
void goHome();
|
||||
|
||||
void toggleFollowMode();
|
||||
|
||||
private:
|
||||
|
||||
static void controlledBroadcastToNodes(unsigned char* broadcastData, size_t dataBytes,
|
||||
|
@ -206,7 +208,7 @@ private:
|
|||
void init();
|
||||
|
||||
void update(float deltaTime);
|
||||
bool isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection,
|
||||
Avatar* isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection,
|
||||
glm::vec3& eyePosition, uint16_t& nodeID);
|
||||
|
||||
void renderLookatIndicator(glm::vec3 pointOfInterest, Camera& whichCamera);
|
||||
|
@ -291,6 +293,8 @@ private:
|
|||
|
||||
QAction* _simulateLeapHand; // When there's no Leap, use this to pretend there is one and feed fake hand data
|
||||
QAction* _testRaveGlove; // Test fancy sparkle-rave-glove mode
|
||||
|
||||
QAction* _followMode;
|
||||
|
||||
BandwidthMeter _bandwidthMeter;
|
||||
BandwidthDialog* _bandwidthDialog;
|
||||
|
|
|
@ -28,6 +28,8 @@ public:
|
|||
void resize(int screenWidth, int screenHeight);
|
||||
|
||||
bool isDisplayed() const {return _isDisplayed;}
|
||||
int getX () const {return _x;}
|
||||
int getY () const {return _y;}
|
||||
|
||||
void mouseMoveEvent (int x, int y);
|
||||
void mousePressEvent (int x, int y);
|
||||
|
|
|
@ -101,7 +101,8 @@ Avatar::Avatar(Node* owningNode) :
|
|||
_lastCollisionPosition(0, 0, 0),
|
||||
_speedBrakes(false),
|
||||
_isThrustOn(false),
|
||||
_voxels(this)
|
||||
_voxels(this),
|
||||
_leadingAvatar(NULL)
|
||||
{
|
||||
// give the pointer to our head to inherited _headData variable from AvatarData
|
||||
_headData = &_head;
|
||||
|
@ -404,6 +405,33 @@ void Avatar::updateThrust(float deltaTime, Transmitter * transmitter) {
|
|||
_thrust += _scale * THRUST_JUMP * up;
|
||||
_shouldJump = false;
|
||||
}
|
||||
|
||||
// Add thrusts from leading avatar
|
||||
if (_leadingAvatar != NULL) {
|
||||
glm::vec3 toTarget = _leadingAvatar->getPosition() - _position;
|
||||
|
||||
if (.5f < up.x * toTarget.x + up.y * toTarget.y + up.z * toTarget.z) {
|
||||
_thrust += _scale * THRUST_MAG_UP * deltaTime * up;
|
||||
} else if (up.x * toTarget.x + up.y * toTarget.y + up.z * toTarget.z < -.5f) {
|
||||
_thrust -= _scale * THRUST_MAG_UP * deltaTime * up;
|
||||
}
|
||||
|
||||
if (glm::length(_position - _leadingAvatar->getPosition()) > _scale * _stringLength) {
|
||||
_thrust += _scale * THRUST_MAG_FWD * deltaTime * front;
|
||||
} else {
|
||||
toTarget = _leadingAvatar->getHead().getLookAtPosition() - _position;
|
||||
getHead().setLookAtPosition(_leadingAvatar->getHead().getLookAtPosition());
|
||||
}
|
||||
|
||||
float yawAngle = angleBetween(front, glm::vec3(toTarget.x, 0.f, toTarget.z));
|
||||
if (yawAngle < -10.f || 10.f < yawAngle){
|
||||
if (right.x * toTarget.x + right.y * toTarget.y + right.z * toTarget.z > 0) {
|
||||
_bodyYawDelta -= YAW_MAG * deltaTime;
|
||||
} else {
|
||||
_bodyYawDelta += YAW_MAG * deltaTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add thrusts from Transmitter
|
||||
if (transmitter) {
|
||||
|
@ -447,6 +475,18 @@ void Avatar::updateThrust(float deltaTime, Transmitter * transmitter) {
|
|||
_isThrustOn = (glm::length(_thrust) > EPSILON);
|
||||
}
|
||||
|
||||
void Avatar::follow(Avatar* leadingAvatar) {
|
||||
const float MAX_STRING_LENGTH = 2;
|
||||
|
||||
_leadingAvatar = leadingAvatar;
|
||||
if (_leadingAvatar != NULL) {
|
||||
_stringLength = glm::length(_position - _leadingAvatar->getPosition()) / _scale;
|
||||
if (_stringLength > MAX_STRING_LENGTH) {
|
||||
_stringLength = MAX_STRING_LENGTH;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
||||
|
||||
glm::quat orientation = getOrientation();
|
||||
|
@ -475,6 +515,13 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
|||
if (isMyAvatar()) {
|
||||
updateThrust(deltaTime, transmitter);
|
||||
}
|
||||
|
||||
// Ajust, scale, thrust and lookAt position when following an other avatar
|
||||
if (isMyAvatar() && _leadingAvatar && _scale != _leadingAvatar->getScale()) {
|
||||
float scale = 0.95f * _scale + 0.05f * _leadingAvatar->getScale();
|
||||
setScale(scale);
|
||||
Application::getInstance()->getCamera()->setScale(scale);
|
||||
}
|
||||
|
||||
// copy velocity so we can use it later for acceleration
|
||||
glm::vec3 oldVelocity = getVelocity();
|
||||
|
@ -681,7 +728,9 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
|||
_head.setScale(_scale);
|
||||
_head.setSkinColor(glm::vec3(SKIN_COLOR[0], SKIN_COLOR[1], SKIN_COLOR[2]));
|
||||
_head.simulate(deltaTime, isMyAvatar());
|
||||
|
||||
|
||||
|
||||
|
||||
// use speed and angular velocity to determine walking vs. standing
|
||||
if (_speed + fabs(_bodyYawDelta) > 0.2) {
|
||||
_mode = AVATAR_MODE_WALKING;
|
||||
|
|
|
@ -114,6 +114,7 @@ public:
|
|||
void reset();
|
||||
void simulate(float deltaTime, Transmitter* transmitter);
|
||||
void updateThrust(float deltaTime, Transmitter * transmitter);
|
||||
void follow(Avatar* leadingAvatar);
|
||||
void updateFromGyrosAndOrWebcam(bool gyroLook,
|
||||
const glm::vec3& amplifyAngle,
|
||||
float yawFromTouch,
|
||||
|
@ -157,18 +158,16 @@ public:
|
|||
float getElapsedTimeMoving () const { return _elapsedTimeMoving;}
|
||||
float getElapsedTimeSinceCollision() const { return _elapsedTimeSinceCollision;}
|
||||
const glm::vec3& getLastCollisionPosition () const { return _lastCollisionPosition;}
|
||||
float getAbsoluteHeadYaw () const;
|
||||
float getAbsoluteHeadPitch () const;
|
||||
Head& getHead () {return _head; }
|
||||
Hand& getHand () {return _hand; }
|
||||
glm::quat getOrientation () const;
|
||||
glm::quat getWorldAlignedOrientation() const;
|
||||
|
||||
const glm::vec3& getMouseRayOrigin() const { return _mouseRayOrigin; }
|
||||
const glm::vec3& getMouseRayDirection() const { return _mouseRayDirection; }
|
||||
|
||||
|
||||
glm::vec3 getGravity () const { return _gravity; }
|
||||
float getAbsoluteHeadYaw () const;
|
||||
float getAbsoluteHeadPitch () const;
|
||||
Head& getHead () {return _head; }
|
||||
Hand& getHand () {return _hand; }
|
||||
glm::quat getOrientation () const;
|
||||
glm::quat getWorldAlignedOrientation() const;
|
||||
const glm::vec3& getMouseRayOrigin () const { return _mouseRayOrigin; }
|
||||
const glm::vec3& getMouseRayDirection () const { return _mouseRayDirection; }
|
||||
Avatar* getLeadingAvatar () const { return _leadingAvatar; }
|
||||
glm::vec3 getGravity () const { return _gravity; }
|
||||
|
||||
glm::vec3 getUprightHeadPosition() const;
|
||||
glm::vec3 getUprightEyeLevelPosition() const;
|
||||
|
@ -255,7 +254,10 @@ private:
|
|||
glm::vec3 _lastCollisionPosition;
|
||||
bool _speedBrakes;
|
||||
bool _isThrustOn;
|
||||
|
||||
|
||||
Avatar* _leadingAvatar;
|
||||
float _stringLength;
|
||||
|
||||
AvatarVoxelSystem _voxels;
|
||||
|
||||
// private methods...
|
||||
|
|
Loading…
Reference in a new issue