Exemple #1
0
        internal static TDerived Parse(BinaryReader reader, W3dParseContext context)
        {
            return(ParseChunk(reader, context, header =>
            {
                var result = new TDerived();

                ParseChunks(reader, context.CurrentEndPosition, chunkType =>
                {
                    switch (chunkType)
                    {
                    case W3dChunkType.W3D_CHUNK_MATERIAL_INFO:
                        result.MaterialInfo = W3dMaterialInfo.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_VERTEX_MATERIALS:
                        result.VertexMaterials = W3dVertexMaterials.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_SHADERS:
                        result.Shaders = W3dShaders.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_TEXTURES:
                        result.Textures = W3dTextures.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_MATERIAL_PASS:
                        if (result.MaterialPass1 == null)
                        {
                            result.MaterialPass1 = W3dMaterialPass.Parse(reader, context);
                        }
                        else
                        {
                            result.MaterialPass2 = W3dMaterialPass.Parse(reader, context);
                        }
                        break;

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

                return result;
            }));
        }
Exemple #2
0
        internal static W3dMesh Parse(BinaryReader reader, W3dParseContext context)
        {
            return(ParseChunk(reader, context, header =>
            {
                var result = new W3dMesh();

                ParseChunks(reader, context.CurrentEndPosition, chunkType =>
                {
                    switch (chunkType)
                    {
                    case W3dChunkType.W3D_CHUNK_MESH_HEADER3:
                        result.Header = W3dMeshHeader3.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_VERTICES:
                        result.Vertices = W3dVector3List.Parse(reader, context, chunkType);
                        break;

                    case W3dChunkType.W3D_CHUNK_VERTEX_NORMALS:
                        result.Normals = W3dVector3List.Parse(reader, context, chunkType);
                        break;

                    case W3dChunkType.W3D_CHUNK_VERTEX_INFLUENCES:
                        result.Influences = W3dVertexInfluences.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_TRIANGLES:
                        result.Triangles = W3dTriangles.Parse(reader, context);
                        break;

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

                    case W3dChunkType.W3D_CHUNK_MATERIAL_INFO:
                        result.MaterialInfo = W3dMaterialInfo.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_VERTEX_MATERIALS:
                        result.VertexMaterials = W3dVertexMaterials.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_SHADERS:
                        result.Shaders = W3dShaders.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_PS2_SHADERS:
                        result.ShadersPs2 = W3dShadersPs2.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_TEXTURES:
                        result.Textures = W3dTextures.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_MATERIAL_PASS:
                        result.MaterialPasses.Add(W3dMaterialPass.Parse(reader, context));
                        break;

                    case W3dChunkType.W3D_CHUNK_AABTREE:
                        result.AabTree = W3dMeshAabTree.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_MESH_USER_TEXT:
                        result.UserText = W3dMeshUserText.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_VERTICES_2:
                        result.Vertices2 = W3dVector3List.Parse(reader, context, chunkType);
                        break;

                    case W3dChunkType.W3D_CHUNK_NORMALS_2:
                        result.Normals2 = W3dVector3List.Parse(reader, context, chunkType);
                        break;

                    case W3dChunkType.W3D_CHUNK_TANGENTS:
                        result.Tangents = W3dVector3List.Parse(reader, context, chunkType);
                        break;

                    case W3dChunkType.W3D_CHUNK_BITANGENTS:
                        result.Bitangents = W3dVector3List.Parse(reader, context, chunkType);
                        break;

                    case W3dChunkType.W3D_CHUNK_SHADER_MATERIALS:
                        result.ShaderMaterials = W3dShaderMaterials.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_PRELIT_VERTEX:
                        result.PrelitVertex = W3dPrelitVertex.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_PRELIT_LIGHTMAP_MULTI_PASS:
                        result.PrelitLightMapMultiPass = W3dPrelitLightMapMultiPass.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_PRELIT_LIGHTMAP_MULTI_TEXTURE:
                        result.PrelitLightMapMultiTexture = W3dPrelitLightMapMultiTexture.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_PRELIT_UNLIT:
                        result.PrelitUnlit = W3dPrelitUnlit.Parse(reader, context);
                        break;

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

                return result;
            }));
        }