72 for (
auto i = 0; i <
engine->
getGUI()->getMouseEvents().size(); i++) {
74 if (event.isProcessed() ==
true)
continue;
77 auto xMoved = (
event.getX() -
mouseLastX) / 5.0f;
78 auto yMoved = (
event.getY() -
mouseLastY) / 5.0f;
83 auto xRotationAngle = xRotation.
getAngle() + xMoved;
84 auto yRotationAngle = yRotation.getAngle() + yMoved;
85 xRotation.setAngle(xRotationAngle);
86 yRotation.setAngle(yRotationAngle);
98 auto mouseWheel =
event.getWheelY();
99 if (mouseWheel != 0) {
100 scale += -mouseWheel * 0.1f;
107 if (event.isProcessed() ==
true)
continue;
108 if (event.getType() == GUIKeyboardEvent::KEYBOARDEVENT_KEY_TYPED)
continue;
109 auto isKeyDown =
event.getType() == GUIKeyboardEvent::KEYBOARDEVENT_KEY_PRESSED;
110 if (event.getKeyCode() == GUIKeyboardEvent::KEYCODE_LEFT)
113 if (event.getKeyCode() == GUIKeyboardEvent::KEYCODE_RIGHT)
116 if (event.getKeyCode() == GUIKeyboardEvent::KEYCODE_UP)
119 if (event.getKeyCode() == GUIKeyboardEvent::KEYCODE_DOWN)
122 if (Character::toLowerCase(event.getKeyChar()) ==
'.')
125 if (Character::toLowerCase(event.getKeyChar()) ==
',')
128 if (Character::toLowerCase(event.getKeyChar()) ==
'+')
131 if (Character::toLowerCase(event.getKeyChar()) ==
'-')
134 if (Character::toLowerCase(event.getKeyChar()) ==
'r')
146 if (
keyRight ==
true) rotationX.setAngle(rotationX.getAngle() + 1.0f);
147 if (
keyUp ==
true) rotationY.setAngle(rotationY.getAngle() + 1.0f);
148 if (
keyDown ==
true) rotationY.setAngle(rotationY.getAngle() - 1.0f);
149 if (
keyComma ==
true) rotationZ.setAngle(rotationZ.getAngle() - 1.0f);
150 if (
keyPeriod ==
true) rotationZ.setAngle(rotationZ.getAngle() + 1.0f);
163 rotationY.setAngle(-45.0f);
164 rotationZ.setAngle(0.0f);
176 if (entity !=
nullptr) {
183 if (entity !=
nullptr) {
184 auto entityBoundingBoxTransformed = entity->getBoundingBoxTransformed();
185 for (
auto i = 0; i < 3; i++) {
192 lookAt.set(0.0f, 0.0f, 0.0f);
196 Vector3 forwardVector(0.0f, 0.0f, 1.0f);
199 auto lookFrom = lookAt.
clone().
add(forwardVectorTransformed);
200 cam->setLookFrom(lookFrom);
201 cam->setLookAt(lookAt);
202 cam->setUpVector(upVector);
const Vector3 & getLookAt() const
Entity * getEntity(const string &id)
Returns a entity by given id.
void setAngle(const float angle)
const Quaternion & getQuaternion() const
const float getAngle() const
const Vector3 & getCenter() const
void update()
Updates this bounding box.
vector< GUIMouseEvent > & getMouseEvents()
vector< GUIKeyboardEvent > & getKeyboardEvents()
Vector3 multiply(const Vector3 &v) const
Multiplies a vector3 with this matrix into destination vector.
Quaternion & multiply(const Quaternion q)
Multiplies this quaternion with quaternion q.
Quaternion & normalize()
Normalize quaternion.
Quaternion clone() const
Clones the quaternion.
Quaternion & add(const Quaternion &q)
Adds given quaternion q to this quaternion.
Vector3 & scale(float scale)
Scale this vector.