Archived

This topic is now archived and is closed to further replies.

ANY way to convert CD3DMesh to ID3DXBaseMesh?

This topic is 5141 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m wanting to use D3DXIntersect in my game and it needs an ID3DXBaseMesh. Now, I have loaded the object (and rendered and stuff) using the CD3DXMesh class. Is there any possible way I could get this same terrain model transfered to ID3DXBaseMesh just for the Intersection test? thx

Share this post


Link to post
Share on other sites
quote:

Umm, isn't CD3DMesh a wrapper for a D3DXMesh? And I believe there is something like a GetMesh method to retrieve it. I don't have my docs handy though.



The following is the header source code for CD3DMesh:


//-----------------------------------------------------------------------------

// Name: class CD3DMesh

// Desc: Class for loading and rendering file-based meshes

//-----------------------------------------------------------------------------

class CD3DMesh
{
public:
TCHAR m_strName[512];

LPD3DXMESH m_pSysMemMesh; // SysMem mesh, lives through resize

LPD3DXMESH m_pLocalMesh; // Local mesh, rebuilt on resize


DWORD m_dwNumMaterials; // Materials for the mesh

D3DMATERIAL9* m_pMaterials;
LPDIRECT3DTEXTURE9* m_pTextures;
bool m_bUseMaterials;

public:
// Rendering

HRESULT Render( LPDIRECT3DDEVICE9 pd3dDevice,
bool bDrawOpaqueSubsets = true,
bool bDrawAlphaSubsets = true );

// Mesh access

LPD3DXMESH GetSysMemMesh() { return m_pSysMemMesh; }
LPD3DXMESH GetLocalMesh() { return m_pLocalMesh; }

// Rendering options

void UseMeshMaterials( bool bFlag ) { m_bUseMaterials = bFlag; }
HRESULT SetFVF( LPDIRECT3DDEVICE9 pd3dDevice, DWORD dwFVF );

// Initializing

HRESULT RestoreDeviceObjects( LPDIRECT3DDEVICE9 pd3dDevice );
HRESULT InvalidateDeviceObjects();

// Creation/destruction

HRESULT Create( LPDIRECT3DDEVICE9 pd3dDevice, TCHAR* strFilename );
HRESULT Create( LPDIRECT3DDEVICE9 pd3dDevice, LPDIRECTXFILEDATA pFileData );
HRESULT Destroy();

CD3DMesh( TCHAR* strName = _T("CD3DFile_Mesh") );
virtual ~CD3DMesh();
};


Two different functions for retrieving the mesh of type ID3DXMesh are outlined below. This is what you want since ID3DXMesh is a concrete class for the base class or abstract class ID3DXBaseMesh. I don't normally use the framework, so I am not sure if there is any real difference in Meshes being returned?

1) ->GetSysMemMesh(); // SysMem mesh, lives through resize
2) ->GetLocalMesh(); // Local mesh, rebuilt on resize
_______________________________________
Understanding is a three edged sword...


[edited by - Sean Doherty on November 13, 2003 6:35:32 PM]

Share this post


Link to post
Share on other sites
Ok... Its tested now and it returns ID3DXMesh *. This is good to knwo cause I need it in other things. Now, the D3DXIntersect functionc is still complaining ''cause it needs an ID3DXBaseMesh(never ever heard of it...). Anyone has an idea how to do this?

thx

Share this post


Link to post
Share on other sites