Jump to content
  • Advertisement
Sign in to follow this  

Practical DX Transforms.

This topic is 4353 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

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
            dxDevice, NULL, &pMatBuffer, NULL,
			&numMaterials, &pMesh ) ) )
//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.

Share this post

Link to post
Share on other sites
One) You should work with each matrix individually.
Your models should manipulate your world matrix only.
Your projection matrix defines what type of camera you are using.
Your view matrix determines where the camera is.

Adjust each separately and they shouldn't interfere with each other.

Two) Open up the .x file with a text editor. Search for one of the file names (or just .png or .bmp) and find where in the file, the texture filenames are. I'm guessing that the full path of the texture is in the file. Its probably easiest to put the .x file and textures in the same directory, and in the model file, leave only the "texture.bmp" filename without the directory structure.

Hope that helps.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!