mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 17:14:59 +02:00
added scale in avatar packets eand slots to change it from the menu
This commit is contained in:
parent
78645964c9
commit
280afed7f0
11 changed files with 82 additions and 52 deletions
|
@ -1182,6 +1182,24 @@ void Application::setRenderThirdPerson(bool thirdPerson) {
|
|||
}
|
||||
}
|
||||
|
||||
void Application::increaseAvatarSize() {
|
||||
if (3.0f < _myAvatar.getScale() + 0.25f) {
|
||||
return;
|
||||
}
|
||||
|
||||
_myAvatar.setScale(_myAvatar.getScale() + 0.25f);
|
||||
_myCamera.setScale(_myAvatar.getScale() + 0.25f);
|
||||
}
|
||||
|
||||
void Application::decreaseAvatarSize() {
|
||||
if (_myAvatar.getScale() + 0.25f < 0.25f) {
|
||||
return;
|
||||
}
|
||||
|
||||
_myAvatar.setScale(_myAvatar.getScale() - 0.25f);
|
||||
_myCamera.setScale(_myAvatar.getScale() - 0.25f);
|
||||
}
|
||||
|
||||
void Application::setFrustumOffset(bool frustumOffset) {
|
||||
// reshape so that OpenGL will get the right lens details for the camera of choice
|
||||
resizeGL(_glWidget->width(), _glWidget->height());
|
||||
|
@ -1555,7 +1573,7 @@ void Application::initMenu() {
|
|||
_renderAvatarsOn->setChecked(true);
|
||||
(_renderAvatarBalls = renderMenu->addAction("Avatar as Balls"))->setCheckable(true);
|
||||
_renderAvatarBalls->setChecked(false);
|
||||
renderMenu->addAction("Cycle Voxeltar Mode", _myAvatar.getVoxels(), SLOT(cycleMode()));
|
||||
renderMenu->addAction("Cycle Voxel Mode", _myAvatar.getVoxels(), SLOT(cycleMode()));
|
||||
(_renderFrameTimerOn = renderMenu->addAction("Show Timer"))->setCheckable(true);
|
||||
_renderFrameTimerOn->setChecked(false);
|
||||
(_renderLookatOn = renderMenu->addAction("Lookat Vectors"))->setCheckable(true);
|
||||
|
@ -1564,6 +1582,9 @@ void Application::initMenu() {
|
|||
"First Person", this, SLOT(setRenderFirstPerson(bool)), Qt::Key_P))->setCheckable(true);
|
||||
(_manualThirdPerson = renderMenu->addAction(
|
||||
"Third Person", this, SLOT(setRenderThirdPerson(bool))))->setCheckable(true);
|
||||
renderMenu->addAction("Increase Avatar Size", this, SLOT(increaseAvatarSize()), Qt::SHIFT | Qt::Key_Plus);
|
||||
renderMenu->addAction("Decrease Avatar Siz+e", this, SLOT(decreaseAvatarSize()), Qt::SHIFT | Qt::Key_Minus);
|
||||
|
||||
|
||||
QMenu* toolsMenu = menuBar->addMenu("Tools");
|
||||
(_renderStatsOn = toolsMenu->addAction("Stats"))->setCheckable(true);
|
||||
|
@ -1750,10 +1771,6 @@ void Application::init() {
|
|||
_palette.addAction(_colorVoxelMode, 0, 2);
|
||||
_palette.addAction(_eyedropperMode, 0, 3);
|
||||
_palette.addAction(_selectVoxelMode, 0, 4);
|
||||
|
||||
float scale = 1.0f;
|
||||
_myAvatar.uniformScale(scale);
|
||||
_myCamera.setScale(scale);
|
||||
}
|
||||
|
||||
const float MAX_AVATAR_EDIT_VELOCITY = 1.0f;
|
||||
|
|
|
@ -118,6 +118,8 @@ private slots:
|
|||
|
||||
void setRenderFirstPerson(bool firstPerson);
|
||||
void setRenderThirdPerson(bool thirdPerson);
|
||||
void increaseAvatarSize();
|
||||
void decreaseAvatarSize();
|
||||
|
||||
void renderThrustAtVoxel(const glm::vec3& thrust);
|
||||
void renderLineToTouchedVoxel();
|
||||
|
|
|
@ -442,6 +442,11 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
|||
glm::vec3 front = orientation * IDENTITY_FRONT;
|
||||
glm::vec3 right = orientation * IDENTITY_RIGHT;
|
||||
|
||||
//
|
||||
if (!isMyAvatar() && _scale != _newScale) {
|
||||
setScale(_newScale);
|
||||
}
|
||||
|
||||
// Update movement timers
|
||||
if (isMyAvatar()) {
|
||||
_elapsedTimeSinceCollision += deltaTime;
|
||||
|
@ -1391,10 +1396,10 @@ void Avatar::renderJointConnectingCone(glm::vec3 position1, glm::vec3 position2,
|
|||
glEnd();
|
||||
}
|
||||
|
||||
void Avatar::uniformScale(float uniformScaler) {
|
||||
_scale *= uniformScaler;
|
||||
void Avatar::setScale(const float scale) {_scale = scale;
|
||||
_newScale = _scale;
|
||||
|
||||
_skeleton.uniformScale(_scale);
|
||||
_skeleton.setScale(_scale);
|
||||
|
||||
// specify the new radius of each ball
|
||||
_bodyBall[ BODY_BALL_PELVIS ].radius = _scale * BODY_BALL_RADIUS_PELVIS;
|
||||
|
@ -1432,3 +1437,4 @@ void Avatar::uniformScale(float uniformScaler) {
|
|||
_pelvisToHeadLength = _skeleton.getPelvisToHeadLength();
|
||||
_avatarTouch.setReachableRadius(_scale * PERIPERSONAL_RADIUS);
|
||||
}
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ public:
|
|||
void setGravity (glm::vec3 gravity);
|
||||
void setMouseRay (const glm::vec3 &origin, const glm::vec3 &direction);
|
||||
void setOrientation (const glm::quat& orientation);
|
||||
void uniformScale(float uniformScaler);
|
||||
void setScale (const float scale);
|
||||
|
||||
//getters
|
||||
bool isInitialized () const { return _initialized;}
|
||||
|
|
|
@ -124,18 +124,18 @@ void Camera::setMode(CameraMode m) {
|
|||
_previousTightness = _tightness;
|
||||
|
||||
if (_mode == CAMERA_MODE_THIRD_PERSON) {
|
||||
_newUpShift = _scale * CAMERA_THIRD_PERSON_MODE_UP_SHIFT;
|
||||
_newDistance = _scale * CAMERA_THIRD_PERSON_MODE_DISTANCE;
|
||||
_newUpShift = CAMERA_THIRD_PERSON_MODE_UP_SHIFT;
|
||||
_newDistance = CAMERA_THIRD_PERSON_MODE_DISTANCE;
|
||||
_newTightness = CAMERA_THIRD_PERSON_MODE_TIGHTNESS;
|
||||
|
||||
} else if (_mode == CAMERA_MODE_FIRST_PERSON) {
|
||||
_newUpShift = _scale * CAMERA_FIRST_PERSON_MODE_UP_SHIFT;
|
||||
_newDistance = _scale * CAMERA_FIRST_PERSON_MODE_DISTANCE;
|
||||
_newUpShift = CAMERA_FIRST_PERSON_MODE_UP_SHIFT;
|
||||
_newDistance = CAMERA_FIRST_PERSON_MODE_DISTANCE;
|
||||
_newTightness = CAMERA_FIRST_PERSON_MODE_TIGHTNESS;
|
||||
|
||||
} else if (_mode == CAMERA_MODE_MIRROR) {
|
||||
_newUpShift = _scale * CAMERA_MIRROR_MODE_UP_SHIFT;
|
||||
_newDistance = _scale * CAMERA_MIRROR_MODE_DISTANCE;
|
||||
_newUpShift = CAMERA_MIRROR_MODE_UP_SHIFT;
|
||||
_newDistance = CAMERA_MIRROR_MODE_DISTANCE;
|
||||
_newTightness = CAMERA_MIRROR_MODE_TIGHTNESS;
|
||||
}
|
||||
}
|
||||
|
@ -177,11 +177,8 @@ void Camera::setEyeOffsetOrientation (const glm::quat& o) {
|
|||
|
||||
void Camera::setScale(float s) {
|
||||
_scale = s;
|
||||
|
||||
_nearClip *= _scale;
|
||||
_farClip *= _scale;
|
||||
_newUpShift *= _scale;
|
||||
_newDistance *= _scale;
|
||||
_needsToInitialize = true;
|
||||
_frustumNeedsReshape = true;
|
||||
}
|
||||
|
||||
void Camera::initialize() {
|
||||
|
|
|
@ -55,8 +55,8 @@ public:
|
|||
CameraMode getMode () { return _mode; }
|
||||
float getFieldOfView () { return _fieldOfView; }
|
||||
float getAspectRatio () { return _aspectRatio; }
|
||||
float getNearClip () { return _nearClip; }
|
||||
float getFarClip () { return _farClip; }
|
||||
float getNearClip () { return _scale * _nearClip; }
|
||||
float getFarClip () { return _scale * _farClip; }
|
||||
const glm::vec3& getEyeOffsetPosition () { return _eyeOffsetPosition; }
|
||||
const glm::quat& getEyeOffsetOrientation () { return _eyeOffsetOrientation; }
|
||||
|
||||
|
|
|
@ -89,39 +89,39 @@ void Skeleton::initialize() {
|
|||
joint[ AVATAR_JOINT_RIGHT_HEEL ].parent = AVATAR_JOINT_RIGHT_KNEE;
|
||||
joint[ AVATAR_JOINT_RIGHT_TOES ].parent = AVATAR_JOINT_RIGHT_HEEL;
|
||||
|
||||
uniformScale(1.0f);
|
||||
setScale(1.0f);
|
||||
}
|
||||
|
||||
void Skeleton::uniformScale(float uniformScaler) {
|
||||
void Skeleton::setScale(float scale) {
|
||||
// specify the bind pose position
|
||||
joint[ AVATAR_JOINT_PELVIS ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_PELVIS;
|
||||
joint[ AVATAR_JOINT_TORSO ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_TORSO;
|
||||
joint[ AVATAR_JOINT_CHEST ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_CHEST;
|
||||
joint[ AVATAR_JOINT_NECK_BASE ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_NECK_BASE;
|
||||
joint[ AVATAR_JOINT_HEAD_BASE ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_HEAD_BASE;
|
||||
joint[ AVATAR_JOINT_HEAD_TOP ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_HEAD_TOP;
|
||||
joint[ AVATAR_JOINT_PELVIS ].bindPosePosition = scale * AVATAR_JOINT_POSITION_PELVIS;
|
||||
joint[ AVATAR_JOINT_TORSO ].bindPosePosition = scale * AVATAR_JOINT_POSITION_TORSO;
|
||||
joint[ AVATAR_JOINT_CHEST ].bindPosePosition = scale * AVATAR_JOINT_POSITION_CHEST;
|
||||
joint[ AVATAR_JOINT_NECK_BASE ].bindPosePosition = scale * AVATAR_JOINT_POSITION_NECK_BASE;
|
||||
joint[ AVATAR_JOINT_HEAD_BASE ].bindPosePosition = scale * AVATAR_JOINT_POSITION_HEAD_BASE;
|
||||
joint[ AVATAR_JOINT_HEAD_TOP ].bindPosePosition = scale * AVATAR_JOINT_POSITION_HEAD_TOP;
|
||||
|
||||
joint[ AVATAR_JOINT_LEFT_COLLAR ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_LEFT_COLLAR;
|
||||
joint[ AVATAR_JOINT_LEFT_SHOULDER ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_LEFT_SHOULDER;
|
||||
joint[ AVATAR_JOINT_LEFT_ELBOW ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_LEFT_ELBOW;
|
||||
joint[ AVATAR_JOINT_LEFT_WRIST ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_LEFT_WRIST;
|
||||
joint[ AVATAR_JOINT_LEFT_FINGERTIPS ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_LEFT_FINGERTIPS;
|
||||
joint[ AVATAR_JOINT_LEFT_COLLAR ].bindPosePosition = scale * AVATAR_JOINT_POSITION_LEFT_COLLAR;
|
||||
joint[ AVATAR_JOINT_LEFT_SHOULDER ].bindPosePosition = scale * AVATAR_JOINT_POSITION_LEFT_SHOULDER;
|
||||
joint[ AVATAR_JOINT_LEFT_ELBOW ].bindPosePosition = scale * AVATAR_JOINT_POSITION_LEFT_ELBOW;
|
||||
joint[ AVATAR_JOINT_LEFT_WRIST ].bindPosePosition = scale * AVATAR_JOINT_POSITION_LEFT_WRIST;
|
||||
joint[ AVATAR_JOINT_LEFT_FINGERTIPS ].bindPosePosition = scale * AVATAR_JOINT_POSITION_LEFT_FINGERTIPS;
|
||||
|
||||
joint[ AVATAR_JOINT_RIGHT_COLLAR ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_RIGHT_COLLAR;
|
||||
joint[ AVATAR_JOINT_RIGHT_SHOULDER ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_RIGHT_SHOULDER;
|
||||
joint[ AVATAR_JOINT_RIGHT_ELBOW ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_RIGHT_ELBOW;
|
||||
joint[ AVATAR_JOINT_RIGHT_WRIST ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_RIGHT_WRIST;
|
||||
joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_RIGHT_FINGERTIPS;
|
||||
joint[ AVATAR_JOINT_RIGHT_COLLAR ].bindPosePosition = scale * AVATAR_JOINT_POSITION_RIGHT_COLLAR;
|
||||
joint[ AVATAR_JOINT_RIGHT_SHOULDER ].bindPosePosition = scale * AVATAR_JOINT_POSITION_RIGHT_SHOULDER;
|
||||
joint[ AVATAR_JOINT_RIGHT_ELBOW ].bindPosePosition = scale * AVATAR_JOINT_POSITION_RIGHT_ELBOW;
|
||||
joint[ AVATAR_JOINT_RIGHT_WRIST ].bindPosePosition = scale * AVATAR_JOINT_POSITION_RIGHT_WRIST;
|
||||
joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].bindPosePosition = scale * AVATAR_JOINT_POSITION_RIGHT_FINGERTIPS;
|
||||
|
||||
joint[ AVATAR_JOINT_LEFT_HIP ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_LEFT_HIP;
|
||||
joint[ AVATAR_JOINT_LEFT_KNEE ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_LEFT_KNEE;
|
||||
joint[ AVATAR_JOINT_LEFT_HEEL ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_LEFT_HEEL;
|
||||
joint[ AVATAR_JOINT_LEFT_TOES ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_LEFT_TOES;
|
||||
joint[ AVATAR_JOINT_LEFT_HIP ].bindPosePosition = scale * AVATAR_JOINT_POSITION_LEFT_HIP;
|
||||
joint[ AVATAR_JOINT_LEFT_KNEE ].bindPosePosition = scale * AVATAR_JOINT_POSITION_LEFT_KNEE;
|
||||
joint[ AVATAR_JOINT_LEFT_HEEL ].bindPosePosition = scale * AVATAR_JOINT_POSITION_LEFT_HEEL;
|
||||
joint[ AVATAR_JOINT_LEFT_TOES ].bindPosePosition = scale * AVATAR_JOINT_POSITION_LEFT_TOES;
|
||||
|
||||
joint[ AVATAR_JOINT_RIGHT_HIP ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_RIGHT_HIP;
|
||||
joint[ AVATAR_JOINT_RIGHT_KNEE ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_RIGHT_KNEE;
|
||||
joint[ AVATAR_JOINT_RIGHT_HEEL ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_RIGHT_HEEL;
|
||||
joint[ AVATAR_JOINT_RIGHT_TOES ].bindPosePosition = uniformScaler * AVATAR_JOINT_POSITION_RIGHT_TOES;
|
||||
joint[ AVATAR_JOINT_RIGHT_HIP ].bindPosePosition = scale * AVATAR_JOINT_POSITION_RIGHT_HIP;
|
||||
joint[ AVATAR_JOINT_RIGHT_KNEE ].bindPosePosition = scale * AVATAR_JOINT_POSITION_RIGHT_KNEE;
|
||||
joint[ AVATAR_JOINT_RIGHT_HEEL ].bindPosePosition = scale * AVATAR_JOINT_POSITION_RIGHT_HEEL;
|
||||
joint[ AVATAR_JOINT_RIGHT_TOES ].bindPosePosition = scale * AVATAR_JOINT_POSITION_RIGHT_TOES;
|
||||
|
||||
// calculate bone length, absolute bind positions/rotations
|
||||
for (int b = 0; b < NUM_AVATAR_JOINTS; b++) {
|
||||
|
@ -139,7 +139,7 @@ void Skeleton::uniformScale(float uniformScaler) {
|
|||
}
|
||||
}
|
||||
|
||||
_floatingHeight = uniformScaler * FLOATING_HEIGHT;
|
||||
_floatingHeight = scale * FLOATING_HEIGHT;
|
||||
}
|
||||
|
||||
// calculate positions and rotations of all bones by traversing the skeleton tree:
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
Skeleton();
|
||||
|
||||
void initialize();
|
||||
void uniformScale(float scaler);
|
||||
void setScale(float scale);
|
||||
void update(float deltaTime, const glm::quat&, glm::vec3 position);
|
||||
void render();
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ AvatarData::AvatarData(Node* owningNode) :
|
|||
_bodyYaw(-90.0),
|
||||
_bodyPitch(0.0),
|
||||
_bodyRoll(0.0),
|
||||
_newScale(1.0f),
|
||||
_handState(0),
|
||||
_cameraPosition(0,0,0),
|
||||
_cameraOrientation(),
|
||||
|
@ -71,6 +72,7 @@ int AvatarData::getBroadcastData(unsigned char* destinationBuffer) {
|
|||
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _bodyYaw);
|
||||
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _bodyPitch);
|
||||
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _bodyRoll);
|
||||
destinationBuffer += packFloatRatioToTwoByte(destinationBuffer, _newScale);
|
||||
|
||||
// Head rotation (NOTE: This needs to become a quaternion to save two bytes)
|
||||
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _headData->_yaw);
|
||||
|
@ -197,7 +199,9 @@ 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);
|
||||
|
||||
sourceBuffer += unpackFloatRatioFromTwoByte( sourceBuffer, _newScale);
|
||||
std::cout << "New Scale : " << _newScale << std::endl;
|
||||
|
||||
// Head rotation (NOTE: This needs to become a quaternion to save two bytes)
|
||||
float headYaw, headPitch, headRoll;
|
||||
sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &headYaw);
|
||||
|
|
|
@ -112,6 +112,7 @@ protected:
|
|||
float _bodyYaw;
|
||||
float _bodyPitch;
|
||||
float _bodyRoll;
|
||||
float _newScale;
|
||||
|
||||
// Hand state (are we grabbing something or not)
|
||||
char _handState;
|
||||
|
|
|
@ -12,6 +12,9 @@
|
|||
|
||||
PACKET_VERSION versionForPacketType(PACKET_TYPE type) {
|
||||
switch (type) {
|
||||
case PACKET_TYPE_HEAD_DATA:
|
||||
return 1;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
break;
|
||||
|
@ -59,4 +62,4 @@ int numBytesForPacketHeader(unsigned char* packetHeader) {
|
|||
|
||||
// currently this need not be dynamic - there are 2 bytes for each packet header
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue