D3DResourceManager.h
#ifndef D3DResourceManager_h_
#define D3DResourceManager_h_
#include <maya/MViewportRenderer.h>
#include <maya/MDagPath.h>
#include <maya/MObjectHandle.h>
#include <maya/MMessage.h>
#include <maya/MStringArray.h>
#include <list>
#include <D3DGeometryItem.h>
#include <D3DTextureItem.h>
#if defined(D3D9_SUPPORTED)
#define WIN32_LEAN_AND_MEAN
#include <d3d9.h>
#include <d3dx9.h>
struct LightItem {
D3DLIGHT9 m_lightDesc;
MCallbackId m_objectDeleteMonitor;
MCallbackId m_objectDirtyMonitor;
bool m_enabled;
};
typedef std::list<LightItem*> LightItemList;
struct CameraItem {
D3DXVECTOR3 m_vEyePt;
D3DXVECTOR3 m_vLookatPt;
D3DXVECTOR3 m_vUpVec;
float m_FieldOfView;
float m_nearClip;
float m_farClip;
bool m_isOrtho;
};
struct PostEffectItem
{
LPD3DXEFFECT fEffect;
MString fName;
};
typedef std::list<PostEffectItem*> PostEffectItemList;
struct SurfaceEffectItem
{
LPD3DXEFFECT fEffect;
MString fName;
};
typedef std::list<SurfaceEffectItem*> SurfaceEffectItemList;
class MDagPath;
class MObject;
class MRenderingInfo;
class D3DResourceManager
{
public:
D3DResourceManager();
virtual ~D3DResourceManager();
D3DGeometry* getGeometry( const MDagPath& dagPath, LPDIRECT3DDEVICE9 D3D);
D3DTexture* getTexture( MObject& mayaTexture);
void clearResources(bool onlyInvalidItems, bool clearShaders);
bool cleanupLighting(LPDIRECT3DDEVICE9 D3D);
bool setupLighting(LPDIRECT3DDEVICE9 D3D);
void enableLights( bool val, LPDIRECT3DDEVICE9 D3D );
bool translateCamera( const MDagPath &cameraPath);
CameraItem* getCamera() { return &m_camera; }
bool initializePostEffects( const MString &effectsLocation,
LPDIRECT3DDEVICE9 D3D);
const MStringArray & getListOfEnabledPostEffects();
const PostEffectItemList & getPostEffectItemList() const
{
return m_PostEffectItemList;
}
bool initializeDefaultSurfaceEffect( const MString &effectsLocation, LPDIRECT3DDEVICE9 D3D,
const MString & effectName );
const SurfaceEffectItemList & getSurfaceEffectItemList() const
{
return m_SurfaceEffectItemList;
}
protected:
void initializeDefaultCamera();
LightItemList m_lightItemList;
unsigned int m_numberLightsEnabled;
GeometryItemList m_geometryItemList;
TextureItemList m_textureItemList;
PostEffectItemList m_PostEffectItemList;
MStringArray m_EnabledPostEffectItemList;
CameraItem m_camera;
SurfaceEffectItemList m_SurfaceEffectItemList;
};
#endif
#endif