#include "pw/scene/projection.hpp"
#include "pw/core/matrix_transform.hpp"

namespace pw {

projection::projection(node &host)
    : component (host)
{
    _m.set_identity();
    // set_matrix(matrix_transform<real_t>::perspective_projection(_fov,1,_near_plane,_far_plane));
}

void projection::set_matrix(const matrix4x4 &projection)
{
    this->_m = projection;

    // recompute the simplified parameters

//	auto near   = _projection(3,4);
//	auto far    = _projection(3,4);

//	right = (1-m14) / m11

//	near   =  (1+m34)/m33;
//	far    = -(1-m34)/m33;
//	bottom =  (1-m24)/m22;
//	top    = -(1+m24)/m22;
//	left   = -(1+m14)/m11;
//	right  =  (1-m14)/m11;

//	real_t fov_raw = float( atan (top / near_)) *  * 2.0f;
}

const matrix4x4 &projection::matrix() const
{
    return _m;
}

void projection::set_frustum(real_t left, real_t right, real_t top, real_t bottom)
{

}


}
