Original Post
Hello, I have two questions: A: How should I organize my DirectX transformation code for optimal useability and speed? I currently have a rather messy Object3D class which deals with translations and it needs to be inherited by anything that wants to 'move' around. Also, I presume that the camera should stay still (at the origin pointing down an axis); so how would I make it so that I could efficiently make things move opposite to the camera's 'movement'? B: Secondly, I wrote an X file mesh wrapper and although it takes practically all of the code for loading and rendering the mesh from the DirectX doc tutorial #6, it loads the mesh fine, but no texture shows; even though it looks like the code should support it. (The DX mesh veiwer shows the same mesh with a texture, and it also appears that the X files also hold their own textures, is this true?) and just for reference, here is my X file loading source:
DXGeomBuffer::DXGeomBuffer(char* file, IDirect3DDevice9* dxDevice, IDirect3D9* dxObject)
{
if(dxDevice != NULL)
dx3DDevice = dxDevice;
if(dxObject != NULL)
dx3DObject = dxObject;
ID3DXBuffer* pMatBuffer;
// Load the mesh from the specified file
if( FAILED( D3DXLoadMeshFromX(file , D3DXMESH_SYSTEMMEM,
dxDevice, NULL, &pMatBuffer, NULL,
&numMaterials, &pMesh ) ) )
{
return;
}
//Get Material buffer pointer.
D3DXMATERIAL* d3dxMaterials = (D3DXMATERIAL*)pMatBuffer->GetBufferPointer();
//Create arrays for material and texture information.
D3DMATERIAL9* g_pMeshMaterials = new D3DMATERIAL9[numMaterials];
LPDIRECT3DTEXTURE9* g_pMeshTextures = new LPDIRECT3DTEXTURE9[numMaterials];
//Load the data into those arrays.
for(unsigned int i = 0; i < numMaterials; i++)
{
g_pMeshMaterials = d3dxMaterials.MatD3D;
g_pMeshMaterials.Ambient = g_pMeshMaterials.Diffuse;
if( FAILED( D3DXCreateTextureFromFile( dx3DDevice, d3dxMaterials.pTextureFilename, &g_pMeshTextures ) ) )
g_pMeshTextures = NULL;
}
It borrows quite heavily from the DX tutorial #6.