PDA

View Full Version : DelphiX - .DDS + .X + .PNG Files



iNFiNiTE615
27-03-2006, 11:40 AM
Ok, I'm a very experienced programmer in pretty much every area except for graphics, especially DirectX. I am writing an editor for a game, and I would like to display some of their models in my application. I don't need to do anything with them but show them in a small window and maybe have them rotate around.

The game has all three files for each model (i.e. a DDS, X & PNG).

I used several of the examples supplied with DelphiX that handle the .X files, but when I load them in those examples I get nothing. I'm assuming this is because it's missing information in the corrisponding .DDS file and the PNG texture file.

Can anyone enlighten me as to how I properly load these files and display them?

Thanks!!!

-Z

Clootie
27-03-2006, 09:40 PM
You can see how mesh (with textures) loading is handled via looking at DXUTMesh.pas implementation (SourceForge CVS repositary) (http://cvs.sourceforge.net/viewcvs.py/delphi-dx9sdk/Samples/Delphi/Common/DXUTmesh.pas?rev=1.12&view=auto). Main areas to look at: CDXUTMesh.CreateMesh & CDXUTMesh.CreateMaterials.

iNFiNiTE615
27-03-2006, 10:00 PM
Thanks!! :) Looking over it now getting an idea of what to do. Could someone maybe give me a high-level overview, cause I'm not sure which order to follow. For Example

Load Mesh - .X/.DDS files ?
Render?
Free Mesh?

I'm not too up on all the graphics terms; I know what textures are, I'm guessing a mesh is the wireframe the textures are applied to. But I'm not clear on the order the functions should be called of this nature; specificly which functions relate to the .X files and which ones to the .DDS files and which ones to the .PNG textures files. Most of the functions I've seen only take a single filename, so how do the .X files relate to the .DDS and those to the textures?

Even just a list of the functions in the order they would be called would help, or reference to some code that ties all these functions together so I can see them all in action.

Anyhelp is greatly appreciated!

iNFiNiTE615
27-03-2006, 10:07 PM
Ok, so the CreateMesh function will load the Mesh from the .X files I have yes? The CreateMaterials function will load the textures? from the .DDS file?

Or do I have this all backwards? Let me rephrase; I'm DirectX illiterate.

Clootie
27-03-2006, 10:37 PM
Yes, you just call CreateMesh (in recerenced code at least :) ). And this function first loads mesh itself (X file with coordinates, topology and attributes), and later calls CreateMaterials to build up material properties in device-friendly format. CreatingMaterials also include loading of textures mentioned in material properties form disk or other user-supplied place. And later it's mostly user responcibility to setup all material properties (colors, textures, constants in new Pixel/Vertex Shader world) and draw mesh segment/subset that has this material applied to it.

Some helper functions from DXUT / D3DX can simplify above mentioned steps, but you can do it all by yourself (to gain some flexibility / efficiency).

iNFiNiTE615
27-03-2006, 11:08 PM
OK, thanks that cleared things up quite a bit for me. This is more of an extra feature that I want to add to my program, so the simplest method is what I'm looking for; I already have enough complex coding to do for the application itself.

Would it be possible for me to use one of the DelphiX sample app code (the one that just displays the cube and rotates it) and just replace the proper functions with the ones you mention that use the .X and .DDS files?

iNFiNiTE615
27-03-2006, 11:31 PM
Wow, didn't know this was available (the Delphi DX9 SDK), all I found was the older DelphiX project. Double thanks for that link!