static void mod_start(void)
{
- int i;
+ int i, count;
int nummodels = Mem_ExpandableArray_IndexRange(&models);
dp_model_t *mod;
+ SCR_PushLoadingScreen(false, "Loading models", 1.0);
+ count = 0;
for (i = 0;i < nummodels;i++)
if ((mod = (dp_model_t*) Mem_ExpandableArray_RecordAtIndex(&models, i)) && mod->name[0] && mod->name[0] != '*')
if (mod->used)
+ ++count;
+ for (i = 0;i < nummodels;i++)
+ if ((mod = (dp_model_t*) Mem_ExpandableArray_RecordAtIndex(&models, i)) && mod->name[0] && mod->name[0] != '*')
+ if (mod->used)
+ {
+ SCR_PushLoadingScreen(true, mod->name, 1.0 / count);
Mod_LoadModel(mod, true, false);
+ SCR_PopLoadingScreen(false);
+ }
+ SCR_PopLoadingScreen(false);
}
static void mod_shutdown(void)
return;
}
+
+typedef void (*mod_framegroupify_parsegroups_t) (unsigned int i, int start, int len, float fps, qboolean loop, void *pass);
+
+int Mod_FrameGroupify_ParseGroups(const char *buf, mod_framegroupify_parsegroups_t cb, void *pass)
+{
+ const char *bufptr;
+ int start, len;
+ float fps;
+ unsigned int i;
+ qboolean loop;
+
+ bufptr = buf;
+ i = 0;
+ for(;;)
+ {
+ // an anim scene!
+ if (!COM_ParseToken_Simple(&bufptr, true, false))
+ break;
+ if (!strcmp(com_token, "\n"))
+ continue; // empty line
+ start = atoi(com_token);
+ if (!COM_ParseToken_Simple(&bufptr, true, false))
+ break;
+ if (!strcmp(com_token, "\n"))
+ {
+ Con_Printf("framegroups file: missing number of frames\n");
+ continue;
+ }
+ len = atoi(com_token);
+ if (!COM_ParseToken_Simple(&bufptr, true, false))
+ break;
+ // we default to looping as it's usually wanted, so to NOT loop you append a 0
+ if (strcmp(com_token, "\n"))
+ {
+ fps = atof(com_token);
+ if (!COM_ParseToken_Simple(&bufptr, true, false))
+ break;
+ if (strcmp(com_token, "\n"))
+ loop = atoi(com_token);
+ else
+ loop = true;
+ }
+ else
+ {
+ fps = 20;
+ loop = true;
+ }
+
+ if(cb)
+ cb(i, start, len, fps, loop, pass);
+ ++i;
+ }
+
+ return i;
+}
+
+void Mod_FrameGroupify_ParseGroups_Count (unsigned int i, int start, int len, float fps, qboolean loop, void *pass)
+{
+ unsigned int *cnt = (unsigned int *) pass;
+ ++*cnt;
+}
+
+void Mod_FrameGroupify_ParseGroups_Store (unsigned int i, int start, int len, float fps, qboolean loop, void *pass)
+{
+ dp_model_t *mod = (dp_model_t *) pass;
+ animscene_t *anim = &mod->animscenes[i];
+ dpsnprintf(anim->name, sizeof(anim[i].name), "groupified_%d", i);
+ anim->firstframe = bound(0, start, mod->num_poses - 1);
+ anim->framecount = bound(1, len, mod->num_poses - anim->firstframe);
+ anim->framerate = max(1, fps);
+ anim->loop = !!loop;
+ //Con_Printf("frame group %d is %d %d %f %d\n", i, start, len, fps, loop);
+}
+
+void Mod_FrameGroupify(dp_model_t *mod, const char *buf)
+{
+ unsigned int cnt;
+
+ // 0. count
+ cnt = Mod_FrameGroupify_ParseGroups(buf, NULL, NULL);
+ if(!cnt)
+ {
+ Con_Printf("no scene found in framegroups file, aborting\n");
+ return;
+ }
+ mod->numframes = cnt;
+
+ // 1. reallocate
+ // (we do not free the previous animscenes, but model unloading will free the pool owning them, so it's okay)
+ mod->animscenes = (animscene_t *) Mem_Alloc(mod->mempool, sizeof(animscene_t) * mod->numframes);
+
+ // 2. parse
+ Mod_FrameGroupify_ParseGroups(buf, Mod_FrameGroupify_ParseGroups_Store, mod);
+}
+
/*
==================
Mod_LoadModel
if (developer_loading.integer)
Con_Printf("loading model %s\n", mod->name);
+
+ SCR_PushLoadingScreen(true, mod->name, 1);
// LordHavoc: unload the existing model in this slot (if there is one)
if (mod->loaded || mod->mempool)
else Con_Printf("Mod_LoadModel: model \"%s\" is of unknown/unsupported type\n", mod->name);
Mem_Free(buf);
- Mod_BuildVBOs();
+ buf = FS_LoadFile (va("%s.framegroups", mod->name), tempmempool, false, &filesize);
+ if(buf)
+ {
+ Mod_FrameGroupify(mod, buf);
+ Mem_Free(buf);
+ }
- // no fatal errors occurred, so this model is ready to use.
- mod->loaded = true;
+ Mod_BuildVBOs();
}
else if (crash)
{
// LordHavoc: Sys_Error was *ANNOYING*
Con_Printf ("Mod_LoadModel: %s not found\n", mod->name);
}
+
+ // no fatal errors occurred, so this model is ready to use.
+ mod->loaded = true;
+
+ SCR_PopLoadingScreen(false);
+
return mod;
}
*/
void Mod_Reload(void)
{
- int i;
+ int i, count;
int nummodels = Mem_ExpandableArray_IndexRange(&models);
dp_model_t *mod;
+
+ SCR_PushLoadingScreen(false, "Reloading models", 1.0);
+ count = 0;
for (i = 0;i < nummodels;i++)
if ((mod = (dp_model_t *) Mem_ExpandableArray_RecordAtIndex(&models, i)) && mod->name[0] && mod->name[0] != '*' && mod->used)
+ ++count;
+ for (i = 0;i < nummodels;i++)
+ if ((mod = (dp_model_t *) Mem_ExpandableArray_RecordAtIndex(&models, i)) && mod->name[0] && mod->name[0] != '*' && mod->used)
+ {
+ SCR_PushLoadingScreen(true, mod->name, 1.0 / count);
Mod_LoadModel(mod, true, true);
+ SCR_PopLoadingScreen(false);
+ }
+ SCR_PopLoadingScreen(false);
}
unsigned char *mod_base;
{
if (strcasecmp (entry->shader.name, shader->name) == 0)
{
- Con_Printf("Shader '%s' already defined\n", shader->name);
+ unsigned char *start, *end, *start2;
+ start = (unsigned char *) (&shader->Q3SHADERINFO_COMPARE_START);
+ end = ((unsigned char *) (&shader->Q3SHADERINFO_COMPARE_END)) + sizeof(shader->Q3SHADERINFO_COMPARE_END);
+ start2 = (unsigned char *) (&entry->shader.Q3SHADERINFO_COMPARE_START);
+ if(memcmp(start, start2, end - start))
+ Con_Printf("Shader '%s' already defined, ignoring mismatching redeclaration\n", shader->name);
+ else
+ Con_DPrintf("Shader '%s' already defined\n", shader->name);
return;
}
lastEntry = entry;
qboolean Mod_LoadTextureFromQ3Shader(texture_t *texture, const char *name, qboolean warnmissing, qboolean fallback, int defaulttexflags)
{
int j;
+ int texflagsmask;
qboolean success = true;
q3shaderinfo_t *shader;
if (!name)
name = "";
strlcpy(texture->name, name, sizeof(texture->name));
shader = name[0] ? Mod_LookupQ3Shader(name) : NULL;
+
+ texflagsmask = ~0;
+ if(!(defaulttexflags & TEXF_PICMIP))
+ texflagsmask &= ~TEXF_PICMIP;
+ if(!(defaulttexflags & TEXF_COMPRESS))
+ texflagsmask &= ~TEXF_COMPRESS;
+
if (shader)
{
if (developer_loading.integer)
Con_Printf("%s: loaded shader for %s\n", loadmodel->name, name);
texture->surfaceparms = shader->surfaceparms;
- texture->textureflags = shader->textureflags;
// allow disabling of picmip or compression by defaulttexflags
- if(!(defaulttexflags & TEXF_PICMIP))
- texture->textureflags &= ~TEXF_PICMIP;
- if(!(defaulttexflags & TEXF_COMPRESS))
- texture->textureflags &= ~TEXF_COMPRESS;
+ texture->textureflags = shader->textureflags & texflagsmask;
if (shader->surfaceparms & Q3SURFACEPARM_SKY)
{
{
texture->skinframes[j] = NULL;
}
- else if (!(texture->skinframes[j] = R_SkinFrame_LoadExternal(primarylayer->texturename[j], primarylayer->texflags, false)))
+ else if (!(texture->skinframes[j] = R_SkinFrame_LoadExternal(primarylayer->texturename[j], primarylayer->texflags & texflagsmask, false)))
{
Con_Printf("^1%s:^7 could not load texture ^3\"%s\"^7 (frame %i) for shader ^2\"%s\"\n", loadmodel->name, primarylayer->texturename[j], j, texture->name);
texture->skinframes[j] = R_SkinFrame_LoadMissing();
if (shader->backgroundlayer >= 0)
{
q3shaderinfo_layer_t* backgroundlayer = shader->layers + shader->backgroundlayer;
+ // copy over one secondarylayer parameter
+ memcpy(texture->backgroundtcmods, backgroundlayer->tcmods, sizeof(texture->backgroundtcmods));
+ // load the textures
texture->backgroundnumskinframes = backgroundlayer->numframes;
texture->backgroundskinframerate = backgroundlayer->framerate;
for (j = 0;j < backgroundlayer->numframes;j++)
{
texture->skinframes[j] = NULL;
}
- else if (!(texture->backgroundskinframes[j] = R_SkinFrame_LoadExternal(backgroundlayer->texturename[j], backgroundlayer->texflags, false)))
+ else if (!(texture->backgroundskinframes[j] = R_SkinFrame_LoadExternal(backgroundlayer->texturename[j], backgroundlayer->texflags & texflagsmask, false)))
{
Con_Printf("^1%s:^7 could not load texture ^3\"%s\"^7 (background frame %i) for shader ^2\"%s\"\n", loadmodel->name, backgroundlayer->texturename[j], j, texture->name);
texture->backgroundskinframes[j] = R_SkinFrame_LoadMissing();
int *firstsurfacefortexture;
int *numsurfacesfortexture;
if (!mod->sortedmodelsurfaces)
- mod->sortedmodelsurfaces = Mem_Alloc(loadmodel->mempool, mod->nummodelsurfaces * sizeof(*mod->sortedmodelsurfaces));
- firstsurfacefortexture = Mem_Alloc(tempmempool, mod->num_textures * sizeof(*firstsurfacefortexture));
- numsurfacesfortexture = Mem_Alloc(tempmempool, mod->num_textures * sizeof(*numsurfacesfortexture));
+ mod->sortedmodelsurfaces = (int *) Mem_Alloc(loadmodel->mempool, mod->nummodelsurfaces * sizeof(*mod->sortedmodelsurfaces));
+ firstsurfacefortexture = (int *) Mem_Alloc(tempmempool, mod->num_textures * sizeof(*firstsurfacefortexture));
+ numsurfacesfortexture = (int *) Mem_Alloc(tempmempool, mod->num_textures * sizeof(*numsurfacesfortexture));
memset(numsurfacesfortexture, 0, mod->num_textures * sizeof(*numsurfacesfortexture));
for (j = 0;j < mod->nummodelsurfaces;j++)
{
if ((animname[l] < '0' || animname[l] > '9') && animname[l] != '_')
k = l + 1;
animname[k] = 0;
- count = (mod->num_poses / mod->num_bones) - first;
+ count = mod->num_poses - first;
for (j = i + 1;j < mod->numframes;j++)
{
strlcpy(animname2, mod->animscenes[j].name, sizeof(animname2));