Inside3D!
     

Removing .ms2 meshing from GLQuake

 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> Programming Tutorials
View previous topic :: View next topic  
Author Message
Baker



Joined: 14 Mar 2006
Posts: 1538

PostPosted: Sun Nov 30, 2008 7:01 pm    Post subject: Removing .ms2 meshing from GLQuake Reply with quote

1. Open gl_vidnt.c

Quote:
Find and comment out this:

Code:
//  Baker: no longer need this
//   sprintf (gldir, "%s/glquake", com_gamedir);
//   Sys_mkdir (gldir);


Since the glquake dir where the .ms2 files used to be output will no longer be used.


2. Open gl_model.c

Quote:
Find "GL_MakeAliasModelDisplayLists (mod, pheader);"

Delete the yellow text above ^^ so it reads like this:

Code:
GL_MakeAliasModelDisplayLists (pheader);


3. Open gl_mesh.c

Quote:
Find this ...

Code:
/*
================
GL_MakeAliasModelDisplayLists
================
*/
void GL_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr)
{
   int      i, j;
   maliasgroup_t   *paliasgroup;
   int         *cmds;
   trivertx_t   *verts;
   char   cache[MAX_QPATH], fullpath[MAX_OSPATH], *c;
   FILE   *f;
   int      len;
   byte   *data;

   aliasmodel = m;
   paliashdr = hdr;   // (aliashdr_t *)Mod_Extradata (m);

   //
   // look for a cached version
   //
   strcpy (cache, "glquake/");
   COM_StripExtension (m->name+strlen("progs/"), cache+strlen("glquake/"));
   strcat (cache, ".ms2");

   COM_FOpenFile (cache, &f);   
   if (f)
   {
      fread (&numcommands, 4, 1, f);
      fread (&numorder, 4, 1, f);
      fread (&commands, numcommands * sizeof(commands[0]), 1, f);
      fread (&vertexorder, numorder * sizeof(vertexorder[0]), 1, f);
      fclose (f);
   }
   else
   {
      //
      // build it from scratch
      //
      Con_Printf ("meshing %s...\n",m->name);

      BuildTris ();      // trifans or lists

      //
      // save out the cached version
      //
      sprintf (fullpath, "%s/%s", com_gamedir, cache);
      f = fopen (fullpath, "wb");
      if (f)
      {
         fwrite (&numcommands, 4, 1, f);
         fwrite (&numorder, 4, 1, f);
         fwrite (&commands, numcommands * sizeof(commands[0]), 1, f);
         fwrite (&vertexorder, numorder * sizeof(vertexorder[0]), 1, f);
         fclose (f);
      }
   }


   // save the data out

   paliashdr->poseverts = numorder;

   cmds = Hunk_Alloc (numcommands * 4);
   paliashdr->commands = (byte *)cmds - (byte *)paliashdr;
   memcpy (cmds, commands, numcommands * 4);

   verts = Hunk_Alloc (paliashdr->numposes * paliashdr->poseverts
      * sizeof(trivertx_t) );
   paliashdr->posedata = (byte *)verts - (byte *)paliashdr;
   for (i=0 ; i<paliashdr->numposes ; i++)
      for (j=0 ; j<numorder ; j++)
         *verts++ = poseverts[i][vertexorder[j]];
}


Delete and replace with ...

Code:
void GL_MakeAliasModelDisplayLists (aliashdr_t *paliashdr) {
   int      i, j, *cmds;
   trivertx_t   *verts;

   // Tonik: don't cache anything, because it seems just as fast
   // (if not faster) to rebuild the tris instead of loading them from disk
      BuildTris ();      // trifans or lists

   // save the data out
   paliashdr->poseverts = numorder;

   cmds = Hunk_Alloc (numcommands * 4);
   paliashdr->commands = (byte *)cmds - (byte *)paliashdr;
   memcpy (cmds, commands, numcommands * 4);

   verts = Hunk_Alloc (paliashdr->numposes * paliashdr->poseverts * sizeof(trivertx_t));
   paliashdr->posedata = (byte *)verts - (byte *)paliashdr;
   for (i=0 ; i<paliashdr->numposes ; i++)
      for (j=0 ; j<numorder ; j++)
         *verts++ = poseverts[i][vertexorder[j]];
}


Compile, delete c:\quake\id1\glquake folder. Start up newly compiled glquake and you'll notice it no longer builds the .ms2 files "meshing something.mdl ..." nor does it read them.
Back to top
View user's profile Send private message
MeTcHsteekle



Joined: 15 May 2008
Posts: 397
Location: its a secret

PostPosted: Sun Nov 30, 2008 8:27 pm    Post subject: Reply with quote

yay Very Happy
_________________
bah
Back to top
View user's profile Send private message AIM Address
ceriux



Joined: 06 Sep 2008
Posts: 969
Location: Florida, USA

PostPosted: Mon Dec 01, 2008 12:51 am    Post subject: Reply with quote

what are they?
_________________
QuakeDB - Quake ModDB Group
Back to top
View user's profile Send private message Yahoo Messenger
Baker



Joined: 14 Mar 2006
Posts: 1538

PostPosted: Mon Dec 01, 2008 1:00 am    Post subject: Reply with quote

ceriux wrote:
what are they?


Load up original GLQuake. They are annoying files that senselessly get written to the glquake directory and serve no purpose except to trash up models.
Back to top
View user's profile Send private message
Tomaz



Joined: 05 Nov 2004
Posts: 49

PostPosted: Mon Dec 01, 2008 11:17 am    Post subject: Reply with quote

WTF?!?!?!?!

First you write a tutorial without a single comment on what is done or why. And then when someone asks what the old code did, you dont even know?

So for those that wonder.

BuildTris() parses all the triangles in the model and builds tri strips and tri fans ( makes the rendering alot faster )

The purpose of the ms2 files was to save out these "commands" that tell the renderer how the tri fans and tri strips are built to avoid having to reparse the model the next time the game was played.

Now as mentioned by TONIK's code comment ( not Baker's ) on a modern computer the parsing is done so fast that caching it does'nt make any sense anymore. The reason the ms2 thrases models is if someone has made a mod with a custum model that has the same name as an original quake model. Because then it will load the .ms2 from the quake id1 dir that is for the original quake model, and use it with the custom model. So the commands for the tri strips and tri fans is'nt correct. This was never an issue if one didnt play mods that shared models with the same name as an original quake model.

After typing this I found out another thing.

Baker, next time you make a tutorial based on code you didnt write ( which I assume you havent given the fact the code has a comment by Tonik and the fact you dont even know what the code does or even mention why one should remove the mod part when calling the function ) please mention who wrote the code.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> Programming Tutorials All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2004 phpBB Group