# mesh.cpp File Reference

`#include "mesh.h"`
`#include "readwrite.h"`
`#include "chunk.h"`
`#include "vector.h"`
`#include "matrix.h"`
`#include <stdlib.h>`
`#include <string.h>`
`#include <math.h>`
`#include "config.h"`

Include dependency graph for mesh.cpp:

## Defines

#define | LIB3DS_EXPORT

## Typedefs

typedef _Lib3dsFaces | Lib3dsFaces

## Functions

Lib3dsMesh * | lib3ds_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 min, Lib3dsVector max)
void | lib3ds_mesh_calculate_normals (Lib3dsMesh *mesh, Lib3dsVector *normalL)
void | lib3ds_mesh_dump (Lib3dsMesh *mesh)
Lib3dsBool | lib3ds_mesh_read (Lib3dsMesh *mesh, FILE *f)
Lib3dsBool | lib3ds_mesh_write (Lib3dsMesh *mesh, FILE *f)

## Define Documentation

#define LIB3DS_EXPORT

## Typedef Documentation

typedef struct _Lib3dsFaces Lib3dsFaces

## Function Documentation

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]