Meshes


Data Structures

struct  Lib3dsPoint
 Triangular mesh point. More...
struct  Lib3dsFace
 Triangular mesh face. More...
struct  Lib3dsBoxMap
 Triangular mesh box mapping settings. More...
struct  Lib3dsMapData
 Triangular mesh texture mapping data. More...
struct  Lib3dsMesh
 Triangular mesh object. More...

Functions

Lib3dsMeshlib3ds_mesh_new (const char *name)
void lib3ds_mesh_free (Lib3dsMesh *mesh)
Lib3dsBool lib3ds_mesh_new_point_list (Lib3dsMesh *mesh, Lib3dsDword points)
void lib3ds_mesh_free_point_list (Lib3dsMesh *mesh)
Lib3dsBool lib3ds_mesh_new_flag_list (Lib3dsMesh *mesh, Lib3dsDword flags)
void lib3ds_mesh_free_flag_list (Lib3dsMesh *mesh)
Lib3dsBool lib3ds_mesh_new_texel_list (Lib3dsMesh *mesh, Lib3dsDword texels)
void lib3ds_mesh_free_texel_list (Lib3dsMesh *mesh)
Lib3dsBool lib3ds_mesh_new_face_list (Lib3dsMesh *mesh, Lib3dsDword faces)
void lib3ds_mesh_free_face_list (Lib3dsMesh *mesh)
void lib3ds_mesh_bounding_box (Lib3dsMesh *mesh, Lib3dsVector bmin, Lib3dsVector bmax)
void lib3ds_mesh_calculate_normals (Lib3dsMesh *mesh, Lib3dsVector *normalL)
void lib3ds_mesh_dump (Lib3dsMesh *mesh)
Lib3dsBool lib3ds_mesh_read (Lib3dsMesh *mesh, Lib3dsIo *io)
Lib3dsBool lib3ds_mesh_write (Lib3dsMesh *mesh, Lib3dsIo *io)

Function Documentation

void lib3ds_mesh_bounding_box ( Lib3dsMesh mesh,
Lib3dsVector  bmin,
Lib3dsVector  bmax 
)

Find the bounding box of a mesh object.

Parameters:
mesh The mesh object
bmin Returned bounding box
bmax Returned bounding box

Definition at line 435 of file mesh.c.

References lib3ds_vector_max(), lib3ds_vector_min(), Lib3dsMesh::pointL, Lib3dsMesh::points, and Lib3dsPoint::pos.

Referenced by lib3ds_file_bounding_box_of_objects().

void lib3ds_mesh_calculate_normals ( Lib3dsMesh mesh,
Lib3dsVector normalL 
)

Calculates the vertex normals corresponding to the smoothing group settings for each face of a mesh.

Parameters:
mesh A pointer to the mesh to calculate the normals for.
normalL A pointer to a buffer to store the calculated normals. The buffer must have the size: 3*sizeof(Lib3dsVector)*mesh->faces.
To allocate the normal buffer do for example the following:
  Lib3dsVector *normalL = malloc(3*sizeof(Lib3dsVector)*mesh->faces);

To access the normal of the i-th vertex of the j-th face do the following:

   normalL[3*j+i]

Definition at line 479 of file mesh.c.

References Lib3dsMesh::faceL, Lib3dsMesh::faces, lib3ds_vector_add(), lib3ds_vector_copy(), lib3ds_vector_dot(), lib3ds_vector_normalize(), lib3ds_vector_zero(), and Lib3dsMesh::points.

void lib3ds_mesh_dump ( Lib3dsMesh mesh  ) 

This function prints data associated with the specified mesh such as vertex and point lists.

Parameters:
mesh Points to a mesh that you wish to view the data for.
Returns:
None
Warning:
WIN32: Should only be used in a console window not in a GUI.

Definition at line 565 of file mesh.c.

References Lib3dsMesh::faceL, Lib3dsMesh::faces, Lib3dsFace::flags, lib3ds_matrix_dump(), lib3ds_vector_copy(), Lib3dsFace::material, Lib3dsMesh::matrix, Lib3dsMesh::name, Lib3dsMesh::pointL, Lib3dsMesh::points, Lib3dsFace::points, Lib3dsPoint::pos, and Lib3dsFace::smoothing.

Referenced by lib3ds_file_dump_meshes().

void lib3ds_mesh_free ( Lib3dsMesh mesh  ) 

Free a mesh object and all of its resources.

Parameters:
mesh Mesh object to be freed.

Definition at line 177 of file mesh.c.

References lib3ds_mesh_free_face_list(), lib3ds_mesh_free_flag_list(), lib3ds_mesh_free_point_list(), and lib3ds_mesh_free_texel_list().

Referenced by lib3ds_file_free().

void lib3ds_mesh_free_face_list ( Lib3dsMesh mesh  ) 

Free face list in mesh object.

The current face list is freed and set to NULL. mesh->faces is set to zero.

Parameters:
mesh Mesh object to be modified.

Definition at line 410 of file mesh.c.

References Lib3dsMesh::faceL, and Lib3dsMesh::faces.

Referenced by lib3ds_mesh_free(), and lib3ds_mesh_new_face_list().

void lib3ds_mesh_free_flag_list ( Lib3dsMesh mesh  ) 

Free flag list in mesh object.

The current flag list is freed and set to NULL. mesh->flags is set to zero.

Parameters:
mesh Mesh object to be modified.

Definition at line 292 of file mesh.c.

References Lib3dsMesh::flagL, and Lib3dsMesh::flags.

Referenced by lib3ds_mesh_free(), lib3ds_mesh_new_flag_list(), and lib3ds_mesh_read().

void lib3ds_mesh_free_point_list ( Lib3dsMesh mesh  ) 

Free point list in mesh object.

The current point list is freed and set to NULL. mesh->points is set to zero.

Parameters:
mesh Mesh object to be modified.

Definition at line 232 of file mesh.c.

References Lib3dsMesh::pointL, and Lib3dsMesh::points.

Referenced by lib3ds_mesh_free(), lib3ds_mesh_new_point_list(), and lib3ds_mesh_read().

void lib3ds_mesh_free_texel_list ( Lib3dsMesh mesh  ) 

Free texel list in mesh object.

The current texel list is freed and set to NULL. mesh->texels is set to zero.

Parameters:
mesh Mesh object to be modified.

Definition at line 351 of file mesh.c.

References Lib3dsMesh::texelL, and Lib3dsMesh::texels.

Referenced by lib3ds_mesh_free(), lib3ds_mesh_new_texel_list(), and lib3ds_mesh_read().

Lib3dsMesh* lib3ds_mesh_new ( const char *  name  ) 

Create and return a new empty mesh object.

Mesh is initialized with the name and an identity matrix; all other fields are zero.

See Lib3dsFaceFlag for definitions of per-face flags.

Parameters:
name Mesh name. Must not be NULL. Must be < 64 characters.
Returns:
mesh object or NULL on error.

Definition at line 151 of file mesh.c.

References LIB3DS_MAP_NONE, lib3ds_matrix_identity(), Lib3dsMesh::map_data, Lib3dsMapData::maptype, Lib3dsMesh::matrix, and Lib3dsMesh::name.

Lib3dsBool lib3ds_mesh_new_face_list ( Lib3dsMesh mesh,
Lib3dsDword  faces 
)

Allocate face list in mesh object.

This function frees the current face list, if any, and allocates a new one large enough to hold the specified number of faces.

Parameters:
mesh Mesh object for which points are to be allocated.
faces Number of faces in the new face list.
Returns:
LIB3DS_TRUE on success, LIB3DS_FALSE on failure.

Definition at line 380 of file mesh.c.

References Lib3dsMesh::faceL, Lib3dsMesh::faces, and lib3ds_mesh_free_face_list().

Lib3dsBool lib3ds_mesh_new_flag_list ( Lib3dsMesh mesh,
Lib3dsDword  flags 
)

Allocate flag list in mesh object.

This function frees the current flag list, if any, and allocates a new one large enough to hold the specified number of flags. All flags are initialized to 0

Parameters:
mesh Mesh object for which points are to be allocated.
flags Number of flags in the new flag list.
Returns:
LIB3DS_TRUE on success, LIB3DS_FALSE on failure.

Definition at line 262 of file mesh.c.

References Lib3dsMesh::flagL, Lib3dsMesh::flags, and lib3ds_mesh_free_flag_list().

Referenced by lib3ds_mesh_read().

Lib3dsBool lib3ds_mesh_new_point_list ( Lib3dsMesh mesh,
Lib3dsDword  points 
)

Allocate point list in mesh object.

This function frees the current point list, if any, and allocates a new one large enough to hold the specified number of points.

Parameters:
mesh Mesh object for which points are to be allocated.
points Number of points in the new point list.
Returns:
LIB3DS_TRUE on success, LIB3DS_FALSE on failure.

Definition at line 202 of file mesh.c.

References lib3ds_mesh_free_point_list(), Lib3dsMesh::pointL, and Lib3dsMesh::points.

Referenced by lib3ds_mesh_read().

Lib3dsBool lib3ds_mesh_new_texel_list ( Lib3dsMesh mesh,
Lib3dsDword  texels 
)

Allocate texel list in mesh object.

This function frees the current texel list, if any, and allocates a new one large enough to hold the specified number of texels.

Parameters:
mesh Mesh object for which points are to be allocated.
texels Number of texels in the new texel list.
Returns:
LIB3DS_TRUE on success, LIB3DS_FALSE on failure.

Definition at line 321 of file mesh.c.

References lib3ds_mesh_free_texel_list(), Lib3dsMesh::texelL, and Lib3dsMesh::texels.

Referenced by lib3ds_mesh_read().


Hosted by
SourceForge.net Logo
Generated at Wed Jun 20 18:51:36 2007 by Doxygen 1.5.2