cglm 0.1.0 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -1
- data/Gemfile.lock +18 -16
- data/README.md +2 -0
- data/cglm.gemspec +3 -3
- data/ext/cglm/cglm-0.6.2/include/cglm/affine-mat.h +168 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/affine.h +490 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/applesimd.h +95 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/bezier.h +154 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/box.h +279 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/call/affine.h +117 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/call/bezier.h +31 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/call/box.h +79 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/call/cam.h +143 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/call/curve.h +23 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/call/ease.h +143 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/call/euler.h +55 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/call/frustum.h +41 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/call/io.h +44 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/call/mat3.h +86 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/call/mat4.h +127 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/call/plane.h +23 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/call/project.h +33 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/call/quat.h +159 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/call/sphere.h +39 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/call/vec3.h +312 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/call/vec4.h +290 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/call.h +36 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/cam.h +585 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/cglm.h +32 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/color.h +26 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/common.h +37 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/curve.h +40 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/ease.h +317 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/euler.h +453 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/frustum.h +255 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/io.h +203 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/mat3.h +422 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/mat4.h +726 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/plane.h +36 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/project.h +118 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/quat.h +828 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/simd/arm.h +83 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/simd/avx/affine.h +66 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/simd/avx/mat4.h +66 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/simd/intrin.h +90 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/simd/neon/mat4.h +57 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/simd/sse2/affine.h +111 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/simd/sse2/mat3.h +59 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/simd/sse2/mat4.h +405 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/simd/sse2/quat.h +46 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/simd/x86.h +192 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/sphere.h +99 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/struct/affine.h +337 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/struct/box.h +256 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/struct/cam.h +451 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/struct/color.h +27 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/struct/curve.h +40 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/struct/euler.h +152 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/struct/frustum.h +155 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/struct/io.h +82 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/struct/mat3.h +285 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/struct/mat4.h +459 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/struct/plane.h +40 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/struct/project.h +104 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/struct/quat.h +532 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/struct/sphere.h +93 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/struct/vec3-ext.h +257 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/struct/vec3.h +970 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/struct/vec4-ext.h +257 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/struct/vec4.h +814 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/struct.h +36 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/types-struct.h +129 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/types.h +76 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/util.h +328 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/vec3-ext.h +272 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/vec3.h +1078 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/vec4-ext.h +315 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/vec4.h +1078 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/version.h +15 -0
- data/ext/cglm/extconf.rb +2 -3
- data/ext/cglm/rb_cglm.h +5 -3
- data/ext/cglm/rb_cglm_mat3.c +3 -3
- data/ext/cglm/rb_cglm_mat4.c +3 -3
- data/ext/cglm/rb_cglm_quat.c +2 -2
- data/ext/cglm/rb_cglm_vec3.c +63 -61
- data/ext/cglm/rb_cglm_vec4.c +2 -0
- data/ext/cglm/ruby_pre27.h +35 -0
- data/lib/cglm/vec3.rb +2 -2
- data/lib/cglm/vec4.rb +2 -2
- data/lib/cglm/vector_type.rb +15 -0
- data/lib/cglm/version.rb +1 -1
- metadata +89 -13
@@ -0,0 +1,451 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c), Recep Aslantas.
|
3
|
+
*
|
4
|
+
* MIT License (MIT), http://opensource.org/licenses/MIT
|
5
|
+
* Full license can be found in the LICENSE file
|
6
|
+
*/
|
7
|
+
|
8
|
+
/*
|
9
|
+
Functions:
|
10
|
+
CGLM_INLINE mat4s glms_frustum(float left, float right,
|
11
|
+
float bottom, float top,
|
12
|
+
float nearVal, float farVal)
|
13
|
+
CGLM_INLINE mat4s glms_ortho(float left, float right,
|
14
|
+
float bottom, float top,
|
15
|
+
float nearVal, float farVal)
|
16
|
+
CGLM_INLINE mat4s glms_ortho_aabb(vec3s box[2]);
|
17
|
+
CGLM_INLINE mat4s glms_ortho_aabb_p(vec3s box[2], float padding);
|
18
|
+
CGLM_INLINE mat4s glms_ortho_aabb_pz(vec3s box[2], float padding);
|
19
|
+
CGLM_INLINE mat4s glms_ortho_default(float aspect)
|
20
|
+
CGLM_INLINE mat4s glms_ortho_default_s(float aspect, float size)
|
21
|
+
CGLM_INLINE mat4s glms_perspective(float fovy,
|
22
|
+
float aspect,
|
23
|
+
float nearVal,
|
24
|
+
float farVal)
|
25
|
+
CGLM_INLINE void glms_persp_move_far(mat4s proj, float deltaFar)
|
26
|
+
CGLM_INLINE mat4s glms_perspective_default(float aspect)
|
27
|
+
CGLM_INLINE void glms_perspective_resize(mat4s proj, float aspect)
|
28
|
+
CGLM_INLINE mat4s glms_lookat(vec3s eye, vec3s center, vec3s up)
|
29
|
+
CGLM_INLINE mat4s glms_look(vec3s eye, vec3s dir, vec3s up)
|
30
|
+
CGLM_INLINE mat4s glms_look_anyup(vec3s eye, vec3s dir)
|
31
|
+
CGLM_INLINE void glms_persp_decomp(mat4s proj,
|
32
|
+
float *nearv, float *farv,
|
33
|
+
float *top, float *bottom,
|
34
|
+
float *left, float *right)
|
35
|
+
CGLM_INLINE void glms_persp_decompv(mat4s proj, float dest[6])
|
36
|
+
CGLM_INLINE void glms_persp_decomp_x(mat4s proj, float *left, float *right)
|
37
|
+
CGLM_INLINE void glms_persp_decomp_y(mat4s proj, float *top, float *bottom)
|
38
|
+
CGLM_INLINE void glms_persp_decomp_z(mat4s proj, float *nearv, float *farv)
|
39
|
+
CGLM_INLINE void glms_persp_decomp_far(mat4s proj, float *farVal)
|
40
|
+
CGLM_INLINE void glms_persp_decomp_near(mat4s proj, float *nearVal)
|
41
|
+
CGLM_INLINE float glms_persp_fovy(mat4s proj)
|
42
|
+
CGLM_INLINE float glms_persp_aspect(mat4s proj)
|
43
|
+
CGLM_INLINE vec4s glms_persp_sizes(mat4s proj, float fovy)
|
44
|
+
*/
|
45
|
+
|
46
|
+
#ifndef cglms_cam_h
|
47
|
+
#define cglms_cam_h
|
48
|
+
|
49
|
+
#include "../common.h"
|
50
|
+
#include "../types-struct.h"
|
51
|
+
#include "../plane.h"
|
52
|
+
#include "../cam.h"
|
53
|
+
|
54
|
+
/*!
|
55
|
+
* @brief set up perspective peprojection matrix
|
56
|
+
*
|
57
|
+
* @param[in] left viewport.left
|
58
|
+
* @param[in] right viewport.right
|
59
|
+
* @param[in] bottom viewport.bottom
|
60
|
+
* @param[in] top viewport.top
|
61
|
+
* @param[in] nearVal near clipping plane
|
62
|
+
* @param[in] farVal far clipping plane
|
63
|
+
* @returns result matrix
|
64
|
+
*/
|
65
|
+
CGLM_INLINE
|
66
|
+
mat4s
|
67
|
+
glms_frustum(float left, float right,
|
68
|
+
float bottom, float top,
|
69
|
+
float nearVal, float farVal) {
|
70
|
+
mat4s dest;
|
71
|
+
glm_frustum(left, right, bottom, top, nearVal, farVal, dest.raw);
|
72
|
+
return dest;
|
73
|
+
}
|
74
|
+
|
75
|
+
/*!
|
76
|
+
* @brief set up orthographic projection matrix
|
77
|
+
*
|
78
|
+
* @param[in] left viewport.left
|
79
|
+
* @param[in] right viewport.right
|
80
|
+
* @param[in] bottom viewport.bottom
|
81
|
+
* @param[in] top viewport.top
|
82
|
+
* @param[in] nearVal near clipping plane
|
83
|
+
* @param[in] farVal far clipping plane
|
84
|
+
* @returns result matrix
|
85
|
+
*/
|
86
|
+
CGLM_INLINE
|
87
|
+
mat4s
|
88
|
+
glms_ortho(float left, float right,
|
89
|
+
float bottom, float top,
|
90
|
+
float nearVal, float farVal) {
|
91
|
+
mat4s dest;
|
92
|
+
glm_ortho(left, right, bottom, top, nearVal, farVal, dest.raw);
|
93
|
+
return dest;
|
94
|
+
}
|
95
|
+
|
96
|
+
/*!
|
97
|
+
* @brief set up orthographic projection matrix using bounding box
|
98
|
+
*
|
99
|
+
* bounding box (AABB) must be in view space
|
100
|
+
*
|
101
|
+
* @param[in] box AABB
|
102
|
+
* @returns result matrix
|
103
|
+
*/
|
104
|
+
CGLM_INLINE
|
105
|
+
mat4s
|
106
|
+
glms_ortho_aabb(vec3s box[2]) {
|
107
|
+
mat4s dest;
|
108
|
+
vec3 rawBox[2];
|
109
|
+
|
110
|
+
glms_vec3_unpack(rawBox, box, 2);
|
111
|
+
glm_ortho_aabb(rawBox, dest.raw);
|
112
|
+
|
113
|
+
return dest;
|
114
|
+
}
|
115
|
+
|
116
|
+
/*!
|
117
|
+
* @brief set up orthographic projection matrix using bounding box
|
118
|
+
*
|
119
|
+
* bounding box (AABB) must be in view space
|
120
|
+
*
|
121
|
+
* @param[in] box AABB
|
122
|
+
* @param[in] padding padding
|
123
|
+
* @returns result matrix
|
124
|
+
*/
|
125
|
+
CGLM_INLINE
|
126
|
+
mat4s
|
127
|
+
glms_ortho_aabb_p(vec3s box[2], float padding) {
|
128
|
+
mat4s dest;
|
129
|
+
vec3 rawBox[2];
|
130
|
+
|
131
|
+
glms_vec3_unpack(rawBox, box, 2);
|
132
|
+
glm_ortho_aabb_p(rawBox, padding, dest.raw);
|
133
|
+
|
134
|
+
return dest;
|
135
|
+
}
|
136
|
+
|
137
|
+
/*!
|
138
|
+
* @brief set up orthographic projection matrix using bounding box
|
139
|
+
*
|
140
|
+
* bounding box (AABB) must be in view space
|
141
|
+
*
|
142
|
+
* @param[in] box AABB
|
143
|
+
* @param[in] padding padding for near and far
|
144
|
+
* @returns result matrix
|
145
|
+
*/
|
146
|
+
CGLM_INLINE
|
147
|
+
mat4s
|
148
|
+
glms_ortho_aabb_pz(vec3s box[2], float padding) {
|
149
|
+
mat4s dest;
|
150
|
+
vec3 rawBox[2];
|
151
|
+
|
152
|
+
glms_vec3_unpack(rawBox, box, 2);
|
153
|
+
glm_ortho_aabb_pz(rawBox, padding, dest.raw);
|
154
|
+
|
155
|
+
return dest;
|
156
|
+
}
|
157
|
+
|
158
|
+
/*!
|
159
|
+
* @brief set up unit orthographic projection matrix
|
160
|
+
*
|
161
|
+
* @param[in] aspect aspect ration ( width / height )
|
162
|
+
* @returns result matrix
|
163
|
+
*/
|
164
|
+
CGLM_INLINE
|
165
|
+
mat4s
|
166
|
+
glms_ortho_default(float aspect) {
|
167
|
+
mat4s dest;
|
168
|
+
glm_ortho_default(aspect, dest.raw);
|
169
|
+
return dest;
|
170
|
+
}
|
171
|
+
|
172
|
+
/*!
|
173
|
+
* @brief set up orthographic projection matrix with given CUBE size
|
174
|
+
*
|
175
|
+
* @param[in] aspect aspect ratio ( width / height )
|
176
|
+
* @param[in] size cube size
|
177
|
+
* @returns result matrix
|
178
|
+
*/
|
179
|
+
CGLM_INLINE
|
180
|
+
mat4s
|
181
|
+
glms_ortho_default_s(float aspect, float size) {
|
182
|
+
mat4s dest;
|
183
|
+
glm_ortho_default_s(aspect, size, dest.raw);
|
184
|
+
return dest;
|
185
|
+
}
|
186
|
+
|
187
|
+
/*!
|
188
|
+
* @brief set up perspective projection matrix
|
189
|
+
*
|
190
|
+
* @param[in] fovy field of view angle
|
191
|
+
* @param[in] aspect aspect ratio ( width / height )
|
192
|
+
* @param[in] nearVal near clipping plane
|
193
|
+
* @param[in] farVal far clipping planes
|
194
|
+
* @returns result matrix
|
195
|
+
*/
|
196
|
+
CGLM_INLINE
|
197
|
+
mat4s
|
198
|
+
glms_perspective(float fovy, float aspect, float nearVal, float farVal) {
|
199
|
+
mat4s dest;
|
200
|
+
glm_perspective(fovy, aspect, nearVal, farVal, dest.raw);
|
201
|
+
return dest;
|
202
|
+
}
|
203
|
+
|
204
|
+
/*!
|
205
|
+
* @brief extend perspective projection matrix's far distance
|
206
|
+
*
|
207
|
+
* this function does not guarantee far >= near, be aware of that!
|
208
|
+
*
|
209
|
+
* @param[in, out] proj projection matrix to extend
|
210
|
+
* @param[in] deltaFar distance from existing far (negative to shink)
|
211
|
+
*/
|
212
|
+
CGLM_INLINE
|
213
|
+
void
|
214
|
+
glms_persp_move_far(mat4s proj, float deltaFar) {
|
215
|
+
glm_persp_move_far(proj.raw, deltaFar);
|
216
|
+
}
|
217
|
+
|
218
|
+
/*!
|
219
|
+
* @brief set up perspective projection matrix with default near/far
|
220
|
+
* and angle values
|
221
|
+
*
|
222
|
+
* @param[in] aspect aspect ratio ( width / height )
|
223
|
+
* @returns result matrix
|
224
|
+
*/
|
225
|
+
CGLM_INLINE
|
226
|
+
mat4s
|
227
|
+
glms_perspective_default(float aspect) {
|
228
|
+
mat4s dest;
|
229
|
+
glm_perspective_default(aspect, dest.raw);
|
230
|
+
return dest;
|
231
|
+
}
|
232
|
+
|
233
|
+
/*!
|
234
|
+
* @brief resize perspective matrix by aspect ratio ( width / height )
|
235
|
+
* this makes very easy to resize proj matrix when window /viewport
|
236
|
+
* reized
|
237
|
+
*
|
238
|
+
* @param[in, out] proj perspective projection matrix
|
239
|
+
* @param[in] aspect aspect ratio ( width / height )
|
240
|
+
*/
|
241
|
+
CGLM_INLINE
|
242
|
+
void
|
243
|
+
glms_perspective_resize(mat4s proj, float aspect) {
|
244
|
+
glm_perspective_resize(aspect, proj.raw);
|
245
|
+
}
|
246
|
+
|
247
|
+
/*!
|
248
|
+
* @brief set up view matrix
|
249
|
+
*
|
250
|
+
* NOTE: The UP vector must not be parallel to the line of sight from
|
251
|
+
* the eye point to the reference point
|
252
|
+
*
|
253
|
+
* @param[in] eye eye vector
|
254
|
+
* @param[in] center center vector
|
255
|
+
* @param[in] up up vector
|
256
|
+
* @returns result matrix
|
257
|
+
*/
|
258
|
+
CGLM_INLINE
|
259
|
+
mat4s
|
260
|
+
glms_lookat(vec3s eye, vec3s center, vec3s up) {
|
261
|
+
mat4s dest;
|
262
|
+
glm_lookat(eye.raw, center.raw, up.raw, dest.raw);
|
263
|
+
return dest;
|
264
|
+
}
|
265
|
+
|
266
|
+
/*!
|
267
|
+
* @brief set up view matrix
|
268
|
+
*
|
269
|
+
* convenient wrapper for lookat: if you only have direction not target self
|
270
|
+
* then this might be useful. Because you need to get target from direction.
|
271
|
+
*
|
272
|
+
* NOTE: The UP vector must not be parallel to the line of sight from
|
273
|
+
* the eye point to the reference point
|
274
|
+
*
|
275
|
+
* @param[in] eye eye vector
|
276
|
+
* @param[in] dir direction vector
|
277
|
+
* @param[in] up up vector
|
278
|
+
* @returns result matrix
|
279
|
+
*/
|
280
|
+
CGLM_INLINE
|
281
|
+
mat4s
|
282
|
+
glms_look(vec3s eye, vec3s dir, vec3s up) {
|
283
|
+
mat4s dest;
|
284
|
+
glm_look(eye.raw, dir.raw, up.raw, dest.raw);
|
285
|
+
return dest;
|
286
|
+
}
|
287
|
+
|
288
|
+
/*!
|
289
|
+
* @brief set up view matrix
|
290
|
+
*
|
291
|
+
* convenient wrapper for look: if you only have direction and if you don't
|
292
|
+
* care what UP vector is then this might be useful to create view matrix
|
293
|
+
*
|
294
|
+
* @param[in] eye eye vector
|
295
|
+
* @param[in] dir direction vector
|
296
|
+
* @returns result matrix
|
297
|
+
*/
|
298
|
+
CGLM_INLINE
|
299
|
+
mat4s
|
300
|
+
glms_look_anyup(vec3s eye, vec3s dir) {
|
301
|
+
mat4s dest;
|
302
|
+
glm_look_anyup(eye.raw, dir.raw, dest.raw);
|
303
|
+
return dest;
|
304
|
+
}
|
305
|
+
|
306
|
+
/*!
|
307
|
+
* @brief decomposes frustum values of perspective projection.
|
308
|
+
*
|
309
|
+
* @param[in] proj perspective projection matrix
|
310
|
+
* @param[out] nearVal near
|
311
|
+
* @param[out] farVal far
|
312
|
+
* @param[out] top top
|
313
|
+
* @param[out] bottom bottom
|
314
|
+
* @param[out] left left
|
315
|
+
* @param[out] right right
|
316
|
+
*/
|
317
|
+
CGLM_INLINE
|
318
|
+
void
|
319
|
+
glms_persp_decomp(mat4s proj,
|
320
|
+
float * __restrict nearVal, float * __restrict farVal,
|
321
|
+
float * __restrict top, float * __restrict bottom,
|
322
|
+
float * __restrict left, float * __restrict right) {
|
323
|
+
glm_persp_decomp(proj.raw, nearVal, farVal, top, bottom, left, right);
|
324
|
+
}
|
325
|
+
|
326
|
+
/*!
|
327
|
+
* @brief decomposes frustum values of perspective projection.
|
328
|
+
* this makes easy to get all values at once
|
329
|
+
*
|
330
|
+
* @param[in] proj perspective projection matrix
|
331
|
+
* @param[out] dest array
|
332
|
+
*/
|
333
|
+
CGLM_INLINE
|
334
|
+
void
|
335
|
+
glms_persp_decompv(mat4s proj, float dest[6]) {
|
336
|
+
glm_persp_decompv(proj.raw, dest);
|
337
|
+
}
|
338
|
+
|
339
|
+
/*!
|
340
|
+
* @brief decomposes left and right values of perspective projection.
|
341
|
+
* x stands for x axis (left / right axis)
|
342
|
+
*
|
343
|
+
* @param[in] proj perspective projection matrix
|
344
|
+
* @param[out] left left
|
345
|
+
* @param[out] right right
|
346
|
+
*/
|
347
|
+
CGLM_INLINE
|
348
|
+
void
|
349
|
+
glms_persp_decomp_x(mat4s proj,
|
350
|
+
float * __restrict left,
|
351
|
+
float * __restrict right) {
|
352
|
+
glm_persp_decomp_x(proj.raw, left, right);
|
353
|
+
}
|
354
|
+
|
355
|
+
/*!
|
356
|
+
* @brief decomposes top and bottom values of perspective projection.
|
357
|
+
* y stands for y axis (top / botom axis)
|
358
|
+
*
|
359
|
+
* @param[in] proj perspective projection matrix
|
360
|
+
* @param[out] top top
|
361
|
+
* @param[out] bottom bottom
|
362
|
+
*/
|
363
|
+
CGLM_INLINE
|
364
|
+
void
|
365
|
+
glms_persp_decomp_y(mat4s proj,
|
366
|
+
float * __restrict top,
|
367
|
+
float * __restrict bottom) {
|
368
|
+
glm_persp_decomp_y(proj.raw, top, bottom);
|
369
|
+
}
|
370
|
+
|
371
|
+
/*!
|
372
|
+
* @brief decomposes near and far values of perspective projection.
|
373
|
+
* z stands for z axis (near / far axis)
|
374
|
+
*
|
375
|
+
* @param[in] proj perspective projection matrix
|
376
|
+
* @param[out] nearVal near
|
377
|
+
* @param[out] farVal far
|
378
|
+
*/
|
379
|
+
CGLM_INLINE
|
380
|
+
void
|
381
|
+
glms_persp_decomp_z(mat4s proj,
|
382
|
+
float * __restrict nearVal,
|
383
|
+
float * __restrict farVal) {
|
384
|
+
glm_persp_decomp_z(proj.raw, nearVal, farVal);
|
385
|
+
}
|
386
|
+
|
387
|
+
/*!
|
388
|
+
* @brief decomposes far value of perspective projection.
|
389
|
+
*
|
390
|
+
* @param[in] proj perspective projection matrix
|
391
|
+
* @param[out] farVal far
|
392
|
+
*/
|
393
|
+
CGLM_INLINE
|
394
|
+
void
|
395
|
+
glms_persp_decomp_far(mat4s proj, float * __restrict farVal) {
|
396
|
+
glm_persp_decomp_far(proj.raw, farVal);
|
397
|
+
}
|
398
|
+
|
399
|
+
/*!
|
400
|
+
* @brief decomposes near value of perspective projection.
|
401
|
+
*
|
402
|
+
* @param[in] proj perspective projection matrix
|
403
|
+
* @param[out] nearVal near
|
404
|
+
*/
|
405
|
+
CGLM_INLINE
|
406
|
+
void
|
407
|
+
glms_persp_decomp_near(mat4s proj, float * __restrict nearVal) {
|
408
|
+
glm_persp_decomp_near(proj.raw, nearVal);
|
409
|
+
}
|
410
|
+
|
411
|
+
/*!
|
412
|
+
* @brief returns field of view angle along the Y-axis (in radians)
|
413
|
+
*
|
414
|
+
* if you need to degrees, use glm_deg to convert it or use this:
|
415
|
+
* fovy_deg = glm_deg(glm_persp_fovy(projMatrix))
|
416
|
+
*
|
417
|
+
* @param[in] proj perspective projection matrix
|
418
|
+
*/
|
419
|
+
CGLM_INLINE
|
420
|
+
float
|
421
|
+
glms_persp_fovy(mat4s proj) {
|
422
|
+
return glm_persp_fovy(proj.raw);
|
423
|
+
}
|
424
|
+
|
425
|
+
/*!
|
426
|
+
* @brief returns aspect ratio of perspective projection
|
427
|
+
*
|
428
|
+
* @param[in] proj perspective projection matrix
|
429
|
+
*/
|
430
|
+
CGLM_INLINE
|
431
|
+
float
|
432
|
+
glms_persp_aspect(mat4s proj) {
|
433
|
+
return glm_persp_aspect(proj.raw);
|
434
|
+
}
|
435
|
+
|
436
|
+
/*!
|
437
|
+
* @brief returns sizes of near and far planes of perspective projection
|
438
|
+
*
|
439
|
+
* @param[in] proj perspective projection matrix
|
440
|
+
* @param[in] fovy fovy (see brief)
|
441
|
+
* @returns sizes as vector, sizes order: [Wnear, Hnear, Wfar, Hfar]
|
442
|
+
*/
|
443
|
+
CGLM_INLINE
|
444
|
+
vec4s
|
445
|
+
glms_persp_sizes(mat4s proj, float fovy) {
|
446
|
+
vec4s dest;
|
447
|
+
glm_persp_sizes(proj.raw, fovy, dest.raw);
|
448
|
+
return dest;
|
449
|
+
}
|
450
|
+
|
451
|
+
#endif /* cglms_cam_h */
|
@@ -0,0 +1,27 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c), Recep Aslantas.
|
3
|
+
*
|
4
|
+
* MIT License (MIT), http://opensource.org/licenses/MIT
|
5
|
+
* Full license can be found in the LICENSE file
|
6
|
+
*/
|
7
|
+
|
8
|
+
#ifndef cglms_colors_h
|
9
|
+
#define cglms_colors_h
|
10
|
+
|
11
|
+
#include "../common.h"
|
12
|
+
#include "../types-struct.h"
|
13
|
+
#include "../color.h"
|
14
|
+
#include "vec3.h"
|
15
|
+
|
16
|
+
/*!
|
17
|
+
* @brief averages the color channels into one value
|
18
|
+
*
|
19
|
+
* @param[in] rgb RGB color
|
20
|
+
*/
|
21
|
+
CGLM_INLINE
|
22
|
+
float
|
23
|
+
glms_luminance(vec3s rgb) {
|
24
|
+
return glm_luminance(rgb.raw);
|
25
|
+
}
|
26
|
+
|
27
|
+
#endif /* cglms_colors_h */
|
@@ -0,0 +1,40 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c), Recep Aslantas.
|
3
|
+
*
|
4
|
+
* MIT License (MIT), http://opensource.org/licenses/MIT
|
5
|
+
* Full license can be found in the LICENSE file
|
6
|
+
*/
|
7
|
+
|
8
|
+
#ifndef cglms_curves_h
|
9
|
+
#define cglms_curves_h
|
10
|
+
|
11
|
+
#include "../common.h"
|
12
|
+
#include "../types-struct.h"
|
13
|
+
#include "../curve.h"
|
14
|
+
#include "vec4.h"
|
15
|
+
#include "mat4.h"
|
16
|
+
|
17
|
+
/*!
|
18
|
+
* @brief helper function to calculate S*M*C multiplication for curves
|
19
|
+
*
|
20
|
+
* This function does not encourage you to use SMC,
|
21
|
+
* instead it is a helper if you use SMC.
|
22
|
+
*
|
23
|
+
* if you want to specify S as vector then use more generic glm_mat4_rmc() func.
|
24
|
+
*
|
25
|
+
* Example usage:
|
26
|
+
* B(s) = glm_smc(s, GLM_BEZIER_MAT, (vec4){p0, c0, c1, p1})
|
27
|
+
*
|
28
|
+
* @param[in] s parameter between 0 and 1 (this will be [s3, s2, s, 1])
|
29
|
+
* @param[in] m basis matrix
|
30
|
+
* @param[in] c position/control vector
|
31
|
+
*
|
32
|
+
* @return B(s)
|
33
|
+
*/
|
34
|
+
CGLM_INLINE
|
35
|
+
float
|
36
|
+
glms_smc(float s, mat4s m, vec4s c) {
|
37
|
+
return glm_smc(s, m.raw, c.raw);
|
38
|
+
}
|
39
|
+
|
40
|
+
#endif /* cglms_curves_h */
|
@@ -0,0 +1,152 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c), Recep Aslantas.
|
3
|
+
*
|
4
|
+
* MIT License (MIT), http://opensource.org/licenses/MIT
|
5
|
+
* Full license can be found in the LICENSE file
|
6
|
+
*/
|
7
|
+
|
8
|
+
/*
|
9
|
+
NOTE:
|
10
|
+
angles must be passed as [X-Angle, Y-Angle, Z-angle] order
|
11
|
+
For instance you don't pass angles as [Z-Angle, X-Angle, Y-angle] to
|
12
|
+
glm_euler_zxy funciton, All RELATED functions accept angles same order
|
13
|
+
which is [X, Y, Z].
|
14
|
+
*/
|
15
|
+
|
16
|
+
/*
|
17
|
+
Types:
|
18
|
+
enum glm_euler_seq
|
19
|
+
|
20
|
+
Functions:
|
21
|
+
CGLM_INLINE vec3s glms_euler_angles(mat4s m)
|
22
|
+
CGLM_INLINE mat4s glms_euler_xyz(vec3s angles)
|
23
|
+
CGLM_INLINE mat4s glms_euler_xzy(vec3s angles)
|
24
|
+
CGLM_INLINE mat4s glms_euler_yxz(vec3s angles)
|
25
|
+
CGLM_INLINE mat4s glms_euler_yzx(vec3s angles)
|
26
|
+
CGLM_INLINE mat4s glms_euler_zxy(vec3s angles)
|
27
|
+
CGLM_INLINE mat4s glms_euler_zyx(vec3s angles)
|
28
|
+
CGLM_INLINE mat4s glms_euler_by_order(vec3s angles, glm_euler_seq ord)
|
29
|
+
*/
|
30
|
+
|
31
|
+
#ifndef cglms_euler_h
|
32
|
+
#define cglms_euler_h
|
33
|
+
|
34
|
+
#include "../common.h"
|
35
|
+
#include "../types-struct.h"
|
36
|
+
#include "../euler.h"
|
37
|
+
|
38
|
+
/*!
|
39
|
+
* @brief extract euler angles (in radians) using xyz order
|
40
|
+
*
|
41
|
+
* @param[in] m affine transform
|
42
|
+
* @returns angles vector [x, y, z]
|
43
|
+
*/
|
44
|
+
CGLM_INLINE
|
45
|
+
vec3s
|
46
|
+
glms_euler_angles(mat4s m) {
|
47
|
+
vec3s dest;
|
48
|
+
glm_euler_angles(m.raw, dest.raw);
|
49
|
+
return dest;
|
50
|
+
}
|
51
|
+
|
52
|
+
/*!
|
53
|
+
* @brief build rotation matrix from euler angles
|
54
|
+
*
|
55
|
+
* @param[in] angles angles as vector [Xangle, Yangle, Zangle]
|
56
|
+
* @returns rotation matrix
|
57
|
+
*/
|
58
|
+
CGLM_INLINE
|
59
|
+
mat4s
|
60
|
+
glms_euler_xyz(vec3s angles) {
|
61
|
+
mat4s dest;
|
62
|
+
glm_euler_xyz(angles.raw, dest.raw);
|
63
|
+
return dest;
|
64
|
+
}
|
65
|
+
|
66
|
+
/*!
|
67
|
+
* @brief build rotation matrix from euler angles
|
68
|
+
*
|
69
|
+
* @param[in] angles angles as vector [Xangle, Yangle, Zangle]
|
70
|
+
* @returns rotation matrix
|
71
|
+
*/
|
72
|
+
CGLM_INLINE
|
73
|
+
mat4s
|
74
|
+
glms_euler_xzy(vec3s angles) {
|
75
|
+
mat4s dest;
|
76
|
+
glm_euler_xzy(angles.raw, dest.raw);
|
77
|
+
return dest;
|
78
|
+
}
|
79
|
+
|
80
|
+
|
81
|
+
/*!
|
82
|
+
* @brief build rotation matrix from euler angles
|
83
|
+
*
|
84
|
+
* @param[in] angles angles as vector [Xangle, Yangle, Zangle]
|
85
|
+
* @returns rotation matrix
|
86
|
+
*/
|
87
|
+
CGLM_INLINE
|
88
|
+
mat4s
|
89
|
+
glms_euler_yxz(vec3s angles) {
|
90
|
+
mat4s dest;
|
91
|
+
glm_euler_yxz(angles.raw, dest.raw);
|
92
|
+
return dest;
|
93
|
+
}
|
94
|
+
|
95
|
+
/*!
|
96
|
+
* @brief build rotation matrix from euler angles
|
97
|
+
*
|
98
|
+
* @param[in] angles angles as vector [Xangle, Yangle, Zangle]
|
99
|
+
* @returns rotation matrix
|
100
|
+
*/
|
101
|
+
CGLM_INLINE
|
102
|
+
mat4s
|
103
|
+
glms_euler_yzx(vec3s angles) {
|
104
|
+
mat4s dest;
|
105
|
+
glm_euler_yzx(angles.raw, dest.raw);
|
106
|
+
return dest;
|
107
|
+
}
|
108
|
+
|
109
|
+
/*!
|
110
|
+
* @brief build rotation matrix from euler angles
|
111
|
+
*
|
112
|
+
* @param[in] angles angles as vector [Xangle, Yangle, Zangle]
|
113
|
+
* @returns rotation matrix
|
114
|
+
*/
|
115
|
+
CGLM_INLINE
|
116
|
+
mat4s
|
117
|
+
glms_euler_zxy(vec3s angles) {
|
118
|
+
mat4s dest;
|
119
|
+
glm_euler_zxy(angles.raw, dest.raw);
|
120
|
+
return dest;
|
121
|
+
}
|
122
|
+
|
123
|
+
/*!
|
124
|
+
* @brief build rotation matrix from euler angles
|
125
|
+
*
|
126
|
+
* @param[in] angles angles as vector [Xangle, Yangle, Zangle]
|
127
|
+
* @returns rotation matrix
|
128
|
+
*/
|
129
|
+
CGLM_INLINE
|
130
|
+
mat4s
|
131
|
+
glms_euler_zyx(vec3s angles) {
|
132
|
+
mat4s dest;
|
133
|
+
glm_euler_zyx(angles.raw, dest.raw);
|
134
|
+
return dest;
|
135
|
+
}
|
136
|
+
|
137
|
+
/*!
|
138
|
+
* @brief build rotation matrix from euler angles
|
139
|
+
*
|
140
|
+
* @param[in] angles angles as vector [Xangle, Yangle, Zangle]
|
141
|
+
* @param[in] ord euler order
|
142
|
+
* @returns rotation matrix
|
143
|
+
*/
|
144
|
+
CGLM_INLINE
|
145
|
+
mat4s
|
146
|
+
glms_euler_by_order(vec3s angles, glm_euler_seq ord) {
|
147
|
+
mat4s dest;
|
148
|
+
glm_euler_by_order(angles.raw, ord, dest.raw);
|
149
|
+
return dest;
|
150
|
+
}
|
151
|
+
|
152
|
+
#endif /* cglms_euler_h */
|