public void read() { MemoryStream stream = new MemoryStream(expected, false); using BinaryReader reader = new BinaryReader(stream); VertexTriangle tri = VertexTriangle.ReadNew(reader); Assert.AreEqual(30806, tri.v1); Assert.AreEqual(48282, tri.v2); Assert.AreEqual(61662, tri.v3); Assert.AreEqual(13330, tri.m); }
protected override void readStruct(Stream stream) { var world = FindParentById(SectionId.World) as RWWorld; if (world == null) { throw new InvalidDataException("RWAtomicSection has to be child of RWWorld"); } GeometryFormat worldFormat = world.format; using BinaryReader reader = new BinaryReader(stream); matIdBase = reader.ReadUInt32(); triangles = new VertexTriangle[reader.ReadUInt32()]; vertices = new Vector3[reader.ReadUInt32()]; bbox1 = reader.ReadVector3(); bbox2 = reader.ReadVector3(); reader.ReadUInt32(); // unused reader.ReadUInt32(); for (int i = 0; i < vertices.Length; i++) { vertices[i] = reader.ReadVector3(); } if ((worldFormat & GeometryFormat.Normals) > 0) { normals = new Normal[vertices.Length]; for (int i = 0; i < normals.Length; i++) { normals[i] = Normal.ReadNew(reader); } } if ((worldFormat & GeometryFormat.Prelit) > 0) { colors = new IColor[vertices.Length]; for (int i = 0; i < colors.Length; i++) { colors[i] = IColor.ReadNew(reader); } } if ((worldFormat & GeometryFormat.Textured) > 0 || (worldFormat & GeometryFormat.Textured2) > 0) { texCoords1 = new Vector2[vertices.Length]; for (int i = 0; i < texCoords1.Length; i++) { texCoords1[i] = reader.ReadVector2(); } } if ((worldFormat & GeometryFormat.Textured2) > 0) { texCoords2 = new Vector2[vertices.Length]; for (int i = 0; i < texCoords2.Length; i++) { texCoords2[i] = reader.ReadVector2(); } } for (int i = 0; i < triangles.Length; i++) { triangles[i] = VertexTriangle.ReadNew(reader); } }