mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-24 13:05:27 +02:00
Added mouse panning in the Yaw direction - at edges of screen.
This commit is contained in:
parent
62a97f23bf
commit
6cfdf96dea
3 changed files with 30 additions and 7 deletions
|
@ -859,6 +859,9 @@ void Application::idle() {
|
||||||
_handControl.stop();
|
_handControl.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update from Mouse
|
||||||
|
_myAvatar.updateFromMouse(_mouseX, _mouseY, _glWidget->width(), _glWidget->height());
|
||||||
|
|
||||||
// Read serial port interface devices
|
// Read serial port interface devices
|
||||||
if (_serialPort.active) {
|
if (_serialPort.active) {
|
||||||
_serialPort.readData();
|
_serialPort.readData();
|
||||||
|
@ -1162,8 +1165,8 @@ void Application::init() {
|
||||||
|
|
||||||
_handControl.setScreenDimensions(_glWidget->width(), _glWidget->height());
|
_handControl.setScreenDimensions(_glWidget->width(), _glWidget->height());
|
||||||
|
|
||||||
_headMouseX = _glWidget->width()/2;
|
_headMouseX = _mouseX = _glWidget->width() / 2;
|
||||||
_headMouseY = _glWidget->height()/2;
|
_headMouseY = _mouseY = _glWidget->height() / 2;
|
||||||
|
|
||||||
_stars.readInput(STAR_FILE, STAR_CACHE_FILE, 0);
|
_stars.readInput(STAR_FILE, STAR_CACHE_FILE, 0);
|
||||||
|
|
||||||
|
@ -1173,7 +1176,9 @@ void Application::init() {
|
||||||
a.distance = 1.5f;
|
a.distance = 1.5f;
|
||||||
a.tightness = 8.0f;
|
a.tightness = 8.0f;
|
||||||
_myCamera.setMode(CAMERA_MODE_THIRD_PERSON, a);
|
_myCamera.setMode(CAMERA_MODE_THIRD_PERSON, a);
|
||||||
_myAvatar.setDisplayingHead(true);
|
_myAvatar.setDisplayingHead(true);
|
||||||
|
|
||||||
|
QCursor::setPos(_headMouseX, _headMouseY);
|
||||||
|
|
||||||
OculusManager::connect();
|
OculusManager::connect();
|
||||||
|
|
||||||
|
@ -1228,7 +1233,6 @@ void Application::updateAvatar(float deltaTime) {
|
||||||
renderPitchSpring * deltaTime * -_myAvatar.getHeadPitch() * RENDER_PITCH_MULTIPLY);
|
renderPitchSpring * deltaTime * -_myAvatar.getHeadPitch() * RENDER_PITCH_MULTIPLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (OculusManager::isConnected()) {
|
if (OculusManager::isConnected()) {
|
||||||
float yaw, pitch, roll;
|
float yaw, pitch, roll;
|
||||||
OculusManager::getEulerAngles(yaw, pitch, roll);
|
OculusManager::getEulerAngles(yaw, pitch, roll);
|
||||||
|
@ -1900,12 +1904,13 @@ void Application::deleteVoxelUnderCursor() {
|
||||||
|
|
||||||
void Application::resetSensors() {
|
void Application::resetSensors() {
|
||||||
_myAvatar.setPosition(START_LOCATION);
|
_myAvatar.setPosition(START_LOCATION);
|
||||||
_headMouseX = _glWidget->width() / 2;
|
_headMouseX = _mouseX = _glWidget->width() / 2;
|
||||||
_headMouseY = _glWidget->height() / 2;
|
_headMouseY = _mouseY = _glWidget->height() / 2;
|
||||||
|
|
||||||
if (_serialPort.active) {
|
if (_serialPort.active) {
|
||||||
_serialPort.resetAverages();
|
_serialPort.resetAverages();
|
||||||
}
|
}
|
||||||
|
QCursor::setPos(_headMouseX, _headMouseY);
|
||||||
_myAvatar.reset();
|
_myAvatar.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -291,6 +291,23 @@ bool Avatar::getIsNearInteractingOther() {
|
||||||
return _avatarTouch.getAbleToReachOtherAvatar();
|
return _avatarTouch.getAbleToReachOtherAvatar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Avatar::updateFromMouse(int mouseX, int mouseY, int screenWidth, int screenHeight) {
|
||||||
|
// Update pitch and yaw based on mouse behavior
|
||||||
|
const float MOUSE_MOVE_RADIUS = 0.25f;
|
||||||
|
const float MOUSE_ROTATE_SPEED = 7.5f;
|
||||||
|
float mouseLocationX = (float)mouseX / (float)screenWidth - 0.5f;
|
||||||
|
|
||||||
|
if (fabs(mouseLocationX) > MOUSE_MOVE_RADIUS) {
|
||||||
|
float mouseMag = (fabs(mouseLocationX) - MOUSE_MOVE_RADIUS) / (0.5f - MOUSE_MOVE_RADIUS) * MOUSE_ROTATE_SPEED;
|
||||||
|
setBodyYaw(getBodyYaw() -
|
||||||
|
((mouseLocationX > 0.f) ?
|
||||||
|
mouseMag :
|
||||||
|
-mouseMag) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
void Avatar::simulate(float deltaTime) {
|
void Avatar::simulate(float deltaTime) {
|
||||||
|
|
||||||
//figure out if the mouse cursor is over any body spheres...
|
//figure out if the mouse cursor is over any body spheres...
|
||||||
|
|
|
@ -82,6 +82,7 @@ public:
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
void updateHeadFromGyros(float frametime, SerialInterface * serialInterface, glm::vec3 * gravity);
|
void updateHeadFromGyros(float frametime, SerialInterface * serialInterface, glm::vec3 * gravity);
|
||||||
|
void updateFromMouse(int mouseX, int mouseY, int screenWidth, int screenHeight);
|
||||||
void setNoise (float mag) {_head.noise = mag;}
|
void setNoise (float mag) {_head.noise = mag;}
|
||||||
void setRenderYaw(float y) {_renderYaw = y;}
|
void setRenderYaw(float y) {_renderYaw = y;}
|
||||||
void setRenderPitch(float p) {_renderPitch = p;}
|
void setRenderPitch(float p) {_renderPitch = p;}
|
||||||
|
|
Loading…
Reference in a new issue