2#include <engine/engine_export.h>
17namespace triangle_flags
109 const std::vector<uint32_t>& vertex_remap,
193 const skin_bind_data& bind_data)
const ->
const std::vector<math::mat4>&;
196 ->
const std::vector<math::mat4>&;
208 int32_t& current_space,
209 int32_t& common_base,
210 int32_t& additional_bones);
219 void assign_bones(std::vector<bool>& bones, std::vector<uint32_t>& faces);
319 uint32_t data_group_id{0};
321 int32_t vertex_start{-1};
323 uint32_t vertex_count{0};
325 int32_t face_start{-1};
327 uint32_t face_count{0};
329 std::string node_id{};
339 uint32_t vertices = 0;
341 uint32_t primitives = 0;
343 uint32_t submeshes = 0;
345 uint32_t data_groups = 0;
354 uint32_t data_group_id = 0;
356 std::array<uint32_t, 3> indices = {0, 0, 0};
377 std::vector<std::unique_ptr<armature_node>>
children;
394 uint32_t vertex_count = 0;
398 uint32_t triangle_count = 0;
402 uint32_t material_count = 0;
406 std::unique_ptr<armature_node> root_node =
nullptr;
434 void bind_render_buffers_for_submesh(
const submesh* submesh);
460 auto set_submeshes(
const std::vector<submesh>& submeshes) -> bool;
487 auto bind_armature(std::unique_ptr<armature_node>& root) -> bool;
489 auto load_mesh(
load_data&& data) -> bool;
507 uint32_t width_segments,
508 uint32_t height_segments,
510 bool hardware_copy =
true) -> bool;
531 uint32_t width_segments,
532 uint32_t height_segments,
533 uint32_t depth_segments,
535 bool hardware_copy =
true) -> bool;
541 uint32_t width_segments,
542 uint32_t height_segments,
543 uint32_t depth_segments,
545 bool hardware_copy =
true) -> bool;
564 bool hardware_copy =
true) -> bool;
585 bool hardware_copy =
true) -> bool;
606 bool hardware_copy =
true) -> bool;
629 bool hardware_copy =
true) -> bool;
650 bool hardware_copy =
true) -> bool;
660 auto create_teapot(
const gfx::vertex_layout& format,
bool hardware_copy =
true) -> bool;
670 auto create_icosahedron(
const gfx::vertex_layout& format,
bool hardware_copy =
true) -> bool;
680 auto create_dodecahedron(
const gfx::vertex_layout& format,
bool hardware_copy =
true) -> bool;
691 auto create_icosphere(
const gfx::vertex_layout& format,
int tesselation_level,
bool hardware_copy =
true) -> bool;
703 auto end_prepare(
bool hardware_copy =
true,
bool build_buffers =
true,
bool weld =
false,
bool optimize =
false)
711 void build_vb(
bool hardware_copy =
true);
718 void build_ib(
bool hardware_copy =
true);
727 auto generate_adjacency(std::vector<uint32_t>& adjacency) -> bool;
734 auto get_face_count() const -> uint32_t;
741 auto get_vertex_count() const -> uint32_t;
748 auto get_system_vb() -> uint8_t*;
755 auto get_system_ib() -> uint32_t*;
762 auto get_vertex_format() const -> const
gfx::vertex_layout&;
792 auto calculate_screen_rect(const
math::transform& world, const
camera& cam) const ->
irect32_t;
801 auto get_submesh(uint32_t submesh_index = 0) const -> const
mesh::
submesh&;
807 auto get_bounds() const -> const
math::bbox&;
821 auto get_data_groups_count() const ->
size_t;
828 auto get_submeshes_count() const ->
size_t;
829 auto get_skinned_submeshes_count() const ->
size_t;
833 auto get_non_skinned_submeshes_count() const ->
size_t;
837 auto get_submesh_index(const
submesh* s) const ->
int;
843 source_contains_normal = 0x1,
844 source_contains_binormal = 0x2,
845 source_contains_tangent = 0x4
849 uint8_t* vertex_source{
nullptr};
851 bool owns_source{
false};
863 uint32_t triangle_count{0};
865 uint32_t vertex_count{0};
869 bool compute_normals{
false};
871 bool compute_binormals{
false};
873 bool compute_tangents{
false};
875 bool compute_barycentric{
false};
877 bool check_for_degenerates{
false};
879 bool compute_per_triangle_material_data{
false};
886 int32_t cache_position{-1};
888 float vertex_score{0.0f};
890 uint32_t unused_triangle_references{0};
898 float triangle_score{0.0f};
906 const math::vec3* vertex1{
nullptr};
908 const math::vec3* vertex2{
nullptr};
914 uint32_t data_group_id{0};
923 uint8_t* vertex{
nullptr};
941 uint32_t data_group_id{0};
951 void check_for_degenerates();
960 auto generate_vertex_components(
bool weld) -> bool;
970 auto generate_vertex_normals(uint32_t* adjacency_ptr, std::vector<uint32_t>* remap_array_ptr =
nullptr) -> bool;
979 auto generate_vertex_barycentrics(uint32_t* adjacency) -> bool;
987 auto generate_vertex_tangents() -> bool;
997 auto weld_vertices(
float tolerance = 0.000001f, std::vector<uint32_t>* vertex_remap_ptr =
nullptr) -> bool;
1005 auto sort_mesh_data() -> bool;
1017 uint32_t* source_buffer_ptr,
1018 uint32_t* destination_buffer_ptr,
1019 uint32_t minimum_vertex,
1020 uint32_t maximum_vertex);
1032 bool force_tangent_generation_ =
false;
1034 bool force_normal_generation_ =
false;
1036 bool force_barycentric_generation_ =
false;
1038 bool disable_final_sort_ =
false;
1041 uint8_t* system_vb_ =
nullptr;
1045 uint32_t* system_ib_ =
nullptr;
1058 size_t skinned_submesh_count_{};
1062 size_t non_skinned_submesh_count_{};
1068 bool hardware_mesh_ =
true;
1070 bool optimize_mesh_ =
false;
1074 uint32_t face_count_ = 0;
1076 uint32_t vertex_count_ = 0;
1088 std::unique_ptr<armature_node> root_ =
nullptr;
Outlines a collection of bones that influence a given set of faces/vertices in the mesh.
std::map< uint32_t, uint32_t > bone_index_map_t
auto get_bones() const -> const std::vector< uint32_t > &
Retrieves the indices of the bones referenced by this palette.
auto get_maximum_size() const -> uint32_t
Retrieves the maximum size of the palette.
bone_index_map_t bones_lut_
< Sorted list of bones in this palette.
void clear_influenced_faces()
Clears out the temporary face influences array.
uint32_t data_group_id_
The maximum size of the palette.
void assign_bones(bone_index_map_t &bones, std::vector< uint32_t > &faces)
Assigns the specified bones (and faces) to this bone palette.
std::vector< uint32_t > faces_
The data group identifier used to separate the mesh data into submeshes relevant tothis bone palette.
auto get_maximum_blend_index() const -> int32_t
Retrieves the maximum vertex blend index for this palette.
auto get_influenced_faces() -> std::vector< uint32_t > &
Retrieves the list of faces assigned to this palette.
auto get_skinning_matrices(const std::vector< math::transform > &node_transforms, const skin_bind_data &bind_data) const -> const std::vector< math::mat4 > &
Gathers the bone/palette information and matrices ready for drawing the skinned mesh.
uint32_t maximum_size_
The maximum vertex blend index for this palette.
void compute_palette_fit(bone_index_map_t &input, int32_t ¤t_space, int32_t &common_base, int32_t &additional_bones)
Determines the relevant "fit" information that can be used to discover if and how the specified combi...
void set_data_group(uint32_t group)
Sets the identifier of the data group assigned to the submesh of the mesh reserved for this bone pale...
void set_maximum_blend_index(int index)
Sets the maximum vertex blend index for this palette.
int32_t maximum_blend_index_
auto translate_bone_to_palette(uint32_t bone_index) const -> uint32_t
Translates the specified bone index into its associated position in the palette.
bone_palette(uint32_t paletteSize)
Constructs a bone palette with the given size.
auto get_data_group() const -> uint32_t
Retrieves the identifier of the data group assigned to the submesh of the mesh reserved for this bone...
std::vector< uint32_t > bones_
List of faces assigned to this palette.
Class representing a camera. Contains functionality for manipulating and updating a camera....
Main class representing a 3D mesh with support for different LODs, submeshes, and skinning.
gfx::vertex_layout vertex_format_
The final system memory copy of the index buffer.
bone_palette_array_t bone_palettes_
List of armature nodes.
std::shared_ptr< void > hardware_vb_
The actual hardware index buffer resource.
submesh_array_map_t non_skinned_submesh_indices_
auto set_vertex_source(void *source, uint32_t vertex_count, const gfx::vertex_layout &source_format) -> bool
Sets the source of the vertex buffer to pull data from while preparing the mesh.
submesh_array_t mesh_submeshes_
Indices in the subset array which are skinned.
std::vector< mesh_submesh_key > submesh_key_array_t
std::map< uint32_t, submesh_array_indices_t > submesh_array_map_t
std::vector< uint8_t > byte_array_t
math::bbox bbox_
Total number of faces in the prepared mesh.
data_group_submesh_map_t data_groups_
Whether the mesh uses a hardware vertex/index buffer.
std::shared_ptr< void > hardware_ib_
The actual list of submeshes maintained by this mesh.
submesh_array_map_t skinned_submesh_indices_
skin_bind_data skin_bind_data_
List of unique combinations of bones to use during rendering.
preparation_data preparation_data_
Data describing how the mesh should be bound as a skin with supplied bone matrices.
std::vector< size_t > submesh_array_indices_t
std::map< mesh_submesh_key, submesh * > submesh_key_map_t
std::vector< bone_palette > bone_palette_array_t
std::vector< submesh * > submesh_array_t
std::map< uint32_t, submesh_array_t > data_group_submesh_map_t
std::vector< triangle > triangle_array_t
submesh_key_array_t triangle_data_
The actual hardware vertex buffer resource.
std::map< bone_combination_key, std::vector< uint32_t > * > bone_combination_map_t
Structure describing how a skinned mesh should be bound to any bones that influence its vertices.
void build_vertex_table(uint32_t vertex_count, const std::vector< uint32_t > &vertex_remap, vertex_data_array_t &table)
Constructs a list of bone influences and weights for each vertex based on the binding data provided.
void remap_vertices(const std::vector< uint32_t > &remap)
Remaps the vertex references stored in the binding based on the supplied remap array.
auto get_bones() const -> const bone_influence_array_t &
Retrieves a list of all bones that influence the skin in some way.
std::vector< vertex_data > vertex_data_array_t
auto find_bone_by_id(const std::string &id) const -> bone_query
Finds a bone by its unique identifier.
void clear()
Clears out the bone information stored in this object.
auto has_bones() const -> bool
Checks whether the skin data has any bones.
void remove_empty_bones()
Removes any bones that do not contain any influences.
std::vector< vertex_influence > vertex_influence_array_t
std::vector< bone_influence > bone_influence_array_t
void clear_vertex_influences()
Releases memory allocated for vertex influences in each stored bone.
void add_bone(const bone_influence &bone)
Adds influence information for a specific bone.
bgfx::VertexLayout vertex_layout
auto operator<(const mesh::adjacent_edge_key &key1, const mesh::adjacent_edge_key &key2) -> bool
@ box
Box type reflection probe.
Storage for box vector values and wraps up common functionality.
std::vector< uint32_t > submeshes
std::string name
< Name of the armature node.
math::transform local_transform
Children nodes of this armature node.
std::vector< std::unique_ptr< armature_node > > children
submesh indices affected by this node
bone_palette::bone_index_map_t bones
< List of unique bones that influence a given number of faces.
Struct used for mesh construction.
triangle_array_t triangle_data
Total number of triangles.
std::vector< mesh::submesh > submeshes
Total number of materials.
std::vector< uint8_t > vertex_data
Total number of vertices.
gfx::vertex_layout vertex_format
< The format of the vertex data.
skin_bind_data skin_data
Root node of the armature.
std::vector< uint32_t > triangle_references
std::vector< uint32_t > vertex_records
Final vertex buffer currently being prepared.
triangle_array_t triangle_data
Total number of triangles currently stored.
gfx::vertex_layout source_format
Records the location in the vertex buffer that each vertex has been placed during data insertion.
std::vector< submesh > submeshes
Whether to compute vertex normals.
byte_array_t vertex_data
Additional descriptive information about the vertices.
byte_array_t vertex_flags
Stores the current face/triangle data.
Structure describing an individual "piece" of the mesh, often grouped by material,...
Structure describing data for a single triangle in the mesh.
gfx::vertex_layout format
Tolerance for welding vertices.
Describes the vertices that are connected to the referenced bone and how much influence it has on the...
std::string bone_id
< The unique identifier of the bone.
math::transform bind_pose_transform
List of vertices influenced by the bone.
vertex_influence_array_t influences
Contains per-vertex influence and weight information.
int32_t palette
The index of the original vertex.
std::vector< int32_t > influences
< List of bones that influence this vertex.
std::vector< float > weights
Index of the palette to which this vertex has been assigned.
Describes how a bone influences a specific vertex.
uint32_t vertex_index
< The index of the vertex influenced by the bone.