Exemple #1
0
        internal static W3xMesh Parse(BinaryReader reader, AssetImportCollection imports, AssetEntry header)
        {
            var result = new W3xMesh
            {
                VertexData   = reader.ReadAtOffset(() => W3xMeshVertexData.Parse(reader, header)),
                GeometryType = reader.ReadUInt32AsEnum <MeshGeometryType>(),
                BoundingBox  = new AxisAlignedBoundingBox(reader.ReadVector3(), reader.ReadVector3())
            };

            var sphereRadius = reader.ReadSingle();
            var sphereCenter = reader.ReadVector3();

            result.BoundingSphere = new BoundingSphere(sphereCenter, sphereRadius);

            result.Triangles = reader.ReadArrayAtOffset(() => W3xTriangle.Parse(reader));

            result.FXShader = FXShaderMaterial.Parse(reader, imports);

            result.AabTree = reader.ReadAtOffset(() => W3xAabTree.Parse(reader));

            result.Hidden     = reader.ReadBooleanChecked();
            result.CastShadow = reader.ReadBooleanChecked();
            result.SortLevel  = reader.ReadByte();

            return(result);
        }
Exemple #2
0
        internal static W3xTriangle Parse(BinaryReader reader)
        {
            var vertexCount = reader.ReadUInt32();

            if (vertexCount != 3)
            {
                throw new InvalidDataException();
            }

            var result = new W3xTriangle();

            reader.ReadAtOffset(() =>
            {
                result.VIndex0 = reader.ReadUInt32();
                result.VIndex1 = reader.ReadUInt32();
                result.VIndex2 = reader.ReadUInt32();
            });

            result.Normal   = reader.ReadVector3();
            result.Distance = reader.ReadSingle();

            return(result);
        }