Merge pull request #791 from Atlante45/stalking_indicator

Stalking indicator
This commit is contained in:
ZappoMan 2013-08-06 12:33:26 -07:00
commit c93ed450a2
9 changed files with 83 additions and 8 deletions

View file

@ -2292,6 +2292,56 @@ void Application::renderLookatIndicator(glm::vec3 pointOfInterest, Camera& which
renderCircle(haloOrigin, INDICATOR_RADIUS, IDENTITY_UP, NUM_SEGMENTS); renderCircle(haloOrigin, INDICATOR_RADIUS, IDENTITY_UP, NUM_SEGMENTS);
} }
void Application::renderFollowIndicator() {
NodeList* nodeList = NodeList::getInstance();
glLineWidth(5);
glBegin(GL_LINES);
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); ++node) {
if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {
Avatar* avatar = (Avatar *) node->getLinkedData();
Avatar* leader = NULL;
if (avatar->getLeaderID() != UNKNOWN_NODE_ID) {
if (avatar->getLeaderID() == NodeList::getInstance()->getOwnerID()) {
leader = &_myAvatar;
} else {
for (NodeList::iterator it = nodeList->begin(); it != nodeList->end(); ++it) {
if(it->getNodeID() == avatar->getLeaderID()
&& it->getType() == NODE_TYPE_AGENT) {
leader = (Avatar*) it->getLinkedData();
}
}
}
if (leader != NULL) {
glColor3f(1.f, 0.f, 0.f);
glVertex3f(avatar->getPosition().x,
avatar->getPosition().y,
avatar->getPosition().z);
glColor3f(0.f, 1.f, 0.f);
glVertex3f(leader->getPosition().x,
leader->getPosition().y,
leader->getPosition().z);
}
}
}
}
if (_myAvatar.getLeadingAvatar() != NULL) {
glColor3f(1.f, 0.f, 0.f);
glVertex3f(_myAvatar.getPosition().x,
_myAvatar.getPosition().y,
_myAvatar.getPosition().z);
glColor3f(0.f, 1.f, 0.f);
glVertex3f(_myAvatar.getLeadingAvatar()->getPosition().x,
_myAvatar.getLeadingAvatar()->getPosition().y,
_myAvatar.getLeadingAvatar()->getPosition().z);
}
glEnd();
}
void Application::update(float deltaTime) { void Application::update(float deltaTime) {
// Use Transmitter Hand to move hand if connected, else use mouse // Use Transmitter Hand to move hand if connected, else use mouse
@ -3062,6 +3112,8 @@ void Application::displaySide(Camera& whichCamera) {
// brad's frustum for debugging // brad's frustum for debugging
if (_frustumOn->isChecked()) renderViewFrustum(_viewFrustum); if (_frustumOn->isChecked()) renderViewFrustum(_viewFrustum);
renderFollowIndicator();
} }
void Application::displayOverlay() { void Application::displayOverlay() {

View file

@ -217,6 +217,7 @@ private:
bool isLookingAtMyAvatar(Avatar* avatar); bool isLookingAtMyAvatar(Avatar* avatar);
void renderLookatIndicator(glm::vec3 pointOfInterest, Camera& whichCamera); void renderLookatIndicator(glm::vec3 pointOfInterest, Camera& whichCamera);
void renderFollowIndicator();
void updateAvatar(float deltaTime); void updateAvatar(float deltaTime);
void loadViewFrustum(Camera& camera, ViewFrustum& viewFrustum); void loadViewFrustum(Camera& camera, ViewFrustum& viewFrustum);

View file

@ -492,10 +492,13 @@ void Avatar::follow(Avatar* leadingAvatar) {
_leadingAvatar = leadingAvatar; _leadingAvatar = leadingAvatar;
if (_leadingAvatar != NULL) { if (_leadingAvatar != NULL) {
_leaderID = leadingAvatar->getOwningNode()->getNodeID();
_stringLength = glm::length(_position - _leadingAvatar->getPosition()) / _scale; _stringLength = glm::length(_position - _leadingAvatar->getPosition()) / _scale;
if (_stringLength > MAX_STRING_LENGTH) { if (_stringLength > MAX_STRING_LENGTH) {
_stringLength = MAX_STRING_LENGTH; _stringLength = MAX_STRING_LENGTH;
} }
} else {
_leaderID = UNKNOWN_NODE_ID;
} }
} }

View file

@ -27,7 +27,7 @@
#include "world.h" #include "world.h"
static const float MAX_SCALE = 5.f; static const float MAX_SCALE = 10.f;
static const float MIN_SCALE = .5f; static const float MIN_SCALE = .5f;
static const float SCALING_RATIO = .05f; static const float SCALING_RATIO = .05f;
static const float SMOOTHING_RATIO = .05f; // 0 < ratio < 1 static const float SMOOTHING_RATIO = .05f; // 0 < ratio < 1

View file

@ -339,7 +339,7 @@ void Head::setScale (float scale) {
} }
void Head::createMohawk() { void Head::createMohawk() {
uint16_t nodeId = 0; uint16_t nodeId = UNKNOWN_NODE_ID;
if (_owningAvatar->getOwningNode()) { if (_owningAvatar->getOwningNode()) {
nodeId = _owningAvatar->getOwningNode()->getNodeID(); nodeId = _owningAvatar->getOwningNode()->getNodeID();
} else { } else {

View file

@ -41,7 +41,8 @@ AvatarData::AvatarData(Node* owningNode) :
_wantLowResMoving(false), _wantLowResMoving(false),
_wantOcclusionCulling(true), _wantOcclusionCulling(true),
_headData(NULL), _headData(NULL),
_handData(NULL) _handData(NULL),
_leaderID(UNKNOWN_NODE_ID)
{ {
} }
@ -91,8 +92,14 @@ int AvatarData::getBroadcastData(unsigned char* destinationBuffer) {
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _bodyYaw); destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _bodyYaw);
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _bodyPitch); destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _bodyPitch);
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _bodyRoll); destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _bodyRoll);
// Body scale
destinationBuffer += packFloatRatioToTwoByte(destinationBuffer, _newScale); destinationBuffer += packFloatRatioToTwoByte(destinationBuffer, _newScale);
// Follow mode info
memcpy(destinationBuffer, &_leaderID, sizeof(uint16_t));
destinationBuffer += sizeof(uint16_t);
// Head rotation (NOTE: This needs to become a quaternion to save two bytes) // Head rotation (NOTE: This needs to become a quaternion to save two bytes)
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _headData->_yaw); destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _headData->_yaw);
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _headData->_pitch); destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _headData->_pitch);
@ -188,8 +195,14 @@ int AvatarData::parseData(unsigned char* sourceBuffer, int numBytes) {
sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &_bodyYaw); sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &_bodyYaw);
sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &_bodyPitch); sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &_bodyPitch);
sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &_bodyRoll); sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &_bodyRoll);
// Body scale
sourceBuffer += unpackFloatRatioFromTwoByte( sourceBuffer, _newScale); sourceBuffer += unpackFloatRatioFromTwoByte( sourceBuffer, _newScale);
// Follow mode info
memcpy(&_leaderID, sourceBuffer, sizeof(uint16_t));
sourceBuffer += sizeof(uint16_t);
// Head rotation (NOTE: This needs to become a quaternion to save two bytes) // Head rotation (NOTE: This needs to become a quaternion to save two bytes)
float headYaw, headPitch, headRoll; float headYaw, headPitch, headRoll;
sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &headYaw); sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &headYaw);

View file

@ -92,10 +92,11 @@ public:
const std::string& chatMessage () const { return _chatMessage; } const std::string& chatMessage () const { return _chatMessage; }
// related to Voxel Sending strategies // related to Voxel Sending strategies
bool getWantColor() const { return _wantColor; } bool getWantColor() const { return _wantColor; }
bool getWantDelta() const { return _wantDelta; } bool getWantDelta() const { return _wantDelta; }
bool getWantLowResMoving() const { return _wantLowResMoving; } bool getWantLowResMoving() const { return _wantLowResMoving; }
bool getWantOcclusionCulling() const { return _wantOcclusionCulling; } bool getWantOcclusionCulling() const { return _wantOcclusionCulling; }
uint16_t getLeaderID() const { return _leaderID; }
void setWantColor(bool wantColor) { _wantColor = wantColor; } void setWantColor(bool wantColor) { _wantColor = wantColor; }
void setWantDelta(bool wantDelta) { _wantDelta = wantDelta; } void setWantDelta(bool wantDelta) { _wantDelta = wantDelta; }
@ -118,8 +119,13 @@ protected:
float _bodyYaw; float _bodyYaw;
float _bodyPitch; float _bodyPitch;
float _bodyRoll; float _bodyRoll;
// Body scale
float _newScale; float _newScale;
// Following mode infos
uint16_t _leaderID;
// Hand state (are we grabbing something or not) // Hand state (are we grabbing something or not)
char _handState; char _handState;

View file

@ -66,7 +66,7 @@ public:
void setDomainIPToLocalhost(); void setDomainIPToLocalhost();
uint16_t getLastNodeID() const { return _lastNodeID; } uint16_t getLastNodeID() const { return _lastNodeID; }
void increaseNodeID() { ++_lastNodeID; } void increaseNodeID() { (++_lastNodeID == UNKNOWN_NODE_ID) ? ++_lastNodeID : _lastNodeID; }
uint16_t getOwnerID() const { return _ownerID; } uint16_t getOwnerID() const { return _ownerID; }
void setOwnerID(uint16_t ownerID) { _ownerID = ownerID; } void setOwnerID(uint16_t ownerID) { _ownerID = ownerID; }

View file

@ -20,7 +20,7 @@ PACKET_VERSION versionForPacketType(PACKET_TYPE type) {
return 1; return 1;
case PACKET_TYPE_HEAD_DATA: case PACKET_TYPE_HEAD_DATA:
return 3; return 4;
case PACKET_TYPE_AVATAR_FACE_VIDEO: case PACKET_TYPE_AVATAR_FACE_VIDEO:
return 1; return 1;