source: GTP/trunk/App/Demos/Illum/RayTraceEffects/Common/DXUTMesh.h @ 755

Revision 755, 4.9 KB checked in by szirmay, 19 years ago (diff)

Added a folder remotely

Line 
1//-----------------------------------------------------------------------------
2// File: DXUTMesh.h
3//
4// Desc: Support code for loading DirectX .X files.
5//
6// Copyright (c) Microsoft Corporation. All rights reserved.
7//-----------------------------------------------------------------------------
8#pragma once
9#ifndef DXUTMESH_H
10#define DXUTMESH_H
11
12
13
14
15
16//-----------------------------------------------------------------------------
17// Name: class CDXUTMesh
18// Desc: Class for loading and rendering file-based meshes
19//-----------------------------------------------------------------------------
20class CDXUTMesh
21{
22public:
23    WCHAR                   m_strName[512];
24
25    LPD3DXMESH              m_pSysMemMesh;    // SysMem mesh, lives through resize
26    LPD3DXMESH              m_pLocalMesh;     // Local mesh, rebuilt on resize
27   
28    DWORD                   m_dwNumMaterials; // Materials for the mesh
29    D3DMATERIAL9*           m_pMaterials;
30    IDirect3DBaseTexture9** m_pTextures;
31    bool                    m_bUseMaterials;
32
33public:
34    // Rendering
35    HRESULT Render( LPDIRECT3DDEVICE9 pd3dDevice,
36                    bool bDrawOpaqueSubsets = true,
37                    bool bDrawAlphaSubsets = true );
38    HRESULT Render( ID3DXEffect *pEffect,
39                    D3DXHANDLE hTexture = NULL,
40                    D3DXHANDLE hDiffuse = NULL,
41                    D3DXHANDLE hAmbient = NULL,
42                    D3DXHANDLE hSpecular = NULL,
43                    D3DXHANDLE hEmissive = NULL,
44                    D3DXHANDLE hPower = NULL,
45                    bool bDrawOpaqueSubsets = true,
46                    bool bDrawAlphaSubsets = true );
47
48    // Mesh access
49    LPD3DXMESH GetSysMemMesh() { return m_pSysMemMesh; }
50    LPD3DXMESH GetLocalMesh()  { return m_pLocalMesh; }
51
52    // Rendering options
53    void    UseMeshMaterials( bool bFlag ) { m_bUseMaterials = bFlag; }
54    HRESULT SetFVF( LPDIRECT3DDEVICE9 pd3dDevice, DWORD dwFVF );
55    HRESULT SetVertexDecl( LPDIRECT3DDEVICE9 pd3dDevice, const D3DVERTEXELEMENT9 *pDecl );
56
57    // Initializing
58    HRESULT RestoreDeviceObjects( LPDIRECT3DDEVICE9 pd3dDevice );
59    HRESULT InvalidateDeviceObjects();
60
61    // Creation/destruction
62    HRESULT Create( LPDIRECT3DDEVICE9 pd3dDevice, LPCWSTR strFilename );
63    HRESULT Create( LPDIRECT3DDEVICE9 pd3dDevice, LPD3DXFILEDATA pFileData );
64    HRESULT CreateMaterials( LPCWSTR strPath, IDirect3DDevice9 *pd3dDevice, ID3DXBuffer *pAdjacencyBuffer, ID3DXBuffer *pMtrlBuffer );
65    HRESULT Destroy();
66
67    CDXUTMesh( LPCWSTR strName = L"CDXUTMeshFile_Mesh" );
68    virtual ~CDXUTMesh();
69};
70
71
72
73
74//-----------------------------------------------------------------------------
75// Name: class CDXUTMeshFrame
76// Desc: Class for loading and rendering file-based meshes
77//-----------------------------------------------------------------------------
78class CDXUTMeshFrame
79{
80public:
81    WCHAR      m_strName[512];
82    D3DXMATRIX m_mat;
83    CDXUTMesh*  m_pMesh;
84
85    CDXUTMeshFrame* m_pNext;
86    CDXUTMeshFrame* m_pChild;
87
88public:
89    // Matrix access
90    void        SetMatrix( D3DXMATRIX* pmat ) { m_mat = *pmat; }
91    D3DXMATRIX* GetMatrix()                   { return &m_mat; }
92
93    CDXUTMesh*   FindMesh( LPCWSTR strMeshName );
94    CDXUTMeshFrame*  FindFrame( LPCWSTR strFrameName );
95    bool        EnumMeshes( bool (*EnumMeshCB)(CDXUTMesh*,void*),
96                            void* pContext );
97
98    HRESULT Destroy();
99    HRESULT RestoreDeviceObjects( LPDIRECT3DDEVICE9 pd3dDevice );
100    HRESULT InvalidateDeviceObjects();
101    HRESULT Render( LPDIRECT3DDEVICE9 pd3dDevice,
102                    bool bDrawOpaqueSubsets = true,
103                    bool bDrawAlphaSubsets = true,
104                    D3DXMATRIX* pmatWorldMatrix = NULL);
105
106    CDXUTMeshFrame( LPCWSTR strName = L"CDXUTMeshFile_Frame" );
107    virtual ~CDXUTMeshFrame();
108};
109
110
111
112
113//-----------------------------------------------------------------------------
114// Name: class CDXUTMeshFile
115// Desc: Class for loading and rendering file-based meshes
116//-----------------------------------------------------------------------------
117class CDXUTMeshFile : public CDXUTMeshFrame
118{
119    HRESULT LoadMesh( LPDIRECT3DDEVICE9 pd3dDevice, LPD3DXFILEDATA pFileData,
120                      CDXUTMeshFrame* pParentFrame );
121    HRESULT LoadFrame( LPDIRECT3DDEVICE9 pd3dDevice, LPD3DXFILEDATA pFileData,
122                       CDXUTMeshFrame* pParentFrame );
123public:
124    HRESULT Create( LPDIRECT3DDEVICE9 pd3dDevice, LPCWSTR strFilename );
125    HRESULT CreateFromResource( LPDIRECT3DDEVICE9 pd3dDevice, LPCWSTR strResource, LPCWSTR strType );
126    // For pure devices, specify the world transform. If the world transform is not
127    // specified on pure devices, this function will fail.
128    HRESULT Render( LPDIRECT3DDEVICE9 pd3dDevice, D3DXMATRIX* pmatWorldMatrix = NULL );
129
130    CDXUTMeshFile() : CDXUTMeshFrame( L"CDXUTMeshFile_Root" ) {}
131};
132
133
134
135#endif
136
137
138
Note: See TracBrowser for help on using the repository browser.