Ejemplo n.º 1
0
void Camera::SetOrientation(glm::vec3 a_v3Orientation)
{
	m_Transform->SetRotation(a_v3Orientation);

	CalculateDirectionVectors();
	CalculateView();
}
Ejemplo n.º 2
0
Camera::Camera(GameObject* gameObject)
	: Component(gameObject)
{
	Init();

	CalculateView();
	CalculateProjection();
}
Ejemplo n.º 3
0
// Constructor
_Camera::_Camera(float Fov, float AspectRatio, float Near, float Far)
: Fov(Fov), AspectRatio(AspectRatio), Near(Near), Far(Far), Type(THIRD_PERSON), Yaw(0.0f), Pitch(0.0f), Distance(5.0f), MinDistance(0.1f), PitchLimit(glm::radians(89.0f)),
LookAt(glm::vec3(0.0f, 0.0f, 0.0f)), Up(glm::vec3(0.0f, 1.0f, 0.0f)), Position(glm::vec3(0.0f, 0.0f, 5.0f)), LastPosition(Position), InterpolatedPosition(Position) {

	CalculateProjection();
	CalculateView();
	CalculateTransform();
}
Ejemplo n.º 4
0
void Camera::MoveUp(float a_fIncrement)
{
	glm::vec3 v3Position = m_Transform->GetPosition();

	v3Position += m_v3Up * a_fIncrement;

	m_Transform->SetPosition(v3Position);
	CalculateView();
}
void CCameraInstance::LookAt(SFloat3* psFrom, SFloat3* psTo, SFloat3* psUp)
{
	Float4x4LookAtRH(&mpsView->sD3DMatrix, psFrom, psTo, psUp);
	Float4x4Inverse(&mpsWorld->sD3DMatrix, NULL, &mpsView->sD3DMatrix);

	//Remove this?
	CalculateView();
	CalculateProjection();
}
Ejemplo n.º 6
0
void Camera::LookAtDirection(glm::vec3 a_v3Direction)
{
	// Makes sure the new direction vector actually points somewhere.
	if (a_v3Direction.length() != 0)
	{
		m_v3Forward = glm::normalize(a_v3Direction);

		CalculateDirectionVectors();
		CalculateView();
	}
}
Ejemplo n.º 7
0
void Camera::ChangeRoll(float a_fIncrement)
{
	glm::vec3 v3Orientation = m_Transform->GetRotation();
	
	v3Orientation.z = a_fIncrement;

	m_Transform->SetRotation(v3Orientation);

	CalculateDirectionVectors();
	CalculateView();
}
Ejemplo n.º 8
0
void Camera::LookAtPosition(glm::vec3 a_v3Target)
{
	glm::vec3 v3Position = m_Transform->GetPosition();

	// Makes sure the new target location is not the current location
	if (a_v3Target != v3Position)
	{
		m_v3Forward = glm::normalize(a_v3Target - v3Position);
		
		CalculateDirectionVectors();
		CalculateView();
	}
}
Ejemplo n.º 9
0
// Update the camera
void _Camera::UpdateRender(float BlendFactor) {
	/*switch(Type) {
		case FREEMOVE: {
		} break;
		case THIRD_PERSON: {
		} break;
	}
	*/
	InterpolatedPosition = BlendFactor * Position + (1.0f - BlendFactor) * LastPosition;
	//InterpolatedPosition = Position;
	CalculateView();
	CalculateTransform();
}
BOOL CCameraInstance::Use(void)
{
	//It's allowable to have a NULL surface... the render target won't be changed.
	if (mpsSurface != NULL)
	{
		gcD3D.SetRenderTarget(mpsSurface);
	}

	//Do this every frame... not a problem on todays hardware.
	CalculateView();
	CalculateProjection();

	return gcD3D.SetCamera(mpsProjection, mpsView);
}
/*  Method
    *@brief: This method zooms camera
    *@param float d: Zoom ratio
    *@retval: None
    */
void GCamera::Zoom(float d)
{
    m_Position -= m_Reference;
    if(d < 0 && length(m_Position) < 500.0f)
        {
        m_Position += m_Position * 0.1f;
        }
    if(d > 0 && length(m_Position) > 0.05f)
        {
        m_Position -= m_Position * 0.1f;
        }

    m_Position += m_Reference;
    CalculateView();
}
/*  Method
    *@brief: This method rotates camera
    *@param float dx: X angle
    *@param float dy: Y agnle
    *@retval: None
    */
void GCamera::Rotate(float dx, float dy)
{
    float sensitivity = 0.25f;
    float hangle = (float)dx * sensitivity;
    float vangle = (float)dy * sensitivity;
    m_Position -= m_Reference;
    m_yAxis = rotate(m_yAxis, vangle, m_xAxis);
    m_zAxis = rotate(m_zAxis, vangle, m_xAxis);

    if(m_yAxis.y < 0.0f)
        {
        m_zAxis = vecG3(0.0f, m_zAxis.y > 0.0f ? 1.0f : -1.0f, 0.0f);
        m_yAxis = cross(m_zAxis, m_xAxis);
        }

    m_xAxis = rotate(m_xAxis, hangle, vecG3(0.0f, 1.0f, 0.0f));
    m_yAxis = rotate(m_yAxis, hangle, vecG3(0.0f, 1.0f, 0.0f));
    m_zAxis = rotate(m_zAxis, hangle, vecG3(0.0f, 1.0f, 0.0f));
    m_Position = m_Reference + m_zAxis * length(m_Position);
    CalculateView();
}
Ejemplo n.º 13
0
void Camera::Init()
{
	m_Transform = _gameObject->GetTransform();

	m_bOrthogonal = false;
	m_b6DoF = false;

	m_v3Up = glm::vec3(0, 1.0f, 0);
	m_v3Forward = glm::vec3(-1.0f, 0, 0);

	m_fFOVy = 45.0f;

	m_fAspectRatio = static_cast<float>( GameWindow::GetCurrentWindow()->GetWidth() ) / GameWindow::GetCurrentWindow()->GetHeight();
	m_fMinPlane = 0.001f;
	m_fMaxPlane = 1024.0f;
	m_fHeight = static_cast<float>( GameWindow::GetCurrentWindow()->GetHeight() );

	CalculateDirectionVectors();
	CalculateView();
	CalculateProjection();
}
Ejemplo n.º 14
0
matrix4 MyCameraSingleton::GetCameraSpaceAdjusted(void)
{
	CalculateView();
	return glm::inverse(m_m4Projection) * glm::translate(vector3(0.0f, 0.0f, -1.2085f));
}
Ejemplo n.º 15
0
matrix4 MyCameraSingleton::GetVP(void)
{
	CalculateView();
	CalculateProjection();
	return m_m4Projection * m_m4View;
}
Ejemplo n.º 16
0
matrix4 MyCameraSingleton::GetMVP(matrix4 a_m4ModelToWorld)
{
	CalculateView();
	CalculateProjection();
	return m_m4Projection * m_m4View * a_m4ModelToWorld;
}
Ejemplo n.º 17
0
matrix4 MyCameraSingleton::GetViewMatrix(void){ CalculateView(); return m_m4View; }
const matG44 &GCamera::GetViewMatrix()
{
    CalculateView();
    return m_ViewMatrix;
}
Ejemplo n.º 19
0
void Camera::SetPosition(glm::vec3 a_v3Position)
{
	m_Transform->SetPosition(a_v3Position);
	CalculateView();
}