예제 #1
0
파일: Chunk_MONR.cs 프로젝트: Kruithne/W3DT
        public Chunk_MONR(WMOFile file)
            : base(file, "MONR", Magic)
        {
            int normalCount = (int)ChunkSize / 12;
            normals = new Position[normalCount];

            for (int i = 0; i < normalCount; i++)
            {
                float x = file.readFloat();
                float z = file.readFloat() * -1;
                float y = file.readFloat();

                normals[i] = new Position(x, y, z);
            }

            LogWrite("Loaded " + normalCount + " normals.");
        }
예제 #2
0
파일: Chunk_MOVT.cs 프로젝트: Kruithne/W3DT
        public Chunk_MOVT(WMOFile file)
            : base(file, "MOVT", Magic)
        {
            int vertCount = (int)ChunkSize / 12;
            vertices = new Position[vertCount];

            for (int i = 0; i < vertCount; i++)
            {
                float x = file.readFloat();
                float z = file.readFloat() * -1;
                float y = file.readFloat();

                vertices[i] = new Position(x, y, z);
            }

            LogWrite("Loaded " + vertCount + " verticies.");
        }
예제 #3
0
파일: Chunk_MCNR.cs 프로젝트: Kruithne/W3DT
        public Chunk_MCNR(ADTFile file)
            : base(file, "MCNR", Magic)
        {
            normals = new Position[145];
            for (int i = 0; i < 145; i++)
            {
                float x = file.readUInt8() / 127;
                float z = file.readUInt8() / 127;
                float y = file.readUInt8() / 127;

                // Super-hacky fix? This does not seem right, but it prevents lighting issues?
                if (y == 1.0 && z == 0.0)
                {
                    z = 1.0f;
                    y = 0.0f;
                }

                normals[i] = new Position(x, y, z);
            }
        }
예제 #4
0
파일: Vert.cs 프로젝트: Kruithne/W3DT
 public Vert(Position point, UV uv = null, int offset = -1)
 {
     Point = point;
     UV = uv;
     Offset = offset;
 }
예제 #5
0
파일: Mesh.cs 프로젝트: Kruithne/W3DT
 public void addVert(Position vert)
 {
     Verts.Add(vert);
 }
예제 #6
0
파일: Mesh.cs 프로젝트: Kruithne/W3DT
 public void addNormal(Position normal)
 {
     Normals.Add(normal);
 }
예제 #7
0
파일: M2File.cs 프로젝트: Kruithne/W3DT
        public override void parse()
        {
            Log.Write("Parsing model file {0} with skin {1}...", BaseName, skin.BaseName);
            skin.parse(); // Parse the given skin file.

            int ofs = 0;
            uint magic = readUInt32();

            if (!magic.Equals(MD20_MAGIC)) // Assume Legion+ chunked format, relate offset to chunk.
            {
                seekPosition(0); // Go back to the start.
                while (!isEndOfStream() && !isOutOfBounds(seek + 8))
                {
                    uint chunkID = readUInt32();
                    uint chunkSize = readUInt32();

                    if (chunkID == MD21_MAGIC)
                    {
                        ofs = seek;
                        break;
                    }
                    else
                    {
                        skip((int)chunkSize);
                    }
                }

                if (ofs == 0)
                    throw new M2Exception("Unable to find MD20 chunk inside MD21 file! Format evolved?");
            }

            // Start reading as MD20
            seekPosition(ofs); // Seek the beginning of the MD20 data.
            magic = readUInt32();

            if (magic != MD20_MAGIC)
                throw new M2Exception(string.Format("Data is not MD20 at {0}", ofs));

            /*
             * 274+ Legion
             * ? - ? Warlords of Draenor
             * 273 Mists of Pandaria
             * 265-272 Cataclysm
             * 264 Wrath of the Lich King
             * 260-263 The Burning Crusade
             * ?-256 World of Warcraft
             */
            Version = readUInt32();
            int iName = (int)readUInt32(); // Contains trailing 0-byte.
            int ofsName = (int)readUInt32();
            Flags = readUInt32();
            int nGlobalSeq = (int)readUInt32();
            int ofsGlobalSeq = (int)readUInt32();
            int nAnims = (int)readUInt32();
            int ofsAnims = (int)readUInt32();
            int nAnimLookup = (int)readUInt32();
            int ofsAnimLookup = (int)readUInt32();
            int nBones = (int)readUInt32();
            int ofsBones = (int)readUInt32();
            int nKeyBoneLookup = (int)readUInt32();
            int ofsKeyBoneLookup = (int)readUInt32();
            int nVerts = (int)readUInt32();
            int ofsVerts = (int)readUInt32();

            seekPosition(ofs + ofsName);
            Name = readString(iName - 1);

            // Verts
            Verts = new Position[nVerts];
            Normals = new Position[nVerts];
            UV1 = new UV[nVerts];
            UV2 = new UV[nVerts];

            seekPosition(ofs + ofsVerts);
            for (int i = 0; i < nVerts; i++)
            {
                float x = readFloat();
                float z = readFloat() * - 1;
                float y = readFloat();

                Verts[i] = new Position(x, y, z);
                uint boneWeight = readUInt32(); // 4 * byte
                uint boneIndices = readUInt32(); // 4 * byte
                Normals[i] = Position.Read(this);
                UV1[i] = UV.Read(this);
                UV2[i] = UV.Read(this);
            }
        }