From ae5a4511595a7d4feebeeee972ffd930a660ca1e Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 9 Jan 2024 17:29:10 -0800 Subject: [PATCH] scan props for textures --- src/main.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/main.rs b/src/main.rs index 9f9d507..7b66ce2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1053,6 +1053,40 @@ fn extract_textures(paths:Vec,vpk_path:std::path::PathBuf)-> for texture in bsp.textures(){ deduplicate.insert(std::path::PathBuf::from(texture.name())); } + //dedupe prop models + let mut model_dedupe=std::collections::HashSet::new(); + for prop in bsp.static_props(){ + model_dedupe.insert(prop.model()); + } + + //grab texture names from props + for model_name in model_dedupe{ + //.mdl, .vvd, .dx90.vtx + let mut path=std::path::PathBuf::from(model_name); + let file_name=std::path::PathBuf::from(path.file_stem().unwrap()); + path.pop(); + path.push(file_name); + let mut vvd_path=path.clone(); + let mut vtx_path=path.clone(); + vvd_path.set_extension("vvd"); + vtx_path.set_extension("dx90.vtx"); + match (bsp.pack.get(model_name),bsp.pack.get(vvd_path.as_os_str().to_str().unwrap()),bsp.pack.get(vtx_path.as_os_str().to_str().unwrap())){ + (Ok(Some(mdl_file)),Ok(Some(vvd_file)),Ok(Some(vtx_file)))=>{ + match (vmdl::mdl::Mdl::read(mdl_file.as_ref()),vmdl::vvd::Vvd::read(vvd_file.as_ref()),vmdl::vtx::Vtx::read(vtx_file.as_ref())){ + (Ok(mdl),Ok(vvd),Ok(vtx))=>{ + let model=vmdl::Model::from_parts(mdl,vtx,vvd); + for texture in model.textures(){ + println!("prop texture={}",texture.name.as_str()); + deduplicate.insert(std::path::PathBuf::from(texture.name.as_str())); + } + }, + _=>print!("model_name={} error",model_name), + } + }, + _=>print!("no model name={}",model_name), + } + } + let mut zippyt=bsp.pack.into_zip().into_inner().unwrap(); let tree=&vpk_index.tree; std::thread::scope(move|s|{