void Camera::SetupPerspective(float _fov, float _aspectRatio, float _near /* = 0.01f*/, float _far /* = 1000.0f*/) { projectionTransform = glm::perspective(_fov, _aspectRatio, _near, _far); perspectiveSet = true; UpdateProjectionViewTransform(); }
//setup functions void Camera::LookAt(glm::vec3 _lookAt, glm::vec3 _up) { glm::vec4 location = worldTransform[3]; //current position data saved because not passed in worldTransform = glm::inverse(glm::lookAt(location.xyz(), _lookAt, _up)); UpdateProjectionViewTransform(); }
void FlyCamera::CalculateRotation( real64_t dt, real64_t xOffset, real64_t yOffset ) { glm::mat4 inversed = glm::inverse( worldTransform ); glm::mat4 rot = glm::rotate( glm::radians( (float)-(xOffset * dt) ), inversed[1].xyz() ); worldTransform = worldTransform * rot; rot = glm::rotate( glm::radians( (float)-(yOffset * dt) ), glm::vec3( 1, 0, 0 ) ); worldTransform = worldTransform * rot; glm::mat4 trans = worldTransform; worldTransform[0].xyz() = glm::normalize( glm::cross( glm::vec3( 0, 1, 0 ), trans[2].xyz() )); worldTransform[0].w = 0.0; worldTransform[1].xyz() = glm::normalize( glm::cross( trans[2].xyz(), worldTransform[0].xyz() ) ); worldTransform[1].w = 0.0; worldTransform[2].w = 0.0; UpdateProjectionViewTransform(); }
Camera::Camera(glm::mat4 _transform) : worldTransform(_transform) //initialisng world transform inline { UpdateProjectionViewTransform(); }
Camera::Camera(glm::vec3 _position) { m_worldTransform = glm::mat4(1); m_worldTransform[3] = glm::vec4(_position, 1); UpdateProjectionViewTransform(); }
BaseCamera::BaseCamera( const Renderer::View &view, const glm::mat4 &transform ) : view( view ), worldTransform( transform ) { UpdateProjectionViewTransform(); }
void Camera::setPosition(vec3 position) { worldTransform[3] = vec4(position, 1); UpdateProjectionViewTransform(); }
void Camera::setOrthographic(float left, float right, float bottom, float top) { projectionTransform = glm::ortho(left, right, bottom, top); UpdateProjectionViewTransform(); }
Camera::Camera(glm::mat4 _transform) : m_worldTransform(_transform) { UpdateProjectionViewTransform(); }
void BaseCamera::SetupPerspective( real32_t fov, real32_t aspectRatio, real32_t zNear, real32_t zFar ) { projectionTransform = glm::perspective( fov, aspectRatio, zNear, zFar ); perspectiveSet = true; UpdateProjectionViewTransform(); }
void BaseCamera::LookAt( const glm::vec3 &position, const glm::vec3 &lookAt, const glm::vec3 &worldUp ) { worldTransform = glm::inverse( glm::lookAt( position, lookAt, worldUp ) ); UpdateProjectionViewTransform(); }
void BaseCamera::LookAt( const glm::vec3 &lookAt, const glm::vec3 &worldUp ) { glm::vec4 vLocation = worldTransform[3]; worldTransform = glm::inverse( glm::lookAt( vLocation.xyz(), lookAt, worldUp ) ); UpdateProjectionViewTransform(); }
void BaseCamera::SetPosition( const glm::vec3 &position ) { worldTransform[3] = glm::vec4( position, 1.0f ); UpdateProjectionViewTransform(); }
void BaseCamera::SetTransform( const glm::mat4 &transform ) { worldTransform = transform; UpdateProjectionViewTransform(); }
void Camera::SetTransform(glm::mat4 _transform) { worldTransform = _transform; UpdateProjectionViewTransform(); }
void Camera::SetPosition(glm::vec3 _position) { worldTransform[3] = glm::vec4(_position, 1); UpdateProjectionViewTransform(); }
void Camera::SetLookAt(glm::vec3 _to, glm::vec3 _up) { glm::vec4 vLocation = m_worldTransform[3]; m_worldTransform = glm::inverse(glm::lookAt(vLocation.xyz(), _to, _up)); UpdateProjectionViewTransform(); }
void Camera::LookAt(glm::vec3 _position, glm::vec3 _lookAt, glm::vec3 _up) { worldTransform = glm::inverse(glm::lookAt(_position, _lookAt, _up)); //position data passed in UpdateProjectionViewTransform(); }
Camera::Camera() { m_worldTransform = glm::mat4(1); UpdateProjectionViewTransform(); }
void Camera::setPerspective(float FOV, float aspectRatio, float nearPlane, float farPlane) { projectionTransform = glm::perspective(FOV, aspectRatio, nearPlane, farPlane); UpdateProjectionViewTransform(); }
void Camera::SetLookAt(glm::vec3 _from, glm::vec3 _to, glm::vec3 _up) { m_worldTransform = glm::inverse(glm::lookAt(_from, _to, _up)); UpdateProjectionViewTransform(); }
void Camera::LookAt(vec3 position, vec3 target, vec3 worldUp) { worldTransform = glm::inverse(glm::lookAt(position, target, worldUp)); UpdateProjectionViewTransform(); }
void Camera::SetPerspective(float _fieldOfView, float _aspectRation, float _near, float _far) { m_projectionTransform = glm::perspective(_fieldOfView, _aspectRation, _near, _far); UpdateProjectionViewTransform(); }
void Camera::setWorldTransform(const glm::mat4& transform) { worldTransform = transform; UpdateProjectionViewTransform(); }
void Camera::Translate(glm::vec3 _translation) { glm::vec4 pos = m_worldTransform[3]; m_worldTransform[3] = pos + glm::vec4(_translation, 0); UpdateProjectionViewTransform(); }