Skip to content

Commit

Permalink
wip: load materials
Browse files Browse the repository at this point in the history
  • Loading branch information
berkus committed Mar 31, 2024
1 parent be3bca7 commit 3a12820
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ use {
// MAT
// PAL
// PIX
use bevy::app::AppExit;

fn setup_cars(
mut commands: Commands,

Check warning on line 55 in src/main.rs

View workflow job for this annotation

GitHub Actions / Clippy Output

variable does not need to be mutable

warning: variable does not need to be mutable --> src/main.rs:55:5 | 55 | mut commands: Commands, | ----^^^^^^^^ | | | help: remove this `mut` | = note: `#[warn(unused_mut)]` on by default

Check warning on line 55 in src/main.rs

View workflow job for this annotation

GitHub Actions / Clippy Output

unused variable: `commands`

warning: unused variable: `commands` --> src/main.rs:55:9 | 55 | mut commands: Commands, | ^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_commands` | = note: `#[warn(unused_variables)]` on by default
Expand All @@ -58,16 +59,34 @@ fn setup_cars(
mut materials: ResMut<Assets<StandardMaterial>>,

Check warning on line 59 in src/main.rs

View workflow job for this annotation

GitHub Actions / Clippy Output

variable does not need to be mutable

warning: variable does not need to be mutable --> src/main.rs:59:5 | 59 | mut materials: ResMut<Assets<StandardMaterial>>, | ----^^^^^^^^^ | | | help: remove this `mut`

Check warning on line 59 in src/main.rs

View workflow job for this annotation

GitHub Actions / Clippy Output

unused variable: `materials`

warning: unused variable: `materials` --> src/main.rs:59:9 | 59 | mut materials: ResMut<Assets<StandardMaterial>>, | ^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_materials`
// mut textures: ResMut<Assets<Texture>>,
// mut texture_atlases: ResMut<Assets<TextureAtlas>>,
mut exit: EventWriter<AppExit>,
) /*-> Result<Vec<Car>>*/
{
// bevy @todo: load all textures into the texture atlas
// TextureAtlasBuilder

let mats =
Material::load_many("assets/DecodedData/DATA/MATERIAL/CITYA.MAT").expect("Load materials");
// for mat in mats {
// debug!("{:?}", mat);
// }
let mut mats = vec![];

let _ = visit_files("assets/DecodedData/DATA/MATERIAL", &mut |dir_entry| {
if let Ok(file_type) = dir_entry.file_type() {
let fname = String::from(dir_entry.path().to_str().unwrap());
if file_type.is_file() && fname.ends_with(".MAT") {
mats.extend(Material::load_many(fname)?);
}
}
Ok(())
});

mats.sort_by_key(|e| e.material.identifier.clone()); // NB
for mat in mats.iter() {
debug!("{:?}", mat.material.identifier);
}
debug!("{:?}", mats[0]);
debug!("{:?}", mats[1]);
debug!("Total {} materials", mats.len()); // 8014 without dedup

exit.send(AppExit);
return;

// models refer to materials to load! check that
let models =
Expand Down

0 comments on commit 3a12820

Please sign in to comment.