Rune Central

The Official Rune Quake Message Board
It is currently Sat Dec 21, 2024 1:14 pm

All times are UTC - 5 hours [ DST ]




Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: Hello there ;)
PostPosted: Wed Sep 29, 2004 4:10 am 
Offline

Joined: Wed Sep 29, 2004 3:53 am
Posts: 8
Im new to this forum, allthough some her might know me from Qsg as reckless :wink:

I have been twiddeling a lot with joe's engine over a little year or so, and added some glow effects and md3 model support :) "just stuck a bit on getting dynamic lighting to work on them but its allmost there" .

The glow effects are from mhquake but modified a lot by me, and can be turned on/off so if someone find them lame its not that big a problem :lol:

md3 support is working great though and adds a lot to it because its easier to make good looking custom models for md3 than the old mdl format :wink:
only bug is the one above, but if joe can use my code feel free to do :D

if the above has any interrest leave me a note and ill give ya a link for the source :wink:

greetz


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Oct 02, 2004 9:08 pm 
Offline
quake.intertex.net
User avatar

Joined: Sat Nov 15, 2003 7:39 pm
Posts: 243
Location: Kansas City!
ya im having trouble getting the md3 model code from QURE to work properly...


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Oct 03, 2004 5:07 pm 
Offline

Joined: Wed Sep 29, 2004 3:53 am
Posts: 8
:) i fixed that it works like a charm now :wink:

only thing still not completely working are shadows & dynamic lighting
"need a struct replacement for the lookuptable"

here's my current code for the md3 renderer

Code:
void R_DrawQ3Model(entity_t *e)
{
   int               i, j, k, lnum;
   int               frame;
   int               lastframe;
   int               vertframeoffset;
   int               lastvertframeoffset;
   float            alpha;
   float            blend, iblend;
   float            l, add, radiusmax = 0.0;
   vec3_t            l_v, vec, normal;
   vec3_t            dist, ang, dlight_color;
   model_t            *clmodel;
   md3header_mem_t      *header;
   md3surface_mem_t   *surf;
   md3shader_mem_t      *shader;
   md3st_mem_t         *tc;
   md3tri_mem_t      *tris;
   md3vert_mem_t      *verts, *vertslast;

   if (!gl_notrans.value) {
      // allways true if not -nehahra
      model_alpha = currententity->transparency;
      if (model_alpha == 0) {
         model_alpha = 1.0;
      }
   } else {
      model_alpha = 1.0;
   }
   
   alpha = (currententity == &cl.viewent && gl_mtexable) ?
   (
      (cl.items & IT_INVISIBILITY) ?
      gl_ringalpha.value : bound(0, r_drawviewmodel.value, 1)
   ) : model_alpha;

   if (alpha < 1.0) {
      glEnable (GL_BLEND);
   }

   //md3 interpolation
   clmodel = e->model;
   e->frame_interval = 0.1f;

   if (e->pose2 != e->frame) {
      e->frame_start_time = realtime;
      e->pose1 = e->pose2;
      e->pose2 = e->frame;
      blend = 0;
   } else {
      blend = (realtime - e->frame_start_time) / e->frame_interval;
      if (blend > 1)
         blend = 1;
   }
   iblend = 1.0 - blend;

   // get lighting information
   // make thunderbolt and torches full light
   if (clmodel->modhint == MOD_THUNDERBOLT) {
      ambientlight = 210;
      shadelight = 0;
      r_lightlevel = true;
   } else if (clmodel->modhint == MOD_FLAME) {
      ambientlight = 255;
      shadelight = 0;
      r_lightlevel = true;
   } else {   
      // normal lighting
       r_lightlevel = false;
      ambientlight = shadelight = R_LightPoint (currententity->origin);
      for (lnum = 0 ; lnum < MAX_DLIGHTS ; lnum++) {
         if (cl_dlights[lnum].die < realtime || !cl_dlights[lnum].radius)   continue;
         VectorSubtract (e->origin, cl_dlights[lnum].origin, dist);
         add = cl_dlights[lnum].radius - Length (dist);
         if (add > 0) {
            if (gl_vertexlights.value) {
               if (!radiusmax || cl_dlights[lnum].radius > radiusmax) {
                  radiusmax = cl_dlights[lnum].radius;
                  VectorCopy(cl_dlights[lnum].origin, vertexlight);
               }
            }
            VectorCopy(bubblecolor[cl_dlights[lnum].type], dlight_color);
            for (i=0 ; i<3 ; i++) {
               lightcolor[i] = lightcolor[i] + (dlight_color[i] * add) * 2;
               if (lightcolor[i] > 256) {
                  switch (i) {
                  case 0:
                     lightcolor[1] = lightcolor[1] - (1 * lightcolor[1]/3);
                     lightcolor[2] = lightcolor[2] - (1 * lightcolor[2]/3);
                     break;

                  case 1:
                     lightcolor[0] = lightcolor[0] - (1 * lightcolor[0]/3);
                     lightcolor[2] = lightcolor[2] - (1 * lightcolor[2]/3);
                     break;

                  case 2:
                     lightcolor[1] = lightcolor[1] - (1 * lightcolor[1]/3);
                     lightcolor[0] = lightcolor[0] - (1 * lightcolor[0]/3);
                     break;
                  }
               }
            }
         }
      }

      // calculate pitch and yaw for vertex lighting
      if (gl_vertexlights.value) {
         apitch = currententity->angles[0];
         ayaw = currententity->angles[1];
         if (!radiusmax) {
            vlight_pitch = 45;
            vlight_yaw = 45;
         } else {
            VectorSubtract(vertexlight, currententity->origin, dist);
            vectoangles(dist, ang);
            vlight_pitch = ang[0];
            vlight_yaw = ang[1];
         }
      }

      // clamp lighting so it doesn't overbright as much
      ambientlight = min(128, ambientlight);
      
      if (ambientlight + shadelight > 192) {
         shadelight = 192 - ambientlight;
      }

      // always give the gun some light
      if (e == &cl.viewent && ambientlight < 24) {
         ambientlight = shadelight = 24;
      }

      // never allow players to go totally black
      if (clmodel->modhint == MOD_PLAYER) {
         if (ambientlight < 8) {
            ambientlight = shadelight = 8;
         }
      }
   }

   if (clmodel->modhint == MOD_PLAYER && r_fullbrightskins.value) {
      ambientlight = shadelight = 128;
      r_lightlevel = true;
   }
   header = (md3header_mem_t *)Mod_Extradata (currententity->model);

   if (*(long *)header->id != MD3IDHEADER){
      Con_Printf("MD3 bad model for: %s\n", header->filename);
      return;
   }
   glPushMatrix();

   //interpolate unless its the viewmodel
   if (e != &cl.viewent) {
      R_BlendedRotateForEntity (e, 0);
   } else {
      R_RotateForEntity (e);
   }
   surf = (md3surface_mem_t *)((byte *)header + header->offs_surfaces);

   for (i = 0; i < header->num_surfaces; i++) {
      if (*(long *)surf->id != MD3IDHEADER){
         Con_Printf("MD3 bad surface for: %s\n", header->filename);
      }

      if (surf->num_surf_frames == 0){
         surf = (md3surface_mem_t *)((byte *)surf + surf->offs_end);
         continue;   //shouldn't ever do this, each surface should have at least one frame
      }

      frame = e->frame;
      frame = frame%surf->num_surf_frames;   //cap the frame inside the list of frames in the model
      vertframeoffset = frame*surf->num_surf_verts * sizeof(md3vert_mem_t);
      lastframe = e->pose1%surf->num_surf_frames;
      lastvertframeoffset = lastframe*surf->num_surf_verts * sizeof(md3vert_mem_t);

      //get pointer to shaders
      shader = (md3shader_mem_t *)((byte *)surf + surf->offs_shaders);
      tc = (md3st_mem_t *)((byte *)surf + surf->offs_tc);
      tris = (md3tri_mem_t *)((byte *)surf + surf->offs_tris);
      verts = (md3vert_mem_t *)((byte *)surf + surf->offs_verts + vertframeoffset);
      vertslast = (md3vert_mem_t *)((byte *)surf + surf->offs_verts + lastvertframeoffset);

      // if shader binds to e->skinum
      // it will fuck up modeltextures
      // so use currententity instead
      if (surf->num_surf_shaders!=0) {
         GL_Bind(shader[(currententity->skinnum%surf->num_surf_shaders)].texnum);
      } else {
         GL_Bind(0);
      }
      
      // normals and vertexes come from the frame list
      // blend the light intensity from the two frames together
      // yeah like fuck it does that right :(
      if (blend >=1) {
         l = R_LerpVertexLight ((int)verts->normal, (int)verts->vec, blend, apitch, ayaw);

         l = min(l, 1);         
      } else {
         l = R_GetVertexLightValue ((int)verts->normal, apitch, ayaw);
      
         l = min(l, 1);
      }
      
      if (!r_lightlevel) {
         for (i=0 ; i<3 ; i++) {
            l_v[i] = lightcolor[i] / 256 + l;
         }
         glColor4f (l_v[0], l_v[1], l_v[2], alpha);
      }

      if (blend >=1) {
         glNormalPointer(GL_FLOAT, 6 * sizeof(float), (float *)verts->normal);
         glEnableClientState(GL_NORMAL_ARRAY);

         glVertexPointer(3, GL_FLOAT, 6 * sizeof(float), (float *)verts->vec);
         glEnableClientState(GL_VERTEX_ARRAY);

         glTexCoordPointer(2, GL_FLOAT, 0, (float *)tc);
         glEnableClientState(GL_TEXTURE_COORD_ARRAY);

         glDrawElements(GL_TRIANGLES, surf->num_surf_tris*3, GL_UNSIGNED_INT, (int *)tris);

         glDisableClientState(GL_NORMAL_ARRAY);
         glDisableClientState(GL_VERTEX_ARRAY);
         glDisableClientState(GL_TEXTURE_COORD_ARRAY);
      } else {
         glBegin(GL_TRIANGLES);
         //for each triangle
         for (j = 0; j < surf->num_surf_tris; j++) {
            //draw the poly
            for (k=0; k < 3; k++) {
               //interpolated
               vec[0] = verts[tris[j].tri[k]].vec[0] * blend + vertslast[tris[j].tri[k]].vec[0] * iblend;
               vec[1] = verts[tris[j].tri[k]].vec[1] * blend + vertslast[tris[j].tri[k]].vec[1] * iblend;
               vec[2] = verts[tris[j].tri[k]].vec[2] * blend + vertslast[tris[j].tri[k]].vec[2] * iblend;

               normal[0] = verts[tris[j].tri[k]].normal[0] * blend + vertslast[tris[j].tri[k]].normal[0] * iblend;
               normal[1] = verts[tris[j].tri[k]].normal[1] * blend + vertslast[tris[j].tri[k]].normal[1] * iblend;
               normal[2] = verts[tris[j].tri[k]].normal[2] * blend + vertslast[tris[j].tri[k]].normal[2] * iblend;
               
               glTexCoord2f (tc[tris[j].tri[k]].s, tc[tris[j].tri[k]].t);
               glTexCoord2f (tc[tris[j].tri[k]].s, tc[tris[j].tri[k]].t);

               glVertex3fv(vec);
               glNormal3fv(normal);
            }
         }
         glEnd();
      }
      surf = (md3surface_mem_t *)((byte *)surf + surf->offs_end);

      if (alpha < 1.0) {
         glDisable (GL_BLEND);
      }
   }
   glPopMatrix();
}


hope this is to some help :wink:


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Oct 03, 2004 9:21 pm 
Offline
quake.intertex.net
User avatar

Joined: Sat Nov 15, 2003 7:39 pm
Posts: 243
Location: Kansas City!
does it matter if u put
md3header_t *model = Mod_Extradata(e->model);

near the top before the lighting information?

Tei's code is similar to this, QMB and others are completely incompatible with JQ, i think.. ill try to encode this... :)

ill let u know if i get any lighting on the alias md3 models, color can come next, ill be happy if i see anything but errors ;)


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Oct 04, 2004 12:07 am 
Offline
quake.intertex.net
User avatar

Joined: Sat Nov 15, 2003 7:39 pm
Posts: 243
Location: Kansas City!
hmm, well i got the code implemented without any erros but how do i test the models now? :P


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Oct 04, 2004 2:34 am 
Offline

Joined: Wed Sep 29, 2004 3:53 am
Posts: 8
:D nice.

hehe allready made a pak with the nessesary model stuff :wink:
got it on ftp but the pak's rather large "hope you dont mind" includes everything needed for max eyecandy :wink:

ftp://80.162.236.139:21 login anonymous no password :)

for the smallest download choose this mini_pak.zip or if you prefer the full thing demonquake_full_pak.zip warning the full pak is in exess of 130 megabyte :?

love to hear if you get by this dynamic lighting buggah its been driving me crazy :lol:


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Oct 04, 2004 2:41 am 
Offline

Joined: Wed Sep 29, 2004 3:53 am
Posts: 8
:) oh almost forgot you might have a look at the source for demonquake
because i load the shaders for the md3 models from two seperate dirs under textures one for weaponmodels and one for bsp models :wink:

i also enabled a few flags in the model code to have rotating weaponmodels & such :) so if theres anything you like feel free to use :wink:


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Oct 07, 2004 2:20 pm 
Offline

Joined: Wed Sep 29, 2004 3:53 am
Posts: 8
:?: any progress yet.
Still working on the fix but is a drag tried splitting up the renderer function
to work more like normal quake does but is a drag :( its working however
but still the dynamic lighting is a pain in the ass :lol:

But succeded in adding shadow volumes on them. I dont think you want that feat though "major fps drop" in some scenes im down to 10 fps :cry:


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Oct 08, 2004 3:43 am 
Offline
quake.intertex.net
User avatar

Joined: Sat Nov 15, 2003 7:39 pm
Posts: 243
Location: Kansas City!
well, i implemented some .md3 code....
tried tie's, then qmb, yours etc.......
the models load up not the skins, (need to add skins to folder)
but then i got freezes in mid game like after 20 minutes of play...
tried to fix that while adding decals from projectile contact to bps then
all sh!t hit the fan.. and reverted back to a base compile b4i started adding md3 code
so im back to square 1, functionable compile, no progress :<

all good, rather proceed with stability and get it right instead of quickly making bugs ;)

I just need to learn a little more openGL coding


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Oct 08, 2004 10:18 am 
Offline

Joined: Wed Sep 29, 2004 3:53 am
Posts: 8
:D me2 i must admit *G* but nice to hear some progress :wink:

hmm the crashy thing i dont get maybe take a look at demonquake source
gl_md3.c gl_md3.h and where i call it in gl_rmain "i use a different approach
than qmb "not called in r_drawaliasmodels" :)

Good luck with getting it to go :wink:


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Oct 18, 2004 3:43 pm 
Offline
User avatar

Joined: Fri Oct 24, 2003 2:09 pm
Posts: 252
Location: Hungary
i'd be interested in seeing the code, but cant reach the site you gave. Could you upload it somewhere elese?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Oct 20, 2004 3:51 pm 
Offline

Joined: Wed Sep 29, 2004 3:53 am
Posts: 8
:D sure sorry for the delay "major server crash" one off my scsi'es went buum :x so had to reinstall everything :(

ftp://83.90.155.229:21 login anonymous no pass

if theres any trouble reaching my ftp please let me know so i can bug it out :lol:


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Oct 21, 2004 3:42 pm 
Offline
User avatar

Joined: Fri Oct 24, 2003 2:09 pm
Posts: 252
Location: Hungary
nope, it times out before i could connect


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Nov 26, 2004 10:59 am 
Offline

Joined: Wed Sep 29, 2004 3:53 am
Posts: 8
:( ugh lost internet connection dunno if it will be back soon :? "trouble with my isp"

Im writing from my old mans comp "not actually state off the art" yuck :lol:

can try to mail it to you. Is about the only option i have atm "need to get it here on cd first though"

Sorry for the late reply been moving :wink:


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Nov 26, 2004 4:41 pm 
Offline
User avatar

Joined: Fri Oct 24, 2003 2:09 pm
Posts: 252
Location: Hungary
no problem.
Could you send the necessarry files to joe_quake@hotmail.com


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 57 guests


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 post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group