faogenlib3
Typedefs | Enumerations | Functions
faogenlib3 Namespace Reference

fast ambient occlusion generator library More...

Typedefs

typedef int obj_handle
 A type that represents object handle.
 

Enumerations

enum  e_index_type { INDEX_U16, INDEX_U32 }
 Selects index type. More...
 

Functions

bool initialize ()
 
void shutdown ()
 
obj_handle create_object_v (float const *vertices3f, size_t vertices_stride, size_t num_vertices, e_index_type index_type, void const *triangle_indices, size_t num_indices)
 
obj_handle create_object_vn (float const *vertices3f, size_t vertices_stride, float const *normals3f, size_t normals_stride, size_t num_vertices, e_index_type index_type, void const *triangle_indices, size_t num_indices)
 
obj_handle create_object_vnt (float const *vertices3f, size_t vertices_stride, float const *normals3f, size_t normals_stride, float const *texcoords2f, size_t texcoords_stride, size_t num_vertices, e_index_type index_type, void const *triangle_indices, size_t num_indices)
 
void set_object_matrix (obj_handle object_id, float const *matrix)
 
bool start_ao_gen_vert (obj_handle object_id, unsigned quality, int hemisphere_mode)
 
bool start_ao_gen_tex (obj_handle object_id, unsigned quality, unsigned width, unsigned height, int hemisphere_mode)
 
unsigned num_iterations (unsigned quality)
 
void ao_vert_generate (size_t iterations)
 
void ao_tex_generate (size_t iterations)
 
bool results_ready ()
 
float const * get_vert_results ()
 
float const * get_tex_results ()
 
void destroy_object (obj_handle object_id)
 

Detailed Description

fast ambient occlusion generator library

Enumeration Type Documentation

Selects index type.

Enumerator
INDEX_U16 

16-bit unsigned integer

INDEX_U32 

32-bit unsigned integer

Function Documentation

void faogenlib3::ao_tex_generate ( size_t  iterations)

Perform texture ao generation.

Parameters
iterationsnumber of iterations in this step.
void faogenlib3::ao_vert_generate ( size_t  iterations)

Perform per-vertex ao generation.

Parameters
iterationsnumber of iterations in this step.
obj_handle faogenlib3::create_object_v ( float const *  vertices3f,
size_t  vertices_stride,
size_t  num_vertices,
e_index_type  index_type,
void const *  triangle_indices,
size_t  num_indices 
)

Create object. For objects, created with this function ambient occlusion data can't be generated, they will serve only as occludders for other objects.

Parameters
vertices3fA pointer to the first coordinate of the first vertex in the array. Each vertex has 3 coordinates - X, Y, Z.
vertices_strideThe byte offset between consecutive vertices. When stride is zero, the vertices are tightly packed in the array.
num_verticesTotal number of vertices.
index_typeThe type of the values in triangle_indices
triangle_indicesA pointer to the location where the indices are stored
num_indicesNumber of indices. Must be a multiple of 3.
Returns
Handle to created object.
obj_handle faogenlib3::create_object_vn ( float const *  vertices3f,
size_t  vertices_stride,
float const *  normals3f,
size_t  normals_stride,
size_t  num_vertices,
e_index_type  index_type,
void const *  triangle_indices,
size_t  num_indices 
)

Create object. For objects, created with this function only per-vertex ambient occlusion data can be generated.

Parameters
vertices3fA pointer to the first coordinate of the first vertex in the array. Each vertex has 3 coordinates - X, Y, Z.
vertices_strideThe byte offset between consecutive vertices. When stride is zero, the vertices are tightly packed in the array.
normals3fA pointer to the first coordinate of the first normal in the array. Each normal has 3 coordinates - X, Y, Z.
normals_strideThe byte offset between consecutive normals. When stride is zero, the normals are tightly packed in the array.
num_verticesTotal number of vertices.
index_typeThe type of the values in triangle_indices
triangle_indicesA pointer to the location where the indices are stored
num_indicesNumber of indices. Must be a multiple of 3.
Returns
Handle to created object.
obj_handle faogenlib3::create_object_vnt ( float const *  vertices3f,
size_t  vertices_stride,
float const *  normals3f,
size_t  normals_stride,
float const *  texcoords2f,
size_t  texcoords_stride,
size_t  num_vertices,
e_index_type  index_type,
void const *  triangle_indices,
size_t  num_indices 
)

Create object. For objects, created with this function both per-vertex and texture ambient occlusion can be generated.

Parameters
vertices3fA pointer to the first coordinate of the first vertex in the array. Each vertex has 3 coordinates - X, Y, Z.
vertices_strideThe byte offset between consecutive vertices. When stride is zero, the vertices are tightly packed in the array.
normals3fA pointer to the first coordinate of the first normal in the array. Each normal has 3 coordinates - X, Y, Z.
normals_strideThe byte offset between consecutive normals. When stride is zero, the normals are tightly packed in the array.
texcoords2fA pointer to the first component of the first texcoord in the array. Each texcoord has 2 components - U, V.
texcoords_strideThe byte offset between consecutive texcoords. When stride is zero, the texcoords are tightly packed in the array.
num_verticesTotal number of vertices.
index_typeThe type of the values in triangle_indices
triangle_indicesA pointer to the location where the indices are stored
num_indicesNumber of indices. Must be a multiple of 3.
Returns
Handle to created object.
void faogenlib3::destroy_object ( obj_handle  object_id)

Delete object from the scene.

Parameters
object_idhandle, returned by create_object_v, create_object_vn or create_object_vnt
float const* faogenlib3::get_tex_results ( )

Retrieve generated texture ao data.

Returns
pointer to array of floating-point values, representing ambient occlusion texture - total of width * height values. Pointer is valid until next successful call to start_ao_gen_vert, start_ao_gen_tex or shutdown
float const* faogenlib3::get_vert_results ( )

Retrieve generated per-vertex ao data.

Returns
pointer to array of floating-point values, representing ambient occlusion - one for each vertex. Pointer is valid until next successful call to start_ao_gen_vert, start_ao_gen_tex or shutdown
bool faogenlib3::initialize ( )

Initialize faogenlib.

Returns
true if initialization was successful.
unsigned faogenlib3::num_iterations ( unsigned  quality)
inline

Helper function to calculate actual number of iterations for specified quality value.

bool faogenlib3::results_ready ( )

Check if ao data is generated.

Returns
true if results generated
void faogenlib3::set_object_matrix ( obj_handle  object_id,
float const *  matrix 
)

Set transformation matrix for object.

Parameters
object_idhandle, returned by create_object_v, create_object_vn or create_object_vnt
matrixpointer to 4*4 matrix
void faogenlib3::shutdown ( )

Shutdown faogenlib. Destroys all left objects.

bool faogenlib3::start_ao_gen_tex ( obj_handle  object_id,
unsigned  quality,
unsigned  width,
unsigned  height,
int  hemisphere_mode 
)

Start texture ambient occlusion generation.

Parameters
object_idobject_id handle, returned by create_object_vnt
qualityThis parameter controls number of iterations. Must be in [1, 100] range.
widthWidth of the AO map to be generated. Must be a power of 2 and in [1, 4096] range.
heightHeight of the AO map to be generated. Must be a power of 2 and in [1, 4096] range.
hemisphere_mode0 for no hemisphere, 1 for y-axis up, 2 for z-axis up.
Returns
true if there was no errors
bool faogenlib3::start_ao_gen_vert ( obj_handle  object_id,
unsigned  quality,
int  hemisphere_mode 
)

Start per-vertex ambient occlusion generation.

Parameters
object_idHandle, returned by create_object_vn or create_object_vnt
qualityThis parameter controls number of iterations. Must be in [1, 100] range.
hemisphere_mode0 for no hemisphere, 1 for y-axis up, 2 for z-axis up.
Returns
true if there was no errors