]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
now supports loading skybox specified by q3 sky shaders
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 9 Mar 2004 04:59:14 +0000 (04:59 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 9 Mar 2004 04:59:14 +0000 (04:59 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@3982 d7cf8633-e32d-0410-b094-e92efae38249

cl_parse.c
model_brush.c
model_shared.h
r_sky.c

index 411fd02c47c7ea089e4ca3f3efbfe6db8f65ca08..7accccbefd19066fa6298f2e2716e788151950f3 100644 (file)
@@ -213,7 +213,8 @@ void CL_ParseEntityLump(char *entdata)
        const char *data;
        char key[128], value[4096];
        FOG_clear(); // LordHavoc: no fog until set
        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;
        data = entdata;
        if (!data)
                return;
index f843dbb1ae9c7d7d7abbfb315e78c00e4fc573f1..4dfd6a8d08581d28e03e58517dedf7bb238e872d 100644 (file)
@@ -3573,6 +3573,7 @@ static void Mod_Q3BSP_LoadTextures(lump_t *l)
        const char *text;
        int flags;
        char shadername[Q3PATHLENGTH];
        const char *text;
        int flags;
        char shadername[Q3PATHLENGTH];
+       char sky[Q3PATHLENGTH];
 
        in = (void *)(mod_base + l->fileofs);
        if (l->filelen % sizeof(*in))
 
        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;
                                {
                                        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))
                                        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;
                                                                }
                                                        }
                                                                        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 }
                                                        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++)
                                                // 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))
                                                        if (!strcasecmp(out->name, shadername))
+                                                       {
                                                                out->surfaceparms = flags;
                                                                out->surfaceparms = flags;
+                                                               if ((flags & Q3SURFACEPARM_SKY) && sky[0])
+                                                                       strcpy(loadmodel->brush.skybox, sky);
+                                                       }
+                                               }
                                        }
                                        else
                                        {
                                        }
                                        else
                                        {
index 9db93214b26bfddfad95aecd76090ae5923bf35c..25721efbc3d742b04518be4ac5ea8e18cb724b6e 100644 (file)
@@ -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);
        // 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;
 
 }
 model_brush_t;
 
diff --git a/r_sky.c b/r_sky.c
index a6fe724e2e1370892a15dad455d82687096b11ed..4bc07d89dceb6ffba94842e8c49fe86cbef2fd44 100644 (file)
--- a/r_sky.c
+++ b/r_sky.c
@@ -62,12 +62,18 @@ void R_LoadSkyBox(void)
                return;
        for (i = 0;i < 6;i++)
        {
                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);
                        }
                }
                skyboxside[i] = R_LoadTexture2D(skytexturepool, va("skyboxside%d", i), image_width, image_height, image_rgba, TEXTYPE_RGBA, TEXF_CLAMP | TEXF_PRECACHE, NULL);