History

added scale in avatar packets eand slots to change it from the menu

atlante45 committed 13 years ago

Commit 280afed1 parent 786459611 files · +82 −52Browse files

Unified · Split

11 files
  1. interface/src/Application.cpp +22 −5
  2. interface/src/Application.h +2 −0
  3. interface/src/Avatar.cpp +9 −3
  4. interface/src/Avatar.h +1 −1
  5. interface/src/Camera.cpp +8 −11
  6. interface/src/Camera.h +2 −2
  7. interface/src/Skeleton.cpp +27 −27
  8. interface/src/Skeleton.h +1 −1
  9. libraries/avatars/src/AvatarData.cpp +5 −1
  10. libraries/avatars/src/AvatarData.h +1 −0
  11. libraries/shared/src/PacketHeaders.cpp +4 −1
interface/src/Application.cpp+22−5
@@ -1182,6 +1182,24 @@ void Application::setRenderThirdPerson(bool thirdPerson) { · 1181 unmodified lines
11821182 }
11831183 }
11841184
1185+void Application::increaseAvatarSize() {
1186+ if (3.0f < _myAvatar.getScale() + 0.25f) {
1187+ return;
1188+ }
1189+
1190+ _myAvatar.setScale(_myAvatar.getScale() + 0.25f);
1191+ _myCamera.setScale(_myAvatar.getScale() + 0.25f);
1192+}
1193+
1194+void Application::decreaseAvatarSize() {
1195+ if (_myAvatar.getScale() + 0.25f < 0.25f) {
1196+ return;
1197+ }
1198+
1199+ _myAvatar.setScale(_myAvatar.getScale() - 0.25f);
1200+ _myCamera.setScale(_myAvatar.getScale() - 0.25f);
1201+}
1202+
11851203 void Application::setFrustumOffset(bool frustumOffset) {
11861204 // reshape so that OpenGL will get the right lens details for the camera of choice
11871205 resizeGL(_glWidget->width(), _glWidget->height());
@@ -1555,7 +1573,7 @@ void Application::initMenu() { · 367 unmodified lines
15551573 _renderAvatarsOn->setChecked(true);
15561574 (_renderAvatarBalls = renderMenu->addAction("Avatar as Balls"))->setCheckable(true);
15571575 _renderAvatarBalls->setChecked(false);
1558− renderMenu->addAction("Cycle Voxeltar Mode", _myAvatar.getVoxels(), SLOT(cycleMode()));
1576+ renderMenu->addAction("Cycle Voxel Mode", _myAvatar.getVoxels(), SLOT(cycleMode()));
15591577 (_renderFrameTimerOn = renderMenu->addAction("Show Timer"))->setCheckable(true);
15601578 _renderFrameTimerOn->setChecked(false);
15611579 (_renderLookatOn = renderMenu->addAction("Lookat Vectors"))->setCheckable(true);
@@ -1564,6 +1582,9 @@ void Application::initMenu() { · 2 unmodified lines
15641582 "First Person", this, SLOT(setRenderFirstPerson(bool)), Qt::Key_P))->setCheckable(true);
15651583 (_manualThirdPerson = renderMenu->addAction(
15661584 "Third Person", this, SLOT(setRenderThirdPerson(bool))))->setCheckable(true);
1585+ renderMenu->addAction("Increase Avatar Size", this, SLOT(increaseAvatarSize()), Qt::SHIFT | Qt::Key_Plus);
1586+ renderMenu->addAction("Decrease Avatar Siz+e", this, SLOT(decreaseAvatarSize()), Qt::SHIFT | Qt::Key_Minus);
1587+
15671588
15681589 QMenu* toolsMenu = menuBar->addMenu("Tools");
15691590 (_renderStatsOn = toolsMenu->addAction("Stats"))->setCheckable(true);
@@ -1750,10 +1771,6 @@ void Application::init() { · 180 unmodified lines
17501771 _palette.addAction(_colorVoxelMode, 0, 2);
17511772 _palette.addAction(_eyedropperMode, 0, 3);
17521773 _palette.addAction(_selectVoxelMode, 0, 4);
1753−
1754− float scale = 1.0f;
1755− _myAvatar.uniformScale(scale);
1756− _myCamera.setScale(scale);
17571774 }
17581775
17591776 const float MAX_AVATAR_EDIT_VELOCITY = 1.0f;
interface/src/Application.h+2−0
@@ -118,6 +118,8 @@ private slots: · 117 unmodified lines
118118
119119 void setRenderFirstPerson(bool firstPerson);
120120 void setRenderThirdPerson(bool thirdPerson);
121+ void increaseAvatarSize();
122+ void decreaseAvatarSize();
121123
122124 void renderThrustAtVoxel(const glm::vec3& thrust);
123125 void renderLineToTouchedVoxel();
interface/src/Avatar.cpp+9−3
@@ -442,6 +442,11 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) { · 441 unmodified lines
442442 glm::vec3 front = orientation * IDENTITY_FRONT;
443443 glm::vec3 right = orientation * IDENTITY_RIGHT;
444444
445+ //
446+ if (!isMyAvatar() && _scale != _newScale) {
447+ setScale(_newScale);
448+ }
449+
445450 // Update movement timers
446451 if (isMyAvatar()) {
447452 _elapsedTimeSinceCollision += deltaTime;
@@ -1391,10 +1396,10 @@ void Avatar::renderJointConnectingCone(glm::vec3 position1, glm::vec3 position2, · 943 unmodified lines
13911396 glEnd();
13921397 }
13931398
1394−void Avatar::uniformScale(float uniformScaler) {
1395− _scale *= uniformScaler;
1399+void Avatar::setScale(const float scale) {_scale = scale;
1400+ _newScale = _scale;
13961401
1397− _skeleton.uniformScale(_scale);
1402+ _skeleton.setScale(_scale);
13981403
13991404 // specify the new radius of each ball
14001405 _bodyBall[ BODY_BALL_PELVIS ].radius = _scale * BODY_BALL_RADIUS_PELVIS;
@@ -1432,3 +1437,4 @@ void Avatar::uniformScale(float uniformScaler) { · 31 unmodified lines
14321437 _pelvisToHeadLength = _skeleton.getPelvisToHeadLength();
14331438 _avatarTouch.setReachableRadius(_scale * PERIPERSONAL_RADIUS);
14341439 }
1440+
interface/src/Avatar.h+1−1
@@ -129,7 +129,7 @@ public: · 128 unmodified lines
129129 void setGravity (glm::vec3 gravity);
130130 void setMouseRay (const glm::vec3 &origin, const glm::vec3 &direction);
131131 void setOrientation (const glm::quat& orientation);
132− void uniformScale(float uniformScaler);
132+ void setScale (const float scale);
133133
134134 //getters
135135 bool isInitialized () const { return _initialized;}
interface/src/Camera.cpp+8−11
@@ -124,18 +124,18 @@ void Camera::setMode(CameraMode m) { · 123 unmodified lines
124124 _previousTightness = _tightness;
125125
126126 if (_mode == CAMERA_MODE_THIRD_PERSON) {
127− _newUpShift = _scale * CAMERA_THIRD_PERSON_MODE_UP_SHIFT;
128− _newDistance = _scale * CAMERA_THIRD_PERSON_MODE_DISTANCE;
127+ _newUpShift = CAMERA_THIRD_PERSON_MODE_UP_SHIFT;
128+ _newDistance = CAMERA_THIRD_PERSON_MODE_DISTANCE;
129129 _newTightness = CAMERA_THIRD_PERSON_MODE_TIGHTNESS;
130130
131131 } else if (_mode == CAMERA_MODE_FIRST_PERSON) {
132− _newUpShift = _scale * CAMERA_FIRST_PERSON_MODE_UP_SHIFT;
133− _newDistance = _scale * CAMERA_FIRST_PERSON_MODE_DISTANCE;
132+ _newUpShift = CAMERA_FIRST_PERSON_MODE_UP_SHIFT;
133+ _newDistance = CAMERA_FIRST_PERSON_MODE_DISTANCE;
134134 _newTightness = CAMERA_FIRST_PERSON_MODE_TIGHTNESS;
135135
136136 } else if (_mode == CAMERA_MODE_MIRROR) {
137− _newUpShift = _scale * CAMERA_MIRROR_MODE_UP_SHIFT;
138− _newDistance = _scale * CAMERA_MIRROR_MODE_DISTANCE;
137+ _newUpShift = CAMERA_MIRROR_MODE_UP_SHIFT;
138+ _newDistance = CAMERA_MIRROR_MODE_DISTANCE;
139139 _newTightness = CAMERA_MIRROR_MODE_TIGHTNESS;
140140 }
141141 }
@@ -177,11 +177,8 @@ void Camera::setEyeOffsetOrientation (const glm::quat& o) { · 35 unmodified lines
177177
178178 void Camera::setScale(float s) {
179179 _scale = s;
180−
181− _nearClip *= _scale;
182− _farClip *= _scale;
183− _newUpShift *= _scale;
184− _newDistance *= _scale;
180+ _needsToInitialize = true;
181+ _frustumNeedsReshape = true;
185182 }
186183
187184 void Camera::initialize() {
interface/src/Camera.h+2−2
@@ -55,8 +55,8 @@ public: · 54 unmodified lines
5555 CameraMode getMode () { return _mode; }
5656 float getFieldOfView () { return _fieldOfView; }
5757 float getAspectRatio () { return _aspectRatio; }
58− float getNearClip () { return _nearClip; }
59− float getFarClip () { return _farClip; }
58+ float getNearClip () { return _scale * _nearClip; }
59+ float getFarClip () { return _scale * _farClip; }
6060 const glm::vec3& getEyeOffsetPosition () { return _eyeOffsetPosition; }
6161 const glm::quat& getEyeOffsetOrientation () { return _eyeOffsetOrientation; }
6262
interface/src/Skeleton.cpp+27−27
@@ -89,39 +89,39 @@ void Skeleton::initialize() { · 88 unmodified lines
8989 joint[ AVATAR_JOINT_RIGHT_HEEL ].parent = AVATAR_JOINT_RIGHT_KNEE;
9090 joint[ AVATAR_JOINT_RIGHT_TOES ].parent = AVATAR_JOINT_RIGHT_HEEL;
9191
92− uniformScale(1.0f);
92+ setScale(1.0f);
9393 }
9494
95−void Skeleton::uniformScale(float uniformScaler) {
95+void Skeleton::setScale(float scale) {
9696 // specify the bind pose position
97− joint[ AVATAR_JOINT_PELVIS ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_PELVIS;
98− joint[ AVATAR_JOINT_TORSO ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_TORSO;
99− joint[ AVATAR_JOINT_CHEST ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_CHEST;
100− joint[ AVATAR_JOINT_NECK_BASE ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_NECK_BASE;
101− joint[ AVATAR_JOINT_HEAD_BASE ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_HEAD_BASE;
102− joint[ AVATAR_JOINT_HEAD_TOP ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_HEAD_TOP;
97+ joint[ AVATAR_JOINT_PELVIS ].bindPosePosition = scale * AVATAR_JOINT_POSITION_PELVIS;
98+ joint[ AVATAR_JOINT_TORSO ].bindPosePosition = scale * AVATAR_JOINT_POSITION_TORSO;
99+ joint[ AVATAR_JOINT_CHEST ].bindPosePosition = scale * AVATAR_JOINT_POSITION_CHEST;
100+ joint[ AVATAR_JOINT_NECK_BASE ].bindPosePosition = scale * AVATAR_JOINT_POSITION_NECK_BASE;
101+ joint[ AVATAR_JOINT_HEAD_BASE ].bindPosePosition = scale * AVATAR_JOINT_POSITION_HEAD_BASE;
102+ joint[ AVATAR_JOINT_HEAD_TOP ].bindPosePosition = scale * AVATAR_JOINT_POSITION_HEAD_TOP;
103103
104− joint[ AVATAR_JOINT_LEFT_COLLAR ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_LEFT_COLLAR;
105− joint[ AVATAR_JOINT_LEFT_SHOULDER ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_LEFT_SHOULDER;
106− joint[ AVATAR_JOINT_LEFT_ELBOW ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_LEFT_ELBOW;
107− joint[ AVATAR_JOINT_LEFT_WRIST ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_LEFT_WRIST;
108− joint[ AVATAR_JOINT_LEFT_FINGERTIPS ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_LEFT_FINGERTIPS;
104+ joint[ AVATAR_JOINT_LEFT_COLLAR ].bindPosePosition = scale * AVATAR_JOINT_POSITION_LEFT_COLLAR;
105+ joint[ AVATAR_JOINT_LEFT_SHOULDER ].bindPosePosition = scale * AVATAR_JOINT_POSITION_LEFT_SHOULDER;
106+ joint[ AVATAR_JOINT_LEFT_ELBOW ].bindPosePosition = scale * AVATAR_JOINT_POSITION_LEFT_ELBOW;
107+ joint[ AVATAR_JOINT_LEFT_WRIST ].bindPosePosition = scale * AVATAR_JOINT_POSITION_LEFT_WRIST;
108+ joint[ AVATAR_JOINT_LEFT_FINGERTIPS ].bindPosePosition = scale * AVATAR_JOINT_POSITION_LEFT_FINGERTIPS;
109109
110− joint[ AVATAR_JOINT_RIGHT_COLLAR ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_RIGHT_COLLAR;
111− joint[ AVATAR_JOINT_RIGHT_SHOULDER ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_RIGHT_SHOULDER;
112− joint[ AVATAR_JOINT_RIGHT_ELBOW ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_RIGHT_ELBOW;
113− joint[ AVATAR_JOINT_RIGHT_WRIST ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_RIGHT_WRIST;
114− joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_RIGHT_FINGERTIPS;
110+ joint[ AVATAR_JOINT_RIGHT_COLLAR ].bindPosePosition = scale * AVATAR_JOINT_POSITION_RIGHT_COLLAR;
111+ joint[ AVATAR_JOINT_RIGHT_SHOULDER ].bindPosePosition = scale * AVATAR_JOINT_POSITION_RIGHT_SHOULDER;
112+ joint[ AVATAR_JOINT_RIGHT_ELBOW ].bindPosePosition = scale * AVATAR_JOINT_POSITION_RIGHT_ELBOW;
113+ joint[ AVATAR_JOINT_RIGHT_WRIST ].bindPosePosition = scale * AVATAR_JOINT_POSITION_RIGHT_WRIST;
114+ joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].bindPosePosition = scale * AVATAR_JOINT_POSITION_RIGHT_FINGERTIPS;
115115
116− joint[ AVATAR_JOINT_LEFT_HIP ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_LEFT_HIP;
117− joint[ AVATAR_JOINT_LEFT_KNEE ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_LEFT_KNEE;
118− joint[ AVATAR_JOINT_LEFT_HEEL ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_LEFT_HEEL;
119− joint[ AVATAR_JOINT_LEFT_TOES ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_LEFT_TOES;
116+ joint[ AVATAR_JOINT_LEFT_HIP ].bindPosePosition = scale * AVATAR_JOINT_POSITION_LEFT_HIP;
117+ joint[ AVATAR_JOINT_LEFT_KNEE ].bindPosePosition = scale * AVATAR_JOINT_POSITION_LEFT_KNEE;
118+ joint[ AVATAR_JOINT_LEFT_HEEL ].bindPosePosition = scale * AVATAR_JOINT_POSITION_LEFT_HEEL;
119+ joint[ AVATAR_JOINT_LEFT_TOES ].bindPosePosition = scale * AVATAR_JOINT_POSITION_LEFT_TOES;
120120
121− joint[ AVATAR_JOINT_RIGHT_HIP ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_RIGHT_HIP;
122− joint[ AVATAR_JOINT_RIGHT_KNEE ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_RIGHT_KNEE;
123− joint[ AVATAR_JOINT_RIGHT_HEEL ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_RIGHT_HEEL;
124− joint[ AVATAR_JOINT_RIGHT_TOES ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_RIGHT_TOES;
121+ joint[ AVATAR_JOINT_RIGHT_HIP ].bindPosePosition = scale * AVATAR_JOINT_POSITION_RIGHT_HIP;
122+ joint[ AVATAR_JOINT_RIGHT_KNEE ].bindPosePosition = scale * AVATAR_JOINT_POSITION_RIGHT_KNEE;
123+ joint[ AVATAR_JOINT_RIGHT_HEEL ].bindPosePosition = scale * AVATAR_JOINT_POSITION_RIGHT_HEEL;
124+ joint[ AVATAR_JOINT_RIGHT_TOES ].bindPosePosition = scale * AVATAR_JOINT_POSITION_RIGHT_TOES;
125125
126126 // calculate bone length, absolute bind positions/rotations
127127 for (int b = 0; b < NUM_AVATAR_JOINTS; b++) {
@@ -139,7 +139,7 @@ void Skeleton::uniformScale(float uniformScaler) { · 11 unmodified lines
139139 }
140140 }
141141
142− _floatingHeight = uniformScaler * FLOATING_HEIGHT;
142+ _floatingHeight = scale * FLOATING_HEIGHT;
143143 }
144144
145145 // calculate positions and rotations of all bones by traversing the skeleton tree:
interface/src/Skeleton.h+1−1
@@ -49,7 +49,7 @@ public: · 48 unmodified lines
4949 Skeleton();
5050
5151 void initialize();
52− void uniformScale(float scaler);
52+ void setScale(float scale);
5353 void update(float deltaTime, const glm::quat&, glm::vec3 position);
5454 void render();
5555
libraries/avatars/src/AvatarData.cpp+5−1
@@ -24,6 +24,7 @@ AvatarData::AvatarData(Node* owningNode) : · 23 unmodified lines
2424 _bodyYaw(-90.0),
2525 _bodyPitch(0.0),
2626 _bodyRoll(0.0),
27+ _newScale(1.0f),
2728 _handState(0),
2829 _cameraPosition(0,0,0),
2930 _cameraOrientation(),
@@ -71,6 +72,7 @@ int AvatarData::getBroadcastData(unsigned char* destinationBuffer) { · 41 unmodified lines
7172 destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _bodyYaw);
7273 destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _bodyPitch);
7374 destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _bodyRoll);
75+ destinationBuffer += packFloatRatioToTwoByte(destinationBuffer, _newScale);
7476
7577 // Head rotation (NOTE: This needs to become a quaternion to save two bytes)
7678 destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _headData->_yaw);
@@ -197,7 +199,9 @@ int AvatarData::parseData(unsigned char* sourceBuffer, int numBytes) { · 120 unmodified lines
197199 sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &_bodyYaw);
198200 sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &_bodyPitch);
199201 sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &_bodyRoll);
200−
202+ sourceBuffer += unpackFloatRatioFromTwoByte( sourceBuffer, _newScale);
203+ std::cout << "New Scale : " << _newScale << std::endl;
204+
201205 // Head rotation (NOTE: This needs to become a quaternion to save two bytes)
202206 float headYaw, headPitch, headRoll;
203207 sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &headYaw);
libraries/avatars/src/AvatarData.h+1−0
@@ -112,6 +112,7 @@ protected: · 111 unmodified lines
112112 float _bodyYaw;
113113 float _bodyPitch;
114114 float _bodyRoll;
115+ float _newScale;
115116
116117 // Hand state (are we grabbing something or not)
117118 char _handState;
libraries/shared/src/PacketHeaders.cpp+4−1
@@ -12,6 +12,9 @@ · 11 unmodified lines
1212
1313 PACKET_VERSION versionForPacketType(PACKET_TYPE type) {
1414 switch (type) {
15+ case PACKET_TYPE_HEAD_DATA:
16+ return 1;
17+ break;
1518 default:
1619 return 0;
1720 break;
@@ -59,4 +62,4 @@ int numBytesForPacketHeader(unsigned char* packetHeader) { · 41 unmodified lines
5962
6063 // currently this need not be dynamic - there are 2 bytes for each packet header
6164 return 2;
62−}
65+}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t