Class IDX8VertexShader

3DS Max Plug-In SDK

Class IDX8VertexShader

See Also: Class IVertexShader, Class IDX8PixelShader, Class ID3DGraphicsWindow , Class BaseInterface

class IDX8VertexShader : virtual public IVertexShader, public BaseInterface

Description:

This class is available in release 4.0 and later only.

The abstract interface to the Direct-3D Vertex Shader architecture.

The drawing functions are necessary as something other than a simple default body if:

  • ·   The VertexShader needs to add additional per vertex data unknown to the Mesh to the VertexBuffer.

  • ·   The VertexShader needs to have per vertex data ordered differently than the standard position, normal, {color, tex coords ordering}.

  • ·   The VertexShader is being used to create cached VertexBuffers or using higher order surfaces.

In the cases of DrawMeshStrips() and DrawWireMesh(), the VertexShader has the option of not only locking and filling the VertexBuffer with data, but also of making the actual DrawPrimitive call. In the case of StartLines(), the VertexShader must make the DrawPrimitive call. The VertexShader indicates that it has done the drawing by returning 'true' in the Draw functions provided.

In the case where the VertexShader does not want to do the drawing but does want to fill in a VertexBuffer with data, the VertexShader can request the GFX to create a VertexBuffer (and possibly an IndexBuffer) of appropriate size. The GetVertexBuffer and GetIndexBuffer calls on the ID3DGraphicsWindow object will do this and return the allocated buffers in subsequent calls or reallocate them if necessary.

Please note that if a PixelShader or PixelShaders are in use, these Draw functions may need to set them for the appropriate passes of a multipass rendering if the drawing is done in these Draw() functions. If the GFX is doing the drawing, then these Draw() functions are only being used to fill in the VertexBuffer with data; the GFX will be doing the drawing and will be setting the PixelShaders as appropriate.

Methods:

public:

Prototype:

virtual Interface_ID GetID();

Remarks:

This method returns the interface ID of the class.

Default Implementation:

{ return DX8_VERTEX_SHADER_INTERFACE_ID; }

Prototype:

virtual HRESULT ConfirmDevice(ID3DGraphicsWindow *gw) = 0;

Remarks:

This method will confirm that the Direct3D Device can handle this VertexShader.

Parameters:

ID3DGraphicsWindow *gw

A pointer to the Direct-3D Graphics Window.

Prototype:

virtual HRESULT ConfirmPixelShader(IDX8PixelShader *pps) = 0;

Remarks:

This method will confirm that an associated PixelShader will work with this VertexShader.

Parameters:

IDX8PixelShader *pps

A pointer to the pixel shader to confirm for.

Prototype:

virtual bool CanTryStrips() = 0;

Remarks:

This method will indicate if it can try tristrips for drawing or must geometry using this VertexShader be drawn as triangles? This should return TRUE unless additional per vertex data is generated by this VertexShader and this data does not map to the Mesh vertices in the same way as existing data the Mesh knows about such as texture coordinates.

Prototype:

virtual int GetNumMultiPass() = 0;

Remarks:

This method returns the number of passes for the effect this VertexShader creates. Note that this value will depend on the hardware currently in use.

Prototype:

virtual DWORD GetVertexShaderHandle(int numPass) = 0;

Remarks:

This method returns the VertexShader handle for the specified pass for use in GFX.

Prototype:

virtual HRESULT SetVertexShader(ID3DGraphicsWindow *gw, int numPass) = 0;

Remarks:

This method allows you to set the VertexShader for the specified pass. This call will be made at least once per object to set the per object data for the VertexShader such as the VertexShader constants.

Parameters:

ID3DGraphicsWindow *gw

A pointer to the Direct-3D Graphics Window.

int numPass

The pass for which to set the vertex shader.

Prototype:

virtual bool DrawMeshStrips(ID3DGraphicsWindow *gw, MeshData *data) = 0;

Remarks:

This method will draw the 3D Mesh as TriStrips. Fill in the VertexBuffer with data in the order desired by the VertexShader.

Parameters:

ID3DGraphicsWindow *gw

A pointer to the Direct-3D Graphics Window.

MeshData *data

A pointer to the mesh data.

Return Value:

TRUE if the Mesh has actually been drawn in this call, FALSE if the GFX is required to make the DrawPrimitive call.

Prototype:

virtual bool DrawWireMesh(ID3DGraphicsWindow *gw, WireMeshData *data) = 0;

Remarks:

This method will draw the 3D Mesh as wireframe. Fill in the VertexBuffer with data in the order desired by the VertexShader.

Parameters:

ID3DGraphicsWindow *gw

A pointer to the Direct-3D Graphics Window.

WireMeshData *data

A pointer to the wire mesh data.

Return Value:

TRUE if the Mesh has actually been drawn in this call, FALSE if the GFX is required to make the DrawPrimitive call.

Prototype:

virtual void StartLines(ID3DGraphicsWindow *gw, WireMeshData *data) = 0;

Remarks:

This method will draw 3D lines. A Mesh is being drawn by having line segments handed

down one at a time. Pass in the Mesh data in preparation for drawing 3D lines.

Parameters:

ID3DGraphicsWindow *gw

A pointer to the Direct-3D Graphics Window.

WireMeshData *data

A pointer to the wire mesh data.

Prototype:

virtual void AddLine(ID3DGraphicsWindow *gw, DWORD *vert, int vis) = 0;

Remarks:

This method will draw 3D lines. A Mesh is being drawn by having line segments handed

down one at a time. Add the connectivity information for one two point line segment.

Parameters:

ID3DGraphicsWindow *gw

A pointer to the Direct-3D Graphics Window.

DWORD *vert

The array of vertices.

int vis

The visibility flag.

Prototype:

virtual bool DrawLines(ID3DGraphicsWindow *gw) = 0;

Remarks:

This method will draw the line segments accumulated. This should restart the filling of a VertexBuffer with the next AddLine call if additional data needs to be drawn before EndLines is called.

Parameters:

ID3DGraphicsWindow *gw

A pointer to the Direct-3D Graphics Window.

Return Value:

TRUE if the Mesh line segments have actually been drawn in this call, FALSE if the GFX is required to make the DrawPrimitive call.

Prototype:

virtual void EndLines(ID3DGraphicsWindow *gw, GFX_ESCAPE_FN fn) = 0;

Remarks:

This method will let the Mesh know that all drawing and data access is finished.

Parameters:

ID3DGraphicsWindow *gw

A pointer to the Direct-3D Graphics Window.

GFX_ESCAPE_FN fn

The graphics escape function.

Prototype:

virtual void StartTriangles(ID3DGraphicsWindow *gw, MeshFaceData *data) = 0;

Remarks:

This method will Draw 3D triangles. A Mesh is being drawn by having triangles handed down one at a time. Pass in the Mesh data in preparation for drawing 3D triangles.

Parameters:

ID3DGraphicsWindow *gw

A pointer to the Direct-3D Graphics Window.

MeshFaceData *data

A pointer to the mesh face data.

Prototype:

virtual void AddTriangle(ID3DGraphicsWindow *gw, DWORD index, int *edgeVis) = 0;

Remarks:

This method will Draw 3D triangles. A Mesh is being drawn by having triangles handed down one at a time. Add the connectivity information for one triangle.

Parameters:

ID3DGraphicsWindow *gw

A pointer to the Direct-3D Graphics Window.

DWORD index

The triangle index.

int *edgeVis

The array of edge visibility information/

Prototype:

virtual bool DrawTriangles(ID3DGraphicsWindow *gw) = 0;

Remarks:

This method will draw the triangles accumulated. This should restart the filling of a VertexBuffer with the next AddTriangle call if additional data needs to be drawn before EndTriangles is called. Return 'true' if the Mesh triangles have actually been drawn in this call, 'false' if the GFX is required to make the DrawPrimitive call.

Parameters:

ID3DGraphicsWindow *gw

A pointer to the Direct-3D Graphics Window.

Prototype:

virtual void EndTriangles(ID3DGraphicsWindow *gw, GFX_ESCAPE_FN fn) = 0;

Remarks:

This method will let the Mesh know that all drawing and data access is finished.

Parameters:

ID3DGraphicsWindow *gw

A pointer to the Direct-3D Graphics Window.

GFX_ESCAPE_FN fn

The graphics escape function.