DHART
|
Functions | |
C_INTERFACE | LoadOBJ (const char *obj_path, HF::Geometry::GROUP_METHOD gm, float xrot, float yrot, float zrot, HF::Geometry::MeshInfo< float > ***out_data_array, int *num_meshes) |
Load an obj from the given path then rotate it by x,y, and z. More... | |
C_INTERFACE | StoreMesh (HF::Geometry::MeshInfo< float > **out_info, const int *indices, int num_indices, const float *vertices, int num_vertices, const char *name, int id) |
Store a mesh in a format usable with DHARTAPI. More... | |
C_INTERFACE | RotateMesh (HF::Geometry::MeshInfo< float > *mesh_to_rotate, float xrot, float yrot, float zrot) |
Rotate an existing mesh (HF::Geometry::MeshInfo) More... | |
C_INTERFACE | GetVertsAndTris (const HF::Geometry::MeshInfo< float > *MI, int **index_out, int *num_triangles, float **vertex_out, int *num_vertices) |
Get a pointer to and the size of a mesh's triangle and vertex arrays. More... | |
C_INTERFACE | GetMeshName (const HF::Geometry::MeshInfo< float > *MI, char **out_name) |
Get the name of a mesh. More... | |
C_INTERFACE | GetMeshID (const HF::Geometry::MeshInfo< float > *MI, int *out_id) |
Get the ID of a mesh. More... | |
C_INTERFACE | DestroyMeshInfo (HF::Geometry::MeshInfo< float > *mesh_to_destroy) |
Free the memory addressed by mesh_to_destroy, which was allocated by either LoadOBJ or StoreMesh. More... | |
C_INTERFACE | DestroyMeshInfoPtrArray (HF::Geometry::MeshInfo< float > **data_array) |
Read and manipulate meshes
First, we prepare the relative path to the mesh. (.obj file)
Then, we prepare a pointer to a vector<HF::Geometry::MeshInfo>.
We pass the address of this pointer to LoadOBJ .
loaded_obj points to the loaded mesh.
When you are finished with the mesh, you must then relinquish its memory resources:
>>> LoadOBJ loaded mesh successfully into loaded_obj at address 000001DBFADFAF50, code: 1
The client is responsible for releasing the memory for
the mesh (vector<HF::Geometry::MeshInfo> *).
Every example for each function should be followed up by the 'teardown' code described above.
LoadOBJ and RotateMesh both call
HF::Geometry::MeshInfo::PerformRotation, which contains the following:
rotation_matrix is a local variable in PerformRotation,
and verts is a private field within HF::Geometry::MeshInfo.
These assertion statements may evaluate false (which will halt execution)
if NANs (not-a-number) or infinity values were created
from the xrot, yrot, or zrot values passed to LoadOBJ or RotateMesh.
C_INTERFACE DestroyMeshInfo | ( | HF::Geometry::MeshInfo< float > * | mesh_to_destroy | ) |
#include <Cinterface/objloader_C.h>
Free the memory addressed by mesh_to_destroy, which was allocated by either LoadOBJ or StoreMesh.
mesh_to_destroy | The HF::Geometry::MeshInfo * whose memory will be released |
Definition at line 126 of file objloader_C.cpp.
References DeleteRawPtr(), and HF::Exceptions::OK.
C_INTERFACE DestroyMeshInfoPtrArray | ( | HF::Geometry::MeshInfo< float > ** | data_array | ) |
#include <Cinterface/objloader_C.h>
Definition at line 132 of file objloader_C.cpp.
References HF::Exceptions::OK.
C_INTERFACE GetMeshID | ( | const HF::Geometry::MeshInfo< float > * | MI, |
int * | out_id | ||
) |
#include <Cinterface/objloader_C.h>
Get the ID of a mesh.
MI | Instance of MeshInfo to get the name of |
out_name | Pointer to the integer to write output to. This must be a valid pointer |
HF_STATUS::OK
Definition at line 119 of file objloader_C.cpp.
References HF::Geometry::MeshInfo< numeric_type >::meshid.
Referenced by LoadOBJ().
C_INTERFACE GetMeshName | ( | const HF::Geometry::MeshInfo< float > * | MI, |
char ** | out_name | ||
) |
#include <Cinterface/objloader_C.h>
Get the name of a mesh.
MI | Instance of MeshInfo to get the name of |
out_name | Pointer to the char array to write output to. This must be a valid pointer |
HF_STATUS::OK
Definition at line 108 of file objloader_C.cpp.
References HF::Geometry::MeshInfo< numeric_type >::name.
C_INTERFACE GetVertsAndTris | ( | const HF::Geometry::MeshInfo< float > * | MI, |
int ** | index_out, | ||
int * | num_triangles, | ||
float ** | vertex_out, | ||
int * | num_vertices | ||
) |
#include <Cinterface/objloader_C.h>
Get a pointer to and the size of a mesh's triangle and vertex arrays.
index_out | Output parameter for a pointer to the mesh's vertex array |
num_triangles | Number of triangles in the index array. Every 3 indices is a new triangle, so this is equal to the length of index_out divided by 3. |
vertex_out | Output parameter for a pointer to the mesh's index array. |
num_vertices | Number of vertices in the vertex array. Every 3 floats is a new vertex, so this is equal to the length of vertex_out divided by 3. |
Definition at line 94 of file objloader_C.cpp.
References HF::Geometry::MeshInfo< numeric_type >::GetIndexPointer(), and HF::Geometry::MeshInfo< numeric_type >::GetVertexPointer().
C_INTERFACE LoadOBJ | ( | const char * | obj_path, |
HF::Geometry::GROUP_METHOD | gm, | ||
float | xrot, | ||
float | yrot, | ||
float | zrot, | ||
HF::Geometry::MeshInfo< float > *** | out_data_array, | ||
int * | num_meshes | ||
) |
#include <Cinterface/objloader_C.h>
Load an obj from the given path then rotate it by x,y, and z.
obj_path | Filepath to the obj file to load. |
gm | Method to use for dividing a single obj file into multiple meshes. |
xrot | Degrees to rotate the mesh on the x axis. |
yrot | Degrees to rotate the mesh on the y axis. |
zrot | Degrees to rotate the mesh on the z axis. |
out_data_array | Output parameter for the new array of meshinfo |
num_meshes | Output parameter for size of out_data_array |
HF_STATUS::OK
If the input was a valid mesh and the function completed successfully HF_STATUS::GENERIC_ERROR
If the input was empty. HF_STATUS::INVALID_OBJ
if the path didn't lead to a valid OBJ file HF_STATUS::NOT_FOUND
if the file at the given path couldn't be found.HF_STATUS::OK
is not called, no memory is allocated, and as such no memory must be deallocated.Definition at line 13 of file objloader_C.cpp.
References GetMeshID(), and HF::Geometry::LoadMeshObjects().
C_INTERFACE RotateMesh | ( | HF::Geometry::MeshInfo< float > * | mesh_to_rotate, |
float | xrot, | ||
float | yrot, | ||
float | zrot | ||
) |
#include <Cinterface/objloader_C.h>
Rotate an existing mesh (HF::Geometry::MeshInfo)
mesh_to_rotate | An operand vector<HF::Geometry::MeshInfo> * that addresses memory allocated by LoadOBJ or StoreMesh |
xrot | Degrees to rotate the mesh about the x axis. 0.0f would mean no rotation about the x axis. |
yrot | Degrees to rotate the mesh about the y axis. 0.0f would mean no rotation about the y axis. |
zrot | Degrees to rotate the mesh about the z axis. 0.0f would mean no rotation about the z axis. |
Definition at line 84 of file objloader_C.cpp.
References HF::Geometry::MeshInfo< numeric_type >::meshid, and HF::Geometry::MeshInfo< numeric_type >::PerformRotation().
C_INTERFACE StoreMesh | ( | HF::Geometry::MeshInfo< float > ** | out_info, |
const int * | indices, | ||
int | num_indices, | ||
const float * | vertices, | ||
int | num_vertices, | ||
const char * | name, | ||
int | id | ||
) |
#include <Cinterface/objloader_C.h>
Store a mesh in a format usable with DHARTAPI.
out_info | Output parameter to contain the new instance of meshinfo |
indices | An array of indices for the triangles within the mesh. Each member in this array is an integer that corresponds to a set of 3 vertex coordinates, { x, y, z }. indices[0] represents { vertices[0], vertices[1], vertices[2] } indices[1] represents { vertices[3], vertices[4], vertices[5] }, etc. Every 3 array members in indices represents a complete triangle for the mesh. |
num_indices | Member count (size) of the indices array. This value should be (size of vertices / 3) && (num_indices % 3 == 0) |
vertices | An array of vertex coordinates, which represents the location of a mesh. Starting at i = 0, { vertices[i], vertices[i + 1], vertices[i + 2] } represents a point in space. |
num_vertices | Member count (size) of the vertices array. This value should be (size of indices * 3) && (num_vertices % 3 == 0) |
name | The desired name for the mesh (a human-readable identifier) |
id | The desired ID for the mesh (an integral value) |
First, we must prepare the values for the mesh to store.
We are now ready to call StoreMesh.
>>> The mesh was stored properly at address 0000029C6317BEB0.
Definition at line 59 of file objloader_C.cpp.
References HF::Exceptions::INVALID_OBJ, and HF::Exceptions::OK.