Skip to main content
GameDev.net gamedev.net
🔒 Locked

internal model format

Started by CoMaNdore Jan 6, 2005 at 3:40 PM 2 replies 600+ views
Original Post
CoMaNdore
CoMaNdore
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
Me
FlyingDemon
FlyingDemon
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.
zedzeek
zedzeek
u should seperate models from your materials completely
eg
struct GModel_t
{
unsigned int TextureID; // this shouldnrt be here

u wanna use something like

struct Object
{
Model modelID;
Material materialID;
};
Promit
Promit
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;		//counts...		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		//AABB		float Min[3];		float Max[3];		//sphere		float Radius;	//always centered at origin				//capsule		//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 )#endif

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.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.