Easy3D 2.6.1
Loading...
Searching...
No Matches
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
43 namespace transform {
44
56 mat4 ortho(float left, float right, float bottom, float top, float near, float far);
57
65 mat4 ortho(float left, float right, float bottom, float top);
66
78 mat4 frustum(float left, float right, float bottom, float top, float near, float far);
79
90 mat4 perspective(float fov_y, float aspect, float near, float far);
101 mat4 perspective(float fov_y, float width, float height, float near, float far);
102
111 mat4 infinite_perspective(float fov_y, float aspect, float near);
112
118 mat4 viewport(float width, float height);
119
126 mat4 look_at(const vec3& eye, const vec3& center, const vec3& up);
127
134 mat4 pick_matrix(const vec2& center, const vec2& delta, const vec4& viewport);
135
146 vec3 project(const vec3& obj, const mat4& model, const mat4& proj, const int viewport[4], bool lowerleft = true);
156 vec3 project(const vec3& obj, const mat4& mvp, const int viewport[4], bool lowerleft = true); // mvp = proj * model;
157
168 vec3 unproject(const vec3& win, const mat4& model, const mat4& proj, const int viewport[4], bool lowerleft = true);
178 vec3 unproject(const vec3& win, const mat4& mvp, const int viewport[4], bool lowerleft = true); // mvp = proj * model;
179
180 // --------------------------------------------------------------------------------------------------
181
188 mat3 normal_matrix(const mat4& mat);
189
196 mat43 normal_matrix_padded(const mat4& mat);
197
198 } // namespace transform
199
200}
201
202
203#endif // EASY3D_RENDERER_TRANSFORM_H
Functions that generate common transformation matrices (all using the right-handed coordinate system)...
Definition transform.cpp:34
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 viewport(float w, float h)
Definition transform.cpp:128
mat4 pick_matrix(const vec2 &center, const vec2 &delta, const vec4 &viewport)
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
Definition collider.cpp:182
Mat< 4, 3, float > mat43
A 4 by 3 matrix of float type.
Definition types.h:71
Vec< 3, float > vec3
A 3D point/vector of float type.
Definition types.h:44
Mat4< float > mat4
A 4 by 4 matrix of float type.
Definition types.h:67
Mat3< float > mat3
A 3 by 3 matrix of float type.
Definition types.h:65
Vec< 4, float > vec4
A 4D point/vector of float type.
Definition types.h:46
Vec< 2, float > vec2
A 2D point/vector of float type.
Definition types.h:42