Beispiel #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;
            }));
        }
Beispiel #2
0
        internal static W3dMaterialPass Parse(BinaryReader reader, W3dParseContext context)
        {
            return(ParseChunk(reader, context, header =>
            {
                var result = new W3dMaterialPass();

                ParseChunks(reader, context.CurrentEndPosition, chunkType =>
                {
                    switch (chunkType)
                    {
                    case W3dChunkType.W3D_CHUNK_VERTEX_MATERIAL_IDS:
                        result.VertexMaterialIds = W3dUInt32List.Parse(reader, context, chunkType);
                        break;

                    case W3dChunkType.W3D_CHUNK_SHADER_IDS:
                        result.ShaderIds = W3dUInt32List.Parse(reader, context, chunkType);
                        break;

                    case W3dChunkType.W3D_CHUNK_DCG:
                        result.Dcg = W3dRgbaList.Parse(reader, context, chunkType);
                        break;

                    case W3dChunkType.W3D_CHUNK_DIG:
                        result.Dig = W3dRgbaList.Parse(reader, context, chunkType);
                        break;

                    case W3dChunkType.W3D_CHUNK_SCG:
                        result.Scg = W3dRgbaList.Parse(reader, context, chunkType);
                        break;

                    case W3dChunkType.W3D_CHUNK_TEXTURE_STAGE:
                        result.TextureStages.Add(W3dTextureStage.Parse(reader, context));
                        break;

                    case W3dChunkType.W3D_CHUNK_SHADER_MATERIAL_ID:
                        result.ShaderMaterialIds = W3dUInt32List.Parse(reader, context, chunkType);
                        break;

                    // Normally this appears inside W3dTextureStage, but it can also
                    // appear directly under W3dMaterialPass if using shader materials.
                    case W3dChunkType.W3D_CHUNK_STAGE_TEXCOORDS:
                        result.TexCoords = W3dVector2List.Parse(reader, context, chunkType);
                        break;

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

                return result;
            }));
        }