#include "mtl.h"
#include "position.h"
#include <float.h>
Go to the source code of this file.
|
| struct | gm3MeshFace |
| | Represents a single face (triangle) in a 3D mesh. More...
|
| struct | gm3Tex |
| | Represents a 2D texture coordinate. More...
|
| struct | gm3Mesh |
| | Represents a 3D mesh composed of vertices, faces, normals, and texture coordinates. More...
|
| | Header for the baked mesh binary format. More...
|
◆ GM3_BAKED_MESH_MAGIC
| #define GM3_BAKED_MESH_MAGIC 0x474D334D |
Magic number for the baked mesh binary format: "GM3M".
◆ gm3_mesh_center()
Centers the mesh geometry around the origin (0,0,0).
This function calculates the bounding box of the mesh and translates all vertices so that the center of the bounding box is at the origin.
- Parameters
-
| m | A pointer to the gm3Mesh to center. |
- Returns
- 0 on success, -1 if the mesh is NULL.
◆ gm3_mesh_deserialize()
| int gm3_mesh_deserialize |
( |
gm3Mesh * | mesh, |
|
|
const void * | data, |
|
|
size_t | size ) |
Deserializes a gm3Mesh from a binary buffer.
This function reconstructs a gm3Mesh from a binary buffer created by gm3_mesh_serialize. The deserialized mesh will have its internal arrays dynamically allocated.
- Parameters
-
| mesh | A pointer to the gm3Mesh to fill with deserialized data. |
| data | A pointer to the binary buffer containing the serialized data. |
| size | The size of the binary buffer. |
- Returns
- 0 on success, -1 on failure (e.g., invalid magic, buffer too small, memory allocation failure).
◆ gm3_mesh_free()
Frees all dynamically allocated memory associated with a gm3Mesh struct.
- Parameters
-
◆ gm3_mesh_serialize()
| int gm3_mesh_serialize |
( |
const gm3Mesh * | mesh, |
|
|
void ** | data, |
|
|
size_t * | size ) |
Serializes a gm3Mesh into a binary buffer.
This function converts the mesh data into a compact binary format, suitable for baking into a file or memory. The caller is responsible for freeing *data.
- Parameters
-
| mesh | A pointer to the gm3Mesh to serialize. |
| data | A pointer to a void* that will be allocated and filled with the serialized data. |
| size | A pointer to a size_t that will store the size of the serialized data. |
- Returns
- 0 on success, -1 on memory allocation failure.