forked from StrafesNET/map-tool
Compare commits
1 Commits
feature/sn
...
obj
| Author | SHA1 | Date | |
|---|---|---|---|
| 0fbac15828 |
9
Cargo.lock
generated
9
Cargo.lock
generated
@@ -790,7 +790,6 @@ dependencies = [
|
|||||||
"rbx_dom_weak",
|
"rbx_dom_weak",
|
||||||
"rbx_reflection_database",
|
"rbx_reflection_database",
|
||||||
"rbx_xml",
|
"rbx_xml",
|
||||||
"strafesnet_snf",
|
|
||||||
"vbsp",
|
"vbsp",
|
||||||
"vmdl",
|
"vmdl",
|
||||||
"vmt-parser",
|
"vmt-parser",
|
||||||
@@ -1335,14 +1334,6 @@ version = "1.1.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "strafesnet_snf"
|
|
||||||
version = "0.1.0"
|
|
||||||
source = "git+https://git.itzana.me/StrafesNET/snf?rev=dea408daeef576cff8ffa61356c89a9d03d95f6b#dea408daeef576cff8ffa61356c89a9d03d95f6b"
|
|
||||||
dependencies = [
|
|
||||||
"binrw",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "strsim"
|
name = "strsim"
|
||||||
version = "0.10.0"
|
version = "0.10.0"
|
||||||
|
|||||||
@@ -16,9 +16,6 @@ rbx_binary = "0.7.1"
|
|||||||
rbx_dom_weak = "2.5.0"
|
rbx_dom_weak = "2.5.0"
|
||||||
rbx_reflection_database = "0.2.7"
|
rbx_reflection_database = "0.2.7"
|
||||||
rbx_xml = "0.13.1"
|
rbx_xml = "0.13.1"
|
||||||
strafesnet_bsp_loader = { git = "https://git.itzana.me/StrafesNET/bsp_loader", rev = "79b8120106e63de237b8ed59c3d3e30db51e7146" }
|
|
||||||
strafesnet_rbx_loader = { git = "https://git.itzana.me/StrafesNET/rbx_loader", rev = "0d2c27f60f4a448063edc57d9a23766775fb2cc5" }
|
|
||||||
strafesnet_snf = { git = "https://git.itzana.me/StrafesNET/snf", rev = "dea408daeef576cff8ffa61356c89a9d03d95f6b" }
|
|
||||||
vbsp = "0.5.0"
|
vbsp = "0.5.0"
|
||||||
vmdl = "0.1.1"
|
vmdl = "0.1.1"
|
||||||
vmt-parser = "0.1.1"
|
vmt-parser = "0.1.1"
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ struct Cli {
|
|||||||
|
|
||||||
#[derive(Subcommand)]
|
#[derive(Subcommand)]
|
||||||
enum Commands {
|
enum Commands {
|
||||||
ConvertToSNF(PathBufList),
|
|
||||||
Download(MapList),
|
Download(MapList),
|
||||||
DownloadTextures(PathBufList),
|
DownloadTextures(PathBufList),
|
||||||
ExtractTextures(PathBufList),
|
ExtractTextures(PathBufList),
|
||||||
@@ -44,7 +43,6 @@ struct MapList {
|
|||||||
fn main() -> AResult<()> {
|
fn main() -> AResult<()> {
|
||||||
let cli = Cli::parse();
|
let cli = Cli::parse();
|
||||||
match cli.command {
|
match cli.command {
|
||||||
Commands::ConvertToSNF(pathlist)=>convert_to_snf(pathlist.paths),
|
|
||||||
Commands::Download(map_list)=>download(map_list.maps),
|
Commands::Download(map_list)=>download(map_list.maps),
|
||||||
Commands::DownloadTextures(pathlist)=>download_textures(pathlist.paths),
|
Commands::DownloadTextures(pathlist)=>download_textures(pathlist.paths),
|
||||||
Commands::ExtractTextures(pathlist)=>extract_textures(vec![cli.path.unwrap()],pathlist.paths),
|
Commands::ExtractTextures(pathlist)=>extract_textures(vec![cli.path.unwrap()],pathlist.paths),
|
||||||
@@ -1276,11 +1274,4 @@ fn bsp_contents(path:std::path::PathBuf)->AResult<()>{
|
|||||||
println!("file_name={:?}",file_name);
|
println!("file_name={:?}",file_name);
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
|
||||||
|
|
||||||
fn convert_to_snf(pathlist:Vec<std::path::PathBuf>)->AResult<()>{
|
|
||||||
for path in pathlist{
|
|
||||||
let something=strafesnet_rbx_loader::read_file(path);
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
41
src/obj.rs
Normal file
41
src/obj.rs
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
|
||||||
|
pub fn generate_indexed_model_list_from_obj(data:obj::ObjData,color:Color4)->Vec<IndexedModel>{
|
||||||
|
let mut unique_vertex_index = std::collections::HashMap::<obj::IndexTuple,u32>::new();
|
||||||
|
return data.objects.iter().map(|object|{
|
||||||
|
unique_vertex_index.clear();
|
||||||
|
let mut unique_vertices = Vec::new();
|
||||||
|
let groups = object.groups.iter().map(|group|{
|
||||||
|
IndexedGroup{
|
||||||
|
texture:None,
|
||||||
|
polys:group.polys.iter().map(|poly|{
|
||||||
|
IndexedPolygon{
|
||||||
|
vertices:poly.0.iter().map(|&tup|{
|
||||||
|
if let Some(&i)=unique_vertex_index.get(&tup){
|
||||||
|
i
|
||||||
|
}else{
|
||||||
|
let i=unique_vertices.len() as u32;
|
||||||
|
unique_vertices.push(IndexedVertex{
|
||||||
|
pos: tup.0 as u32,
|
||||||
|
tex: tup.1.unwrap() as u32,
|
||||||
|
normal: tup.2.unwrap() as u32,
|
||||||
|
color: 0,
|
||||||
|
});
|
||||||
|
unique_vertex_index.insert(tup,i);
|
||||||
|
i
|
||||||
|
}
|
||||||
|
}).collect()
|
||||||
|
}
|
||||||
|
}).collect()
|
||||||
|
}
|
||||||
|
}).collect();
|
||||||
|
IndexedModel{
|
||||||
|
unique_pos: data.position.iter().map(|&v|Planar64Vec3::try_from(v).unwrap()).collect(),
|
||||||
|
unique_tex: data.texture.iter().map(|&v|TextureCoordinate::from_array(v)).collect(),
|
||||||
|
unique_normal: data.normal.iter().map(|&v|Planar64Vec3::try_from(v).unwrap()).collect(),
|
||||||
|
unique_color: vec![color],
|
||||||
|
unique_vertices,
|
||||||
|
groups,
|
||||||
|
instances:Vec::new(),
|
||||||
|
}
|
||||||
|
}).collect()
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user