mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 23:49:55 +02:00
Added hand movement and body motion to transmitter. Feel much better - like dancing.
This commit is contained in:
parent
0d7644d1fc
commit
3539ec858e
4 changed files with 41 additions and 9 deletions
|
@ -849,7 +849,7 @@ void Application::idle() {
|
||||||
timeval check;
|
timeval check;
|
||||||
gettimeofday(&check, NULL);
|
gettimeofday(&check, NULL);
|
||||||
|
|
||||||
// Only run simulation code if more than IDLE_SIMULATE_MSECS have passed since last time
|
// Only run simulation code if more than IDLE_SIMULATE_MSECS have passed since last time we ran
|
||||||
|
|
||||||
if (diffclock(&_lastTimeIdle, &check) > IDLE_SIMULATE_MSECS) {
|
if (diffclock(&_lastTimeIdle, &check) > IDLE_SIMULATE_MSECS) {
|
||||||
|
|
||||||
|
@ -857,8 +857,10 @@ void Application::idle() {
|
||||||
|
|
||||||
// Use Transmitter Hand to move hand if connected, else use mouse
|
// Use Transmitter Hand to move hand if connected, else use mouse
|
||||||
if (_myTransmitter.isConnected()) {
|
if (_myTransmitter.isConnected()) {
|
||||||
const float HAND_FORCE_SCALING = 0.05f;
|
const float HAND_FORCE_SCALING = 0.01f;
|
||||||
_myAvatar.setMovedHandOffset(_myTransmitter.getLastAcceleration() * HAND_FORCE_SCALING);
|
glm::vec3 estimatedRotation = _myTransmitter.getEstimatedRotation();
|
||||||
|
glm::vec3 handForce(-estimatedRotation.z, -estimatedRotation.x, estimatedRotation.y);
|
||||||
|
_myAvatar.setMovedHandOffset(handForce * HAND_FORCE_SCALING);
|
||||||
} else {
|
} else {
|
||||||
// update behaviors for avatar hand movement: handControl takes mouse values as input,
|
// update behaviors for avatar hand movement: handControl takes mouse values as input,
|
||||||
// and gives back 3D values modulated for smooth transitioning between interaction modes.
|
// and gives back 3D values modulated for smooth transitioning between interaction modes.
|
||||||
|
@ -964,20 +966,26 @@ void Application::idle() {
|
||||||
networkReceive(0);
|
networkReceive(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//loop through all the remote avatars and simulate them...
|
//loop through all the other avatars and simulate them...
|
||||||
AgentList* agentList = AgentList::getInstance();
|
AgentList* agentList = AgentList::getInstance();
|
||||||
agentList->lock();
|
agentList->lock();
|
||||||
for(AgentList::iterator agent = agentList->begin(); agent != agentList->end(); agent++) {
|
for(AgentList::iterator agent = agentList->begin(); agent != agentList->end(); agent++) {
|
||||||
if (agent->getLinkedData() != NULL) {
|
if (agent->getLinkedData() != NULL) {
|
||||||
Avatar *avatar = (Avatar *)agent->getLinkedData();
|
Avatar *avatar = (Avatar *)agent->getLinkedData();
|
||||||
avatar->simulate(deltaTime);
|
avatar->simulate(deltaTime, false);
|
||||||
avatar->setMouseRay(mouseRayOrigin, mouseRayDirection);
|
avatar->setMouseRay(mouseRayOrigin, mouseRayDirection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
agentList->unlock();
|
agentList->unlock();
|
||||||
|
|
||||||
|
// Simulate myself
|
||||||
_myAvatar.setGravity(getGravity(_myAvatar.getPosition()));
|
_myAvatar.setGravity(getGravity(_myAvatar.getPosition()));
|
||||||
_myAvatar.simulate(deltaTime);
|
if (_transmitterDrives->isChecked() && _myTransmitter.isConnected()) {
|
||||||
|
_myAvatar.simulate(deltaTime, &_myTransmitter);
|
||||||
|
} else {
|
||||||
|
_myAvatar.simulate(deltaTime, NULL);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Update audio stats for procedural sounds
|
// Update audio stats for procedural sounds
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
|
@ -1204,6 +1212,9 @@ void Application::initMenu() {
|
||||||
_gyroLook->setChecked(true);
|
_gyroLook->setChecked(true);
|
||||||
(_mouseLook = optionsMenu->addAction("Mouse Look"))->setCheckable(true);
|
(_mouseLook = optionsMenu->addAction("Mouse Look"))->setCheckable(true);
|
||||||
_mouseLook->setChecked(false);
|
_mouseLook->setChecked(false);
|
||||||
|
(_transmitterDrives = optionsMenu->addAction("Transmitter Drive"))->setCheckable(true);
|
||||||
|
_transmitterDrives->setChecked(true);
|
||||||
|
|
||||||
optionsMenu->addAction("Fullscreen", this, SLOT(setFullscreen(bool)), Qt::Key_F)->setCheckable(true);
|
optionsMenu->addAction("Fullscreen", this, SLOT(setFullscreen(bool)), Qt::Key_F)->setCheckable(true);
|
||||||
|
|
||||||
QMenu* renderMenu = menuBar->addMenu("Render");
|
QMenu* renderMenu = menuBar->addMenu("Render");
|
||||||
|
@ -2055,6 +2066,7 @@ void Application::resetSensors() {
|
||||||
}
|
}
|
||||||
QCursor::setPos(_headMouseX, _headMouseY);
|
QCursor::setPos(_headMouseX, _headMouseY);
|
||||||
_myAvatar.reset();
|
_myAvatar.reset();
|
||||||
|
_myTransmitter.resetLevels();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setShortcutsEnabled(QWidget* widget, bool enabled) {
|
static void setShortcutsEnabled(QWidget* widget, bool enabled) {
|
||||||
|
|
|
@ -134,6 +134,7 @@ private:
|
||||||
QAction* _lookingInMirror; // Are we currently rendering one's own head as if in mirror?
|
QAction* _lookingInMirror; // Are we currently rendering one's own head as if in mirror?
|
||||||
QAction* _gyroLook; // Whether to allow the gyro data from head to move your view
|
QAction* _gyroLook; // Whether to allow the gyro data from head to move your view
|
||||||
QAction* _mouseLook; // Whether the have the mouse near edge of screen move your view
|
QAction* _mouseLook; // Whether the have the mouse near edge of screen move your view
|
||||||
|
QAction* _transmitterDrives; // Whether to have Transmitter data move/steer the Avatar
|
||||||
QAction* _renderVoxels; // Whether to render voxels
|
QAction* _renderVoxels; // Whether to render voxels
|
||||||
QAction* _renderVoxelTextures; // Whether to render noise textures on voxels
|
QAction* _renderVoxelTextures; // Whether to render noise textures on voxels
|
||||||
QAction* _renderStarsOn; // Whether to display the stars
|
QAction* _renderStarsOn; // Whether to display the stars
|
||||||
|
|
|
@ -209,7 +209,7 @@ void Avatar::updateFromMouse(int mouseX, int mouseY, int screenWidth, int scree
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Avatar::simulate(float deltaTime) {
|
void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
||||||
|
|
||||||
//figure out if the mouse cursor is over any body spheres...
|
//figure out if the mouse cursor is over any body spheres...
|
||||||
if (_isMine) {
|
if (_isMine) {
|
||||||
|
@ -259,6 +259,7 @@ void Avatar::simulate(float deltaTime) {
|
||||||
|
|
||||||
_thrust = glm::vec3(0.0f, 0.0f, 0.0f);
|
_thrust = glm::vec3(0.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
|
// Add Thrusts from keyboard
|
||||||
if (_driveKeys[FWD ]) {_thrust += THRUST_MAG * deltaTime * _orientation.getFront();}
|
if (_driveKeys[FWD ]) {_thrust += THRUST_MAG * deltaTime * _orientation.getFront();}
|
||||||
if (_driveKeys[BACK ]) {_thrust -= THRUST_MAG * deltaTime * _orientation.getFront();}
|
if (_driveKeys[BACK ]) {_thrust -= THRUST_MAG * deltaTime * _orientation.getFront();}
|
||||||
if (_driveKeys[RIGHT ]) {_thrust += THRUST_MAG * deltaTime * _orientation.getRight();}
|
if (_driveKeys[RIGHT ]) {_thrust += THRUST_MAG * deltaTime * _orientation.getRight();}
|
||||||
|
@ -267,6 +268,24 @@ void Avatar::simulate(float deltaTime) {
|
||||||
if (_driveKeys[DOWN ]) {_thrust -= THRUST_MAG * deltaTime * _orientation.getUp();}
|
if (_driveKeys[DOWN ]) {_thrust -= THRUST_MAG * deltaTime * _orientation.getUp();}
|
||||||
if (_driveKeys[ROT_RIGHT]) {_bodyYawDelta -= YAW_MAG * deltaTime;}
|
if (_driveKeys[ROT_RIGHT]) {_bodyYawDelta -= YAW_MAG * deltaTime;}
|
||||||
if (_driveKeys[ROT_LEFT ]) {_bodyYawDelta += YAW_MAG * deltaTime;}
|
if (_driveKeys[ROT_LEFT ]) {_bodyYawDelta += YAW_MAG * deltaTime;}
|
||||||
|
|
||||||
|
// Add thrusts from Transmitter
|
||||||
|
if (transmitter) {
|
||||||
|
glm::vec3 rotation = transmitter->getEstimatedRotation();
|
||||||
|
const float TRANSMITTER_MIN_RATE = 1.f;
|
||||||
|
const float TRANSMITTER_LATERAL_FORCE_SCALE = 25.f;
|
||||||
|
const float TRANSMITTER_FWD_FORCE_SCALE = 50.f;
|
||||||
|
const float TRANSMITTER_YAW_SCALE = 7.0f;
|
||||||
|
if (fabs(rotation.z) > TRANSMITTER_MIN_RATE) {
|
||||||
|
_thrust += rotation.z * TRANSMITTER_LATERAL_FORCE_SCALE * deltaTime * _orientation.getRight();
|
||||||
|
}
|
||||||
|
if (fabs(rotation.x) > TRANSMITTER_MIN_RATE) {
|
||||||
|
_thrust += -rotation.x * TRANSMITTER_FWD_FORCE_SCALE * deltaTime * _orientation.getFront();
|
||||||
|
}
|
||||||
|
if (fabs(rotation.y) > TRANSMITTER_MIN_RATE) {
|
||||||
|
_bodyYawDelta += rotation.y * TRANSMITTER_YAW_SCALE * deltaTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// update body yaw by body yaw delta
|
// update body yaw by body yaw delta
|
||||||
|
|
|
@ -110,7 +110,7 @@ public:
|
||||||
void setMousePressed(bool pressed);
|
void setMousePressed(bool pressed);
|
||||||
void render(bool lookingInMirror, glm::vec3 cameraPosition);
|
void render(bool lookingInMirror, glm::vec3 cameraPosition);
|
||||||
void renderBody(bool lookingInMirror);
|
void renderBody(bool lookingInMirror);
|
||||||
void simulate(float);
|
void simulate(float deltaTime, Transmitter* transmitter);
|
||||||
void setMovedHandOffset(glm::vec3 movedHandOffset) { _movedHandOffset = movedHandOffset; }
|
void setMovedHandOffset(glm::vec3 movedHandOffset) { _movedHandOffset = movedHandOffset; }
|
||||||
void updateArmIKAndConstraints( float deltaTime );
|
void updateArmIKAndConstraints( float deltaTime );
|
||||||
void setDisplayingHead( bool displayingHead );
|
void setDisplayingHead( bool displayingHead );
|
||||||
|
|
Loading…
Reference in a new issue