Skip to content

Commit 1f49f15

Browse files
committed
Merge branch 'release' of https://github.com/uic-evl/omegalib into release
2 parents 673fb4d + 69ff07a commit 1f49f15

File tree

3 files changed

+57
-16
lines changed

3 files changed

+57
-16
lines changed

include/omega/GamepadCameraController.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,15 @@ namespace omega {
5757
float myStrafeMultiplier;
5858
float myYawMultiplier;
5959
float myPitchMultiplier;
60-
60+
float myRollMultiplier;
6161
Vector3f mySpeedVector;
6262
float myYaw;
6363
float myPitch;
64+
float myRoll;
65+
bool goingUp;
66+
bool goingDown;
67+
bool deaccelerate;
68+
bool accelerate;
6469
Quaternion myTorque;
6570
};
6671

include/version.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#define __OMEGA_VERSION_
33

44
#define OMEGA_VERSION_MAJOR 7
5-
#define OMEGA_VERSION_MINOR 0
6-
#define OMEGA_VERSION_REVISION 1
5+
#define OMEGA_VERSION_MINOR 1
6+
#define OMEGA_VERSION_REVISION 0
77

88
#define _VSTH(v) #v
99
#define _VERSTR(v) _VSTH(v)

src/omega/GamepadCameraController.cpp

Lines changed: 49 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,20 @@
3939
using namespace omega;
4040

4141
///////////////////////////////////////////////////////////////////////////////
42-
GamepadCameraController::GamepadCameraController():
43-
myStrafeMultiplier(1.0f),
44-
myYawMultiplier(-1.0f),
45-
myPitchMultiplier(1.0f),
46-
mySpeedVector(Vector3f::Zero()),
47-
myTorque(Quaternion::Identity()),
48-
myPitch(0),
49-
myYaw(0)
42+
GamepadCameraController::GamepadCameraController() :
43+
myStrafeMultiplier(1.0f),
44+
myYawMultiplier(-1.0f),
45+
myPitchMultiplier(1.0f),
46+
myRollMultiplier(-1.0f),
47+
mySpeedVector(Vector3f::Zero()),
48+
myTorque(Quaternion::Identity()),
49+
myPitch(0),
50+
myYaw(0),
51+
myRoll(0),
52+
goingDown(false),
53+
goingUp(false),
54+
accelerate(false),
55+
deaccelerate(false)
5056
{
5157
}
5258

@@ -58,29 +64,59 @@ void GamepadCameraController::handleEvent(const Event& evt)
5864
{
5965
float x = evt.getExtraDataFloat(0);
6066
float y = evt.getExtraDataFloat(1);
61-
float z = evt.getExtraDataFloat(4);
67+
float roll = evt.getExtraDataFloat(5) - evt.getExtraDataFloat(4);
6268
float yaw = evt.getExtraDataFloat(2);
6369
float pitch = evt.getExtraDataFloat(3);
70+
if (evt.isButtonDown(omicron::EventBase::ButtonUp))
71+
goingUp = true;
72+
if (evt.isButtonDown(omicron::EventBase::ButtonDown))
73+
goingDown = true;
74+
if (evt.isButtonUp(omicron::EventBase::ButtonUp))
75+
goingUp = false;
76+
if (evt.isButtonUp(omicron::EventBase::ButtonDown))
77+
goingDown = false;
78+
if (evt.isButtonDown(omicron::EventBase::Button8))
79+
accelerate = true;
80+
if (evt.isButtonDown(omicron::EventBase::Button5))
81+
deaccelerate = true;
82+
if (evt.isButtonUp(omicron::EventBase::Button8))
83+
accelerate = false;
84+
if (evt.isButtonUp(omicron::EventBase::Button5))
85+
deaccelerate = false;
86+
87+
float z = 0;
88+
float speedModifier = 1.0f;
6489
float tresh = 0.2f;
6590

91+
if (goingUp)
92+
z += 2 * tresh;
93+
if (goingDown)
94+
z -= 2 * tresh;
95+
if (accelerate)
96+
speedModifier *= 64;
97+
if (deaccelerate)
98+
speedModifier /= 64;
6699
if(abs(x) < tresh) x = 0;
67100
if(abs(y) < tresh) y = 0;
68101
if(abs(z) < tresh) z = 0;
69102
if(abs(yaw) < tresh) yaw = 0;
70103
if(abs(pitch) < tresh) pitch = 0;
71-
104+
if (abs(roll) < tresh) roll = 0;
105+
72106
myYaw = yaw * myYawMultiplier;
73107
if(myFreeFlyEnabled)
74108
{
75109
myPitch = pitch * myPitchMultiplier;
110+
myRoll = roll * myRollMultiplier;
76111
}
77112
else
78113
{
79114
// If freefly is disabled and trigger is pressed, pitch control is
80115
// used to move camera up/down
81116
if(z != 0) z = pitch;
117+
speedModifier = 1;
82118
}
83-
mySpeedVector = Vector3f(x, z, y) * CameraController::mySpeed;
119+
mySpeedVector = Vector3f(x*speedModifier, z*speedModifier, y*speedModifier) * CameraController::mySpeed;
84120
}
85121
}
86122

@@ -95,7 +131,7 @@ void GamepadCameraController::update(const UpdateContext& context)
95131
Vector3f mv = mySpeedVector * context.dt;
96132
// The movement vector is oriented based on Camera AND Head orientation
97133
// To make it work reasonably well when using an untracked controller
98-
// in a head-tracked environment (we want 'forward' to be the direction
134+
// in a head-trackeAd environment (we want 'forward' to be the direction
99135
// the user is looking at).
100136
Quaternion o = c->getOrientation() * c->getHeadOrientation();
101137
mv = o * mv;
@@ -106,7 +142,7 @@ void GamepadCameraController::update(const UpdateContext& context)
106142
}
107143

108144
c->translate(mv, Node::TransformWorld);
109-
Vector3f pyr(myPitch * context.dt, myYaw * context.dt, 0);
145+
Vector3f pyr(myPitch * context.dt, myYaw * context.dt, myRoll * context.dt);
110146
c->rotate(Math::quaternionFromEuler(pyr), Node::TransformLocal);
111147
}
112148
}

0 commit comments

Comments
 (0)