Advertisement Jump to content
Sign in to follow this  

internal model format

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

Okay The thing is that I have always bound myself to one model format ( md2 ) Now I want to change this and have a internal model format instead. I was wondering how it would look, right now im thinking allong the lines of this:
typedef unsigned int GIndex_t;

struct GFace_t
	GIndex_t vertIdx[3];		// index's for vertexs

struct GModel_t
	unsigned int	TextureID;

	unsigned int	nVertices;
	GVertex_t*		pVertices; // vertex contains, normal + uv

	unsigned int	nFaces;
	GFace_t*		pFaces;
I know that I havent realy put inn any information about animation, so any advises on this would be good. Also what kind of VA should I use to render indexed verts like used in faces? thanks - CoMaNdore

Share this post

Link to post
Share on other sites
Indexed vertex arrays are pretty fast. Try adding more texture unit id's so your models can have more then one texture, usefull for multi-texturing. Maybe add some bounding box, sphere, elipse objects or whatever for collision.

Share this post

Link to post
Share on other sites
u should seperate models from your materials completely
struct GModel_t
unsigned int TextureID; // this shouldnrt be here

u wanna use something like

struct Object
Model modelID;
Material materialID;

Share this post

Link to post
Share on other sites
When I got fed up with MD2, due to its numerous stupidities, I designed an alternate model format called MDT instead.

#ifndef _MDT_H
#define _MDT_H

#pragma pack( push, MdtPacking, 4 )

namespace Mdt
const unsigned int Version = 2;

struct Header
//basic checksum information
char Id[4];
int Version;

unsigned int NumFaces;
unsigned int NumFrames;
unsigned int NumAnims;

//and offsets
unsigned int FrameOffset;
unsigned int AnimOffset;

//the Text segment is basically misc. generic data
unsigned int TextOffset;

struct Vertex
float x, y, z;
float tu, tv;
float nx, ny, nz;
float tx, ty, tz; //tangents

struct Frame
//bounding volumes
float Min[3];
float Max[3];

float Radius; //always centered at origin

//NOTE: Capsules are not guaranteed to contain all of an object's geometry!
float CapsuleRadius;
float Height;

Vertex* Vertices;

struct Animation
//basic properties
char Name[64];
float AnimFps;

//frames used by this anim
unsigned int FrameStart;
unsigned int FrameCount;

#pragma pack( pop, MdtPacking )


It requires essentially no preprocessing between reading from disk and rendering. It stores AABB, sphere, and capsule bounding information, which i useful for physics integration if you don't want to do poly-perfect collision. It includes a text segment for whatever purposes you might want, maybe some sort of script. Hell, you could embed a shader or a CgFX/D3DX effect file in there. It stores tangents, which allows you to do normal mapping easily. It's using the same sort of keyframe animation as MD2. Also, it defines animations in the file, which gets you away from Q2's annoying hard coded animation system. Each mesh has its own animations, but the animations aren't pre-specified to a certain game.

I have a prototype exporter plugin for MS3D. Unfortunately, it doesn't do animations yet, because I haven't figured out how to get animation data out of MS3D. I also having loading/rendering code. PM if you're interested.

Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. 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!