DXMesh |
public class DXMeshGeometry3D : MeshBase, IDynamicVertexBufferCreator, IRayHitTestedObject, ITriangularMesh, IOctTreeMesh
The DXMeshGeometry3D type exposes the following members.
Name | Description | |
---|---|---|
DXMeshGeometry3D | Constructor - note: it is recommended to use static Create method instead. |
Name | Description | |
---|---|---|
AutomaticallyChangeToDynamicVertexBuffer | Gets or sets a Boolean property that after 3 changes of the vertex buffer sets the CreateDynamicVertexBuffer to true (if not already set to true). This improves performance of subsequent buffer changes. Default value is true. | |
CreateDynamicIndexBuffer | Gets or sets a Boolean that specifies if the index buffer is created as a dynamic buffer. This can provide slightly better performance for cases when index buffer is updated very often. Default value is false. | |
CreateDynamicVertexBuffer | Gets or sets a Boolean that specifies if the vertex buffer is created as a dynamic buffer. This can provide slightly better performance for cases when vertex buffer is updated very often. Default value is false. | |
FlipYTextureCoordinate | Gets or sets a Boolean that specifies if y texture coordinate is changed to y' = 1 - y (flipped texture coordinates instead of flipping the image is much faster) | |
IsIndexBufferDirty | Gets a boolean that specifies that index buffer needs to be regenerated. | |
IsVertexBufferDirty | Gets a boolean that specifies that vertex buffer needs to be regenerated (Positions, Normals or TextureCoordinates have changed) | |
MeshGeometry | Gets MeshGeometry3D that is used to create this DXMeshGeometry3D. | |
OctTree | Gets or sets an MeshOctTree that can be used for hit testing. The MeshOctTree is automatically generated when number of positions in this mesh is bigger or equal to the value set in MeshPositionsCountForOctTreeGeneration. | |
PositionsCount | Gets a number of positions that are defined by this mesh. | |
TriangleIndicesCount | Gets a number of triangle indices that are defined by this mesh. | |
TrianglesCount | Gets the number of triangles that are used to define this mesh. | |
Version | Gets the version number of the DirectX buffers created from this MeshGeometry3D. Version is increased each time the buffers change. Note: When MeshGeometry3D is changed a lot of times, the Version value can overflow from positive to negative numbers (to prevent problems do not check for bigger value but for not equal value) |
Name | Description | |
---|---|---|
CreateOctTree | CreateOctTree returns a MeshOctTree that is created from the mesh defined in this DXMeshGeometry3D. This method must be called after the DXMeshGeometry3D has been initialized (added to DXScene or after InitializeResources method is called). | |
GetClosestHitResult | GetClosestHitResult method returns a DXRayHitTestResult with the closest triangle hit by the specified ray. When no triangle is hit, null is returned. | |
GetDetailsText | Returns string that tells details about this SceneNode | |
GetNextHitResult | GetNextHitResult method continues hit testing from the previously returned hit test and returns a DXRayHitTestResult with the next hit triangle (not necessary the next closest triangle) or null if no other triangle is hit. This method can be used to get all hit results. | |
GetTrianglePositions | GetTrianglePositions sets the 3 positions that define the triangle with the specified triangle index. | |
GetUsedDXMeshGeometry3D | GetUsedDXMeshGeometry3D method returns DXMeshGeometry3D that was created from the WPF MeshGeometry3D (or null if no DXMeshGeometry3D was created for the WPF material). parentDXDevice is requireed to check if the created DXMeshGeometry3D was created for the same device. | |
GetVertexAndIndexBuffers | GetVertexAndIndexBuffers method gets vertex and index buffer array that are created from MeshGeometry3D. This method must be called after the DXMeshGeometry3D was initialized or the Update method was called. Otherwise the returned array will be null. | |
HitTest | HitTest method test the triangles defined in this mesh for hitting with the specified ray. When getOnlyNextHitTest is false, then the closest hit result is returned, else the next hit result is returned. When no hit is found, null is returned. | |
RecreateMesh | Forces creation of new VertexBuffers and IndexBuffer. This method sets IsVertexBufferDirty and IsIndexBufferDirty to true and then calls Update(Boolean) method. | |
SetUsedDXMeshGeometry3D | Sets a DXMeshGeometry3D that will be used when showing WPF MeshGeometry3D in DXEngine (must be set before the objects are initialized in DXEngine). | |
SortTrianglesByCameraDistance | SortTrianglesByCameraDistance method sorts the triangle indices so that the triangles are sorted by camera distance - triangles that are farther away are rendered first. After sorting indices, the Update(Boolean) method needs to be called to update the DirectX buffer. When using this method it is highly recommended to set CreateDynamicIndexBuffer to true. See remarks for more info. | |
ToString |
Returns a String that represents this instance.
(Overrides ObjectToString) | |
Update | Updates vertex and index buffers based on the IsVertexBufferDirty and IsIndexBufferDirty. To force update both vertex and index buffer call RecreateMesh method. When updateGpuBuffers parameter is false, then the vertex buffer array and index buffer array can be created without a DXDevice object and they will not be sent to the GPU. |
DXMeshGeometry3D class is initialized by the WPF's MeshGeometry3D and uses its data to prepare the low level DirectX objects (Index and Vertex buffers) that are needed to render the mesh.
The created vertex buffer is set to the VertexBufferBindings property. Index buffer is set to the IndexBuffer property.
Vertex buffer is created with Position (as SharpDX.Vector3), Normal (as SharpDX.Vector3) and TextureCoordinate (as SharpDX.Vector).
When MeshTangentArray attribute is set to the MeshGeometry3D (with using SetDXAttribute(Geometry3D, DXAttributeType, Object) extension method), a special vertex buffer with tangent data is created and set to the second slot of the created VertexBufferBindings property. In this case the Tangent is added to the InputLayoutType value.