Public Member Functions

IEffectParser Class Reference

This reference page is linked to from the following overview topics: Parsers and Shader Effect Files, Loading and Parsing Shader Effect Files.


Search for all occurrences

Detailed Description

Implemented by Effect Parser.

Effect parsers will implement this interface in order to actually render the effect

#include <RTMax.h>

Inheritance diagram for IEffectParser:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual bool  ParseEffectFile (LPVOID pDevice, const MaxSDK::AssetManagement::AssetUser &file, IEffectManager *em)=0
  Parse the actual effect file.
virtual bool  LoadTexture (LPVOID pDevice, MCHAR *paramName, MCHAR *filename, bool forceReload, PBBitmap *pBitmap=NULL)=0
  The UI code will use this to make sure the effect has all the textures loaded and applied to the effect when they change from the UI.
virtual void  DestroyParser ()=0
  Remove the parser.
virtual bool  PreRender (LPVOID pDevice, IRenderMesh *rmesh, ILightManager *lm, IParameterManager *pm, D3DCOLOR bkgColor, int width, int height)=0
  Any initialisation or one off setup, before the render passes happens here.
virtual bool  Render (LPVOID pDevice, IRenderMesh *rmesh, D3DXHANDLE primaryTechnique)=0
  Render the actual object, based on the data supplied in the effect file.
virtual void  SetMappingChannel (D3DXHANDLE handle, int Channel)=0
  Alows the user to change the mapping channel used by the texture in the UI.
virtual void  SetUseLPRT (bool state)
  Used internally.
virtual bool  LoadEffect (LPVOID pDevice, IEffectManager *em, const MCHAR *effect, bool fileType, bool forceReload)=0
  Load a shader based on the filename supplied.
virtual const MCHAR *  GetLastParserError ()=0
  retrieves the last error message maintained by the parser
virtual  ~IEffectParser ()
  virtual destructor
virtual int  GetNumberOfLightParameters ()=0
  Allow the EffectManager access to lighting data, so it can expose it through the public interfaces.
virtual MaxSemantics  GetLightSemantic (int index)=0
  The light parameter usage.
virtual const MCHAR *  GetLightHandle (int index)=0
  Get a handle to the light based on the index supplied.
virtual void  OnLostDevice ()=0
  Called when a Lost Device is detected - free any resources here.
virtual void  OnResetDevice ()=0
  Called when a ResetDevice is detected - free and rebuild any resources here.
virtual bool  LoadTexture (LPVOID pTexture, const MCHAR *paramName)=0
  Provides the ability to load a texture created out side the parser.

Constructor & Destructor Documentation

virtual ~IEffectParser ( ) [inline, virtual]

virtual destructor

{}

Member Function Documentation

virtual bool ParseEffectFile ( LPVOID  pDevice,
const MaxSDK::AssetManagement::AssetUser file,
IEffectManager em 
) [pure virtual]

Parse the actual effect file.

All data that is needed to actually render the effect is extracted here. If a UI is needed, then the IEffectManager interface can be used for this purpose

Parameters:
pDevice The main D3D device
file The actual file asset that represents the effect file
*em A pointer to the Effect Manager
Returns:
true/false depending on whether the parsing was successful
virtual bool LoadTexture ( LPVOID  pDevice,
MCHAR *  paramName,
MCHAR *  filename,
bool  forceReload,
PBBitmap pBitmap = NULL 
) [pure virtual]

The UI code will use this to make sure the effect has all the textures loaded and applied to the effect when they change from the UI.

Parameters:
pDevice The main D3D device
paramName The handle of the texture parameter from the effect file
*filename The name of the texture to load
forceReload If true don't pull the texture from a cache, you need to load from disk
*pBitmap If supplied the DirectX resource system will use data contained in PBBitmap to load the file based on the user's settings. This will be used when the DirectX texture loader fails to load the file directly, at which point the internal 3ds Max representation could be used as pointed to by the PBBitmap structure.
Returns:
true/false depending on whether loading was successful
virtual void DestroyParser ( ) [pure virtual]

Remove the parser.

virtual bool PreRender ( LPVOID  pDevice,
IRenderMesh rmesh,
ILightManager lm,
IParameterManager pm,
D3DCOLOR  bkgColor,
int  width,
int  height 
) [pure virtual]

Any initialisation or one off setup, before the render passes happens here.

If new rendertargets are needed or back buffers, this is the place to do it

Parameters:
pDevice The main D3D device
*rmesh The render mesh that needs to be drawn
*lm A pointer to the light manager
*pm A pointer to the Parameter manager
bkgColor The color of the background to clear to
width The width of the viewport
height The height of the viewport
Returns:
True/False
virtual bool Render ( LPVOID  pDevice,
IRenderMesh rmesh,
D3DXHANDLE  primaryTechnique 
) [pure virtual]

Render the actual object, based on the data supplied in the effect file.

Parameters:
pDevice The main D3D device
*rmesh The render mesh that needs to be drawn
primaryTechnique The actual technique that should be used for the final result.
virtual void SetMappingChannel ( D3DXHANDLE  handle,
int  Channel 
) [pure virtual]

Alows the user to change the mapping channel used by the texture in the UI.

Parameters:
handle The handle of the parameter to set
Channel The value of the mapping channel
virtual void SetUseLPRT ( bool  state ) [inline, virtual]

Used internally.

{ UNUSED_PARAM(state); };
virtual bool LoadEffect ( LPVOID  pDevice,
IEffectManager em,
const MCHAR *  effect,
bool  fileType,
bool  forceReload 
) [pure virtual]

Load a shader based on the filename supplied.

The parser must keep a pointer to this effect, and manage any resources associated with it

Parameters:
pDevice The DirectX device
em A pointer to the IEffectManager instance
effect A string containing the effect - this can either be a filename or a buffer contaning the effect
fileType Defines whether the string contains a file name or a buffer
forceReload If true don't pull the effect from a cache, you need to reload from disk
Returns:
True if successful
virtual const MCHAR* GetLastParserError ( ) [pure virtual]

retrieves the last error message maintained by the parser

virtual int GetNumberOfLightParameters ( ) [pure virtual]

Allow the EffectManager access to lighting data, so it can expose it through the public interfaces.

The EffectManager used to maintain all the lights, now it simply host the UI. This means the parser needs to keep tabs on the lights, or at least what parameters of the lights are needed. This is simple for the parser, as it will need to keep a local list of the light data so it can request the actual 3ds Max data from the LightManager.The number of light based parameters the effect contains

virtual MaxSemantics GetLightSemantic ( int  index ) [pure virtual]

The light parameter usage.

virtual const MCHAR* GetLightHandle ( int  index ) [pure virtual]

Get a handle to the light based on the index supplied.

virtual void OnLostDevice ( ) [pure virtual]

Called when a Lost Device is detected - free any resources here.

virtual void OnResetDevice ( ) [pure virtual]

Called when a ResetDevice is detected - free and rebuild any resources here.

virtual bool LoadTexture ( LPVOID  pTexture,
const MCHAR *  paramName 
) [pure virtual]

Provides the ability to load a texture created out side the parser.

Parameters:
pTexture A pointer to DirectX texture resource
paramName The name of the parameter who should receive the texture
Returns:
True/False depending on whether the texture was uploaded correctly

IEffectParser IEffectParser IEffectParser IEffectParser IEffectParser IEffectParser IEffectParser IEffectParser IEffectParser IEffectParser
IEffectParser IEffectParser IEffectParser IEffectParser IEffectParser IEffectParser IEffectParser IEffectParser IEffectParser IEffectParser