Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (Keyboard::isPressed(GLFW_KEY_T))
- {
- is3rdPerson = true;
- }
- else
- {
- is3rdPerson = false;
- }
- if (Keyboard::isPressed(GLFW_KEY_LEFT_CONTROL))
- {
- posZ = posZ - speed;
- }
- if (Keyboard::isPressed(GLFW_KEY_SPACE))
- {
- posZ = posZ + speed;
- }
- // zmiana parametrow kamery w czasie ruchu
- if (is3rdPerson)
- {
- float rotX = (float)cos(rotate * 3.14 / 180) * 1.4f;
- float rotY = (float)sin(rotate * 3.14 / 180) * 1.4f;
- camera.setPosition(glm::vec3(posX - rotX, posY + rotY, posZ));
- }
- else
- camera.setPosition(glm::vec3(posX, posY, posZ));
- glm::mat4 camRot = glm::rotate(glm::mat4(1.0f), (rotate + 90), glm::vec3(0.0f, 0.0f, 1.0f));
- glm::vec4 up = camRot * glm::vec4(0, 1, 0, 1);
- float upX = (float)cos((rotate)* 3.14 / 180);
- float upY = (float)sin((rotate)* 3.14 / 180);
- camera.setUp(glm::vec3(upX, -upY, 1));
- float camTZ = posZ;
- float camTY = posY - 3 * upY;
- float camTX = posX + 3 * upX;
- camera.setTarget(glm::vec3(camTX, camTY, camTZ));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement