Sign in to follow this  
bbr125

models in DirectX 10

Recommended Posts

What are the most common model formats used with DirectX 10? I'm looking to use a format that would be generated by an artist using 3DS Max or other professional modeling software. How would I go about importing it into a ID3DX10Mesh?

Share this post


Link to post
Share on other sites
Check out http://assimp.sourceforge.net/index.html for model loading.
As to what format to use: which ever one you want. Most model formats are supported by ASSIMP.
After you load the model using ASSIMP you should save the model to your own custom binary format for quick loading. This is done by all games because loading most 3d file formats takes a long time and writing your own binary format will cut load time down by many many times. I don't mean by maybe 5-10%, I mean by like 500-1000% speed increase.

Thats it in a nutshell

Share this post


Link to post
Share on other sites
[quote name='smasherprog' timestamp='1312692145' post='4845661']
Check out [url="http://assimp.sourceforge.net/index.html"]http://assimp.source....net/index.html[/url] for model loading.
As to what format to use: which ever one you want. Most model formats are supported by ASSIMP.
After you load the model using ASSIMP you should save the model to your own custom binary format for quick loading. This is done by all games because loading most 3d file formats takes a long time and writing your own binary format will cut load time down by many many times. I don't mean by maybe 5-10%, I mean by like 500-1000% speed increase.

Thats it in a nutshell
[/quote]

Thanks, I just downloaded this program and opened an .x model in it. What would be the first step to creating my own binary format? Is there any tutorial on how to do this?

Share this post


Link to post
Share on other sites
no because it depends on your needs. If you want to store a static mesh, it is pretty simple: write your vertex buffers to a file, include the texture names, index buffer and the few other pieces of into you need. There isn't a specific way to do it because it is a very simple process. Should take you less than 100 lines of code to write your loader and saver for a static mesh. The animated mesh will get a little more complicated, but I wrote an animation helper to go with ASSIMP; it saves the animation data, loads it and precalculates the bone transforms needed for animations. If you are just starting, do not tinker with animation. Start by getting the static mesh loader down. Once you are able to load/save static mesh, then move onto animation stuff.

Here is my blog post for the animation loader
http://nolimitsdesigns.com/game-design/open-asset-import-library-animation-loader/
and a follow up
http://nolimitsdesigns.com/game-design/animation-code-update/

Share this post


Link to post
Share on other sites
[quote name='smasherprog' timestamp='1312694943' post='4845669']
no because it depends on your needs. If you want to store a static mesh, it is pretty simple: write your vertex buffers to a file, include the texture names, index buffer and the few other pieces of into you need. There isn't a specific way to do it because it is a very simple process. Should take you less than 100 lines of code to write your loader and saver for a static mesh. The animated mesh will get a little more complicated, but I wrote an animation helper to go with ASSIMP; it saves the animation data, loads it and precalculates the bone transforms needed for animations. If you are just starting, do not tinker with animation. Start by getting the static mesh loader down. Once you are able to load/save static mesh, then move onto animation stuff.

Here is my blog post for the animation loader
[url="http://nolimitsdesigns.com/game-design/open-asset-import-library-animation-loader/"]http://nolimitsdesig...imation-loader/[/url]
and a follow up
[url="http://nolimitsdesigns.com/game-design/animation-code-update/"]http://nolimitsdesig...on-code-update/[/url]
[/quote]

Okay. I'm just going to deal with the static mesh like you said because I'm just starting but I want to make sure I'm understanding correctly.

First I link with the assimp lib and copy the .dll into the active directory.

Then in my code something along the lines of:

[code]
Assimp::Importer importer;


const aiScene* scene = importer.ReadFile( pFile,
aiProcess_CalcTangentSpace |
aiProcess_Triangulate |
aiProcess_JoinIdenticalVertices |
aiProcess_SortByPType);
[/code]

Then I use this aiScene* to get information about the model and choose a way I want to store it. Then I write out this information to a file on disk (my own file format that I decide).

So I can build a separate 'converter' program using ASSIMP to create a special file format that I decide. And then in future games I can just include the 'loader' code to load my custom file format.

Am I on the right track or totally off base?

Share this post


Link to post
Share on other sites
That is pretty much it. To see how to extract the information from ASSIMP after you load a file, check out the file assimp_view.cpp function CreateAssetData() that has the bulk of the code for extracting the verticies, textures, and bones.

Share this post


Link to post
Share on other sites
[quote name='smasherprog' timestamp='1312725562' post='4845784']
That is pretty much it. To see how to extract the information from ASSIMP after you load a file, check out the file assimp_view.cpp function CreateAssetData() that has the bulk of the code for extracting the verticies, textures, and bones.
[/quote]

Thanks I'll take a look. Seems like a lot of work involved for something which should be a very common task. :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this