The following interfaces can be used in the CustomRenderItemHandle
:
IVirtualDevice
- This is very similar to Direct3D (D3D) IDirect3DDevice
. You can use it to create, set, and draw graphics data.BaseMaterialHandle
and concrete material handles - These are different material classes. A material handle can be used for shading a render item.VertexBufferHandle
- This is a buffer that stores vertices with a given format. It is similar to D3D's vertex buffer.IndexBufferHandle
- This is a buffer that stores indices. It is similar to D3D's index buffer.TextureHandle
and TargetHandle
- These two classes can be used as texture parameter for material.The plug-ins can provide complex display in Nitrous using these interfaces.
Nitrous provides the following material classes that can be used by both the object and material plug-ins:
SolidColorMaterialHandle
VertexColorMaterialHandle
TextureMaterialHandle
StandardMaterialHandle
To use these materials to shade vertex buffers, the plug-ins need to initialize the handle in proper time. The plug-ins must make sure that the MeshRequiredStreams
of the material handle and the vertex buffer format is consistent, and use the BaseMaterialHandle
functions to draw. Following is an example:
// Use a material handle to draw something
void XXXPlugin_CustomItem::Display(DrawContext& dc)
{
// Assuming that the material handle is properly initialized
BaseMaterialHandle hMaterial;
hMaterial.Activate(dc);
int numPass = hMaterial.GetPassCount(dc);
for (int i = 0; i < numPass; ++i)
{
// Assuming that the vertex buffer has a consistent format
hMaterial.ActivatePass(dc, i);
// Use IVirtualDevice to draw the vertex buffer
}
hMaterial.PassFinished(dc);
hMaterial.Terminate();
}
Nitrous also provides a HLSLMaterialHandle
class that allows plug-ins to use the DirectX effect. Plug-ins can directly use the DirectX effect string or file ( \.fx* ) to initialize the material handle and use it as other material handles.
When Nitrous is in DirectX 9 (DX9) mode, this class only supports DX9 effects, and when Nitrous is in DirectX 11 (DX11) mode, this class only supports DX11 effects. Plug-ins can get the device capability through IVirtualDevice::FeatureLevel()
.