User panel stuff on forum
  16 posts on 1 page  1
Client Talk
2009-01-29, 18:49
Member
357 posts

Registered:
Mar 2006
Okay, as promised I have implemented real-time simple item support for ezQuake. Same functionality as cg_simpleitems for Quake3.

Command: r_simpleitems 0 | 1 {default 0}
Description: Set to 1 and all ammo boxes, armor, health packs, weapons, and powerups are drawn as sprites.

Here's a recompiled (unofficial) ezQuake 1.90 with this feature implemented for you to test.
http://www.quakeone.com/qrack/ezquake-gl.exe
Here is the required pak file containing all the media.
http://www.quakeone.com/qrack/simpleitems.pak
Make sure you put the simpleitems.pak in your ezquake folder RENAME IT CORRECTLY.

And here's the code for the ezQuake dev team (or anyone else with a C compiler)

In cl_ents.c, find void CL_InitEnts(void) ,
Above that function add this...
model_t *mod_2dshells;
model_t *mod_2dcells;
model_t *mod_2drockets;
model_t *mod_2dnails;
model_t *mod_2dmega;
model_t *mod_2dpent;
model_t *mod_2dquad;
model_t *mod_2dring;
model_t *mod_2dsuit;
model_t *mod_2darmor1;
model_t *mod_2darmor2;
model_t *mod_2darmor3;
model_t *mod_2dbackpack;
model_t *mod_2dhealth10;
model_t *mod_2dhealth25;
model_t *mod_2drl;
model_t *mod_2dgl;
model_t *mod_2dlg;
model_t *mod_2dng;
model_t *mod_2dsng;
model_t *mod_2dssg;

Now, within the CL_InitEnts function find
for (i = 0; i < cl_num_modelindices; i++)
{
if (!cl_modelnames[i])
Sys_Error("cl_modelnames[%d] not initialized", i);
}

then right after that add...
//R00k load replacement sprites for models
mod_2dshells = Mod_ForName ("sprites/s_shells.spr", false);
mod_2dcells = Mod_ForName ("sprites/s_cells.spr", false);
mod_2drockets = Mod_ForName ("sprites/s_rockets.spr", false);
mod_2dnails = Mod_ForName ("sprites/s_nails.spr", false);
mod_2dmega = Mod_ForName ("sprites/s_mega.spr", false);
mod_2dpent = Mod_ForName ("sprites/s_invuln.spr", false);
mod_2dquad = Mod_ForName ("sprites/s_quad.spr", false);
mod_2dring = Mod_ForName ("sprites/s_invis.spr", false);
mod_2dsuit = Mod_ForName ("sprites/s_suit.spr", false);
mod_2darmor1 = Mod_ForName ("sprites/s_armor1.spr", false);
mod_2darmor2 = Mod_ForName ("sprites/s_armor2.spr", false);
mod_2darmor3 = Mod_ForName ("sprites/s_armor3.spr", false);
mod_2dbackpack = Mod_ForName ("sprites/s_backpack.spr", false);
mod_2dhealth10 = Mod_ForName ("sprites/s_health10.spr", false);
mod_2dhealth25 = Mod_ForName ("sprites/s_health25.spr", false);
mod_2dssg = Mod_ForName ("sprites/s_g_shot.spr", false);
mod_2dng = Mod_ForName ("sprites/s_g_nail.spr", false);
mod_2dsng = Mod_ForName ("sprites/s_g_nail2.spr", false);
mod_2dgl = Mod_ForName ("sprites/s_g_rock.spr", false);
mod_2drl = Mod_ForName ("sprites/s_g_rock2.spr", false);
mod_2dlg = Mod_ForName ("sprites/s_g_light.spr", false);

Now load up client.h and add this to the bottom..
//R00k for simple items...
extern struct model_s *mod_2dshells;
extern struct model_s *mod_2dcells;
extern struct model_s *mod_2drockets;
extern struct model_s *mod_2dnails;
extern struct model_s *mod_2dmega;
extern struct model_s *mod_2dpent;
extern struct model_s *mod_2dquad;
extern struct model_s *mod_2dring;
extern struct model_s *mod_2dsuit;
extern struct model_s *mod_2darmor1;
extern struct model_s *mod_2darmor2;
extern struct model_s *mod_2darmor3;
extern struct model_s *mod_2dbackpack;
extern struct model_s *mod_2dhealth10;
extern struct model_s *mod_2dhealth25;
extern struct model_s *mod_2dssg;
extern struct model_s *mod_2dng;
extern struct model_s *mod_2dsng;
extern struct model_s *mod_2dgl;
extern struct model_s *mod_2drl;
extern struct model_s *mod_2dlg;

Now in GL_Rmain.c find..
void R_DrawEntitiesOnList (visentlist_t *vislist)

just below
// draw sprites separately, because of alpha_test
for (i = 0; i < vislist->count; i++)
{
currententity = &vislist->list[i];

that portion, add this to look like this...
for (i = 0; i < vislist->count; i++)
{
currententity = &vislist->list[i];
//R00k-----------------------------------------------------------------------------------------------------------------start
if (r_simpleitems.value)
{
if ((!strcmp(currententity->model->name, "maps/b_shell0.bsp") || (!strcmp(currententity->model->name, "maps/b_shell1.bsp"))
{
currententity->model = mod_2dshells;
}
else
if ((!strcmp(currententity->model->name, "maps/b_batt0.bsp") || (!strcmp(currententity->model->name, "maps/b_batt1.bsp"))
{
currententity->model = mod_2dcells;
}
else
if ((!strcmp(currententity->model->name, "maps/b_rock0.bsp") || (!strcmp(currententity->model->name, "maps/b_rock1.bsp"))
{
currententity->model = mod_2drockets;
}
else
if ((!strcmp(currententity->model->name, "maps/b_nail0.bsp") || (!strcmp(currententity->model->name, "maps/b_nail1.bsp"))
{
currententity->model = mod_2dnails;
}
else
if (!strcmp(currententity->model->name, "maps/b_bh100.bsp")
{
currententity->model = mod_2dmega;
}
else
if (!strcmp(currententity->model->name, "maps/b_bh10.bsp")
{
currententity->model = mod_2dhealth10;
}
else
if (!strcmp(currententity->model->name, "maps/b_bh25.bsp")
{
currententity->model = mod_2dhealth25;
}
else
if (!strcmp(currententity->model->name, "progs/invulner.mdl")
{
currententity->model = mod_2dpent;
}
else
if (!strcmp(currententity->model->name, "progs/quaddama.mdl")
{
currententity->model = mod_2dquad;
}
else
if (!strcmp(currententity->model->name, "progs/invisibl.mdl")
{
currententity->model = mod_2dring;
}
else
if (!strcmp(currententity->model->name, "progs/suit.mdl")
{
currententity->model = mod_2dsuit;
}
else
if (!strcmp(currententity->model->name, "progs/armor.mdl")
{
if (currententity->skinnum == 0)
currententity->model = mod_2darmor1;
else
if (currententity->skinnum == 1)
currententity->model = mod_2darmor2;
else
if (currententity->skinnum == 2)
currententity->model = mod_2darmor3;
}
else
if(!strcmp(currententity->model->name, "progs/backpack.mdl")
{
currententity->model = mod_2dbackpack;
}
else
if(!strcmp(currententity->model->name, "progs/g_rock2.mdl")
{
currententity->model = mod_2drl;
}
else
if(!strcmp(currententity->model->name, "progs/g_rock.mdl")
{
currententity->model = mod_2dgl;
}
else
if(!strcmp(currententity->model->name, "progs/g_light.mdl")
{
currententity->model = mod_2dlg;
}
else
if(!strcmp(currententity->model->name, "progs/g_nail.mdl")
{
currententity->model = mod_2dng;
}
else
if(!strcmp(currententity->model->name, "progs/g_nail2.mdl")
{
currententity->model = mod_2dsng;
}
else
if(!strcmp(currententity->model->name, "progs/g_shot.mdl")
{
currententity->model = mod_2dssg;
}
}
//R00k-----------------------------------------------------------------------------------------------------------------end
switch (currententity->model->type)
{

and finally in that same function near the bottom we need to draw the sprites correctly for their 24bit replacement textures so...
find 'case mod_sprite' and replace with this
case mod_sprite:
GL_DisableMultitexture ();
glEnable (GL_ALPHA_TEST);
R_DrawSpriteModel (currententity);
glDisable (GL_ALPHA_TEST);
break;

Compile, we're done.
Make sure you put the simpleitems.pak in your ezquake folder RENAME IT CORRECTLY. (Future Release: I'd suggest putting all the files actually in the pak0 of ezquake)

THAT'S IT!
2009-01-29, 18:59
Member
569 posts

Registered:
Feb 2006
Not looking into the code, but if someone used a larger sized images for the simpleitems. would they be displayed in a cheaty way?
2009-01-29, 19:01
Member
340 posts

Registered:
Nov 2006
what about creating a real patch with the "diff -u" command? :-)
2009-01-29, 19:16
Member
357 posts

Registered:
Mar 2006
I suppose there could be CRC checking added for VALID replacement sprites.

Another issue is that sprites are rendered FULLBRIGHT, which I have disabled on my netQuake version

void R_DrawSpriteModel (entity_t *e)
{
vec3_t point, forward, right, up;
mspriteframe_t *frame;
msprite_t *psprite;
extern void R_SetupLighting (entity_t *ent);
float out[3], l, alpha;
extern float shadelight, ambientlight;

R_SetupLighting(e);
l = ((shadelight + ambientlight) / 256);
out[0]=out[1]=out[2]= 0.99609375;

// don't even bother culling, because it's just a single
// polygon without a surface cache
frame = R_GetSpriteFrame (e);
psprite = currententity->model->cache.data;

if (psprite->type == SPR_ORIENTED)
{
// bullet marks on walls
AngleVectors (currententity->angles, forward, right, up);
}
else if (psprite->type == SPR_FACING_UPRIGHT)
{
VectorSet (up, 0, 0, 1);
right[0] = e->origin[1] - r_origin[1];
right[1] = -(e->origin[0] - r_origin[0]);
right[2] = 0;
VectorNormalize (right);
}
else if (psprite->type == SPR_VP_PARALLEL_UPRIGHT)
{
VectorSet (up, 0, 0, 1);
VectorCopy (vright, right);
}
else
{ // normal sprite
VectorCopy (vup, up);
VectorCopy (vright, right);
}

GL_Bind (frame->gl_texturenum);

glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

alpha = 1;
/*
if (e->transparency)//R00k: support for transparent sprites
{
glEnable (GL_BLEND);
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glBlendFunc (GL_SRC_COLOR, GL_SRC_ALPHA);
alpha = 0.4;
}
*/
VectorScale(out, l, out);// lower lightlevel in shade
glColor4f(out[0],out[1],out[2],alpha);

glBegin (GL_QUADS);

glTexCoord2f (0, 1);
VectorMA (e->origin, frame->down, up, point);
VectorMA (point, frame->left, right, point);
glVertex3fv (point);

glTexCoord2f (0, 0);
VectorMA (e->origin, frame->up, up, point);
VectorMA (point, frame->left, right, point);
glVertex3fv (point);

glTexCoord2f (1, 0);
VectorMA (e->origin, frame->up, up, point);
VectorMA (point, frame->right, right, point);
glVertex3fv (point);

glTexCoord2f (1, 1);
VectorMA (e->origin, frame->down, up, point);
VectorMA (point, frame->right, right, point);
glVertex3fv (point);

glEnd ();
/*
if (e->transparency)
{
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable (GL_BLEND);
}
*/
glColor4f(1,1,1,1);
}

"Diff -u" I dont have the SVN for ezquake installed, and I was in a hurry
2009-01-29, 21:38
Member
51 posts

Registered:
Sep 2006
I cant get it to work, ezQuake CTD (with no error message) as soon as I set r_simpleitems to 1 ingame (not when I'm disconnected and just write it in the console, but when I join a game..), even tried with a clean install.

I've put simpleitems.pak in the ezquake folder (still shouldn't CTD even if ezQuake doesn't find it imo), tried renaming it to pak1.pak, add it to the pak.lst.

Maybe I'm writing here to fast without more testing now.

Edit: Tried it some more now and got it to work, simpleitems.pak should be renamed to simpleitems.pk3, and you have to put it in the pak.lst if you want it in the ezquake-folder, bu putting it in the qw-dir works too.

Great work!
2009-01-29, 23:29
Member
705 posts

Registered:
Feb 2006
how bout a screenie
2009-01-29, 23:47
Member
51 posts

Registered:
Sep 2006
http://upload.snelhest.org/images/090130simple1.png

Tada
2009-01-30, 04:50
Member
357 posts

Registered:
Mar 2006
Hmm well I dont know what you did wrong, or right but if it works I just plopped it into /ezquake/pak1.pak and it works but im using bare bones cfg and older v1.90(stable)
A note about the scaling, the larger the image size just means the more texture detail, it will either clip or scale down by power of X2.
2009-01-30, 13:45
Member
51 posts

Registered:
Sep 2006
It's just that if the sprites in your pak ain't found when typing r_simpleitems 1 ezQuake will crash without any warnings, which is not that good.

And some kind of bug/request: Would it be possible to move the b_model-sprites so that they are more in the middle, very noticeable on the mega health and health boxes, but you can see it on the ammo boxes too. If you understand what I mean or I can show it with a picture. :S
2009-01-30, 23:48
Member
303 posts

Registered:
Jun 2007
That's know problem with them. Model offset is weird (and the fact ammo/health models are in .bsp format while they already had .mdl), i think id guys just weren't experienced enough with 3D stuff back then (in fact few people in gaming industry was). It's even more clear when you look at v_ and g_ models. Or maybe tools were still too unperfect to make proper geometry? Now it's possible to make low-poly symmetric models without almost any skills.

It looks like this metod is based on cheating engine so it reads sprites as bsp and mdl files and accept 24-bit replacement textures for them. So i doubt there is a way to correct offset right now.

But on the other hand... we finally have real simple items support!
2009-01-31, 05:23
Member
357 posts

Registered:
Mar 2006
No hacks involved. This is because quake draws based on the media's header not the file extension. .mdl vs .md3 .spr
The offset from center, of the image, is based on the actual sprite file that you create. If you make a 32x32 sprite, then your replacement 24bit IMAGE must be same dimensional ratio. I was in a hurry so some images are not equal thus the off-tilt-ness of the images Sorry But this is just to get a foundation of a working fps saving feature like fast turb etc. This is mainly for the linux users out there on iPHONE
2009-02-01, 02:37
Member
303 posts

Registered:
Jun 2007
Ok, i have little problem with them. Simple items are rendenered in really weird way it looks like they are not affected by texture filtering at all - thei edges are really jaggy and they loose much detail when you are far from them. This effect is not present in Q3, and normal model textures arent affected by it.
2009-02-02, 22:47
Member
51 posts

Registered:
Sep 2006
So there is no way to fix the offset of the sprites?
And is s_light.spr used for anything?

I made some replacements for the 8 bit sprites in your pack, they look like the 32 bit ones, but lower res and they use the Quake palette, for those who like software or gl_no24bit.
http://upload.snelhest.org/images/090202simple3.png


Link: http://www.quaketastic.com/upload/files/misc/8bit_simpleitems_20090202.zip
2009-02-03, 22:49
Member
355 posts

Registered:
Jun 2006
For some odd reason, ezquake just crashes whenever I try to load up a map with r_simplitems 1. If I go on a map and change it, it crashes D:?

Edit: Ok, so it's a .pk3 file named as a .pak? Strange but yeah, works fine.
2009-02-28, 11:38
Member
18 posts

Registered:
Nov 2008
I was trying to port the 2d images of the simple item models I made to the game, but I'm getting crazy scaling issues.

http://img3.imageshack.us/img3/31/ezquake010.th.png


The image is a png converted into .spr at 128x128 resolution. How can I fix this problem?
2009-02-28, 16:57
Administrator
1859 posts

Registered:
Feb 2006
You can't use 128x128 as spr, they will be too big, you have to use 32x32 for those
  16 posts on 1 page  1