30 camLookRotationX(
Vector3(1.0f, 0.0f, 0.0f), -45.0f),
31 camLookRotationY(
Vector3(0.0f, 1.0f, 0.0f), 0.0f)
52 for (
auto i = 0; i <
engine->
getGUI()->getKeyboardEvents().size(); i++) {
54 if (event.isProcessed() ==
true)
continue;
55 if (event.getType() == GUIKeyboardEvent::KEYBOARDEVENT_KEY_TYPED)
continue;
56 auto isKeyDown =
event.getType() == GUIKeyboardEvent::KEYBOARDEVENT_KEY_PRESSED;
59 if (event.getKeyCode() == GUIKeyboardEvent::KEYCODE_LEFT) {
61 event.setProcessed(
true);
63 if (event.getKeyCode() == GUIKeyboardEvent::KEYCODE_RIGHT) {
65 event.setProcessed(
true);
67 if (event.getKeyCode() == GUIKeyboardEvent::KEYCODE_UP) {
69 event.setProcessed(
true);
71 if (event.getKeyCode() == GUIKeyboardEvent::KEYCODE_DOWN) {
73 event.setProcessed(
true);
75 if (Character::toLowerCase(event.getKeyChar()) ==
'a') {
77 event.setProcessed(
true);
79 if (Character::toLowerCase(event.getKeyChar()) ==
'd') {
81 event.setProcessed(
true);
83 if (Character::toLowerCase(event.getKeyChar()) ==
'w') {
85 event.setProcessed(
true);
87 if (Character::toLowerCase(event.getKeyChar()) ==
's') {
89 event.setProcessed(
true);
91 if (Character::toLowerCase(event.getKeyChar()) ==
'+') {
93 event.setProcessed(
true);
95 if (Character::toLowerCase(event.getKeyChar()) ==
'-') {
97 event.setProcessed(
true);
99 if (Character::toLowerCase(event.getKeyChar()) ==
'r') {
101 event.setProcessed(
true);
107 for (
auto i = 0; i <
engine->
getGUI()->getMouseEvents().size(); i++) {
110 if (event.isProcessed() ==
true)
continue;
112 if (event.getType() == GUIMouseEvent::MOUSEEVENT_DRAGGED) {
117 event.setProcessed(
true);
124 event.setProcessed(
true);
132 event.setProcessed(
true);
139 event.setProcessed(
true);
142 if (event.getType() == GUIMouseEvent::MOUSEEVENT_RELEASED) {
149 event.setProcessed(
true);
151 auto mouseWheel =
event.getWheelY();
152 if (mouseWheel != 0) {
156 event.setProcessed(
true);
213 Vector3 forwardVector(0.0f, 0.0f, 1.0f);
214 Vector3 sideVector(1.0f, 0.0f, 0.0f);
217 auto camLookAtToFromVector = forwardVectorTransformed.
clone().
scale(
camScale * 10.0f);
221 auto camLookAt = cam->getLookAt();
222 if (
keyUp ==
true) camLookAt.
sub(forwardVectorTransformed.set(camForwardVector).scale(0.1f));
223 if (
keyDown ==
true) camLookAt.
add(forwardVectorTransformed.set(camForwardVector).scale(0.1f));
224 if (
keyLeft ==
true) camLookAt.
sub(forwardVectorTransformed.set(camSideVector).scale(0.1f));
225 if (
keyRight ==
true) camLookAt.
add(forwardVectorTransformed.set(camSideVector).scale(0.1f));
227 camLookAt.
sub(forwardVectorTransformed.set(camForwardVector).scale(mousePanningForward / 15.0f));
232 camLookAt.sub(forwardVectorTransformed.set(camSideVector).scale(mousePanningSide / 15.0f));
236 cam->setLookAt(camLookAt);
237 cam->setLookFrom(cam->getLookAt().clone().add(camLookAtToFromVector));
238 cam->setUpVector(cam->computeUpVector(cam->getLookFrom(), cam->getLookAt()));
void setAngle(const float angle)
const Quaternion & getQuaternion() const
void update()
Computes rotation matrix.
const float getAngle() const
int64_t getDeltaTime()
Gets the time passed between last and current frame.
vector< GUIMouseEvent > & getMouseEvents()
vector< GUIKeyboardEvent > & getKeyboardEvents()
Quaternion & multiply(const Quaternion q)
Multiplies this quaternion with quaternion q.
Quaternion clone() const
Clones the quaternion.
Quaternion & scale(float value)
Scales this quaternion with given value.
Quaternion & sub(const Quaternion &q)
Subtracts given quaternion q from this quaternion.
Quaternion & add(const Quaternion &q)
Adds given quaternion q to this quaternion.