private void readTexture(BinaryReader inStream, bool textureId)
        {
            warp_Texture t = null;
            int id = inStream.ReadSByte();
            if (id == 1)
            {
                t = new warp_Texture("c:/source/warp3d/materials/skymap.jpg");

                if (t != null && textureId)
                {
                    texturePath = t.path;
                    textureSettings = null;
                    setTexture(t);
                }
                if (t != null && !textureId)
                {
                    envmapPath = t.path;
                    envmapSettings = null;
                    setEnvmap(t);
                }
            }

            if (id == 2)
            {
                int w = readInt(inStream);
                int h = readInt(inStream);
                int type = inStream.ReadSByte();

                float persistency = readInt(inStream);
                float density = readInt(inStream);

                persistency = .5f;
                density = .5f;

                int samples = inStream.ReadByte();
                int numColors = inStream.ReadByte();
                int[] colors = new int[numColors];
                for (int i = 0; i < numColors; i++)
                {
                    colors[i] = readInt(inStream);

                }
                if (type == 1)
                {
                    t = warp_TextureFactory.PERLIN(w, h, persistency, density, samples, 1024).colorize(warp_Color.makeGradient(colors, 1024));
                }
                if (type == 2)
                {
                    t = warp_TextureFactory.WAVE(w, h, persistency, density, samples, 1024).colorize(warp_Color.makeGradient(colors, 1024));
                }
                if (type == 3)
                {
                    t = warp_TextureFactory.GRAIN(w, h, persistency, density, samples, 20, 1024).colorize(warp_Color.makeGradient(colors, 1024));

                }

                if (textureId)
                {
                    texturePath = null;
                    textureSettings = new warp_TextureSettings(t, w, h, type, persistency, density, samples, colors);
                    setTexture(t);
                }
                else
                {
                    envmapPath = null;
                    envmapSettings = new warp_TextureSettings(t, w, h, type, persistency, density, samples, colors);
                    setEnvmap(t);
                }
            }
        }
Пример #2
0
        private void readTexture(BinaryReader inStream, bool textureId)
        {
            warp_Texture t  = null;
            int          id = inStream.ReadSByte();

            if (id == 1)
            {
                t = new warp_Texture("c:/source/warp3d/materials/skymap.jpg");

                if (t != null && textureId)
                {
                    texturePath     = t.path;
                    textureSettings = null;
                    setTexture(t);
                }
                if (t != null && !textureId)
                {
                    envmapPath     = t.path;
                    envmapSettings = null;
                    setEnvmap(t);
                }
            }

            if (id == 2)
            {
                int w    = readInt(inStream);
                int h    = readInt(inStream);
                int type = inStream.ReadSByte();

                float persistency = readInt(inStream);
                float density     = readInt(inStream);

                persistency = .5f;
                density     = .5f;

                int   samples   = inStream.ReadByte();
                int   numColors = inStream.ReadByte();
                int[] colors    = new int[numColors];
                for (int i = 0; i < numColors; i++)
                {
                    colors[i] = readInt(inStream);
                }
                if (type == 1)
                {
                    t = warp_TextureFactory.PERLIN(w, h, persistency, density, samples, 1024).colorize(warp_Color.makeGradient(colors, 1024));
                }
                if (type == 2)
                {
                    t = warp_TextureFactory.WAVE(w, h, persistency, density, samples, 1024).colorize(warp_Color.makeGradient(colors, 1024));
                }
                if (type == 3)
                {
                    t = warp_TextureFactory.GRAIN(w, h, persistency, density, samples, 20, 1024).colorize(warp_Color.makeGradient(colors, 1024));
                }

                if (textureId)
                {
                    texturePath     = null;
                    textureSettings = new warp_TextureSettings(t, w, h, type, persistency, density, samples, colors);
                    setTexture(t);
                }
                else
                {
                    envmapPath     = null;
                    envmapSettings = new warp_TextureSettings(t, w, h, type, persistency, density, samples, colors);
                    setEnvmap(t);
                }
            }
        }