internal ModelDetailLevel(ModelMesh mesh, int index, AssetLoader loader, int dataOffset, ArrayBackedList <byte> bufferData) : base(mesh, index, loader) { var reader = loader.Reader; Mesh = mesh; const int indexSize = 2; Threshold = reader.ReadInt32(); Unknowns.ReadInt16s(reader, IsDS1 ? 1 : 2); if (IsDS1) { reader.RequireZeroes(2); } IndexCount = reader.ReadInt32(); IndexDataOffset = reader.ReadInt32() + dataOffset; int indexDataSize = reader.ReadInt32(); if (indexDataSize != IndexCount * indexSize) { throw new InvalidDataException("Index data size doesn't match the expected value from the index count."); } reader.RequireZeroes(4 * 3); BufferIndexOffset = bufferData.Count; long reset = reader.BaseStream.Position; reader.BaseStream.Position = IndexDataOffset; bufferData.AddRange(reader, IndexCount * indexSize); reader.BaseStream.Position = reset; }
internal ModelDetailLevel(ModelMesh mesh, int index, AssetLoader loader, int dataOffset, ArrayBackedList<byte> bufferData) : base(mesh, index, loader) { var reader = loader.Reader; Mesh = mesh; const int indexSize = 2; Threshold = reader.ReadInt32(); Unknowns.ReadInt16s(reader, IsDS1 ? 1 : 2); if (IsDS1) reader.RequireZeroes(2); IndexCount = reader.ReadInt32(); IndexDataOffset = reader.ReadInt32() + dataOffset; int indexDataSize = reader.ReadInt32(); if (indexDataSize != IndexCount * indexSize) throw new InvalidDataException("Index data size doesn't match the expected value from the index count."); reader.RequireZeroes(4 * 3); BufferIndexOffset = bufferData.Count; long reset = reader.BaseStream.Position; reader.BaseStream.Position = IndexDataOffset; bufferData.AddRange(reader, IndexCount * indexSize); reader.BaseStream.Position = reset; }
/// <summary> /// Bind the vertex declaration to the program. /// </summary> /// <param name="program"></param> /// <param name="mesh"></param> /// <param name="stride"></param> public void Bind(ModelProgram program, ModelMesh mesh, int stride) { GraphicsBuffer buffer = Model.Buffer; foreach (ModelVertexAttribute attribute in Attributes) { int offset = attribute.Offset + mesh.BufferDataOffset; ProgramAttribute programAttribute = attribute.MatchAttribute(program); if (programAttribute != null) { programAttribute.Bind(buffer, offset, attribute.GraphicsFormat, stride); } } }
/// <summary> /// Bind the vertex declaration to the program. /// </summary> /// <param name="program"></param> /// <param name="mesh"></param> /// <param name="stride"></param> public void Bind(ModelProgram program, ModelMesh mesh, int stride) { GraphicsBuffer buffer = Model.Buffer; foreach (ModelVertexAttribute attribute in Attributes) { int offset = attribute.Offset + mesh.BufferDataOffset; ProgramAttribute programAttribute = attribute.MatchAttribute(program); if (programAttribute != null) programAttribute.Bind(buffer, offset, attribute.GraphicsFormat, stride); } }