Exemplo n.º 1
0
        private static void ReadNormalMap(BinaryReader br, uint ChunkEnd)
        {
            W3DMesh.Texture tex = new W3DMesh.Texture();
            tex.type = W3DMesh.textureType.bumpMapped;
            while (br.BaseStream.Position < ChunkEnd)
            {
                uint Chunktype   = ReadLong(br);
                uint Chunksize   = getChunkSize(ReadLong(br));
                uint subChunkEnd = (uint)br.BaseStream.Position + Chunksize;

                switch (Chunktype)
                {
                case 82:
                    ReadNormalMapHeader(br);
                    break;

                case 83:
                    ReadNormalMapEntryStruct(br, subChunkEnd, tex);
                    break;

                default:
                    Console.WriteLine("unknown chunktype: " + Chunktype + " in MeshNormalMap");
                    br.ReadBytes((int)Chunksize);
                    break;
                }
            }
            mesh.textures.Add(texName, tex);
        }
Exemplo n.º 2
0
        //#######################################################################################
        //# Texture
        //#######################################################################################

        private static void ReadTexture(BinaryReader br, uint ChunkEnd)
        {
            while (br.BaseStream.Position < ChunkEnd)
            {
                uint Chunktype   = ReadLong(br);
                uint Chunksize   = getChunkSize(ReadLong(br));
                uint subChunkEnd = (uint)br.BaseStream.Position + Chunksize;

                W3DMesh.Texture tex = new W3DMesh.Texture();
                switch (Chunktype)
                {
                case 50:
                    texName  = ReadString(br);
                    tex.type = W3DMesh.textureType.standard;
                    break;

                case 51:
                    tex.attributes = ReadShort(br);
                    tex.animType   = ReadShort(br);
                    tex.frameCount = ReadLong(br);
                    tex.frameRate  = ReadFloat(br);
                    tex.type       = W3DMesh.textureType.animated;
                    break;

                default:
                    Console.WriteLine("unknown chunktype: " + Chunktype + "   in MeshTexture");
                    br.ReadBytes((int)Chunksize);
                    break;
                }
                mesh.textures.Add(texName, tex);
            }
        }
Exemplo n.º 3
0
        private static void ReadNormalMapEntryStruct(BinaryReader br, uint ChunkEnd, W3DMesh.Texture tex)
        {
            long   type = ReadLong(br); //1 texture, 2 bumpScale/ specularExponent, 5 color, 7 alphaTest
            long   size = ReadLong(br);
            string name = ReadString(br);

            switch (name)
            {
            case "DiffuseTexture":
                long unknown = ReadLong(br);
                texName = ReadString(br);
                break;

            case "NormalMap":
                long unknown_nrm = ReadLong(br);
                tex.normalMap = ReadString(br);
                break;

            case "BumpScale":
                tex.bumpScale = ReadFloat(br);
                break;

            case "AmbientColor":
                tex.ambientColor = ReadRGBA(br);
                break;

            case "DiffuseColor":
                tex.diffuseColor = ReadRGBA(br);
                break;

            case "SpecularColor":
                tex.specularColor = ReadRGBA(br);
                break;

            case "SpecularExponent":
                tex.specularExponent = ReadFloat(br);
                break;

            case "AlphaTestEnable":
                tex.alphaTestEnable = ReadByte(br);
                break;

            default:
                //Console.WriteLine("##W3D: unknown entryStruct: " + name + "   in MeshNormalMapEntryStruct (size: " + size + ")");
                while (br.BaseStream.Position < ChunkEnd)
                {
                    ReadByte(br);
                }
                break;
            }
        }