aboutsummaryrefslogtreecommitdiff
path: root/contrib/cgltf-tangents/cgltf_tangents.h
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2025-06-27 10:18:39 -0700
committer3gg <3gg@shellblade.net>2025-06-27 10:18:39 -0700
commitbd57f345ed9dbed1d81683e48199626de2ea9044 (patch)
tree4221f2f2a7ad2244d2e93052bd68187ec91b8ea9 /contrib/cgltf-tangents/cgltf_tangents.h
parent9a82ce0083437a4f9f58108b2c23b957d2249ad8 (diff)
Restructure projectHEADmain
Diffstat (limited to 'contrib/cgltf-tangents/cgltf_tangents.h')
-rw-r--r--contrib/cgltf-tangents/cgltf_tangents.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/contrib/cgltf-tangents/cgltf_tangents.h b/contrib/cgltf-tangents/cgltf_tangents.h
new file mode 100644
index 0000000..79e3502
--- /dev/null
+++ b/contrib/cgltf-tangents/cgltf_tangents.h
@@ -0,0 +1,67 @@
1/*
2Copyright 2022 Marc Sunet
3
4Redistribution and use in source and binary forms, with or without modification,
5are permitted provided that the following conditions are met:
6
71. Redistributions of source code must retain the above copyright notice, this
8list of conditions and the following disclaimer.
9
102. Redistributions in binary form must reproduce the above copyright notice,
11this list of conditions and the following disclaimer in the documentation and/or
12other materials provided with the distribution.
13
14THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
18ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24*/
25#ifndef CGLTF_TANGENTS_H_INCLUDED__
26#define CGLTF_TANGENTS_H_INCLUDED__
27
28#include <cgltf.h>
29
30/// A buffer that holds tangent vectors.
31///
32/// Tangent vectors are tightly packed in the array.
33///
34/// Tangent vectors have 4 coordinates: (X,Y,Z) for the vector, W for the sign.
35/// The usual rules of MikkTSpace apply, namely that the bitangent should be
36/// computed as:
37///
38/// bitangent = tangent.w * cross(normal, tangent.xyz);
39///
40/// Refer to the MikkTSpace documentation for more details.
41///
42/// The primitive pointer points to the mesh primitive for which the tangents in
43/// this buffer were computed. When your application loads mesh primitives, it
44/// can scan the cgltfTangetBuffer array outputed by cgltf_compute_tangents() to
45/// see whether tangents were computed for the mesh primitive.
46typedef struct cgltfTangentBuffer {
47 void* data; // X-coordinate of the first tangent vector.
48 cgltf_size size_bytes; // Total Size of data in bytes.
49 cgltf_primitive* primitive; // The primitive these tangents belong to.
50} cgltfTangentBuffer;
51
52/// Compute tangent vectors for normal-mapped mesh primitives missing them.
53///
54/// cgltf_options can be zeroed out but must be non-null.
55///
56/// cgltf_data is the scene previously loaded by cgltf.
57///
58/// out_tangent_buffers is an output array of tangent buffers, one buffer per
59/// mesh primitive for which tangents were computed.
60///
61/// out_num_tangent_buffers is the number of tangent buffers in the output
62/// array.
63cgltf_result cgltf_compute_tangents(const cgltf_options*, const cgltf_data*,
64 cgltfTangentBuffer** out_tangent_buffers,
65 cgltf_size* out_num_tangent_buffers);
66
67#endif // CGLTF_TANGENTS_H_INCLUDED__