示例#1
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;
            }));
        }
示例#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;

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

                return result;
            }));
        }