Missing Model Support (Uber crappy)
Moderator: InsideQC Admins
11 posts
• Page 1 of 1
Missing Model Support (Uber crappy)
Sometimes you are going for elegant. Sometimes you go for "works". This is that 2nd group.
Time matters and sometimes inelegant solutions take 10 minutes and proper ones take potentially days of planning. And in reality, a released mod will not have missing models. Missing model support is important because it allows you to more rapidly develop mods. It is one of the greatest features in DarkPlaces to make life easy on the modder. Sure this doesn't draw the OpenGL colored pyramid that DP does and does need some sort of fallback media, but if you are developing a mod you are really looking for a hack to allow you to merrily continue momentum and not something to cover a major omission in a mod release.
We begin ...
1. Open gl_model.c [model.c in WinQuakey clients or video_hardware_model.cpp in PSP ones and go to Mod_LoadModel function].
And find this ...
And paste this code in the place indicated above that says <<insert code here>> ...
Make sure some model called missing_model.mdl is located in quake\id1\progs folder.
Don't worry, it'll still crash if it can't find the substitute model.
Time matters and sometimes inelegant solutions take 10 minutes and proper ones take potentially days of planning. And in reality, a released mod will not have missing models. Missing model support is important because it allows you to more rapidly develop mods. It is one of the greatest features in DarkPlaces to make life easy on the modder. Sure this doesn't draw the OpenGL colored pyramid that DP does and does need some sort of fallback media, but if you are developing a mod you are really looking for a hack to allow you to merrily continue momentum and not something to cover a major omission in a mod release.
We begin ...
1. Open gl_model.c [model.c in WinQuakey clients or video_hardware_model.cpp in PSP ones and go to Mod_LoadModel function].
And find this ...
- Code: Select all
//
// load the file
//
buf = (unsigned *)COM_LoadStackFile (mod->name, stackbuf, sizeof(stackbuf));
<<<< INSERT CODE BELOW HERE>>>>
if (!buf)
{
if (crash)
Sys_Error ("Mod_LoadModel: %s not found", mod->name);
return NULL;
}
And paste this code in the place indicated above that says <<insert code here>> ...
- Code: Select all
#define RUNS_WITH_MISSING_MODELS 1
#if RUNS_WITH_MISSING_MODELS
if (!buf && crash)
{
// Reload with another .mdl
buf = (unsigned *)COM_LoadStackFile("missing_model.mdl", stackbuf, sizeof(stackbuf));
if (buf)
{
Con_Printf ("Missing model %s substituted\n", mod->name);
}
}
#endif
Make sure some model called missing_model.mdl is located in quake\id1\progs folder.
Don't worry, it'll still crash if it can't find the substitute model.
The night is young. How else can I annoy the world before sunsrise?
Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
-

Baker - Posts: 3666
- Joined: Tue Mar 14, 2006 5:15 am
Re: Missing Model Support (Uber crappy)
- Code: Select all
buf = (unsigned *)COM_LoadStackFile("progs/missing_model.mdl", stackbuf, sizeof(stackbuf));
Would be correct if missing_model.mdl is supposed to be in the progs folder.
If someone is in need of a missing_model.mdl:
http://www.mediafire.com/?i9dsojjf9e6sk0w
Thanks Baker, i love small additions anyone can implement with ease.
-

Ranger366 - Posts: 203
- Joined: Thu Mar 18, 2010 5:51 pm
hmm bit like Q2's NULL model thingy ?
got it working on quake 1 and if no model it draws a pink square
the funny thing is it doesnt need a model instead it does something a bit like notexture.
call it in R_DrawViewModel in the check for no model like this
if (!currententity->model)
{
R_DrawNullModel (currententity);
return;
}
got it working on quake 1 and if no model it draws a pink square
the funny thing is it doesnt need a model instead it does something a bit like notexture.
- Code: Select all
/*
=============
R_DrawNullModel
=============
*/
void R_DrawNullModel(entity_t *e)
{
int i;
glPushMatrix();
R_RotateForEntity(e);
glDisable(GL_TEXTURE_2D);
glColor3f(1, 0, 1);
glBegin(GL_TRIANGLE_FAN);
glVertex3f(0, 0, -8);
for (i = 0; i <= 4; i++)
glVertex3f(8 * cos(i * M_PI * 0.5f), 8 * sin(i * M_PI * 0.5f),
0);
glEnd();
glBegin(GL_TRIANGLE_FAN);
glVertex3f(0, 0, 8);
for (i = 4; i >= 0; i--)
glVertex3f(8 * cos(i * M_PI * 0.5f), 8 * sin(i * M_PI * 0.5f),
0);
glEnd();
glColor3f(1, 1, 1);
glPopMatrix();
glEnable(GL_TEXTURE_2D);
}
call it in R_DrawViewModel in the check for no model like this
if (!currententity->model)
{
R_DrawNullModel (currententity);
return;
}
-

revelator - Posts: 2567
- Joined: Thu Jan 24, 2008 12:04 pm
- Location: inside tha debugger
However, this could crash the engine if the wrong kind of model is used.
For example, the rendering code for beams and for viewmodels expects the model to be a MDL, and crashes if a BSP is used. Using MDLs would also not work when a solid BSP is expected.
[edit] Yeah, the nullmodel seems to be a better solution.
For example, the rendering code for beams and for viewmodels expects the model to be a MDL, and crashes if a BSP is used. Using MDLs would also not work when a solid BSP is expected.
[edit] Yeah, the nullmodel seems to be a better solution.
-

mankrip - Posts: 915
- Joined: Fri Jul 04, 2008 3:02 am
Re: Missing Model Support (Uber crappy)
Thats remamber me on the Hl2 error model thats show if there was a missing model. its a good idea 
I am sorry for my English...
-

Rikku2000 - Posts: 49
- Joined: Wed Oct 20, 2010 6:33 pm
- Location: Germany
Re: Missing Model Support (Uber crappy)
Hmmm crappy as you say, but definitely works and I might definitely use this. Could this also be used for "model not precached" crash error on some (and PSP) engines? To spawn the "no model" model as well, if the model desired isnt precached?
- Ghost_Fang
- Posts: 336
- Joined: Thu Nov 12, 2009 4:37 am
Re: Missing Model Support (Uber crappy)
Ghost_Fang wrote:Hmmm crappy as you say, but definitely works and I might definitely use this. Could this also be used for "model not precached" crash error on some (and PSP) engines? To spawn the "no model" model as well, if the model desired isnt precached?
these are not the fixes you are looking for...
models not precached is purely a qc coder's error. note that in engines that do support late precaches you still get a warning or something from setmodel. basically placeholder models still require a valid precache.
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
Re: Missing Model Support (Uber crappy)
Right, I know, I usually have no problems with that. But every once in a while I sometimes get a "X not precached" message, and I enjoy how convenient that is rather than crashing.
- Ghost_Fang
- Posts: 336
- Joined: Thu Nov 12, 2009 4:37 am
11 posts
• Page 1 of 1
Return to Programming Tutorials
Who is online
Users browsing this forum: No registered users and 1 guest