forked from StrafesNET/map-tool
scan props for textures
This commit is contained in:
parent
02310c5653
commit
ae5a451159
34
src/main.rs
34
src/main.rs
@ -1053,6 +1053,40 @@ fn extract_textures(paths:Vec<std::path::PathBuf>,vpk_path:std::path::PathBuf)->
|
|||||||
for texture in bsp.textures(){
|
for texture in bsp.textures(){
|
||||||
deduplicate.insert(std::path::PathBuf::from(texture.name()));
|
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 mut zippyt=bsp.pack.into_zip().into_inner().unwrap();
|
||||||
let tree=&vpk_index.tree;
|
let tree=&vpk_index.tree;
|
||||||
std::thread::scope(move|s|{
|
std::thread::scope(move|s|{
|
||||||
|
Loading…
Reference in New Issue
Block a user