mirror of
https://github.com/overte-org/overte.git
synced 2025-08-12 10:34:16 +02:00
spacing fixes in Avatar class
This commit is contained in:
parent
507f39a052
commit
7e0dab6224
2 changed files with 107 additions and 118 deletions
|
@ -357,28 +357,21 @@ void Avatar::simulate(float deltaTime) {
|
||||||
_interactingOther = NULL;
|
_interactingOther = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( usingBigSphereCollisionTest ) {
|
if (usingBigSphereCollisionTest) {
|
||||||
|
|
||||||
// test for avatar collision response (using a big sphere :)
|
// test for avatar collision response (using a big sphere :)
|
||||||
updateAvatarCollisionDetectionAndResponse
|
updateAvatarCollisionDetectionAndResponse(_TEST_bigSpherePosition,
|
||||||
(
|
_TEST_bigSphereRadius,
|
||||||
_TEST_bigSpherePosition,
|
_TEST_bigSphereRadius,
|
||||||
_TEST_bigSphereRadius,
|
glm::vec3( 0.0, 1.0, 0.0 ),
|
||||||
_TEST_bigSphereRadius,
|
deltaTime);
|
||||||
glm::vec3( 0.0, 1.0, 0.0 ),
|
|
||||||
deltaTime
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( AVATAR_GRAVITY ) {
|
if ( AVATAR_GRAVITY ) {
|
||||||
if ( _position.y > _bone[ AVATAR_BONE_RIGHT_FOOT ].radius * 2.0 ) {
|
if ( _position.y > _bone[ AVATAR_BONE_RIGHT_FOOT ].radius * 2.0 ) {
|
||||||
_velocity += glm::dvec3( 0.0, -1.0, 0.0 ) * ( 6.0 * deltaTime );
|
_velocity += glm::dvec3( 0.0, -1.0, 0.0 ) * ( 6.0 * deltaTime );
|
||||||
}
|
} else if ( _position.y < _bone[ AVATAR_BONE_RIGHT_FOOT ].radius ) {
|
||||||
else {
|
_position.y = _bone[ AVATAR_BONE_RIGHT_FOOT ].radius;
|
||||||
if ( _position.y < _bone[ AVATAR_BONE_RIGHT_FOOT ].radius ) {
|
_velocity.y = 0.0;
|
||||||
_position.y = _bone[ AVATAR_BONE_RIGHT_FOOT ].radius;
|
|
||||||
_velocity.y = 0.0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -157,112 +157,108 @@ struct AvatarHead
|
||||||
|
|
||||||
|
|
||||||
class Avatar : public AvatarData {
|
class Avatar : public AvatarData {
|
||||||
public:
|
public:
|
||||||
Avatar(bool isMine);
|
Avatar(bool isMine);
|
||||||
~Avatar();
|
~Avatar();
|
||||||
Avatar(const Avatar &otherAvatar);
|
Avatar(const Avatar &otherAvatar);
|
||||||
Avatar* clone() const;
|
Avatar* clone() const;
|
||||||
|
|
||||||
|
void reset();
|
||||||
|
void UpdateGyros(float frametime, SerialInterface * serialInterface, glm::vec3 * gravity);
|
||||||
|
void setNoise (float mag) { _head.noise = mag; }
|
||||||
|
void setScale(float s) {_head.scale = s; };
|
||||||
|
void setRenderYaw(float y) {_renderYaw = y;}
|
||||||
|
void setRenderPitch(float p) {_renderPitch = p;}
|
||||||
|
float getRenderYaw() {return _renderYaw;}
|
||||||
|
float getRenderPitch() {return _renderPitch;}
|
||||||
|
void setLeanForward(float dist);
|
||||||
|
void setLeanSideways(float dist);
|
||||||
|
void addLean(float x, float z);
|
||||||
|
float getLastMeasuredHeadYaw() const {return _head.yawRate;}
|
||||||
|
float getBodyYaw() {return _bodyYaw;};
|
||||||
|
void addBodyYaw(float y) {_bodyYaw += y;};
|
||||||
|
|
||||||
|
const glm::vec3& getHeadLookatDirection() const { return _orientation.getFront(); };
|
||||||
|
const glm::vec3& getHeadLookatDirectionUp() const { return _orientation.getUp(); };
|
||||||
|
const glm::vec3& getHeadLookatDirectionRight() const { return _orientation.getRight(); };
|
||||||
|
const glm::vec3& getHeadPosition() const ;
|
||||||
|
const glm::vec3& getBonePosition(AvatarBoneID b) const { return _bone[b].position; };
|
||||||
|
const glm::vec3& getBodyUpDirection() const { return _orientation.getUp(); };
|
||||||
|
float getGirth();
|
||||||
|
float getHeight();
|
||||||
|
|
||||||
void reset();
|
AvatarMode getMode();
|
||||||
void UpdateGyros(float frametime, SerialInterface * serialInterface, glm::vec3 * gravity);
|
|
||||||
void setNoise (float mag) { _head.noise = mag; }
|
|
||||||
void setScale(float s) {_head.scale = s; };
|
|
||||||
void setRenderYaw(float y) {_renderYaw = y;}
|
|
||||||
void setRenderPitch(float p) {_renderPitch = p;}
|
|
||||||
float getRenderYaw() {return _renderYaw;}
|
|
||||||
float getRenderPitch() {return _renderPitch;}
|
|
||||||
void setLeanForward(float dist);
|
|
||||||
void setLeanSideways(float dist);
|
|
||||||
void addLean(float x, float z);
|
|
||||||
float getLastMeasuredHeadYaw() const {return _head.yawRate;}
|
|
||||||
float getBodyYaw() {return _bodyYaw;};
|
|
||||||
void addBodyYaw(float y) {_bodyYaw += y;};
|
|
||||||
|
|
||||||
const glm::vec3& getHeadLookatDirection() const { return _orientation.getFront(); };
|
void setMousePressed( bool pressed );
|
||||||
const glm::vec3& getHeadLookatDirectionUp() const { return _orientation.getUp(); };
|
void render(bool lookingInMirror);
|
||||||
const glm::vec3& getHeadLookatDirectionRight() const { return _orientation.getRight(); };
|
void renderBody();
|
||||||
const glm::vec3& getHeadPosition() const ;
|
void renderHead(bool lookingInMirror);
|
||||||
const glm::vec3& getBonePosition(AvatarBoneID b) const { return _bone[b].position; };
|
void simulate(float);
|
||||||
const glm::vec3& getBodyUpDirection() const { return _orientation.getUp(); };
|
void startHandMovement();
|
||||||
float getGirth();
|
void stopHandMovement();
|
||||||
float getHeight();
|
void setHandMovementValues( glm::vec3 movement );
|
||||||
|
void updateHandMovement( float deltaTime );
|
||||||
AvatarMode getMode();
|
void updateArmIKAndConstraints( float deltaTime );
|
||||||
|
|
||||||
void setMousePressed( bool pressed );
|
|
||||||
void render(bool lookingInMirror);
|
|
||||||
void renderBody();
|
|
||||||
void renderHead(bool lookingInMirror);
|
|
||||||
void simulate(float);
|
|
||||||
void startHandMovement();
|
|
||||||
void stopHandMovement();
|
|
||||||
void setHandMovementValues( glm::vec3 movement );
|
|
||||||
void updateHandMovement( float deltaTime );
|
|
||||||
void updateArmIKAndConstraints( float deltaTime );
|
|
||||||
|
|
||||||
float getAverageLoudness() {return _head.averageLoudness;};
|
|
||||||
void setAverageLoudness(float al) {_head.averageLoudness = al;};
|
|
||||||
|
|
||||||
void SetNewHeadTarget(float, float);
|
|
||||||
|
|
||||||
// Set what driving keys are being pressed to control thrust levels
|
float getAverageLoudness() {return _head.averageLoudness;};
|
||||||
void setDriveKeys(int key, bool val) { _driveKeys[key] = val; };
|
void setAverageLoudness(float al) {_head.averageLoudness = al;};
|
||||||
bool getDriveKeys(int key) { return _driveKeys[key]; };
|
|
||||||
|
void SetNewHeadTarget(float, float);
|
||||||
|
|
||||||
|
// Set what driving keys are being pressed to control thrust levels
|
||||||
|
void setDriveKeys(int key, bool val) { _driveKeys[key] = val; };
|
||||||
|
bool getDriveKeys(int key) { return _driveKeys[key]; };
|
||||||
|
|
||||||
|
// Set/Get update the thrust that will move the avatar around
|
||||||
|
void setThrust(glm::vec3 newThrust) { _thrust = newThrust; };
|
||||||
|
void addThrust(glm::vec3 newThrust) { _thrust += newThrust; };
|
||||||
|
glm::vec3 getThrust() { return _thrust; };
|
||||||
|
|
||||||
|
// Related to getting transmitter UDP data used to animate the avatar hand
|
||||||
|
void processTransmitterData(unsigned char * packetData, int numBytes);
|
||||||
|
float getTransmitterHz() { return _transmitterHz; };
|
||||||
|
|
||||||
|
private:
|
||||||
|
AvatarHead _head;
|
||||||
|
bool _isMine;
|
||||||
|
glm::vec3 _TEST_bigSpherePosition;
|
||||||
|
float _TEST_bigSphereRadius;
|
||||||
|
bool _mousePressed;
|
||||||
|
float _bodyYawDelta;
|
||||||
|
bool _usingBodySprings;
|
||||||
|
glm::vec3 _movedHandOffset;
|
||||||
|
float _springVelocityDecay;
|
||||||
|
float _springForce;
|
||||||
|
glm::quat _rotation; // the rotation of the avatar body as a whole expressed as a quaternion
|
||||||
|
AvatarBone _bone[ NUM_AVATAR_BONES ];
|
||||||
|
AvatarMode _mode;
|
||||||
|
AvatarHandHolding _handHolding;
|
||||||
|
glm::dvec3 _velocity;
|
||||||
|
glm::vec3 _thrust;
|
||||||
|
float _maxArmLength;
|
||||||
|
Orientation _orientation;
|
||||||
|
int _driveKeys[MAX_DRIVE_KEYS];
|
||||||
|
GLUquadric* _sphere;
|
||||||
|
float _renderYaw;
|
||||||
|
float _renderPitch; // Pitch from view frustum when this is own head
|
||||||
|
timeval _transmitterTimer;
|
||||||
|
float _transmitterHz;
|
||||||
|
int _transmitterPackets;
|
||||||
|
Avatar* _interactingOther;
|
||||||
|
bool _interactingOtherIsNearby;
|
||||||
|
|
||||||
// Set/Get update the thrust that will move the avatar around
|
void initializeSkeleton();
|
||||||
void setThrust(glm::vec3 newThrust) { _thrust = newThrust; };
|
void updateSkeleton();
|
||||||
void addThrust(glm::vec3 newThrust) { _thrust += newThrust; };
|
void initializeBodySprings();
|
||||||
glm::vec3 getThrust() { return _thrust; };
|
void updateBodySprings( float deltaTime );
|
||||||
|
void calculateBoneLengths();
|
||||||
// Related to getting transmitter UDP data used to animate the avatar hand
|
void readSensors();
|
||||||
void processTransmitterData(unsigned char * packetData, int numBytes);
|
void renderBoneAsBlock( AvatarBoneID b );
|
||||||
float getTransmitterHz() { return _transmitterHz; };
|
void updateAvatarCollisionDetectionAndResponse(glm::vec3 collisionPosition,
|
||||||
|
float collisionGirth,
|
||||||
private:
|
float collisionHeight,
|
||||||
AvatarHead _head;
|
glm::vec3 collisionUpVector,
|
||||||
bool _isMine;
|
float deltaTime);
|
||||||
glm::vec3 _TEST_bigSpherePosition;
|
|
||||||
float _TEST_bigSphereRadius;
|
|
||||||
bool _mousePressed;
|
|
||||||
float _bodyYawDelta;
|
|
||||||
bool _usingBodySprings;
|
|
||||||
glm::vec3 _movedHandOffset;
|
|
||||||
float _springVelocityDecay;
|
|
||||||
float _springForce;
|
|
||||||
glm::quat _rotation; // the rotation of the avatar body as a whole expressed as a quaternion
|
|
||||||
AvatarBone _bone[ NUM_AVATAR_BONES ];
|
|
||||||
AvatarMode _mode;
|
|
||||||
AvatarHandHolding _handHolding;
|
|
||||||
glm::dvec3 _velocity;
|
|
||||||
glm::vec3 _thrust;
|
|
||||||
float _maxArmLength;
|
|
||||||
Orientation _orientation;
|
|
||||||
int _driveKeys[MAX_DRIVE_KEYS];
|
|
||||||
GLUquadric* _sphere;
|
|
||||||
float _renderYaw;
|
|
||||||
float _renderPitch; // Pitch from view frustum when this is own head
|
|
||||||
timeval _transmitterTimer;
|
|
||||||
float _transmitterHz;
|
|
||||||
int _transmitterPackets;
|
|
||||||
Avatar* _interactingOther;
|
|
||||||
bool _interactingOtherIsNearby;
|
|
||||||
|
|
||||||
// private methods...
|
|
||||||
void initializeSkeleton();
|
|
||||||
void updateSkeleton();
|
|
||||||
void initializeBodySprings();
|
|
||||||
void updateBodySprings( float deltaTime );
|
|
||||||
void calculateBoneLengths();
|
|
||||||
void readSensors();
|
|
||||||
void renderBoneAsBlock( AvatarBoneID b );
|
|
||||||
void updateAvatarCollisionDetectionAndResponse
|
|
||||||
(
|
|
||||||
glm::vec3 collisionPosition,
|
|
||||||
float collisionGirth,
|
|
||||||
float collisionHeight,
|
|
||||||
glm::vec3 collisionUpVector,
|
|
||||||
float deltaTime
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue