Antkeeper  0.0.1
mesh-functions.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 Christopher J. Howard
3  *
4  * This file is part of Antkeeper source code.
5  *
6  * Antkeeper source code is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Antkeeper source code is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef ANTKEEPER_GEOM_MESH_FUNCTIONS_HPP
21 #define ANTKEEPER_GEOM_MESH_FUNCTIONS_HPP
22 
24 #include <engine/geom/mesh.hpp>
26 #include <array>
27 #include <vector>
28 
29 namespace geom {
30 
39 void create_triangle_mesh(mesh& mesh, const std::vector<float3>& vertices, const std::vector<std::array<std::uint_fast32_t, 3>>& triangles);
40 
46 void calculate_face_normals(float3* normals, const mesh& mesh);
47 
48 float3 calculate_face_normal(const mesh::face& face);
49 
57 void calculate_vertex_tangents(float4* tangents, const float2* texcoords, const float3* normals, const mesh& mesh);
58 
62 box<float> calculate_bounds(const mesh& mesh);
63 
71 mesh::vertex* poke_face(mesh& mesh, std::size_t index);
72 
73 } // namespace geom
74 
75 #endif // ANTKEEPER_GEOM_MESH_FUNCTIONS_HPP
76 
Geometric algorithms.
Definition: cartesian.hpp:26
void calculate_face_normals(float3 *normals, const mesh &mesh)
Calculates normals for each face.
void create_triangle_mesh(mesh &mesh, const std::vector< float3 > &vertices, const std::vector< std::array< std::uint_fast32_t, 3 >> &triangles)
Creates a triangle mesh from a list of vertices and indices.
box< float > calculate_bounds(const mesh &mesh)
Calculates the AABB bounds of a mesh.
mesh::vertex * poke_face(mesh &mesh, std::size_t index)
Triangulates a face by adding a new vertex in the center, then creating triangles between the edges o...
void calculate_vertex_tangents(float4 *tangents, const float2 *texcoords, const float3 *normals, const mesh &mesh)
Calculates smooth tangents per-vertex.
float3 calculate_face_normal(const mesh::face &face)
@ index
General purpose index (uint)