Archived

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

fluxmaster

Using Direct 3D with non-Microsoft file formats

Recommended Posts

fluxmaster    122
Here is a question on using using Direct 3D with models in other formats. The project that I am working on has code to run using both Direct 3D and OpenGL, since I want to have maximum flexibility and haven''t decided which one the final version will use. Originally, I created models using Direct 3D ".x" format to work with both the Direct 3D code and the OpenGL code. However, as my artistic ability is very limited when it comes to the graphic arts, the models were not of high quality. I now have a contractor who is creating models for me using MilkShape. The files are in MilkSkape ".ms3d" format. This is not a problem with OpenGL, but how do I use ".ms3d" files with Direct 3D? Currently, the code uses D3DXLoadMeshFromX() to read Direct 3D files. I could change this to D3DXLoadMeshFromXInMemory() to read the data directly from memory. But how should the memory be formated? Whould I have to convert the ".ms3d" files to ".x" text format on the fly to be able to use them with Direct 3D? Or is there a way to load a mesh from binary data, and, if so, what is the format of the binary data. I have been searching the Internet for this information but have been unable to find it. Before you give the obvious answer, "Convert the files to .x format and save them in that format," consider that I may want to create my own private file format, which will contain additional information, so I need the code to be able to load models created in any file format. Thank you. The Fluxmaster

Share this post


Link to post
Share on other sites
fluxmaster    122
Thanks for the links. The first link provided some very useful information about another topic that I didn''t ask about in my question--drawing transparent objects with OpenGL--which I was also looking for, and which was actually more important than my original question.

But back to my original question, I looked through both sites and couldn''t find the information on loading Direct 3D models from non-Direct 3D files. In particular, the second link seemed to be entirely about OpenGL. The one link on the page about DirectX was to a site in German, which I cannot read.

If I missed something, can you point it out. Otherwise, is the information available elsewhere? Thanks.

The Fluxmaster

Share this post


Link to post
Share on other sites
RenderTarget    398
ID3DXMesh objects really only consist of a few things: A single vertex buffer, a single index buffer (tri list format), and an attribute buffer which doesn''t get initialized by file data. The D3DXLoadMeshFromX functions also read material and texture information, but that''s really about it. You don''t have to use ID3DXMeshes, but if you want to you can just create it yourself, and set the loaded data by hand.

I like pie.

Share this post


Link to post
Share on other sites
fluxmaster    122
Thanks for the information, RenderTarget. I''m conferring with my contractor on whether the best way to do it is with meshes or triangle lists. If we decide to go with meshes, I might have a couple of more questions.

The Fluxmaster

Share this post


Link to post
Share on other sites
acw83    174
Do you know how to read in a file? If so just read in the .ms3d file and place the data into appropriate structures. It''s not as easy as te built in D3D stuff, but that''s the way it''s done in the real world.

Share this post


Link to post
Share on other sites
fluxmaster    122
Reading in the file is no problem. In fact, the code already works, more or less, in OpenGL. (It doesn''t do textures or transparency yet, but I''m working on it.) But I want the code to work in both Direct 3D and OpenGL so that I''ll have maximum flexibility.

Direct 3D has built-in functions for reading in ".x" files, and that was what I was using before. But to use a different file format requires a bit more work. Miss one function call or get it wrong, and it doesn''t render. But if that''s the way it''s done in the real world, then that''s how I''ll do it.

The Fluxmaster

Share this post


Link to post
Share on other sites