Render a string to show who is following who

This commit is contained in:
atlante45 2013-08-06 10:53:10 -07:00
parent cc8c92c4e0
commit 32c155ef71
9 changed files with 83 additions and 8 deletions

View file

@ -2287,6 +2287,56 @@ void Application::renderLookatIndicator(glm::vec3 pointOfInterest, Camera& which
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) {
// Use Transmitter Hand to move hand if connected, else use mouse
@ -3060,6 +3110,8 @@ void Application::displaySide(Camera& whichCamera) {
// brad's frustum for debugging
if (_frustumOn->isChecked()) renderViewFrustum(_viewFrustum);
renderFollowIndicator();
}
void Application::displayOverlay() {

View file

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

View file

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

View file

@ -27,7 +27,7 @@
#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 SCALING_RATIO = .05f;
static const float SMOOTHING_RATIO = .05f; // 0 < ratio < 1

View file

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

View file

@ -41,7 +41,8 @@ AvatarData::AvatarData(Node* owningNode) :
_wantLowResMoving(false),
_wantOcclusionCulling(true),
_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, _bodyPitch);
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _bodyRoll);
// Body scale
destinationBuffer += packFloatRatioToTwoByte(destinationBuffer, _newScale);
// Follow mode info
memcpy(destinationBuffer, &_leaderID, sizeof(_leaderID));
destinationBuffer += sizeof(uint16_t);
// Head rotation (NOTE: This needs to become a quaternion to save two bytes)
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _headData->_yaw);
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, &_bodyPitch);
sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &_bodyRoll);
// Body scale
sourceBuffer += unpackFloatRatioFromTwoByte( sourceBuffer, _newScale);
// Follow mode info
memcpy(&_leaderID, sourceBuffer, sizeof(_leaderID));
sourceBuffer += sizeof(uint16_t);
// Head rotation (NOTE: This needs to become a quaternion to save two bytes)
float headYaw, headPitch, headRoll;
sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &headYaw);

View file

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

View file

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

View file

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