72 auto rotation =
false;
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);
99 auto mouseWheel =
event.getWheelY();
100 if (mouseWheel != 0) {
101 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) {
187 lookAt.set(0.0f, 0.0f, 0.0f);
191 Vector3 forwardVector(0.0f, 0.0f, 1.0f);
194 auto lookFrom = lookAt.
clone().
add(forwardVectorTransformed);
195 cam->setLookFrom(lookFrom);
196 cam->setLookAt(lookAt);
197 cam->setUpVector(upVector);
202 if ((rotation ==
true ||
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
vector< GUIMouseEvent > & getMouseEvents()
vector< GUIKeyboardEvent > & getKeyboardEvents()
Matrix4x4 class representing matrix4x4 mathematical structure and operations for 3d space.
Vector3 multiply(const Vector3 &vector3) const
Multiplies this matrix with vector3.
Quaternion class representing quaternion mathematical structure and operations with x,...
Quaternion & add(const Quaternion &quaternion)
Adds quaternion.
Quaternion & multiply(const Quaternion quaternion)
Multiplies this quaternion with given quaternion.
Quaternion clone() const
Clones this quaternion.
Quaternion & normalize()
Normalizes this quaternion.
Vector3 class representing vector3 mathematical structure and operations with x, y,...
Vector3 & scale(float scalar)
Scales by scalar.