Bounding Boxes and Powerups
Bounding Boxes and Powerups
Hello,
I would like to how to draw bounding boxes around other players, is it possible to use drawtools like CG_FillRect for this?
and my second question is: how to display the powerups respawn time like how many seconds are left to the quad damage respawn?
Thank you,
s.
I would like to how to draw bounding boxes around other players, is it possible to use drawtools like CG_FillRect for this?
and my second question is: how to display the powerups respawn time like how many seconds are left to the quad damage respawn?
Thank you,
s.
-
- Posts: 4022
- Joined: Sat Mar 12, 2005 6:24 pm
Re: Bounding Boxes and Powerups
Not CG_FillRect(), it's only for 2D drawing. You probably want trap_R_AddPolysToScene().I would like to how to draw bounding boxes around other players, is it possible to use drawtools like CG_FillRect for this
Do you want to know how to calculate the time remaining to respawn or how to make it visible on-screen?how to display the powerups respawn time like how many seconds are left to the quad damage respawn
Re: Bounding Boxes and Powerups
How to calculate the time remaining to respawnDo you want to know how to calculate the time remaining to respawn or how to make it visible on-screen?
-
- Posts: 4022
- Joined: Sat Mar 12, 2005 6:24 pm
Re: Bounding Boxes and Powerups
You'll have to listen for the pickup event from the server. item->quantity (I kid you not) is the respawn time, in the below snippet from cgame/cg_event.c:
Code: Select all
case EV_GLOBAL_ITEM_PICKUP:
DEBUGNAME("EV_GLOBAL_ITEM_PICKUP");
{
gitem_t *item;
int index;
index = es->eventParm; // player predicted
if ( index < 1 || index >= bg_numItems ) {
break;
}
item = &bg_itemlist[ index ];
// powerup pickups are global
if( item->pickup_sound ) {
trap_S_StartSound (NULL, cg.snap->ps.clientNum, CHAN_AUTO, trap_S_RegisterSound( item->pickup_sound, qfalse ) );
}
// show icon and name on status bar
if ( es->number == cg.snap->ps.clientNum ) {
CG_ItemPickup( index );
}
}
break;
Re: Bounding Boxes and Powerups
You mean like this:

BTW, this is real code, took me 3 hours to write it :P
Bounding boxes are a bit big on some players so it needs a bit of work.
The problem is, trap_R_ModelBounds only gets the bounding box of the model for it's first frame. So I'll probably have to implement my own bounding boxes for the player's body / legs.

BTW, this is real code, took me 3 hours to write it :P
Bounding boxes are a bit big on some players so it needs a bit of work.
The problem is, trap_R_ModelBounds only gets the bounding box of the model for it's first frame. So I'll probably have to implement my own bounding boxes for the player's body / legs.

-
- Posts: 4022
- Joined: Sat Mar 12, 2005 6:24 pm
Re: Bounding Boxes and Powerups
Hxrmn, I'm afraid I don't understand. The bounding box is static, right? What is it you would want to do with it?
Re: Bounding Boxes and Powerups
I assumed he meant some sort of hud element like the kind they made for dystopia:I would like to how to draw bounding boxes around other players, is it possible to use drawtools like CG_FillRect

Based on the fact that he was asking about a 2D drawing function ("CG_FillRect").
But yeah if you wanted to do a 3D bounding box, you'll still have the same issue with not being able to get the animated bounding box.
Re: Bounding Boxes and Powerups
I'm talking about 3d box not simple frame...
btw. maybe u guys know how to link two vec3_t and make a line ?
btw. maybe u guys know how to link two vec3_t and make a line ?
Re: Bounding Boxes and Powerups
Like I said, you can do a bounding box based on the player model but it only uses the bounding box for the first frame of animation. So on some of the player models where the death animation is on the first frame, the bounding box is huge. You could just fake it by defining your own bounding box mins/maxs.
Your mins/maxs could just be:
[-20,-20,0]
[20,20,100]
I dunno, mess with it.
Then you can get the the 8 points that make up the box using this code:
Then it's just a matter of drawing lines between the right points, and you can just use a refentity_t with RT_BEAM.
Might want to make it a function. :P
-Cheers
Your mins/maxs could just be:
[-20,-20,0]
[20,20,100]
I dunno, mess with it.
Then you can get the the 8 points that make up the box using this code:
Code: Select all
void BoundingBoxPoints(vec3_t origin, vec3_t mins, vec3_t maxs, vec3_t nodes[8]) {
vec3_t tmaxs, tmins;
float old;
VectorAdd(mins, origin, tmins);
VectorAdd(maxs, origin, tmaxs);
VectorCopy(tmins,nodes[0]);
old = tmins[0];
tmins[0] = tmaxs[0];
VectorCopy(tmins,nodes[1]);
tmins[0] = old;
tmins[1] = tmaxs[1];
VectorCopy(tmins,nodes[2]);
tmins[0] = tmaxs[0];
VectorCopy(tmins,nodes[3]);
VectorAdd(mins, origin, tmins);
VectorCopy(tmaxs,nodes[4]);
old = tmaxs[0];
tmaxs[0] = tmins[0];
VectorCopy(tmaxs,nodes[5]);
tmaxs[0] = old;
tmaxs[1] = tmins[1];
VectorCopy(tmaxs,nodes[6]);
tmaxs[0] = tmins[0];
VectorCopy(tmaxs,nodes[7]);
}
Code: Select all
refEntity_t re;
re.shaderTime = cg.time;
re.reType = RT_RAIL_CORE;
re.customShader = cgs.media.railCoreShader;
re.shaderRGBA[0] = 255;
re.shaderRGBA[1] = 255;
re.shaderRGBA[2] = 255;
re.shaderRGBA[3] = 255;
VectorCopy(start, re.origin);
VectorCopy(end, re.oldorigin);
trap_R_AddRefEntityToScene( &re);
-Cheers
Re: Bounding Boxes and Powerups
Oh maybe u know how to make this line rotate with me?
Re: Bounding Boxes and Powerups
Ok when you make your bounding box points, pass vec3_origin as the origin (0,0,0), this allows us to rotate the points properly
You'll need the following code for rotations.
create your rotation axis:
rotate + translate the points:
You will need to supply values for "yourPlayerAngle" and "yourPlayerOrigin" which are both vec3_t.
Good luck to you.
You'll need the following code for rotations.
Code: Select all
void RotateForAxis(vec3_t v, vec3_t axis[3]) {
int i;
vec3_t temp,temp2;
VectorClear(temp);
VectorClear(temp2);
for(i=0; i<3; i++) {
VectorScale(axis[i], v[i], temp);
VectorAdd(temp,temp2,temp2);
}
VectorCopy(temp2,v);
}
Code: Select all
vec3_t rotation[3];
...
AnglesToAxis(yourPlayerAngle, rotation);
Code: Select all
for(i=0, i<8, i++) {
RotateForAxis(nodes[i], rotation);
VectorAdd(nodes[i],yourPlayerOrigin,nodes[i]);
}
Good luck to you.