40 px1 = _p1.
m_x; py1 = _p1.m_y; pz1 = _p1.m_z;
41 px2 = _p2.m_x; py2 = _p2.m_y; pz2 = _p2.m_z;
42 px3 = _p3.m_x; py3 = _p3.m_y; pz3 = _p3.m_z;
46 coa = -(py1 * (pz2-pz3) + py2*(pz3-pz1) + py3*(pz1-pz2)) ;
47 cob = -(pz1 * (px2-px3) + pz2*(px3-px1) + pz3*(px1-px2)) ;
48 coc = -(px1 * (py2-py3) + px2*(py3-py1) + px3*(py1-py2)) ;
51 absvec = sqrtf ( ((coa*coa) + (cob*cob) + (coc*coc))) ;
52 norm.
m_x = coa/absvec ;
53 norm.
m_y = cob/absvec ;
54 norm.
m_z = coc/absvec ;
70 px1 = _p1.
m_x; py1 = _p1.m_y; pz1 = _p1.m_z;
71 px2 = _p2.m_x; py2 = _p2.m_y; pz2 = _p2.m_z;
72 px3 = _p3.m_x; py3 = _p3.m_y; pz3 = _p3.m_z;
76 coa = -(py1 * (pz2-pz3) + py2*(pz3-pz1) + py3*(pz1-pz2)) ;
77 cob = -(pz1 * (px2-px3) + pz2*(px3-px1) + pz3*(px1-px2)) ;
78 coc = -(px1 * (py2-py3) + px2*(py3-py1) + px3*(py1-py2)) ;
81 absvec = sqrtf ( ((coa*coa) + (cob*cob) + (coc*coc))) ;
82 norm.
m_x = coa/absvec ;
83 norm.
m_y = cob/absvec ;
84 norm.
m_z = coc/absvec ;
91 return (_deg/180.0
f) *
static_cast<Real>(M_PI);
97 return (_rad / static_cast<Real>(M_PI)) * 180.0f;
125 std::cerr<<
"GL error "<< str<<
" line : "<<_line<<
" file : "<<_file<<
"\n";
153 result.
m_00 = (2.0f * _zNear) / (right - left);
154 result.
m_11 = (2.0f * _zNear) / (top - bottom);
155 result.
m_22 = - (_zFar + _zNear) / (_zFar - _zNear);
156 result.
m_23 = - 1.0f;
157 result.
m_32 = - (2.0f* _zFar * _zNear) / (_zFar - _zNear);
165 Real h = cosf(0.5
f * rad) / sinf(0.5
f * rad);
166 Real w = h * _height / _width;
173 result.
m_22 = - (_zFar + _zNear) / (_zFar - _zNear);
174 result.
m_23 = - 1.0f;
175 result.
m_32 = - (2.0f* _zFar * _zNear) / (_zFar - _zNear);
192 result.
m_00 = (2.0f * _zNear) / (right - left);
193 result.
m_11 = (2.0f * _zNear) / (top - bottom);
194 result.
m_22 = - 1.0f;
195 result.
m_23 = - 1.0f;
196 result.
m_32 = - 2.0f * _zNear;
204 Vec3 n = _center-_eye;
222 result.
m_30=-_eye.dot(v);
223 result.
m_31=-_eye.dot(u);
224 result.
m_32= _eye.dot(n);
231 result.
m_00= 2.0f / (_right - _left);
232 result.
m_11= 2.0f / (_top - _bottom);
233 result.
m_22= - 2.0f / (_zFar - _zNear);
234 result.
m_30= - (_right + _left) / (_right - _left);
235 result.
m_31= - (_top + _bottom) / (_top - _bottom);
236 result.
m_32= - (_zFar + _zNear) / (_zFar - _zNear);
243 result.
m_00=
Real(2) / (_right - _left);
244 result.
m_11=
Real(2) / (_top - _bottom);
246 result.
m_30= - (_right + _left) / (_right - _left);
247 result.
m_31= - (_top + _bottom) / (_top - _bottom);
255 result.
m_00 = (2.0f * _nearVal) / (_right - _left);
256 result.
m_11 = (2.0f * _nearVal) / (_top - _bottom);
257 result.
m_20 = (_right + _left) / (_right - _left);
258 result.
m_21 = (_top + _bottom) / (_top - _bottom);
259 result.
m_22 = -(_farVal + _nearVal) / (_farVal - _nearVal);
261 result.
m_32 = -(2.0f * _farVal * _nearVal) / (_farVal - _nearVal);
273 Vec4 tmp(0,0,_win.m_z,1.0f);
275 tmp.
m_x=(2.0f * _win.m_x) / _viewport.m_openGL[2] - 1.0f;
276 tmp.
m_y=1.0f - (2.0f * _win.m_y) / _viewport.m_openGL[3];
289 tmp = _model*_project*tmp;
291 tmp = tmp * float(0.5);
293 tmp[0] = tmp[0] * float(_viewport[2]) + float(_viewport[0]);
294 tmp[1] = tmp[1] * float(_viewport[3]) + float(_viewport[1]);
303 while (((_x % 2) == 0) && _x > 1)
GLfloat GLfloat GLfloat top
Real m_11
individual matrix element maps to m_m[1][1] or m_openGL[5]
Real m_21
individual matrix element maps to m_m[2][1] or m_openGL[9]
simple Vector class for OpenGL graphics, contains overloaded operators for most math functions...
const Mat4 & null() noexcept
clear the matrix to all 0
main definition of types and namespace
NGL_DLLEXPORT Vec3 calcNormal(const Vec4 &_p1, const Vec4 &_p2, const Vec4 &_p3) noexcept
calculates the normal from 3 points and return the new normal as a Vector
#define GL_INVALID_OPERATION
Real m_22
individual matrix element maps to m_m[2][2] or m_openGL[10]
const Mat4 & transpose() noexcept
method to transpose the matrix
Real m_12
individual matrix element maps to m_m[1][2] or m_openGL[6]
#define GL_STACK_OVERFLOW
Vec3 toVec3() const noexcept
get as a Vec3 for glsl etc
Real m_31
individual matrix element maps to m_m[3][1] or m_openGL[13]
NGL_DLLEXPORT Mat4 perspectiveFov(Real const &_fov, Real const &_width, Real const &_height, Real const &_zNear, Real const &_zFar) noexcept
computer a perspective projection matrix similar to the one from the GLM library this is to help make...
simple Vec3 encapsulates a 3 float object like glsl vec3 but not maths use the Vec3 class for maths a...
NGL_DLLEXPORT Mat4 frustum(Real _left, Real _right, Real _bottom, Real _top, Real _nearVal, Real _farVal) noexcept
calculate frustum matrix similar to the one from the GLM library this is to help make porting glm cod...
NGL_DLLEXPORT bool isPowerOfTwo(unsigned int _x) noexcept
returns if value is a power of 2
implementation files for RibExport class
Real m_30
individual matrix element maps to m_m[3][0] or m_openGL[12]
#define GL_STACK_UNDERFLOW
PRECISION Real
create a variable called Real which is the main data type we use (GLfloat for most cases) ...
encapsulates a 4d Homogenous Point / Vector object
Real m_02
individual matrix element maps to m_m[0][2] or m_openGL[2]
NGL_DLLEXPORT Mat4 lookAt(const Vec3 &_eye, const Vec3 &_center, const Vec3 &_up) noexcept
calculate a look at matrix similar to the one from the GLM library this is to help make porting glm c...
NGL_DLLEXPORT Mat4 ortho(Real _left, Real _right, Real _bottom, Real _top, Real _zNear, Real _zFar) noexcept
calculate an ortho graphic projection at matrix similar to the one from the GLM library this is to he...
NGL_DLLEXPORT Vec3 project(const Vec3 &_pos, const Mat4 &_model, const Mat4 &_project, const Vec4 &_viewport) noexcept
GLubyte GLubyte GLubyte GLubyte w
Real m_01
individual matrix element maps to m_m[0][1] or m_openGL[1]
Real m_00
individual matrix element maps to m_m[0][0] or m_openGL[0]
Real m_10
individual matrix element maps to m_m[1][0] or m_openGL[4]
Real m_23
individual matrix element maps to m_m[2][3] or m_openGL[11]
NGL_DLLEXPORT Real degrees(const Real _rad) noexcept
converts Radians to Degrees
GLfloat GLfloat GLfloat GLfloat h
GLAPI GLenum GLAPIENTRY glGetError(void)
Real m_32
individual matrix element maps to m_m[3][2] or m_openGL[14]
NGL_DLLEXPORT Real radians(const Real _deg)
converts Degrees to Radians
Matrix Class to do simple matrix operations included operator overloaded functions for maths and matr...
Real m_20
individual matrix element maps to m_m[2][0] or m_openGL[8]
Real m_w
w component 0 for vector 1 for point
NGL_DLLEXPORT Mat4 perspective(Real _fovy, Real _aspect, Real _zNear, Real _zFar) noexcept
computer a perspective projection matrix similar to the one from the GLM library this is to help make...
void normalize() noexcept
Normalize the vector using .
NGL_DLLEXPORT Vec3 unProject(const Vec3 &_win, const Mat4 &_model, const Mat4 &_project, const Vec4 &_viewport) noexcept
unproject points similar to the one from the GLM library this is to help make porting glm code easier...
NGL_DLLEXPORT void NGLCheckGLError(const std::string &_file, const int _line) noexcept
check for openGL errors and print out.
GLsizei const GLchar *const * string
NGL_DLLEXPORT Mat4 infinitePerspective(Real _fovy, Real _aspect, Real _zNear) noexcept
computer a perspective projection matrix similar to the one from the GLM library this is to help make...
NGL_DLLEXPORT unsigned int nextPow2(unsigned int _x) noexcept
rounds up the value to next power of 2
void cross(const Vec3 &_v1, const Vec3 &_v2) noexcept
set the Vec3 as the cross product from 2 other Vec3
#define GL_INVALID_FRAMEBUFFER_OPERATION