This mail contain some Quake1 code about the subject. Can be somewhat
similar (or not) to the real Half-Life code.
I'm recreating the entity every frame (actually every second with p->die
set to the current time plus 1).
If I use a model like
"models/apache.mdl", then the entitiy shows up fine. I can even get it
to animate by using the callback function. It seems that CL_LoadModel()
only loads .mdl and .spr models, not BSP models ("*51").
At Quake1 these models are called "inline model", and stored at array
like that:
char localmodels[MAX_MODELS][5];
At worldspawn where loaded from the man bsp data:
for (i=1 ; inumsubmodels ; i++)
{
sv.model_precache[1+i] = localmodels[i];
sv.models[i+1] = Mod_ForName (localmodels[i], false);
}
What you use at Half-Life looks like temporalentity on Quake1:
entity_t *CL_NewTempEntity (void)
{
entity_t*ent;
if (cl_numvisedicts == MAX_VISEDICTS)
return NULL;
if (num_temp_entities == MAX_TEMP_ENTITIES)
return NULL;
ent = &cl_temp_entities[num_temp_entities];
memset (ent, 0, sizeof(*ent));
num_temp_entities++;
cl_visedicts[cl_numvisedicts] = ent;
cl_numvisedicts++;
ent->colormap = vid.colormap;
return ent;
}
the entity is cleared everytime you ask for. So will not contain
framerate interpolation data, and other misc stuff, and will be reset to
frame 0, angle 0 0 0, etc...
(I think Half-Life work very similar)
To fake animations, etc, you have to set everytime all options
1) spawn the model
2) set the new frame
3) set the new angle
off the top of my head and probably wrong anything created in
HUD_CreateEntities has to be created every frame... HUD_CreateEntities
is basically how you add something to the render list :s
jc
Have you access to the render list directly? cl_visedicts[cl_numvisedicts]?
-
Looks like the SDK reference this stuff:
(new features at SDK 2.3)
"Also, the client .dll is given the chance to create totally new
entities each frame. By creating entities in HUD_CreateEntities() ( in
entity.cpp ), the client .dll can simulate and draw arbitrary entities
by itself ( including particle and temporary entities ). Some sample
code demonstrating this has been left in entity.cpp, but is commented out."
HEee... I have found a function!
void DLLEXPORT HUD_TempEntUpdate (
double frametime, // Simulation time
double client_time, // Absolute time on client
double cl_gravity, // True gravity on client
TEMPENTITY **ppTempEntFree, // List of freed temporary ents
TEMPENTITY **ppTempEntActive, // List
int ( *Callback_AddVisibleEntity )( cl_entity_t *pEntity ),
void( *Callback_TempEntPlaySound )( TEMPENTITY *pTemp, float damp ) )
{
But is bloated :(
Looks that you can make (insert whatever magic here) with that :D
___
To unsubscribe, edit your list preferences, or view the list archives, please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders