mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-08 03:42:35 +01:00
ba7eb63941
rwengine + Make renderWorld() take a ViewCamera parameter. + add rotation and getView to ViewCamera + correct directions for vehicle and character movement. rwgame + Remove GenericState + Add State::getCamera() to control the ViewCamera used for rendering + Clean up state camera control + Remove now unused view parameters from main
32 lines
560 B
C++
32 lines
560 B
C++
#ifndef _VIEWCAMERA_HPP_
|
|
#define _VIEWCAMERA_HPP_
|
|
#include "ViewFrustum.hpp"
|
|
#include <glm/gtc/quaternion.hpp>
|
|
|
|
class ViewCamera
|
|
{
|
|
public:
|
|
|
|
ViewFrustum frustum;
|
|
|
|
glm::vec3 position;
|
|
glm::quat rotation;
|
|
|
|
ViewCamera(const glm::vec3& pos = {}, const glm::quat& rot = {})
|
|
: frustum({0.1f, 5000.f, glm::radians(45.f), 1.f}),
|
|
position(pos), rotation(rot)
|
|
{
|
|
|
|
}
|
|
|
|
glm::mat4 getView()
|
|
{
|
|
auto up = rotation * glm::vec3(0.f, 0.f, 1.f);
|
|
return glm::lookAt(position,
|
|
position + rotation * glm::vec3(1.f, 0.f, 0.f),
|
|
up);
|
|
}
|
|
};
|
|
|
|
#endif
|