jc wrote:
> where abouts did you set the values (remembering that im not much more
> than a dumb ass n00b)
There are two ways that I know of, both in pm_shared, since I can't see
any other way to get a pointer to the engine's models array (Botman - I
tried GetModelPointer but it fails for brush models :) )
First, you can loop through all of the physents every frame and check
whether it's a BSP model and if so, set hulls.clip_mins and clip_maxs,like
so:
// My hullfile looks like this:
8 8 18
16 16 16
8 8 9
// I have my hull mins and maxs stored in global arrays like this:
#define SCALE_FACTOR 4.0
vec3_t VEC_HULL_MIN = { -16 / SCALE_FACTOR, -16 / SCALE_FACTOR, -36 /
SCALE_FACTOR };
vec3_t VEC_HULL_MAX = { 16 / SCALE_FACTOR, 16 / SCALE_FACTOR, 36 /
SCALE_FACTOR };
vec3_t VEC_DUCK_HULL_MIN = { -16 / SCALE_FACTOR, -16 / SCALE_FACTOR, -18 /
SCALE_FACTOR };
vec3_t VEC_DUCK_HULL_MAX = { 16 / SCALE_FACTOR, 16 / SCALE_FACTOR, 18 /
SCALE_FACTOR };
vec3_t VEC_LARGE_HULL_MIN = { -32 / SCALE_FACTOR, -32 / SCALE_FACTOR, -32
/ SCALE_FACTOR };
vec3_t VEC_LARGE_HULL_MAX = { 32 / SCALE_FACTOR, 32 / SCALE_FACTOR, 32 /
SCALE_FACTOR };
....
// In PM_Move before the call to PM_PlayerMove
for (i=0; i < pmove->numphysents; i++)
{
if (pmove->physent[i].model) // physent::model is NULL if it's not a
BSP model
{
hull_t * hulls = pmove->physents[i].model->hulls;
// Note the hulls are in different order than usual
VectorCopy(VEC_HULL_MIN, hulls[1].clip_mins);
VectorCopy(VEC_HULL_MAX, hulls[1].clip_maxs);
VectorCopy(VEC_DUCK_HULL_MIN, hulls[3].clip_mins);
VectorCopy(VEC_DUCK_HULL_MAX, hulls[3].clip_maxs);
VectorCopy(VEC_LARGE_HULL_MIN, hulls[2].clip_mins);
VectorCopy(VEC_LARGE_HULL_MAX, hulls[2].clip_maxs);
}
}
The other way (which is how I'm currently doing it... use at your own
risk), is to make a few assumptions (which as far as I can tell are
valid):
1. The values for clip_mins and clip_maxs are loaded once at map load time
2. The address pointed to by pmove->physent[0].model when the FIRST map
is loaded is the first element in the engine's models array and this
address does not change when a new map is loaded.
3. The order of models in the models array does not change during a map.
4. The models array has 512 elements. This one I have no way to test;
the 512 was posted previously on this list. Quake I had 256.
I added the following to pm_shared.c:
model_t * g_modelarray = NULL;
int g_model_hulls_fixed = 0;
void PM_FixModelHulls()
{
int model;
// Get pointer to the world model, which is the first element in
// the models array when the first map is loaded
if (!g_modelarray)
{
g_modelarray = pmove->physents[0].model;
}
// Special case for the world model, since its name doesn't start with '*'
// It is only the first element of the models array for the first map.
// It is always pmove->physent[0], though
hull_t * hulls = pmove->physents[0].model->hulls;
VectorCopy(VEC_HULL_MIN, hulls[1].clip_mins);
VectorCopy(VEC_HULL_MAX, hulls[1].clip_maxs);
VectorCopy(VEC_DUCK_HULL_MIN, hulls[3].clip_mins);
VectorCopy(VEC_DUCK_HULL_MAX, hulls[3].clip_maxs);
VectorCopy(VEC_LARGE_HULL_MIN, hulls[2].clip_mins);
VectorCopy(VEC_LARGE_HULL_MAX, hulls[2].clip_maxs);
// All the BSP models other than the world have names in the format "*%d"
// Max # of models (of all types) assumed to be 512
for (model = 0; model < 512; model++)
{
if (g_modelarray[model].name[0] == '*')
{
VectorCopy(VEC_HULL_MIN, g_modelarray[model].hulls[1].clip_mins);
VectorCopy(VEC_HULL_MAX, g_modelarray[model].hulls[1].clip_maxs);
VectorCopy(VEC_DUCK_HULL_MIN,
g_modelarray[model].hulls[3].clip_mins);
VectorCopy(VEC_DUCK_HULL_MAX,
g_modelarray[model].hulls[3].clip_maxs);
VectorCopy(VEC_LARGE_HULL_MIN,
g_modelarray[model].hulls[2].clip_mins);
VectorCopy(VEC_LARGE_HULL_MAX,
g_modelarray[model].hulls[2].clip_maxs);
}
}
}
// In PM_Move, before the call to PM_PlayerMove:
if (!g_model_hulls_fixed)
{
PM_FixModelHulls();
g_model_hulls_fixed = 1;
}
// In world.cpp:
extern "C" int g_model_hulls_fixed;
// In CWorld::Spawn:
g_model_hulls_fixed = 0; // New map - make sure all the models get
fixed again
// In hud_msg.cpp:
extern "C" int g_model_hulls_fixed;
// In CHud::MsgFunc_ResetHUD:
g_model_hulls_fixed = 0;
_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders