mirror of
https://codeberg.org/icewind/vmdl.git
synced 2026-06-03 16:44:11 +02:00
skin mapping wip
This commit is contained in:
parent
7948e6ba5b
commit
ca8c16dca1
5 changed files with 36 additions and 11 deletions
|
|
@ -46,6 +46,10 @@ impl Model {
|
|||
&self.mdl.textures
|
||||
}
|
||||
|
||||
pub fn skin_tables(&self) -> &[Vec<u16>] {
|
||||
&self.mdl.skin_table
|
||||
}
|
||||
|
||||
pub fn meshes(&self) -> impl Iterator<Item = Mesh> {
|
||||
let mdl_meshes = self
|
||||
.mdl
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ pub struct Mdl {
|
|||
pub body_parts: Vec<BodyPart>,
|
||||
pub textures: Vec<TextureInfo>,
|
||||
pub texture_paths: Vec<String>,
|
||||
pub skin_table: Vec<Vec<u16>>,
|
||||
}
|
||||
|
||||
impl Mdl {
|
||||
|
|
@ -36,6 +37,14 @@ impl Mdl {
|
|||
.map(|path| path.map(|path| path.replace('\\', "/")))
|
||||
.collect::<Result<Vec<_>>>()?;
|
||||
|
||||
let raw_skin_table = read_relative::<u16, _>(data, header.skin_reference_indexes())?;
|
||||
let skin_table = raw_skin_table
|
||||
.chunks(header.skin_reference_count as usize)
|
||||
.map(|chunk| chunk.into())
|
||||
.collect();
|
||||
|
||||
dbg!(raw_skin_table);
|
||||
|
||||
let bones = read_indexes(header.bone_indexes(), data).collect::<Result<_>>()?;
|
||||
Ok(Mdl {
|
||||
bones,
|
||||
|
|
@ -52,6 +61,7 @@ impl Mdl {
|
|||
.collect::<Result<_>>()?,
|
||||
textures,
|
||||
texture_paths,
|
||||
skin_table,
|
||||
header,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,8 +60,8 @@ pub struct StudioHeader {
|
|||
|
||||
// Each skin-family assigns a texture-id to a skin location
|
||||
pub skin_reference_count: i32,
|
||||
pub skin_r_family_count: i32,
|
||||
pub skin_reference_index: i32,
|
||||
pub skin_family_count: i32,
|
||||
pub skin_reference_offset: i32,
|
||||
|
||||
// mstudiobodyparts_t
|
||||
body_part_count: i32,
|
||||
|
|
@ -244,6 +244,14 @@ impl StudioHeader {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn skin_reference_indexes(&self) -> impl Iterator<Item = usize> {
|
||||
index_range(
|
||||
self.skin_reference_offset,
|
||||
self.skin_reference_count * self.skin_family_count,
|
||||
size_of::<u16>(),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn body_part_indexes(&self) -> impl Iterator<Item = usize> {
|
||||
index_range(
|
||||
self.body_part_offset,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue