viewer wip

This commit is contained in:
Robin Appelman 2022-03-11 20:29:11 +01:00
commit 88bcdb35e7
8 changed files with 329 additions and 5 deletions

View file

@ -142,6 +142,7 @@ impl Mesh {
pub struct StripGroup {
// todo vertex indexes
// todo topologies
pub indices: Vec<u16>,
pub vertices: Vec<Vertex>,
pub strips: Vec<Strip>,
pub flags: StripGroupFlags,
@ -173,6 +174,17 @@ impl StripGroup {
Strip::read(data, header)
})
.collect::<Result<_>>()?,
indices: header
.index_indexes()
.map(|index| {
let data = data.get(index..).ok_or_else(|| ModelError::OutOfBounds {
data: "VertexIndex",
offset: index,
})?;
let mut reader = Cursor::new(data);
Ok(reader.read_le()?)
})
.collect::<Result<_>>()?,
flags: header.flags,
})
}

View file

@ -123,7 +123,7 @@ impl StripGroupHeader {
}
pub fn index_indexes(&self) -> impl Iterator<Item = usize> {
index_range(self.index_offset, self.index_count, size_of::<Vertex>())
index_range(self.index_offset, self.index_count, size_of::<u16>())
}
pub fn strip_indexes(&self) -> impl Iterator<Item = usize> {