예제 #1
0
        private List <TextureWrapper> getModelTextures(List <string> names)
        {
            List <TextureWrapper> res     = new List <TextureWrapper>();
            TextureWrapper        white_w = loadTexHeader("white.dds");

            for (int tex_idx = 0; tex_idx < names.Count; ++tex_idx)
            {
                TextureWrapper found = white_w; // initialize this, so if we're missing a texture, we'll get something
                string         fe;
                string         tex_to_find = names[tex_idx];
                if (tex_to_find.ToUpper().Contains("PORTAL"))
                {
                    tex_to_find = "invisible.dds";
                }

                string local_path = getNamedTexturePath(tex_to_find);
                if (local_path == null)
                {
                    fe  = String.Format("Model needs texture {0}\n", tex_to_find);
                    fe += String.Format("Resource system does not have it");
                    Debug.LogWarning(fe);
                }

                if (local_path != null)
                {
                    found = loadTexHeader(tex_to_find);
                }
                // TODO: make missing textures much more visible ( high contrast + text ? )
                res.Add(found);
            }

            if (names.Count == 0)
            {
                res.Add(white_w);
            }
            return(res);
        }
예제 #2
0
        static public TextureWrapper loadTexHeader(string tex_name)
        {
            string fname = getNamedTexturePath(tex_name);

            if (String.IsNullOrEmpty(fname))
            {
                Debug.LogFormat("LoadTexHeader failed for asset {0}->{1}", tex_name, fname);
                return(null);
            }
            RuntimeData    rd = RuntimeData.get();
            TextureWrapper res;

            FileInfo tex_path     = new FileInfo(fname);
            string   lookupstring = Path.GetFileNameWithoutExtension(tex_path.Name).ToLower();

            if (rd.m_loaded_textures.TryGetValue(lookupstring, out res))
            {
                return(res);
            }

            res     = new TextureWrapper();
            res.tex = AssetDatabase.LoadAssetAtPath <Texture>(fname);

            res.info = modFromTextureName(Path.GetDirectoryName(fname) + "/" + Path.GetFileNameWithoutExtension(fname));
            TexOpt texopt_flags = 0;

            if (res.info != null)
            {
                texopt_flags = (TexOpt)res.info.Flags;
            }
            string upname = fname.ToUpper();

            if (upname.Contains("PLAYERS/") ||
                upname.Contains("ENEMIES/") ||
                upname.Contains("NPCS/"))
            {
                res.flags |= TextureWrapper.TexFlag.BUMPMAP_MIRROR | TextureWrapper.TexFlag.CLAMP;
            }

            if (upname.Contains("MAPS/"))
            {
                res.flags |= TextureWrapper.TexFlag.CLAMP;
            }

            if (texopt_flags.HasFlag(TexOpt.REPLACEABLE))
            {
                res.flags |= TextureWrapper.TexFlag.REPLACEABLE;
            }

            if (texopt_flags.HasFlag(TexOpt.BUMPMAP))
            {
                res.flags |= TextureWrapper.TexFlag.BUMPMAP;
            }

            res.scaleUV0 = new Vector2(1, 1);
            res.scaleUV1 = new Vector2(1, 1);

            if (res.info != null && 0 != res.info.BumpMap.Length)
            {
                res.bumpmap = res.info.BumpMap;
            }
            string detailname;

            if (texopt_flags.HasFlag(TexOpt.DUAL))
            {
                if (res.info.Blend.Length != 0)
                {
                    res.flags     |= TextureWrapper.TexFlag.DUAL;
                    res.BlendType  = (CoHBlendMode)res.info.BlendType;
                    res.scaleUV0   = res.info.ScaleST0;
                    res.scaleUV1   = res.info.ScaleST1;
                    res.detailname = res.info.Blend;

                    if (res.BlendType == CoHBlendMode.ADDGLOW && res.detailname.ToLower() == "grey")
                    {
                        res.detailname = "black";
                    }

                    // copy the 'res' into the handle based storage, and record the handle
                    rd.m_loaded_textures[lookupstring] = res;
                    return(res);
                }

                Debug.Log("Detail texture " + res.info.Blend + " does not exist for texture mod" + res.info.name);
                detailname = "grey";
            }
            else if (lookupstring.ToLower() == "invisible")
            {
                detailname = "invisible";
            }
            else
            {
                detailname = "grey";
            }

            if (res.BlendType == CoHBlendMode.ADDGLOW && detailname.ToLower() == "grey")
            {
                detailname = "black";
            }

            res.detailname = detailname;
            // copy the 'res' into the handle based storage, and record the handle
            rd.m_loaded_textures[lookupstring] = res;
            return(res);
        }