Unigine::ObjectMeshCluster Class
Header: | #include <UnigineObjects.h> |
Inherits: | Object |
A MeshCluster class allows you to bake identical meshes (with the same material applied to their surfaces) into one object, which provides less cluttered spatial tree, reduces the number of texture fetches and speeds up rendering.
Meshes are rendered within a specified visibility distance from the camera. When moving away from this distance, meshes fade out and then disappear completely.
The following samples demonstrate the ObjectMeshCluster class usage:
ObjectMeshCluster Class
Members
static ObjectMeshClusterPtr create(const char * arg1, int unique = 0)
ObjectMeshCluster constructor.Arguments
- const char * arg1 - Name of the mesh file.
- int unique - When you create several objects out of a single .mesh file, the instance of the mesh geometry is created. If you then change the source geometry, its instances will be changed as well. To avoid this, set the unique flag to 1, so a copy of the mesh geometry will be created and changes won't be applied.
Ptr<ObjectMeshCluster> cast(const Ptr<Node> & node)
Casts an ObjectMeshCluster out of the Node instance.Arguments
- const Ptr<Node> & node - Pointer to Node.
Return value
Pointer to ObjectMeshCluster.Ptr<ObjectMeshCluster> cast(const Ptr<Object> & base)
Casts an ObjectMeshCluster out of the Object instance.Arguments
- const Ptr<Object> & base - Pointer to Object.
Return value
Pointer to ObjectMeshCluster.void setFadeDistance(float distance)
Sets the distance up to which meshes handled by the mesh cluster will be fading out (that is, fewer meshes will be rendered instead of all). The distance is measured starting from the visible distance. The default is 0. Using fade distance allows the objects to disappear one by one until up to the fade distance only a few left. It makes the disappearing smooth and much less noticeable.Arguments
- float distance - Fading distance for meshes in units. If a negative value is provided, 0 will be used instead.
float getFadeDistance()
Returns the distance up to which meshes handled by the mesh cluster will be fading out. The default is 0.Return value
Fading distance for meshes in units.int setMesh(const Ptr<Mesh> & mesh)
Copies the source mesh into the current mesh.Arguments
- const Ptr<Mesh> & mesh - The source mesh to be copied.
Return value
1 if the mesh is copied successfully; otherwise, 0.int getMesh(const Ptr<Mesh> & mesh)
Copies the current mesh into the source mesh.Arguments
- const Ptr<Mesh> & mesh - The source mesh.
Return value
1 if the mesh is copied successfully; otherwise, 0.void setMeshName(const char * name)
Sets a name for the mesh handled by the mesh cluster.Arguments
- const char * name - Name to be set for the mesh.
const char * getMeshName()
Returns the name of the mesh handled by a mesh cluster.Return value
Mesh name.void setMeshTransform(int num, const Math::mat4 & transform)
Sets the transformation of the given mesh instance.Arguments
- int num - Mesh instance number.
- const Math::mat4 & transform - Mesh transformation matrix.
Math::mat4 getMeshTransform(int num)
Returns the transformation of the given mesh instance.Arguments
- int num - Mesh instance number.
Return value
Mesh transformation matrix.int getNumMeshes()
Returns the total number of meshes handled by the mesh cluster.Return value
Number of meshes.int getNumSurfaceTargets(int surface)
Returns the number of surface targets.Arguments
- int surface - Surface number.
Return value
Number of surface targets.void setShadowRadius(float radius)
Sets the distance to draw additional meshes outside the view frustum. Setting the shadow radius allows you to eliminate popping shadows at the edges of the screen when the camera turns. The shadow radius depends on the mesh size, how high meshes are positioned and also the angle of the global light (which determines how long the shadows from them would be). The longer shadows, the bigger shadow radius is required.Arguments
- float radius - Distance in units. If a negative value is provided, 0 will be used instead. The default is 0.
float getShadowRadius()
Returns the distance to draw additional meshes outside the view frustum. The shadow radius depends on the mesh size, how high meshes are positioned and also the angle of the global light (which determines how long the shadows from them would be). The longer shadows, the bigger shadow radius is required.Return value
Distance in units.const char * getSurfaceTargetName(int surface, int target)
Returns the name of a given surface target.Arguments
- int surface - Surface number.
- int target - Target number.
Return value
Target name.void setVisibleDistance(float distance)
Sets the distance up to which meshes handled by the mesh cluster will be rendered. The default is infinity (in this case, fade distance will be ignored).Arguments
- float distance - Visibility distance for meshes in units. If a negative value is provided, 0 will be used instead.
float getVisibleDistance()
Returns the distance up to which meshes handled by the mesh cluster are rendered. The default is infinity (in this case, fade distance is ignored).Return value
Visibility distance for meshes in units.void clearMeshes()
Deletes all meshes from the mesh cluster.int createMesh(const char * name, int unique = 0)
Creates a mesh.Arguments
- const char * name - Path to the mesh file.
- int unique - When you create several objects out of a single .mesh file, the instance of the mesh geometry is created. If you then change the source geometry, its instances will be changed as well. To avoid this, set the unique flag to 1, so a copy of the mesh geometry will be created and changes won't be applied.
Return value
Returns 1 if the mesh is created successfully; otherwise, 0.void createMeshes(const Vector< Math::Mat4 > & transforms)
Creates mesh transformations vector, which is used to bake child meshes of the mesh cluster into this cluster. For meshes to be baked, they must be identical to mesh cluster mesh and have the same material applied to its surfaces.Arguments
- const Vector< Math::Mat4 > & transforms - Transformations vector.
int findSurfaceTarget(const char * name, int surface)
Searches for an surface target with a given name.Arguments
- const char * name - Target name.
- int surface - Surface number.
Return value
Target number if it is exists; otherwise, -1.void flushMesh()
Flushes the mesh geometry into the video memory.int loadMesh(const char * name)
Loads a mesh file.Arguments
- const char * name - Mesh file name.
Return value
Returns 1 if the mesh is loaded successfully; otherwise, 0.int saveMesh(const char * name)
Saves the dynamic mesh into a file.Arguments
- const char * name - Mesh file name.
Return value
Returns 1 if the mesh is saved successfully; otherwise, 0.static int type()
Returns the type of ObjectMeshStatic.Return value
ObjectMeshStatic type identifier.Last update: 03.07.2017
Помогите сделать статью лучше
Была ли эта статья полезной?
(или выберите слово/фразу и нажмите Ctrl+Enter