Inside3D!
     

Surface Flags ... making note of certain textures

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



Joined: 14 Mar 2006
Posts: 1538

PostPosted: Wed Dec 23, 2009 9:56 am    Post subject: Surface Flags ... making note of certain textures Reply with quote

I was looking through Qrack 1.60 and found this ...

Code:
static int Mod_FindSurfaceFlags(char *name)
{
   int   i;

   for (i = 0; i < numsflags; i++) {
      if (surfaceflags[i].len > 0) {
         if (!strncmp(name, surfaceflags[i].name, surfaceflags[i].len)) {
            return surfaceflags[i].flags;
         }
      } else {
         if (!strcmp(name, surfaceflags[i].name)) {
            return surfaceflags[i].flags;
         }
      }
   }
   return 0;
}


Rook is apparently using this for gl_shiny and such:

Code:
static sflags_t surfaceflags[] =
{
   // mirrors
   { "window", 6, SURF_MIRROR },
   { "wizwin", 6, SURF_MIRROR },
   { "window01_", 9, SURF_MIRROR },
   { "window02_", 9, SURF_MIRROR },
   { "window03_", 9, SURF_MIRROR },
   // Runes
   { "rune", 4, SURF_METAL },
   // Metal misc
   { "metal6_1", 8, SURF_METAL },
   { "metal6_2", 8, SURF_METAL },
   { "metal6_3", 8, SURF_METAL },
   { "metal6_4", 8, SURF_METAL },
   { "switch_1", 8, SURF_METAL },
   { "wkey02_1", 8, SURF_METAL },
   { "wkey02_2", 8, SURF_METAL },
   { "wkey02_3", 8, SURF_METAL },
   { "+0mtlsw", 7, SURF_METAL },
   { "+1mtlsw", 7, SURF_METAL },
   { "+2mtlsw", 7, SURF_METAL },
   { "+3mtlsw", 7, SURF_METAL },
   { "+amtlsw", 7, SURF_METAL },
   { "arrow_m", 7, SURF_METAL },
   { "azswitch3", 9, SURF_METAL },
   { "key", 3, SURF_METAL },

   // end of list
   { (NULL), 0, 0 }
};


This is where the first function gets called ...

Code:
/*
=================
Mod_LoadFaces
=================
*/
void Mod_LoadFaces (lump_t *l)
{
   dface_t      *in;
   msurface_t    *out;
   int      i, count, surfnum, planenum, side;

   in = (void *)(mod_base + l->fileofs);
   if (l->filelen % sizeof(*in))
      Sys_Error ("MOD_LoadBrushModel: funny lump size in %s", loadmodel->name);

   count = l->filelen / sizeof(*in);
   out = Hunk_AllocName (count * sizeof(*out), loadname);

   loadmodel->surfaces = out;
   loadmodel->numsurfaces = count;

   for (surfnum=0 ; surfnum<count ; surfnum++, in++, out++)
   {
      out->firstedge = LittleLong(in->firstedge);
      out->numedges = LittleShort(in->numedges);      
      out->flags = 0;

      planenum = LittleShort(in->planenum);
      side = LittleShort(in->side);

      if (side) out->flags |= SURF_PLANEBACK;         

      out->plane = loadmodel->planes + planenum;

      out->texinfo = loadmodel->texinfo + LittleShort (in->texinfo);
      CalcSurfaceExtents (out);

   // lighting info
      for (i=0 ; i<MAXLIGHTMAPS ; i++)
         out->styles[i] = in->styles[i];
      i = LittleLong(in->lightofs);
      out->samples = (i == -1) ? NULL : loadmodel->lightdata + i * 3;

   // set the drawing flags flag
      if (ISSKYTEX(out->texinfo->texture->name))   // sky
      {
         out->flags |= (SURF_DRAWSKY | SURF_DRAWTILED);
         GL_SubdivideSurface (out);   // cut up polygon for warps
         continue;
      }
      
      if (ISTURBTEX(out->texinfo->texture->name))   // turbulent
      {
         out->flags |= (SURF_DRAWTURB | SURF_DRAWTILED);
         for (i=0 ; i<2 ; i++)
         {
            out->extents[i] = 16384;
            out->texturemins[i] = -8192;
         }
         GL_SubdivideSurface (out);   // cut up polygon for warps
         continue;
      }
      // keep these flags seperate or else !!
      if (!(out->sflags = Mod_FindSurfaceFlags (out->texinfo->texture->name)))
      {
         out->sflags |= SURF_DETAIL;
      }
   }
}
Back to top
View user's profile Send private message
r00k



Joined: 13 Nov 2004
Posts: 483

PostPosted: Wed Dec 23, 2009 11:07 am    Post subject: Reply with quote

I think Reckless wrote that part..
Back to top
View user's profile Send private message
MeTcHsteekle



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

PostPosted: Wed Dec 23, 2009 4:05 pm    Post subject: Reply with quote

oooh man i LOVE gl_shiny, can we have that in proquake?
_________________
bah
Back to top
View user's profile Send private message AIM Address
reckless



Joined: 24 Jan 2008
Posts: 390
Location: inside tha debugger

PostPosted: Wed Dec 30, 2009 9:37 pm    Post subject: Reply with quote

the actuall idea itself is from labman i just made some changes because it became a bit messy Razz

actually it should be pretty easy to add scripting those shinies in Wink

(might even work for quakes mirror 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 -> Engine Programming 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