Easy3D 2.5.3
transform.h
1/********************************************************************
2 * Copyright (C) 2015 Liangliang Nan <liangliang.nan@gmail.com>
3 * https://3d.bk.tudelft.nl/liangliang/
4 *
5 * This file is part of Easy3D. If it is useful in your research/work,
6 * I would be grateful if you show your appreciation by citing it:
7 * ------------------------------------------------------------------
8 * Liangliang Nan.
9 * Easy3D: a lightweight, easy-to-use, and efficient C++ library
10 * for processing and rendering 3D data.
11 * Journal of Open Source Software, 6(64), 3255, 2021.
12 * ------------------------------------------------------------------
13 *
14 * Easy3D is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License Version 3
16 * as published by the Free Software Foundation.
17 *
18 * Easy3D is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 ********************************************************************/
26
27#ifndef EASY3D_RENDERER_TRANSFORM_H
28#define EASY3D_RENDERER_TRANSFORM_H
29
30#include <easy3d/core/types.h>
31
32
33namespace easy3d {
34
42 namespace transform {
43
51 mat4 ortho(float left, float right, float bottom, float top, float near, float far);
52
54 mat4 ortho(float left, float right, float bottom, float top);
55
61 mat4 frustum(float left, float right, float bottom, float top, float near, float far);
62
73 mat4 perspective(float fov_y, float aspect, float near, float far);
74 mat4 perspective(float fov_y, float width, float height, float near, float far);
75
83 mat4 infinite_perspective(float fov_y, float aspect, float near);
84
86 mat4 viewport(float width, float height);
87
94 mat4 look_at(const vec3& eye, const vec3& center, const vec3& up);
95
97 mat4 pick_matrix(const vec2& center, const vec2& delta, const vec4& viewport);
98
112 vec3 project(const vec3& obj, const mat4& model, const mat4& proj, const int viewport[4], bool lowerleft = true);
113 vec3 project(const vec3& obj, const mat4& mvp, const int viewport[4], bool lowerleft = true); // mvp = proj * model;
114
128 vec3 unproject(const vec3& win, const mat4& model, const mat4& proj, const int viewport[4], bool lowerleft = true);
129 vec3 unproject(const vec3& win, const mat4& mvp, const int viewport[4], bool lowerleft = true); // mvp = proj * model;
130
131 // --------------------------------------------------------------------------------------------------
132
137 mat3 normal_matrix(const mat4& mat);
138
143 mat43 normal_matrix_padded(const mat4& mat);
144
145 } // namespace transform
146
147}
148
149
150#endif // EASY3D_RENDERER_TRANSFORM_H
mat4 frustum(float left, float right, float bottom, float top, float nearVal, float farVal)
Definition: transform.cpp:57
mat43 normal_matrix_padded(const mat4 &mat)
Definition: transform.cpp:229
mat4 pick_matrix(const vec2 &center, const vec2 &delta, const vec4 &viewport)
Defines a picking region.
Definition: transform.cpp:204
mat4 infinite_perspective(float fov_y, float aspect, float zNear)
Definition: transform.cpp:112
mat4 perspective(float fov_y, float aspect, float zNear, float zFar)
Definition: transform.cpp:69
mat3 normal_matrix(const mat4 &mat)
Definition: transform.cpp:223
vec3 unproject(const vec3 &win, const mat4 &mv, const mat4 &proj, const int viewport[4], bool lowerleft)
Definition: transform.cpp:157
vec3 project(const vec3 &obj, const mat4 &mv, const mat4 &proj, const int viewport[4], bool lowerleft)
Definition: transform.cpp:132
mat4 look_at(const vec3 &eye, const vec3 &center, const vec3 &up)
Definition: transform.cpp:183
mat4 ortho(float left, float right, float bottom, float top, float zNear, float zFar)
Definition: transform.cpp:36
mat4 viewport(float w, float h)
Creates a viewport matrix. Simulating glViewport().
Definition: transform.cpp:128
Definition: collider.cpp:182
Mat< 4, 3, float > mat43
A 4 by 3 matrix of float type.
Definition: types.h:72
Vec< 3, float > vec3
A 3D point/vector of float type.
Definition: types.h:45
Mat4< float > mat4
A 4 by 4 matrix of float type.
Definition: types.h:68
Mat3< float > mat3
A 3 by 3 matrix of float type.
Definition: types.h:66
Vec< 4, float > vec4
A 4D point/vector of float type.
Definition: types.h:47
Vec< 2, float > vec2
A 2D point/vector of float type.
Definition: types.h:43