Ejemplo n.º 1
0
        internal static W3dTextureStage Parse(BinaryReader reader, W3dParseContext context)
        {
            return(ParseChunk(reader, context, header =>
            {
                var result = new W3dTextureStage();

                ParseChunks(reader, context.CurrentEndPosition, chunkType =>
                {
                    switch (chunkType)
                    {
                    case W3dChunkType.W3D_CHUNK_TEXTURE_IDS:
                        result.TextureIds = W3dTextureIds.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_PER_FACE_TEXCOORD_IDS:
                        result.PerFaceTexCoordIds = new W3dVectorUInt32[header.ChunkSize / W3dVectorUInt32.SizeInBytes];
                        for (var count = 0; count < result.PerFaceTexCoordIds.Length; count++)
                        {
                            result.PerFaceTexCoordIds[count] = W3dVectorUInt32.Parse(reader);
                        }
                        break;

                    case W3dChunkType.W3D_CHUNK_STAGE_TEXCOORDS:
                        result.TexCoords = W3dVector2List.Parse(reader, context, chunkType);
                        break;

                    default:
                        throw CreateUnknownChunkException(chunkType);
                    }
                });

                return result;
            }));
        }
Ejemplo n.º 2
0
        public static W3dTextureStage Parse(BinaryReader reader, uint chunkSize)
        {
            return(ParseChunk <W3dTextureStage>(reader, chunkSize, (result, header) =>
            {
                switch (header.ChunkType)
                {
                case W3dChunkType.W3D_CHUNK_TEXTURE_IDS:
                    result.TextureIds = new uint[header.ChunkSize / sizeof(uint)];
                    for (var count = 0; count < result.TextureIds.Length; count++)
                    {
                        result.TextureIds[count] = reader.ReadUInt32();
                    }
                    break;

                case W3dChunkType.W3D_CHUNK_PER_FACE_TEXCOORD_IDS:
                    result.PerFaceTexCoordIds = new W3dVectorUInt32[header.ChunkSize / W3dVectorUInt32.SizeInBytes];
                    for (var count = 0; count < result.PerFaceTexCoordIds.Length; count++)
                    {
                        result.PerFaceTexCoordIds[count] = W3dVectorUInt32.Parse(reader);
                    }
                    break;

                case W3dChunkType.W3D_CHUNK_STAGE_TEXCOORDS:
                    result.TexCoords = new Vector2[header.ChunkSize / (sizeof(float) * 2)];
                    for (var count = 0; count < result.TexCoords.Length; count++)
                    {
                        result.TexCoords[count] = reader.ReadVector2();
                    }
                    break;

                default:
                    throw CreateUnknownChunkException(header);
                }
            }));
        }