Jump to content
  • Advertisement


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


Custom model format question

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

Hi, if i want to create a custom file format for 3D Models, so that i can load them in OpenGL, were should i start? And is it hard to write an exporter for 3D Studio or Maya. I know discreet now has the Game Export API, but not much is documented, at least i haven''t found any good documentation. Thanks in advance,

Share this post

Link to post
Share on other sites
You should start by deciding what you want the model to be capable of. Some starting questions:

Do you want skeletal animation? vertex morphing animation? textures? how many? do you want to support artist generated normals and smooth groups? do you want to store complex bounding information in the file? what vertex format will be best for your engine (this also depends on most of the above questions)? are all the faces triangles or do you need more general polygons? do you have any other special effects that would require per-model data?

Once you know what your model needs, defining the format is (almost) trivial.

Exporters are not exactly 'hard' (as long as you've got a grasp of the SDK you are working with) but they can be tricky.

I thought I'd include an example. The current game I'm working on, I decided I'd like the following stuff for static building models:

1) No animation
2) One texture per model
3) Normals for lighting
4) A 2D perimeter line (drawn using a line primitive in max) used for collisions
5) A bounding sphere
6) Faces are triangles

Once I knew this, I defined some simple structures:


// Building Models:

struct NEON_B_Hdr
int numVerts;
int numFaces;
float radius; // bounding sphere

float p[3];
char name[32]; // MAX object name

char texture[64]; // Texture filename (in same directory as modelfile)

int numPts; // number of points in collision hull

float height; // height of hull.

// Immediately following header are numPts * float[2] structures


// Then come verts

struct NEON_B_Vert
float p[3];
float normal[3];
float t[2];

// Then come faces, as int[3] array

So basically the file consists of a header, followed by float[numPts*2] array, followed by NEON_B_Vert[numVerts] array of vertices, followed by int[3*numFaces] which are the vertex indices into the vertex array.

This is an extremely simple format, it means I can just load the verts and faces directly (well, almost) into vertex and index buffers (this is for a DirectX engine but that is irrelevant).

[edited by - JuNC on April 18, 2003 3:10:44 PM]

Share this post

Link to post
Share on other sites
thanks for the post. I guess then what i have to do first is understand MAX API so that i can start by exporting some vertices and add more stuff to it little by little. In the end, of course, it will be ideal if the format could have skeletal and all ''standart'' features.

Share this post

Link to post
Share on other sites
if you are interested
i have finished a model compiler to compile SMD files into .mdl format(my own format not halflife`s)
you can create SMD files with milkshape which is cheap and available as shareware

it supports

1.) skeletal animtions
2.) multiple bodyparts (helmets, detachable limbs....)
3.) triangle meshes easy to store for use in vertex buffers/vertex arrays
4.) boundingbox( it automatically rescales the model to fit into the defined box
5.) alpha blended polygons

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!