Forum

Tutorial Request MD3 and attachment support

Post tutorials on how to do certain tasks within game or engine code here.

Moderator: InsideQC Admins

Tutorial Request MD3 and attachment support

Postby ceriux » Mon Dec 14, 2009 8:03 pm

Iv found tutorials for implementing md2's but not md3's i was wondering if anyone would be kind enough to make up a tutorial for it. id be extremely appreciative if who did would. thanks for if anyone does!
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Re: Tutorial Request MD3 and attachment support

Postby Baker » Tue Dec 15, 2009 2:57 am

ceriux wrote:Iv found tutorials for implementing md2's but not md3's i was wondering if anyone would be kind enough to make up a tutorial for it. id be extremely appreciative if who did would. thanks for if anyone does!


Depending on how things go, this could happen this week.

And if not this week, it is an automatic for by the end of the year.

By the way, do have any links for the md2 implementation? I know MH has a mostly written tutorial for md2, but I'd just like to lazily assess where the changes are while trying to wrap up a few things this week.
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Postby ceriux » Tue Dec 15, 2009 3:13 am

this is the only one i know of.

http://www.quake-1.com/docs/quakesrc.org/98.html
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Postby Downsider » Tue Dec 15, 2009 3:59 pm

Wouldn't implementing some kind of MD3 tagging require a change to Quake's protocol?
User avatar
Downsider
 
Posts: 621
Joined: Tue Sep 16, 2008 1:35 am

Re: Tutorial Request MD3 and attachment support

Postby mh » Tue Dec 15, 2009 7:05 pm

Baker wrote:I know MH has a mostly written tutorial for md2.

That reminds me, I need to drag that one out from wherever I've hidden it, finalize it and post it.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Postby revelator » Wed Dec 16, 2009 4:03 am

i had one in the tutorial discussion section on quakesrc once but after the site went down most got lost so might be hard recovering.

i still have the engine i fiddled with back then but its an older version and doesnt have shadows implemented yet (later version had) and is based on code from dr labman where the new one was based of harvens md3 code.

ill see if i can polish it up to the code i posted back then.
User avatar
revelator
 
Posts: 2567
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Postby ceriux » Wed Dec 23, 2009 7:48 am

any updates? sorry i leave around the first of the year so =/ i been gettin kinda blah about stuff lol... -.- i can make visual content for engine tutorial trade =D
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Postby Baker » Wed Dec 23, 2009 8:02 am

Well ... I'm working on the Universal Servers project at the moment (amazing stuff!) ... but let me see what I can do.

It won't have attachment support, that's an extension --- someone else will have to add their 2 cents in on how to best achieve attachment support. And it'll be standard single model md3 ... no torso, legs, head stuff.

Let me quickly assess how long it would take to write up the md3 tutorial and build a test GLQuake .... if it will take approximately an hour or less I'll do it right now ...
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Postby ceriux » Wed Dec 23, 2009 8:04 am

oh dont rush yourself. like i said im leaving around the first of the year. my needs arnt that important as to those of the entire community!
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Postby Baker » Wed Dec 23, 2009 8:20 am

ceriux wrote:oh dont rush yourself. like i said im leaving around the first of the year. my needs arnt that important as to those of the entire community!


Changes are located in almost exclusively:

gl_model.h
gl_model.c
gl_rmain.c

Ah, it'd be funny to add md3 support into crusty old GLQuake just for fun and doesn't look too hard. I think I'll do it now just because it'd be funny.
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Postby Baker » Wed Dec 23, 2009 9:14 am

Planning ....

1) Will need to check for md3 vs. mdl format header on load
2) Mark such models
3) Load their textures; they are 24 bit. Have the textures loaded from the progs folder like DarkPlaces does it. The default GLQuake 8-bit texture extension cannot be used; software renderer is 8-bit (WinQuake) can't be used [I wonder if FTEQW's 24-bit software render does Q3 models? Hmmm]
4) When drawing all the entities, handle md3 separately
5) The code to render and light the md3 models.
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Postby revelator » Wed Dec 23, 2009 9:30 am

on it still ;) takes a while though i had made some very massive changes to get shadows etc. to work on the new code i started out having two different rendering sections one that handled nor mal mdl and one for md3 the latter code had all this wrapped up in the same function (was pretty messy before) :P.

hmm with csqc this could become very interresting indeed 8)
User avatar
revelator
 
Posts: 2567
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Part 1

Postby Baker » Wed Dec 30, 2009 11:36 am

Part 1 ... revision possible ... modelling after JoeQuake and the Qrack implementation

1a. gl_model.h

Add mod_md3 to the model types ...

typedef enum {mod_brush, mod_sprite, mod_alias, mod_md3} modtype_t;


1b. Locate the following ...

Code: Select all
//
// Whole model
//


And insert the Q3 model header declarations before ...

Code: Select all
//===================================================================
/*
==============================================================================

            Q3 MODELS

==============================================================================
*/

typedef struct
{
   int      ident;
   int      version;
   char      name[MAX_QPATH];
   int         flags;
   int      numframes;
   int      numtags;
   int      numsurfs;
   int      numskins;
   int      ofsframes;
   int      ofstags;
   int      ofssurfs;
   int      ofsend;
} md3header_t;

typedef struct
{
   vec3_t      mins, maxs;
   vec3_t      pos;
   float      radius;
   char      name[16];
} md3frame_t;

typedef struct
{
   char      name[MAX_QPATH];
   vec3_t      pos;
   vec3_t      rot[3];
} md3tag_t;

typedef struct
{
   int      ident;
   char      name[MAX_QPATH];
   int      flags;
   int      numframes;
   int      numshaders;
   int      numverts;
   int      numtris;
   int      ofstris;
   int      ofsshaders;
   int      ofstc;
   int      ofsverts;
   int      ofsend;
} md3surface_t;

typedef struct
{
   char      name[MAX_QPATH];
   int      index;
} md3shader_t;

typedef struct
{
   char      name[MAX_QPATH];
   int      index;
   int      gl_texnum, fb_texnum;
} md3shader_mem_t;

typedef struct
{
   int      indexes[3];
} md3triangle_t;

typedef struct
{
   float      s, t;
} md3tc_t;

typedef struct
{
   short      vec[3];
   unsigned short   normal;
} md3vert_t;

typedef struct
{
   vec3_t      vec;
   vec3_t      normal;
   byte      anorm_pitch, anorm_yaw;
   unsigned short   oldnormal;   // needed for normal lighting
} md3vert_mem_t;

#define   MD3_XYZ_SCALE   (1.0 / 64)

#define   MAXMD3FRAMES   1024
#define   MAXMD3TAGS   16
#define   MAXMD3SURFS   32
#define   MAXMD3SHADERS   256
#define   MAXMD3VERTS   4096
#define   MAXMD3TRIS   8192

typedef struct animdata_s
{
   int   offset;
   int   num_frames;
   int   loop_frames;
   float   interval;
} animdata_t;


1c. Locate and add the yellow, allowing us to know the type of alias model loaded ...

typedef struct model_s
{
char name[MAX_QPATH];
qboolean needload; // bmodels and sprites don't cache normally

modtype_t type;


int aliastype; // Alternate model format support

int numframes;
synctype_t synctype;

int flags;

//
// volume occupied by the model graphics
//
vec3_t mins, maxs;


Remainder of the tutorial will follow as time permits.
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Part 2

Postby Baker » Wed Dec 30, 2009 1:34 pm

Continued ... all subject to revision:

2a. gl_rmain.c

In R_DrawEntitiesOnList we need to check for MD3 ...

// draw sprites seperately, because of alpha blending
for (i=0 ; i<cl_numvisedicts ; i++)
{
currententity = cl_visedicts[i];

switch (currententity->model->type)
{
case mod_alias:
R_DrawAliasModel (currententity);
break;

case mod_md3:
R_DrawQ3Model (currententity);
break;


case mod_brush:
R_DrawBrushModel (currententity);
break;

default:
break;
}
}


2b. Likewise for the view model (R_DrawViewModel), we need to check for MD3 ...

// hack the depth range to prevent view model from poking into walls
glDepthRange (gldepthmin, gldepthmin + 0.3*(gldepthmax-gldepthmin));

switch (currententity->model->type)
{
case mod_alias:
R_DrawAliasModel (currententity);
break;

case mod_md3:
R_DrawQ3Model (currententity);
break;
}


glDepthRange (gldepthmin, gldepthmax);
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Postby ceriux » Wed Dec 30, 2009 7:16 pm

baker all of this is for MD3 support without attachments?
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Next

Return to Programming Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest