diff --git a/core/grim/src/scene/cube_tex/io.rs b/core/grim/src/scene/cube_tex/io.rs index 4a84dc0..17cfc4a 100644 --- a/core/grim/src/scene/cube_tex/io.rs +++ b/core/grim/src/scene/cube_tex/io.rs @@ -1,14 +1,15 @@ use crate::io::{BinaryStream, SeekFrom, Stream}; use crate::scene::*; -use crate::SystemInfo; use crate::texture::Bitmap; +use crate::SystemInfo; use grim_traits::scene::*; use std::error::Error; fn is_version_supported(version: u32) -> bool { match version { 1 => true, // GH2 360 - _ => false + 2 => true, // TBRB/RB3/DC1 + _ => false, } } @@ -24,8 +25,12 @@ impl ObjectReadWrite for CubeTexObject { load_object(self, &mut stream, info)?; - self.some_num_1 = stream.read_uint32()?; - self.some_num_2 = stream.read_uint32()?; + if version < 2 { + self.some_num_1 = stream.read_uint32()?; + self.some_num_2 = stream.read_uint32()?; + } else { + self.properties = load_cubetex_properties(&mut stream)?; + } self.right_ext_path = stream.read_prefixed_string()?; self.left_ext_path = stream.read_prefixed_string()?; @@ -34,7 +39,9 @@ impl ObjectReadWrite for CubeTexObject { self.front_ext_path = stream.read_prefixed_string()?; self.back_ext_path = stream.read_prefixed_string()?; - self.some_bool = stream.read_boolean()?; + if version < 2 { + self.some_bool = stream.read_boolean()?; // only seems to exist on version 1 + } if stream.pos() == stream.len()? as u64 { return Ok(()); @@ -108,4 +115,19 @@ impl ObjectReadWrite for CubeTexObject { Ok(()) } -} \ No newline at end of file +} + +fn load_cubetex_properties(reader: &mut Box,) -> Result, Box> { + let mut properties = Vec::new(); + for _ in 0..7 { + let bpp = reader.read_uint32()?; + let width = reader.read_uint32()?; + let height = reader.read_uint32()?; + let num_mip_maps = reader.read_uint32()?; + let bitmap_encoding = reader.read_uint32()?; + + properties.push(CubeTexProperties {bpp,width,height,num_mip_maps,bitmap_encoding,}) + } + + Ok(properties) +} diff --git a/core/grim/src/scene/cube_tex/mod.rs b/core/grim/src/scene/cube_tex/mod.rs index d676f69..51eae12 100644 --- a/core/grim/src/scene/cube_tex/mod.rs +++ b/core/grim/src/scene/cube_tex/mod.rs @@ -5,11 +5,21 @@ use grim_macros::*; use grim_traits::scene::*; pub use io::*; +pub struct CubeTexProperties { + pub bpp: u32, + pub width: u32, + pub height: u32, + pub num_mip_maps: u32, + pub bitmap_encoding: u32, // DXT5, RGBA, etc. +} + #[milo] pub struct CubeTexObject { pub some_num_1: u32, pub some_num_2: u32, + pub properties: Vec, + pub right_ext_path: String, pub left_ext_path: String, pub top_ext_path: String, @@ -39,6 +49,8 @@ impl Default for CubeTexObject { some_num_1: 64, some_num_2: 4, + properties: Vec::new(), + right_ext_path: String::default(), left_ext_path: String::default(), top_ext_path: String::default(), @@ -56,4 +68,4 @@ impl Default for CubeTexObject { back: None, } } -} \ No newline at end of file +}