
It took me a while to figure this stuff out, here's the code so you don't have to.
http://pastebin.com/CKkdDTfm
You'll want to put this code in your cg_local.h depending on what functions you want to use:
Code: Select all
//
//cg_project.c
//
void VectorToScreen(vec3_t vector, refdef_t def, vec3_t out, qboolean screenScale);
qboolean quickProject(vec3_t v, float *x, float *y);
void BoundingBoxPoints(vec3_t origin, vec3_t mins, vec3_t maxs, vec3_t nodes[8]);
void CompareMins(vec3_t pmins, vec3_t cmins, vec3_t out);
void CompareMaxs(vec3_t pmaxs, vec3_t cmaxs, vec3_t out);
void RotateFoxAxis(vec3_t v, vec3_t axis[3]);
qboolean ProjectBounds( vec3_t mins, vec3_t maxs, vec3_t origin, float *xv, float *yv);
qboolean ProjectRotatedBounds( vec3_t mins, vec3_t maxs, vec3_t axis[3], float *xv, float *yv, vec3_t origin );
Code: Select all
VectorToScreen(vec3_t vector, refdef_t refdef, vec3_t out, qboolean screenScale);
//if screenScale is true the size of the refdef will be converted from the renderer screen size.
Code: Select all
qboolean quickProject(vec3_t v, float *x, float *y);
//The refdef is cg.refdef and it returns true if the point is visible on the screen.
//Pass in a float pointer for *x and *y
BoundingBoxPoints fills out nodes[8] with the 8 vectors that make up the box.
ProjectBounds and ProjectRotatedBounds out *xv, *yv with the 8 projected values that make up the box.
Pass in an 8 float array for *xv, *yv
So have fun and make some cool stuff.
