#include <spSceneMesh.hpp>
Public Member Functions | |
Mesh () | |
virtual | ~Mesh () |
virtual bool | compareMeshBuffers (const Mesh *Other) const |
void | addTexture (video::Texture *Tex, const u8 Layer=video::TEXLAYER_LAST, const video::ETextureLayerTypes LayerType=video::TEXLAYER_DEFAULT) |
Adds the specifies texture to all mesh buffers. | |
void | textureAutoMap (const u8 Layer, const f32 Density=1.0, const u32 MeshBufferIndex=MESHBUFFER_IGNORE, bool GlobalProjection=true, bool AllowNegativeTexCoords=false) |
std::vector< video::Texture * > | getTextureList () const |
Returns a list with all textures of all mesh buffers. | |
u32 | getTextureCount () const |
Returns count of textures of the specified surface. | |
virtual void | updateNormals () |
void | updateTangentSpace (const u8 TangentLayer=video::TEXTURE_IGNORE, const u8 BinormalLayer=video::TEXTURE_IGNORE, bool UpdateNormals=true) |
void | updateVertexBuffer () |
Updates each vertex buffer. | |
void | updateIndexBuffer () |
Updates each index buffer. | |
void | updateMeshBuffer () |
Updates each vertex- and index buffer. | |
void | meshTranslate (const dim::vector3df &Direction) |
void | meshTransform (const dim::vector3df &Size) |
void | meshTransform (const dim::matrix4f &Matrix) |
void | meshTurn (const dim::vector3df &Rotation) |
void | meshFlip () |
Flips the mesh. i.e. each vertex's coordinate will be inverted. | |
void | meshFlip (bool isXAxis, bool isYAxis, bool isZAxis) |
void | meshFit (const dim::vector3df &Position, const dim::vector3df &Size) |
void | meshSpherify (f32 Factor) |
void | meshTwist (f32 Rotation) |
void | mergeFamily (bool isDeleteChildren=true) |
dim::vector3df | centerOrigin () |
void | seperateTriangles () |
Seperates concatenated triangles for each mesh buffer. After calling this function each triangle has its own vertices. | |
void | flipTriangles () |
bool | getMeshBoundingBox (dim::vector3df &Min, dim::vector3df &Max, bool isGlobal=false) const |
dim::aabbox3df | getMeshBoundingBox (bool isGlobal=false) const |
Returns dimension of the mesh AABB (axis-aliend-bounding-box). | |
f32 | getMeshBoundingSphere (bool isGlobal=false) const |
Returns radius of the mesh bounding sphere. | |
void | addLODSubMesh (Mesh *LODSubMesh, bool isCopyMaterials=false) |
void | clearLODSubMeshes () |
Clears the LOD (level-of-detail) sub mesh list. | |
void | setLODSubMeshList (const std::vector< Mesh * > &LODSubMeshList) |
Sets the LOD (level-of-detail) sub meshes list directly. | |
void | setLODDistance (f32 Distance) |
void | setLOD (bool Enable) |
Enables or disables the LOD (level-of-detail) management. | |
video::MeshBuffer * | createMeshBuffer (const video::VertexFormat *VertexFormat=0, const video::ERendererDataTypes IndexFormat=video::DATATYPE_UNSIGNED_SHORT) |
void | deleteMeshBuffer (const u32 Index) |
Deletes the specified mesh buffer. | |
void | deleteMeshBuffers () |
Deletes all mesh buffers. | |
void | mergeMeshBuffers () |
void | optimizeTransparency () |
u32 | getVertexCount () const |
Returns count of vertices for the specified surface. | |
u32 | getTriangleCount () const |
Returns count of triangles for the specified surface. | |
u32 | getOrigVertexCount () const |
Returns count of vertices for the specified surface. | |
u32 | getOrigTriangleCount () const |
Returns count of triangles for the specified surface. | |
void | setReference (Mesh *ReferenceMesh, bool CopyLocation=false, bool CopyMaterial=false) |
Mesh * | getReference () |
const Mesh * | getReference () const |
void | paint (const video::color &Color, bool CombineColors=false) |
void | setShading (const video::EShadingTypes Type, bool UpdateImmediate=false) |
void | copy (const Mesh *Other) |
Mesh * | copy () const |
Returns a pointer to a new Mesh object which has been copied by this Mesh. | |
virtual void | render () |
video::MeshBuffer * | getMeshBuffer (const u32 Index) |
Returns the specified video::MeshBuffer object. | |
const video::MeshBuffer * | getMeshBuffer (const u32 Index) const |
Returns the specified constant video::MeshBuffer object. | |
video::MeshBuffer * | getOrigMeshBuffer (const u32 Index) |
Returns the specified original video::MeshBuffer object. | |
const video::MeshBuffer * | getOrigMeshBuffer (const u32 Index) const |
Returns the specified constant original video::MeshBuffer object. | |
video::MeshBuffer * | getLastMeshBuffer () |
Returns the last video::MeshBuffer object. | |
const video::MeshBuffer * | getLastMeshBuffer () const |
Returns the last constant video::MeshBuffer object. | |
u32 | getMeshBufferCount () const |
Returns cound of mesh buffers. | |
u32 | getOrigMeshBufferCount () const |
Returns cound of mesh buffers. | |
const std::vector < video::MeshBuffer * > & | getMeshBufferList () const |
Returns the mesh buffer (or rather surface) list. Useful for iterating with boost/foreach. | |
void | setRenderCallback (const video::UserRenderCallback &RenderCallback) |
Sets the render callback. By default 0. | |
const std::vector< Mesh * > & | getLODSubMeshList () const |
Returns list of the LOD (level-of-detail) sub meshes. | |
f32 | getLODDistance () const |
Returns LOD distance. | |
bool | getLOD () const |
Returns status of the LOD management. | |
bool | isInstanced () const |
Protected Member Functions | |
u32 | updateLevelOfDetail () |
void | copyMesh (Mesh *NewMesh) const |
Protected Attributes | |
std::vector< video::MeshBuffer * > | OrigSurfaceList_ |
std::vector< video::MeshBuffer * > * | SurfaceList_ |
std::vector< video::MeshBuffer * > * | LODSurfaceList_ |
bool | UseLODSubMeshes_ |
f32 | LODSubMeshDistance_ |
std::vector< Mesh * > | LODSubMeshList_ |
Mesh * | Reference_ |
video::UserRenderCallback | UserRenderProc_ |
Friends | |
class | SceneGraph |
class | SimpleSceneManager |
struct | SCollisionSystemObject |
struct | SPickingObject |
struct | SCollisionObject |
bool | cmpObjectMeshes (Mesh *&obj1, Mesh *&obj2) |
Meshes represents the main 3D objects which are also called "Entity", "Model" or just "3D Object". A Mesh consists basically of information about its location (position, rotation, scaling), a material (see video::SMeshMaterial) with its color, shader etc. and multiple surfaces which form the 3D data (vertices, triangles, textures). The way to create a 3D model is the following: create a Mesh, add one or more surfaces, add vertices to the surface, add triangles to the surface and finish! Don't forget to update the mesh buffer using the "updateMeshBuffer" function. Then you can add textures on it. Actually there are only surfaces to use multiple textures which shall not lie one upon the other (that would be multi-texturing). But each surface uses the same Mesh's material. Consider that not only a large count of triangle can be a performance problem but also the count of surfaces and entities!
Example code:
// Create the mesh scene::Mesh* Obj = spSmngr->createMesh(); // Create a new mesh buffer video::MeshBuffer* Shape = Obj->createMeshBuffer(); // Add a texture Shape->addTexture(spDriver->loadTexture("ExampleTexture.jpg")); // Add three vertices Shape->addVertex(dim::vector3df( 0.0f, 1.0f, 0.0f), dim::point2df(0.5f, 0.0f), video::color(255, 0, 0)); // Vertex 0 Shape->addVertex(dim::vector3df( 1.0f, -1.0f, 0.0f), dim::point2df(1.0f, 1.0f), video::color(0, 255, 0)); // Vertex 1 Shape->addVertex(dim::vector3df(-1.0f, -1.0f, 0.0f), dim::point2df(0.0f, 1.0f), video::color(0, 0, 255)); // Vertex 2 // Add a triangle Shape->addTriangle(0, 1, 2); // Update vertex- and index buffer after creating the geometry Shape->updateMeshBuffer();
sp::scene::Mesh::Mesh | ( | ) |
sp::scene::Mesh::~Mesh | ( | ) | [virtual] |
void sp::scene::Mesh::addLODSubMesh | ( | Mesh * | LODSubMesh, | |
bool | isCopyMaterials = false | |||
) |
Adds a LOD (level-of-detail) sub mesh.
void sp::scene::Mesh::addTexture | ( | video::Texture * | Tex, | |
const u8 | Layer = video::TEXLAYER_LAST , |
|||
const video::ETextureLayerTypes | LayerType = video::TEXLAYER_DEFAULT | |||
) |
Adds the specifies texture to all mesh buffers.
dim::vector3df sp::scene::Mesh::centerOrigin | ( | ) |
Centers the mesh's origin. After this operation the mesh's origin (vector [0|0|0]) is in the middle of the model.
void sp::scene::Mesh::clearLODSubMeshes | ( | ) |
Clears the LOD (level-of-detail) sub mesh list.
bool sp::scene::Mesh::compareMeshBuffers | ( | const Mesh * | Other | ) | const [virtual] |
Compares this and the given mesh object by their mesh buffers. This will be used by the 'SceneGraphsortRenderList' function when the sorting method is 'RENDERLIST_SORT_MESHBUFFER'.
void sp::scene::Mesh::copy | ( | const Mesh * | Other | ) |
Copies the mesh. Normally used inside the SceneManager but can also be used manual.
other,: | Specifies the mesh where the data of this mesh shall be stored. |
Mesh * sp::scene::Mesh::copy | ( | ) | const |
Returns a pointer to a new Mesh object which has been copied by this Mesh.
Reimplemented from sp::scene::SceneNode.
void sp::scene::Mesh::copyMesh | ( | Mesh * | NewMesh | ) | const [protected] |
video::MeshBuffer * sp::scene::Mesh::createMeshBuffer | ( | const video::VertexFormat * | VertexFormat = 0 , |
|
const video::ERendererDataTypes | IndexFormat = video::DATATYPE_UNSIGNED_SHORT | |||
) |
Creates a new video::MeshBuffer object. This object can hold 3D geometry data.
VertexFormat,: | Specifies the initial vertex format. By default video::VertexFormatDefault (can be used with RenderSystem::getVertexFormatDefault()). | |
IndexFormat,: | Specifies the initial index format. By default ATTRIBUTE_USNIGNED_SHORT. |
void sp::scene::Mesh::deleteMeshBuffer | ( | const u32 | Index | ) |
Deletes the specified mesh buffer.
void sp::scene::Mesh::deleteMeshBuffers | ( | ) |
Deletes all mesh buffers.
void sp::scene::Mesh::flipTriangles | ( | ) |
Flips each mesh's triangle. Each triangle's indices A and C are swapping their value. e.g. when a triangle has the indices (0, 1, 2) after flipping it has the indices (2, 1, 0).
video::MeshBuffer* sp::scene::Mesh::getLastMeshBuffer | ( | ) | [inline] |
Returns the last video::MeshBuffer object.
const video::MeshBuffer* sp::scene::Mesh::getLastMeshBuffer | ( | ) | const [inline] |
Returns the last constant video::MeshBuffer object.
bool sp::scene::Mesh::getLOD | ( | ) | const [inline] |
Returns status of the LOD management.
f32 sp::scene::Mesh::getLODDistance | ( | ) | const [inline] |
Returns LOD distance.
const std::vector<Mesh*>& sp::scene::Mesh::getLODSubMeshList | ( | ) | const [inline] |
Returns list of the LOD (level-of-detail) sub meshes.
dim::aabbox3df sp::scene::Mesh::getMeshBoundingBox | ( | bool | isGlobal = false |
) | const |
Returns dimension of the mesh AABB (axis-aliend-bounding-box).
bool sp::scene::Mesh::getMeshBoundingBox | ( | dim::vector3df & | Min, | |
dim::vector3df & | Max, | |||
bool | isGlobal = false | |||
) | const |
Gives you the mesh's bounding box which is formed by each vertex-coordinate. There is still a function called "getBoundingBox" in the Node class which gives you user defined bounding box for frustum-culling.
Min,: | Vector which will receive the minimal point of the bounding box. | |
Max,: | Vector which will receive the maximal point of the bounding box. | |
isGlobal,: | Specifies whether the coordinates are to be transformed by the object's matrix or not. |
f32 sp::scene::Mesh::getMeshBoundingSphere | ( | bool | isGlobal = false |
) | const |
Returns radius of the mesh bounding sphere.
video::MeshBuffer* sp::scene::Mesh::getMeshBuffer | ( | const u32 | Index | ) | [inline] |
Returns the specified video::MeshBuffer object.
const video::MeshBuffer* sp::scene::Mesh::getMeshBuffer | ( | const u32 | Index | ) | const [inline] |
Returns the specified constant video::MeshBuffer object.
u32 sp::scene::Mesh::getMeshBufferCount | ( | ) | const [inline] |
Returns cound of mesh buffers.
const std::vector<video::MeshBuffer*>& sp::scene::Mesh::getMeshBufferList | ( | ) | const [inline] |
Returns the mesh buffer (or rather surface) list. Useful for iterating with boost/foreach.
const video::MeshBuffer* sp::scene::Mesh::getOrigMeshBuffer | ( | const u32 | Index | ) | const [inline] |
Returns the specified constant original video::MeshBuffer object.
video::MeshBuffer* sp::scene::Mesh::getOrigMeshBuffer | ( | const u32 | Index | ) | [inline] |
Returns the specified original video::MeshBuffer object.
u32 sp::scene::Mesh::getOrigMeshBufferCount | ( | ) | const [inline] |
Returns cound of mesh buffers.
u32 sp::scene::Mesh::getOrigTriangleCount | ( | ) | const |
Returns count of triangles for the specified surface.
u32 sp::scene::Mesh::getOrigVertexCount | ( | ) | const |
Returns count of vertices for the specified surface.
Mesh * sp::scene::Mesh::getReference | ( | ) |
const Mesh * sp::scene::Mesh::getReference | ( | ) | const |
u32 sp::scene::Mesh::getTextureCount | ( | ) | const |
Returns count of textures of the specified surface.
std::vector< video::Texture * > sp::scene::Mesh::getTextureList | ( | ) | const |
Returns a list with all textures of all mesh buffers.
u32 sp::scene::Mesh::getTriangleCount | ( | ) | const |
Returns count of triangles for the specified surface.
u32 sp::scene::Mesh::getVertexCount | ( | ) | const |
Returns count of vertices for the specified surface.
bool sp::scene::Mesh::isInstanced | ( | ) | const [inline] |
Returns true if this mesh is an instance of another mesh, i.e. "setReference" was used.
void sp::scene::Mesh::mergeFamily | ( | bool | isDeleteChildren = true |
) |
Merges each child mesh as a new surface to this mesh object. This only works if the children are specified in the node's children list. Use "Node::addChild" or "Node::addChildren".
isDeleteChildren,: | If true each child mesh will be deleted after the merging process (by default true). |
void sp::scene::Mesh::mergeMeshBuffers | ( | ) |
Merges the given mesh, i.e. all mesh buffers which are equal in its structure (textures, vertex- and index format) are summarized.
void sp::scene::Mesh::meshFit | ( | const dim::vector3df & | Position, | |
const dim::vector3df & | Size | |||
) |
void sp::scene::Mesh::meshFlip | ( | bool | isXAxis, | |
bool | isYAxis, | |||
bool | isZAxis | |||
) |
void sp::scene::Mesh::meshFlip | ( | ) |
Flips the mesh. i.e. each vertex's coordinate will be inverted.
void sp::scene::Mesh::meshSpherify | ( | f32 | Factor | ) |
void sp::scene::Mesh::meshTransform | ( | const dim::vector3df & | Size | ) |
void sp::scene::Mesh::meshTransform | ( | const dim::matrix4f & | Matrix | ) |
void sp::scene::Mesh::meshTranslate | ( | const dim::vector3df & | Direction | ) |
Translates each vertex to the specified direction.
Direction,: | Direction in which the mesh shall be moved. | |
Surface,: | Affected surface(s). |
void sp::scene::Mesh::meshTurn | ( | const dim::vector3df & | Rotation | ) |
void sp::scene::Mesh::meshTwist | ( | f32 | Rotation | ) |
void sp::scene::Mesh::optimizeTransparency | ( | ) |
Optimizes the mesh vertices order depending on their transparency. Most transparent vertices will be placed at the end and less transparent vertices at the begin. This function can be used to avoid the overlapping problem with alpha-blending.
void sp::scene::Mesh::paint | ( | const video::color & | Color, | |
bool | CombineColors = false | |||
) |
Paints the whole mesh witht he specified color.
Color,: | Specifies the color which is to be set. | |
CombineColors,: | Specifies whether the color is to be multiplied with each vertex color or not. |
void sp::scene::Mesh::render | ( | ) | [virtual] |
Renders the whole mesh. This function is called in the "renderScene" function of the SceneManager. Here the object-transformation, frustum-culling, level of detail and drawing the surfaces' mesh buffers are proceeded.
Implements sp::scene::MaterialNode.
void sp::scene::Mesh::seperateTriangles | ( | ) |
Seperates concatenated triangles for each mesh buffer. After calling this function each triangle has its own vertices.
void sp::scene::Mesh::setLOD | ( | bool | Enable | ) |
Enables or disables the LOD (level-of-detail) management.
void sp::scene::Mesh::setLODDistance | ( | f32 | Distance | ) |
Sets the LOD distance.
Distance,: | Specifies the distance which shall be used for LOD computing. Only linear and not exponentially yet. |
void sp::scene::Mesh::setLODSubMeshList | ( | const std::vector< Mesh * > & | LODSubMeshList | ) |
Sets the LOD (level-of-detail) sub meshes list directly.
void sp::scene::Mesh::setReference | ( | Mesh * | ReferenceMesh, | |
bool | CopyLocation = false , |
|||
bool | CopyMaterial = false | |||
) |
Sets a mesh reference. This feature is very usfull when rendering multiple equal 3D models. This saves much memory and for animation much performance costs. e.g. very good for animated grass when you have thousands of Mesh objects which all refers to only one animated mesh. Each of these objecsts uses the same mesh buffer. Small memory costs and small animation performance costs but many movement in the scene.
ReferenceMesh,: | Mesh object which holds the mesh buffer which is to be used. | |
CopyLocation,: | If true the location is copied from the "ReferenceEntity" object. | |
CopyMaterial,: | If true the material settings are copied from the "ReferenceEntity" object. |
void sp::scene::Mesh::setRenderCallback | ( | const video::UserRenderCallback & | RenderCallback | ) | [inline] |
Sets the render callback. By default 0.
void sp::scene::Mesh::setShading | ( | const video::EShadingTypes | Type, | |
bool | UpdateImmediate = false | |||
) |
Sets the shading type.
Type,: | Type of shading (flat, gouraud, phong, per-pixel). | |
UpdateImmediate,: | If true the normals will be updated immediately (updateNormals). |
void sp::scene::Mesh::textureAutoMap | ( | const u8 | Layer, | |
const f32 | Density = 1.0 , |
|||
const u32 | MeshBufferIndex = MESHBUFFER_IGNORE , |
|||
bool | GlobalProjection = true , |
|||
bool | AllowNegativeTexCoords = false | |||
) |
Computes the texture coordinates automatically by the triangles' normal (typically used for lightmap texturing).
[in] | Layer | Layer/ level which shall be used. |
[in] | Density | Factor which will be multiplied with the space coordinates to change it into texture coordinates. |
[in] | MeshBufferIndex | Specifies the index for the mesh buffer which is to be used. By default MESHBUFFER_IGNORE to use all. |
[in] | GlobalProjection | Specifies whether texture coordinate projection is to be done global or local. By default global. |
[in] | AllowNegativeTexCoords | Specifies whether negative texture coordinates are allowed. By default false. When you are using any normal-mapping techniques, you should avoid negative texture coordinates! |
void sp::scene::Mesh::updateIndexBuffer | ( | ) |
Updates each index buffer.
u32 sp::scene::Mesh::updateLevelOfDetail | ( | ) | [protected] |
void sp::scene::Mesh::updateMeshBuffer | ( | ) |
Updates each vertex- and index buffer.
void sp::scene::Mesh::updateNormals | ( | ) | [virtual] |
Updates the normal vectors for each mesh buffer.
void sp::scene::Mesh::updateTangentSpace | ( | const u8 | TangentLayer = video::TEXTURE_IGNORE , |
|
const u8 | BinormalLayer = video::TEXTURE_IGNORE , |
|||
bool | UpdateNormals = true | |||
) |
Updates the tangent space for each mesh buffer.
void sp::scene::Mesh::updateVertexBuffer | ( | ) |
Updates each vertex buffer.
friend class SceneGraph [friend] |
Reimplemented from sp::scene::MaterialNode.
friend struct SCollisionObject [friend] |
friend struct SCollisionSystemObject [friend] |
friend class SimpleSceneManager [friend] |
friend struct SPickingObject [friend] |
f32 sp::scene::Mesh::LODSubMeshDistance_ [protected] |
std::vector<Mesh*> sp::scene::Mesh::LODSubMeshList_ [protected] |
std::vector<video::MeshBuffer*> * sp::scene::Mesh::LODSurfaceList_ [protected] |
std::vector<video::MeshBuffer*> sp::scene::Mesh::OrigSurfaceList_ [protected] |
Mesh* sp::scene::Mesh::Reference_ [protected] |
std::vector<video::MeshBuffer*>* sp::scene::Mesh::SurfaceList_ [protected] |
bool sp::scene::Mesh::UseLODSubMeshes_ [protected] |