/// <summary> /// Initializes a new instance of the <see cref="Face" /> class. /// </summary> /// <param name="header">Rsm Header</param> /// <param name="reader">The reader.</param> public Face(RsmHeader header, IBinaryReader reader) { int len = -1; if (header.Version >= 2.2) { len = reader.Int32(); } VertexIds = reader.ArrayUInt16(3); TextureVertexIds = reader.ArrayUInt16(3); TextureId = reader.UInt16(); Padding = reader.UInt16(); TwoSide = reader.Int32(); SmoothGroup[0] = SmoothGroup[1] = SmoothGroup[2] = reader.Int32(); if (len > 24) { SmoothGroup[1] = reader.Int32(); } if (len > 28) { SmoothGroup[2] = reader.Int32(); } }
/// <summary> /// Initializes a new instance of the <see cref="Face" /> class. /// </summary> /// <param name="header">Rsm Header</param> /// <param name="reader">The reader.</param> /// <param name="smoothGroup">The smooth group.</param> public Face(RsmHeader header, IBinaryReader reader, int smoothGroup) { VertexIds = reader.ArrayUInt16(3); TextureVertexIds = reader.ArrayUInt16(3); TextureId = reader.UInt16(); Padding = reader.UInt16(); TwoSide = reader.Int32(); for (int i = 0; i < 3; i++) { SmoothGroup[i] = smoothGroup; } }
private Rsm(IBinaryReader reader) { int count; Header = new RsmHeader(reader); AnimationLength = reader.Int32(); ShadeType = reader.Int32(); Alpha = 0xFF; if (Version >= 1.4) { Alpha = reader.Byte(); } if (Version >= 2.3) { FrameRatePerSecond = reader.Float(); count = reader.Int32(); for (int i = 0; i < count; i++) { MainMeshNames.Add(reader.String(reader.Int32(), '\0')); } count = reader.Int32(); } else if (Version >= 2.2) { FrameRatePerSecond = reader.Float(); int numberOfTextures = reader.Int32(); for (int i = 0; i < numberOfTextures; i++) { _textures.Add(reader.String(reader.Int32(), '\0')); } count = reader.Int32(); for (int i = 0; i < count; i++) { MainMeshNames.Add(reader.String(reader.Int32(), '\0')); } count = reader.Int32(); } else { Reserved = reader.Bytes(16); count = reader.Int32(); for (int i = 0; i < count; i++) { _textures.Add(reader.String(40, '\0')); } MainMeshNames.Add(reader.String(40, '\0')); count = reader.Int32(); } for (int i = 0; i < count; i++) { _meshes.Add(new Mesh(this, reader)); } // Resolve parent/child associations if (MainMeshNames.Count == 0) { MainMeshNames.Add(_meshes[0].Name); } MainMesh = _meshes.FirstOrDefault(m => m.Name == MainMeshNames[0]) ?? _meshes[0]; _setParents(); foreach (Mesh mesh in _meshes) { if (String.IsNullOrEmpty(mesh.ParentName)) { _parents.Add(mesh); } else { var meshParent = _meshes.FirstOrDefault(p => p.Name == mesh.ParentName); if (meshParent == null) { // no parent _parents.Add(mesh); } else { mesh.Parent = meshParent; } } } if (Version < 1.6) { count = reader.Int32(); for (int i = 0; i < count; i++) { _scaleKeyFrames.Add(new ScaleKeyFrame { Frame = reader.Int32(), Sx = reader.Float(), Sy = reader.Float(), Sz = reader.Float(), Data = reader.Float() }); } } count = reader.CanRead ? reader.Int32() : 0; if (Version >= 1.3) { for (int i = 0; i < count; i++) { VolumeBoxes.Add(new VolumeBox(reader)); } } else { for (int i = 0; i < count; i++) { VolumeBoxes.Add(new VolumeBox(reader, true)); } } _uniqueTextures(); Box = new BoundingBox(); }