![]() |
DI-Guy SDK Documentation
13.8
|
A class that represents a shared mesh object. More...
#include <diguyGraphicsMesh.h>
Public Member Functions | |
| int | get_num_switched_graphics_states () const |
| This function returns the number of switched graphics states this mesh has. More... | |
| int | get_is_skinned_mesh () |
| This function returns whether or not the mesh is "skinned". More... | |
| int | get_is_blend_shape () |
| This function returns whether or not the mesh is actually a morph object. More... | |
| void | free_loader_memory () |
| This function frees most memory allocated by the DI-Guy geometry loader for this object. More... | |
Accessor Functions | |
The functions in this section provide access to data in this object. They are designed to be called by DI-Guy programmers. | |
| const char * | get_name () |
| Returns the name of the mesh. More... | |
| long | get_uid () |
| All meshes are assigned a unique identifier (uid) This function returns the uid of the mesh. More... | |
| diguyGraphicsState * | get_state (int graphics_state_switch_index=0) |
| This function returns the graphics state with which faces in this mesh should be drawn. More... | |
| const diguyGraphicsState * | get_state (int graphics_state_switch_index=0) const |
Shader Accessor Functions | |
| diguyGraphicsShaderProgram * | get_shader_program () |
| This function returns a pointer to the shader program designated for this mesh, if any. More... | |
| diguyGraphicsShaderInstance * | get_shader_instance () |
| If this mesh has a shader program specified (see get_shader_program()), this function returns a pointer to the shader instance object specific to this mesh. More... | |
Vertex Buffer Data Accessor Functions | |
| diguyGraphicsVertexFormat | get_vertex_format () |
| Returns: vertex format that describes the format of the data returned by the get_vertex_buffer_data() function. More... | |
| int | get_vertex_count () |
| Returns: how many vertices this mesh has. More... | |
| int | get_vertex_buffer_size () |
| Returns: size, in bytes, of the data buffer returned by get_vertex_buffer_data() More... | |
| diguyGraphicsMesh * | get_blend_shape (int index) |
| Returns: Pointer to a blend shape mesh that represents the offsets from this mesh, currently we only have 1 of these which we use to adjust the weight of the character. More... | |
| int | get_num_blend_shapes () |
| Returns: Number of blend shapes associated with this mesh, currently max of 1. More... | |
| float * | get_data_as_blend_shape_verts () |
| this is necessary for the new SSBO based implementation of blend shapes that has a specific layout More... | |
| int | get_blend_shape_vertex_buffer_size () |
| this is necessary for the new SSBO based implementation of blend shapes that has a specific layout More... | |
| void * | get_vertex_buffer_data () |
| This function returns a pointer to the raw vertex buffer data of this mesh. More... | |
| float * | get_first_vertex () |
| This function returns a pointer to vertex position data of the first vertex in the raw vertex buffer data returned by get_vertex_buffer_data(). More... | |
| int | get_vertex_offset () |
| This function returns how many bytes the first vertex position is into the raw vertex buffer data returned by get_vertex_buffer_data(). More... | |
| int | get_vertex_stride () |
| This function returns how many bytes there are between each vertex position in the raw data returned by get_vertex_buffer_data(). More... | |
| float * | get_first_normal () |
| Returns: pointer to normal of first vertex in vertex buffer data; see get_first_vertex() for more information. More... | |
| int | get_normal_offset () |
| Returns: offset in bytes of the first normal in raw vertex buffer data; see get_vertex_offset() for more information. More... | |
| float * | get_first_texture_indices () |
| Returns: pointer to texture indices of first vertex in vertex buffer data. More... | |
| int | get_texture_indices_offset () |
| Returns: offset in bytes of the first texture indices in raw vertex buffer data; see get_vertex_offset() for more information. More... | |
| float * | get_first_link_index () |
| Returns: pointer to link index of first vertex in vertex buffer data, in float form. More... | |
| int | get_link_index_offset () |
| Returns: offset in bytes of the first link index in raw vertex buffer data; see get_vertex_offset() for more information. More... | |
| float * | get_first_link_weight () |
| Returns: pointer to link weight of first vertex in vertex buffer data. More... | |
| int | get_link_weight_offset () |
| Returns: offset in bytes of the first link weight offset in raw vertex buffer data; see get_vertex_offset() for more information. More... | |
| float * | get_first_tangent () |
| Returns a pointer to the UV tangent and flip bit of first vertex in the vertex buffer data. More... | |
| int | get_tangent_offset () |
| Returns: offset in bytes of the first tangent in raw vertex buffer data; see get_vertex_offset() for more information. More... | |
Index Buffer Data Accessor Functions | |
| diguyGraphicsIndexType | get_index_type () |
| Returns: index type used in data returned by the get_index_buffer_data() function. More... | |
| int | get_index_count () |
| This function returns how many indices there are in this mesh. More... | |
| int | get_index_buffer_size () |
| Returns: size, in bytes, of the data buffer returned by get_index_buffer_data() More... | |
| void * | get_index_buffer_data () |
| This function returns a pointer to the raw index buffer data of this mesh. More... | |
Virtual Functions | |
The functions in this section are all virtual functions that will be called by DI-Guy at various times during DI-Guy execution. Because the functions are all virtual, DI-Guy programmers can create a subclass of this class and override them. Unless otherwise stated, the base class functions do not need to be called. | |
| virtual void | build () |
| This function will be called by DI-Guy when it is time for a renderer-specific mesh object to be created. More... | |
| virtual void | unbuild () |
| This function will be called by DI-Guy when it is time for a renderer-specific mesh object to be destroyed. More... | |
| virtual void | draw (diguyDrawCallData *draw_data) |
| This function will be called by DI-Guy when the mesh should be drawn. More... | |
Experimental Functions | |
This function returns the last bound graphic state object this mesh used. There should always be at least one. This can be used by immediate mode renderers during draw calls to find out more about the properties of the mesh. See get_state() for more information on switched graphics states. Returns: object of type diguyGraphicsState; NULL on failure The following functions are experimental and may change or disappear with no warning. | |
| int | get_bounding_box (float *bbox_min_x, float *bbox_min_y, float *bbox_min_z, float *bbox_max_x, float *bbox_max_y, float *bbox_max_z) |
| int | get_normal_stride () |
| deprecated as of 13.2.0 since we've always laid out data with vnt/vnt/vnt type layouts, strides are always the same. More... | |
| int | get_texture_indices_stride () |
| int | get_tangent_stride () |
| int | get_link_weight_stride () |
| int | get_link_index_stride () |
| int | get_is_deformable () |
| This function returns whether or not the mesh is deformable. More... | |
Private Functions | |
The functions and variables past this point are for internal use only. No external access to them is expected or necessary. | |
| bdiGeometryMesh * | m_mesh |
| A pointer to internal data. More... | |
| class | bdiGeometryGeosetMesh |
| class | bdiGeometryMesh |
| class | bdiGeometryFactory |
| class | diguyGraphicsMeshArray |
| bdiGeometryMesh * | get_internal_data () |
| diguyGraphicsMesh (void *internal_data) | |
| A protected constructor. More... | |
| virtual | ~diguyGraphicsMesh () |
| A protected destructor. More... | |
A class that represents a shared mesh object.
Can be subclassed by filling out the diguy_graphics_set_mesh_create_func().
|
protected |
A protected constructor.
Constructors are called automatically by DI-Guy.
|
protectedvirtual |
A protected destructor.
Destructors are called automatically by DI-Guy.
| const char* diguyGraphicsMesh::get_name | ( | ) |
Returns the name of the mesh.
This pointer will never be NULL.
Returns:
name of the mesh
| long diguyGraphicsMesh::get_uid | ( | ) |
All meshes are assigned a unique identifier (uid) This function returns the uid of the mesh.
Note: uids will change between DI-Guy runs.
Returns:
unique identifier of the object
| diguyGraphicsState* diguyGraphicsMesh::get_state | ( | int | graphics_state_switch_index = 0 | ) |
This function returns the graphics state with which faces in this mesh should be drawn.
Specific information about material and texture can then be accessed from this object.
Some meshes may have multiple possible graphics states associated with them. In effect this means that depending on a character's appearance, different textures or material settings may be used.
Call get_num_switched_graphics_states() to get the number of graphics states that are associated with this mesh.
This function is typically called during the Build stage for scene graph renderers, when geoset/mesh objects are being created and their graphics states set.
Returns:
object of type diguyGraphicsState; NULL on failure
| const diguyGraphicsState* diguyGraphicsMesh::get_state | ( | int | graphics_state_switch_index = 0 | ) | const |
| int diguyGraphicsMesh::get_num_switched_graphics_states | ( | ) | const |
This function returns the number of switched graphics states this mesh has.
There should always be at least one.
See get_state() for more information on switched graphics states.
Returns:
number of switched graphics states this mesh has
| int diguyGraphicsMesh::get_is_skinned_mesh | ( | ) |
This function returns whether or not the mesh is "skinned".
The position of vertices in a skinned mesh are determined at run-time by transforming them with multiple link transforms.
It is likely that some type of shader is required to render the mesh correctly. The shader recommended for this mesh can be obtained by calling get_shader_program().
Though they sound similar, skinned meshes and deformable meshes are different. The vertices in a deformable mesh have already been transformed when the draw() function is called; nothing more needs to be done. The vertices in a skinned are not ready to be drawn, as they must first be transformed by a shader.
Returns:
1 if mesh is skinned, 0 if not, -1 on failure
| int diguyGraphicsMesh::get_is_blend_shape | ( | ) |
This function returns whether or not the mesh is actually a morph object.
the pos,normals and tangents will then just be the deltas from the base mesh.
| void diguyGraphicsMesh::free_loader_memory | ( | ) |
This function frees most memory allocated by the DI-Guy geometry loader for this object.
This function should only be called during or after the object's build() function has been called. After it has been called, calls to many accessor functions will fail.
| diguyGraphicsShaderProgram* diguyGraphicsMesh::get_shader_program | ( | ) |
This function returns a pointer to the shader program designated for this mesh, if any.
Shader programs are shared objects usable by many meshes.
Returns:
pointer to diguyGraphicsShaderProgram, or NULL if this mesh does not have a shader specified
| diguyGraphicsShaderInstance* diguyGraphicsMesh::get_shader_instance | ( | ) |
If this mesh has a shader program specified (see get_shader_program()), this function returns a pointer to the shader instance object specific to this mesh.
Returns:
pointer to diguyGraphicsShaderInstance, or NULL if this mesh does not have a shader specified
| diguyGraphicsVertexFormat diguyGraphicsMesh::get_vertex_format | ( | ) |
Returns: vertex format that describes the format of the data returned by the get_vertex_buffer_data() function.
| int diguyGraphicsMesh::get_vertex_count | ( | ) |
Returns: how many vertices this mesh has.
| int diguyGraphicsMesh::get_vertex_buffer_size | ( | ) |
Returns: size, in bytes, of the data buffer returned by get_vertex_buffer_data()
| diguyGraphicsMesh* diguyGraphicsMesh::get_blend_shape | ( | int | index | ) |
Returns: Pointer to a blend shape mesh that represents the offsets from this mesh, currently we only have 1 of these which we use to adjust the weight of the character.
| int diguyGraphicsMesh::get_num_blend_shapes | ( | ) |
Returns: Number of blend shapes associated with this mesh, currently max of 1.
| float* diguyGraphicsMesh::get_data_as_blend_shape_verts | ( | ) |
this is necessary for the new SSBO based implementation of blend shapes that has a specific layout
| int diguyGraphicsMesh::get_blend_shape_vertex_buffer_size | ( | ) |
this is necessary for the new SSBO based implementation of blend shapes that has a specific layout
| void* diguyGraphicsMesh::get_vertex_buffer_data | ( | ) |
This function returns a pointer to the raw vertex buffer data of this mesh.
The format of the data can be obtained by calling get_vertex_format().
Type-correct pointers into the data can be obtained by calling get_first_vertex(), get_first_normal(), etc.
Returns:
pointer to raw vertex buffer data
| float* diguyGraphicsMesh::get_first_vertex | ( | ) |
This function returns a pointer to vertex position data of the first vertex in the raw vertex buffer data returned by get_vertex_buffer_data().
The XYZ position of the first vertex is stored in the first three values of the returned pointer. The XYZ positions of subsequent vertices need to be obtained by consecutively adding the vertex stride to this returned pointer, as returned by get_vertex_stride().
NOTE: get_vertex_stride() returns a value in ** ytes*, not sizeof(float), so be careful about pointer arithmetic.
This approach is also used for the first normal, texture indices, link index, and link weight of the vertex data.
An alternative approach to getting a pointer to the first vertex position is to use get_vertex_offset(). See that function for more information.
Returns:
pointer to vertex position of first vertex in vertex buffer data
| int diguyGraphicsMesh::get_vertex_offset | ( | ) |
This function returns how many bytes the first vertex position is into the raw vertex buffer data returned by get_vertex_buffer_data().
The XYZ positions of subsequent vertices need to be obtained by consecutively adding the vertex stride to this offset, as returned by get_vertex_stride().
NOTE: get_vertex_stride() returns a value in ** ytes*, not sizeof(float), so be careful about pointer arithmetic.
This approach is also used for the first normal, texture indices, link index, and link weight offsets into the vertex data.
An alternative approach to getting a pointer to the first vertex position is to use get_first_vertex() to get a type-correct pointer.
Returns:
offset in bytes of the first vertex position in raw vertex buffer data
| int diguyGraphicsMesh::get_vertex_stride | ( | ) |
This function returns how many bytes there are between each vertex position in the raw data returned by get_vertex_buffer_data().
See get_first_vertex() and get_vertex_offset() for more information.
NOTE: this function returns a value in ** ytes*, not sizeof(float), so be careful about pointer arithmetic.
Returns:
stride in bytes between each vertex position in raw vertex buffer data
| float* diguyGraphicsMesh::get_first_normal | ( | ) |
Returns: pointer to normal of first vertex in vertex buffer data; see get_first_vertex() for more information.
| int diguyGraphicsMesh::get_normal_offset | ( | ) |
Returns: offset in bytes of the first normal in raw vertex buffer data; see get_vertex_offset() for more information.
| float* diguyGraphicsMesh::get_first_texture_indices | ( | ) |
Returns: pointer to texture indices of first vertex in vertex buffer data.
| int diguyGraphicsMesh::get_texture_indices_offset | ( | ) |
Returns: offset in bytes of the first texture indices in raw vertex buffer data; see get_vertex_offset() for more information.
| float* diguyGraphicsMesh::get_first_link_index | ( | ) |
Returns: pointer to link index of first vertex in vertex buffer data, in float form.
| int diguyGraphicsMesh::get_link_index_offset | ( | ) |
Returns: offset in bytes of the first link index in raw vertex buffer data; see get_vertex_offset() for more information.
| float* diguyGraphicsMesh::get_first_link_weight | ( | ) |
Returns: pointer to link weight of first vertex in vertex buffer data.
| int diguyGraphicsMesh::get_link_weight_offset | ( | ) |
Returns: offset in bytes of the first link weight offset in raw vertex buffer data; see get_vertex_offset() for more information.
| float* diguyGraphicsMesh::get_first_tangent | ( | ) |
Returns a pointer to the UV tangent and flip bit of first vertex in the vertex buffer data.
There are 3 floats representing the tangent, and one for UV mirroring. See http://www.dhpoware.com/demos/glslNormalMapping.html for an outline of how tangents are calculated. Binormals are calculated in the vertex shader making their storage unnecessary. Tangents should exist for all skinned/dae models.
See get_first_vertex() for more information about how to interpret tangent pointers and strides.
| int diguyGraphicsMesh::get_tangent_offset | ( | ) |
Returns: offset in bytes of the first tangent in raw vertex buffer data; see get_vertex_offset() for more information.
| diguyGraphicsIndexType diguyGraphicsMesh::get_index_type | ( | ) |
Returns: index type used in data returned by the get_index_buffer_data() function.
| int diguyGraphicsMesh::get_index_count | ( | ) |
This function returns how many indices there are in this mesh.
The number of triangles in this mesh can be derived by dividing this value by 3.
Note that indices in index buffer data are different than the indices contained in vertex buffer data. Index buffer indices specify which vertices in vertex buffer data are used to create polygons in a mesh (e.g., for the first triangle, use vertices 0, 1, and 2), while indices stored in vertex buffer data specify which **inks* affect the final position of the vertex.
Returns:
number of indices in index buffer data returned by get_index_buffer_data()
| int diguyGraphicsMesh::get_index_buffer_size | ( | ) |
Returns: size, in bytes, of the data buffer returned by get_index_buffer_data()
| void* diguyGraphicsMesh::get_index_buffer_data | ( | ) |
This function returns a pointer to the raw index buffer data of this mesh.
The format of the data can be obtained by calling get_index_type().
Returns:
pointer to raw index buffer data
|
virtual |
This function will be called by DI-Guy when it is time for a renderer-specific mesh object to be created.
All information necessary to build the mesh should be available via the Accessor Functions above when this function is called.
Immediate Mode:
Immediate mode renderers may override this function, to create an object that may be invoked by draw().
Scene Graph:
Scene graph renderers usually do override this function, to create a geometry object that gets associated with a diguyGraphicsState object obtained by calling get_state().
Callable From:
Reimplemented in diguyOglGraphicsMesh, diguyDx9GraphicsMesh, diguyOsgGraphicsMesh, diguyOglGraphicsMesh, and diguyDx11GraphicsMesh.
|
virtual |
This function will be called by DI-Guy when it is time for a renderer-specific mesh object to be destroyed.
Immediate Mode:
Immediate mode renderers may override this function, to destroy any object that may have been created by build().
Scene Graph:
Scene graph renderers usually do override this function, to destroy any object that may have been created by build().
Callable From:
Reimplemented in diguyOglGraphicsMesh, diguyDx9GraphicsMesh, diguyOsgGraphicsMesh, diguyOglGraphicsMesh, and diguyDx11GraphicsMesh.
|
virtual |
This function will be called by DI-Guy when the mesh should be drawn.
For scene graph renderers, most likely nothing more needs to be done by this function.
Callable From:
Reimplemented in diguyOglGraphicsMesh, diguyDx9GraphicsMesh, diguyOglGraphicsMesh, and diguyDx11GraphicsMesh.
| int diguyGraphicsMesh::get_bounding_box | ( | float * | bbox_min_x, |
| float * | bbox_min_y, | ||
| float * | bbox_min_z, | ||
| float * | bbox_max_x, | ||
| float * | bbox_max_y, | ||
| float * | bbox_max_z | ||
| ) |
|
inline |
deprecated as of 13.2.0 since we've always laid out data with vnt/vnt/vnt type layouts, strides are always the same.
|
inline |
|
inline |
|
inline |
|
inline |
| int diguyGraphicsMesh::get_is_deformable | ( | ) |
This function returns whether or not the mesh is deformable.
The position of vertices in a deformable mesh may shift from frame to frame and therefore should not be put into a renderer-specific object that cannot be updated. (For example, vertex buffer objects in OpenGL.)
The position of vertices in a non-deformable, non-skinned mesh remain fixed from frame to frame.
Though they sound similar, skinned meshes and deformable meshes are different. The vertices in a deformable mesh have already been transformed when the draw() function is called; nothing more needs to be done. The vertices in a skinned mesh are not ready to be drawn, as they must first be transformed by a shader.
We don't currently ever have deformable meshes... and you'd still need to stream them to the videocard.
Returns:
1 if mesh is deformable, 0 if not, -1 on failure
|
inline |
|
friend |
|
friend |
|
friend |
|
friend |
|
private |
A pointer to internal data.