From: havoc Date: Tue, 9 Mar 2004 04:59:14 +0000 (+0000) Subject: now supports loading skybox specified by q3 sky shaders X-Git-Tag: xonotic-v0.1.0preview~6025 X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=commitdiff_plain;h=46e99101734cfd6e80142188ac44cf548a978603 now supports loading skybox specified by q3 sky shaders git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@3982 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/cl_parse.c b/cl_parse.c index 411fd02c..7accccbe 100644 --- a/cl_parse.c +++ b/cl_parse.c @@ -213,7 +213,8 @@ void CL_ParseEntityLump(char *entdata) const char *data; char key[128], value[4096]; FOG_clear(); // LordHavoc: no fog until set - R_SetSkyBox(""); // LordHavoc: no environment mapped sky until set + // LordHavoc: default to the map's sky (q3 shader parsing sets this) + R_SetSkyBox(cl.worldmodel->brush.skybox); data = entdata; if (!data) return; diff --git a/model_brush.c b/model_brush.c index f843dbb1..4dfd6a8d 100644 --- a/model_brush.c +++ b/model_brush.c @@ -3573,6 +3573,7 @@ static void Mod_Q3BSP_LoadTextures(lump_t *l) const char *text; int flags; char shadername[Q3PATHLENGTH]; + char sky[Q3PATHLENGTH]; in = (void *)(mod_base + l->fileofs); if (l->filelen % sizeof(*in)) @@ -3606,6 +3607,7 @@ static void Mod_Q3BSP_LoadTextures(lump_t *l) { snprintf(shadername, sizeof(shadername), "%s", com_token); flags = 0; + sky[0] = 0; if (COM_ParseToken(&text, false) && !strcasecmp(com_token, "{")) { while (COM_ParseToken(&text, false)) @@ -3690,6 +3692,22 @@ static void Mod_Q3BSP_LoadTextures(lump_t *l) goto parseerror; } } + else if (!strcasecmp(com_token, "sky")) + { + if (COM_ParseToken(&text, true) && strcasecmp(com_token, "\n")) + if (strlen(com_token) < sizeof(sky)) + strcpy(sky, com_token); + } + else if (!strcasecmp(com_token, "skyparms")) + { + if (COM_ParseToken(&text, true) && strcasecmp(com_token, "\n")) + { + if (strlen(com_token) < sizeof(sky) && !atoi(com_token) && strcasecmp(com_token, "-")) + strcpy(sky, com_token); + if (COM_ParseToken(&text, true) && strcasecmp(com_token, "\n")) + COM_ParseToken(&text, true); + } + } else { // look for linebreak or } @@ -3702,8 +3720,14 @@ static void Mod_Q3BSP_LoadTextures(lump_t *l) // add shader to list (shadername and flags) // actually here we just poke into the texture settings for (j = 0, out = loadmodel->brushq3.data_textures;j < loadmodel->brushq3.num_textures;j++, out++) + { if (!strcasecmp(out->name, shadername)) + { out->surfaceparms = flags; + if ((flags & Q3SURFACEPARM_SKY) && sky[0]) + strcpy(loadmodel->brush.skybox, sky); + } + } } else { diff --git a/model_shared.h b/model_shared.h index 9db93214..25721efb 100644 --- a/model_shared.h +++ b/model_shared.h @@ -189,6 +189,8 @@ typedef struct model_brush_s // these are actually only found on brushq1, but NULL is handled gracefully void (*AmbientSoundLevelsForPoint)(struct model_s *model, const vec3_t p, qbyte *out, int outsize); void (*RoundUpToHullSize)(struct model_s *cmodel, const vec3_t inmins, const vec3_t inmaxs, vec3_t outmins, vec3_t outmaxs); + + char skybox[64]; } model_brush_t; diff --git a/r_sky.c b/r_sky.c index a6fe724e..4bc07d89 100644 --- a/r_sky.c +++ b/r_sky.c @@ -62,12 +62,18 @@ void R_LoadSkyBox(void) return; for (i = 0;i < 6;i++) { - if (snprintf(name, sizeof(name), "env/%s%s", skyname, suf[i]) >= (int)sizeof(name) || !(image_rgba = loadimagepixels(name, false, 0, 0))) + if (snprintf(name, sizeof(name), "%s_%s", skyname, suf[i]) >= (int)sizeof(name) || !(image_rgba = loadimagepixels(name, false, 0, 0))) { - if (snprintf(name, sizeof(name), "gfx/env/%s%s", skyname, suf[i]) >= (int)sizeof(name) || !(image_rgba = loadimagepixels(name, false, 0, 0))) + if (snprintf(name, sizeof(name), "%s%s", skyname, suf[i]) >= (int)sizeof(name) || !(image_rgba = loadimagepixels(name, false, 0, 0))) { - Con_Printf ("Couldn't load env/%s%s or gfx/env/%s%s\n", skyname, suf[i], skyname, suf[i]); - continue; + if (snprintf(name, sizeof(name), "env/%s%s", skyname, suf[i]) >= (int)sizeof(name) || !(image_rgba = loadimagepixels(name, false, 0, 0))) + { + if (snprintf(name, sizeof(name), "gfx/env/%s%s", skyname, suf[i]) >= (int)sizeof(name) || !(image_rgba = loadimagepixels(name, false, 0, 0))) + { + Con_Printf("Couldn't load %s_%s or %s%s or env/%s%s or gfx/env/%s%s\n", skyname, suf[i], skyname, suf[i], skyname, suf[i], skyname, suf[i]); + continue; + } + } } } skyboxside[i] = R_LoadTexture2D(skytexturepool, va("skyboxside%d", i), image_width, image_height, image_rgba, TEXTYPE_RGBA, TEXF_CLAMP | TEXF_PRECACHE, NULL);