Quake3World.com Forums
     Programming Discussion
        Bounding Boxes and Powerups


Post new topicReply to topic
Login | Profile | | FAQ | Search | IRC




Print view Previous topic | Next topic 
Topic Starter Topic: Bounding Boxes and Powerups

Gibblet
Gibblet
Joined: 14 May 2010
Posts: 11
PostPosted: 07-02-2010 06:53 AM           Profile Send private message  E-mail  Edit post Reply with quote


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.




Top
                 

Mentor
Mentor
Joined: 12 Mar 2005
Posts: 3958
PostPosted: 07-03-2010 12:33 AM           Profile Send private message  E-mail  Edit post Reply with quote


Quote:
I would like to how to draw bounding boxes around other players, is it possible to use drawtools like CG_FillRect for this

Not CG_FillRect(), it's only for 2D drawing. You probably want trap_R_AddPolysToScene().

Quote:
how to display the powerups respawn time like how many seconds are left to the quad damage respawn

Do you want to know how to calculate the time remaining to respawn or how to make it visible on-screen?




Top
                 

Gibblet
Gibblet
Joined: 14 May 2010
Posts: 11
PostPosted: 07-03-2010 08:04 AM           Profile Send private message  E-mail  Edit post Reply with quote


Quote:
Do you want to know how to calculate the time remaining to respawn or how to make it visible on-screen?

How to calculate the time remaining to respawn




Top
                 

Mentor
Mentor
Joined: 12 Mar 2005
Posts: 3958
PostPosted: 07-03-2010 09:02 AM           Profile Send private message  E-mail  Edit post Reply with quote


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:
        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;




Top
                 

Gibblet
Gibblet
Joined: 10 Jun 2010
Posts: 17
PostPosted: 08-08-2010 03:27 PM           Profile Send private message  E-mail  Edit post Reply with quote


You mean like this:
Image

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. :(




Top
                 

Mentor
Mentor
Joined: 12 Mar 2005
Posts: 3958
PostPosted: 08-09-2010 02:15 AM           Profile Send private message  E-mail  Edit post Reply with quote


Hxrmn, I'm afraid I don't understand. The bounding box is static, right? What is it you would want to do with it?




Top
                 

Gibblet
Gibblet
Joined: 10 Jun 2010
Posts: 17
PostPosted: 08-09-2010 09:57 AM           Profile Send private message  E-mail  Edit post Reply with quote


Quote:
I would like to how to draw bounding boxes around other players, is it possible to use drawtools like CG_FillRect


I assumed he meant some sort of hud element like the kind they made for dystopia:
Image

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.




Top
                 

Gibblet
Gibblet
Joined: 14 May 2010
Posts: 11
PostPosted: 08-10-2010 08:41 AM           Profile Send private message  E-mail  Edit post Reply with quote


I'm talking about 3d box not simple frame...
btw. maybe u guys know how to link two vec3_t and make a line ?




Top
                 

Gibblet
Gibblet
Joined: 10 Jun 2010
Posts: 17
PostPosted: 08-10-2010 10:42 AM           Profile Send private message  E-mail  Edit post Reply with quote


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:
Code:
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]);
}


Then it's just a matter of drawing lines between the right points, and you can just use a refentity_t with RT_BEAM.
Code:
   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);

Might want to make it a function. :P
-Cheers




Top
                 

Gibblet
Gibblet
Joined: 14 May 2010
Posts: 11
PostPosted: 08-11-2010 02:31 AM           Profile Send private message  E-mail  Edit post Reply with quote


works perfect :)




Top
                 

Gibblet
Gibblet
Joined: 14 May 2010
Posts: 11
PostPosted: 08-12-2010 03:17 AM           Profile Send private message  E-mail  Edit post Reply with quote


Oh maybe u know how to make this line rotate with me?




Top
                 

Gibblet
Gibblet
Joined: 10 Jun 2010
Posts: 17
PostPosted: 08-13-2010 10:21 AM           Profile Send private message  E-mail  Edit post Reply with quote


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.
Code:
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);
}

create your rotation axis:
Code:
vec3_t rotation[3];
...
AnglesToAxis(yourPlayerAngle, rotation);

rotate + translate the points:
Code:
for(i=0, i<8, i++) {
       RotateForAxis(nodes[i], rotation);
       VectorAdd(nodes[i],yourPlayerOrigin,nodes[i]);
}


You will need to supply values for "yourPlayerAngle" and "yourPlayerOrigin" which are both vec3_t.
Good luck to you.




Top
                 
Quake3World.com | Forum Index | Programming Discussion


Post new topic Reply to topic


cron
Quake3World.com
© ZeniMax. Zenimax, QUAKE III ARENA, Id Software and associated trademarks are trademarks of the ZeniMax group of companies. All rights reserved.
This is an unofficial fan website without any affiliation with or endorsement by ZeniMax.
All views and opinions expressed are those of the author.