implement roblox mesh loading
This commit is contained in:
parent
3756af9638
commit
5fdcf9047c
17
src/file.rs
17
src/file.rs
@ -49,14 +49,25 @@ pub fn load<P:AsRef<std::path::Path>>(path:P)->Result<strafesnet_common::map::Co
|
|||||||
DataStructure::Roblox(dom)=>{
|
DataStructure::Roblox(dom)=>{
|
||||||
let mut loader=strafesnet_deferred_loader::roblox_legacy();
|
let mut loader=strafesnet_deferred_loader::roblox_legacy();
|
||||||
|
|
||||||
|
let (texture_loader,mesh_loader)=loader.get_inner_mut();
|
||||||
|
|
||||||
let map_step1=strafesnet_rbx_loader::convert(
|
let map_step1=strafesnet_rbx_loader::convert(
|
||||||
&dom,
|
&dom,
|
||||||
|name|loader.acquire_render_config_id(name)
|
|name|texture_loader.acquire_render_config_id(name),
|
||||||
|
|name|mesh_loader.acquire_mesh_id(name),
|
||||||
|
);
|
||||||
|
|
||||||
|
let meshpart_meshes=mesh_loader.load_meshes().map_err(LoadError::Io)?;
|
||||||
|
|
||||||
|
let map_step2=map_step1.add_meshpart_meshes_and_calculate_attributes(
|
||||||
|
meshpart_meshes.into_iter().map(|(mesh_id,loader_model)|
|
||||||
|
(mesh_id,strafesnet_rbx_loader::data::RobloxMeshBytes::new(loader_model.get()))
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
let (textures,render_configs)=loader.into_render_configs().map_err(LoadError::Io)?.consume();
|
let (textures,render_configs)=loader.into_render_configs().map_err(LoadError::Io)?.consume();
|
||||||
|
|
||||||
let map=map_step1.add_render_configs_and_textures(
|
let map=map_step2.add_render_configs_and_textures(
|
||||||
render_configs.into_iter(),
|
render_configs.into_iter(),
|
||||||
textures.into_iter().map(|(texture_id,texture)|
|
textures.into_iter().map(|(texture_id,texture)|
|
||||||
(texture_id,match texture{
|
(texture_id,match texture{
|
||||||
@ -74,9 +85,7 @@ pub fn load<P:AsRef<std::path::Path>>(path:P)->Result<strafesnet_common::map::Co
|
|||||||
|
|
||||||
let map_step1=strafesnet_bsp_loader::convert(
|
let map_step1=strafesnet_bsp_loader::convert(
|
||||||
&bsp,
|
&bsp,
|
||||||
//acquire_render_config_id
|
|
||||||
|name|texture_loader.acquire_render_config_id(name),
|
|name|texture_loader.acquire_render_config_id(name),
|
||||||
//acquire_mesh_id
|
|
||||||
|name|mesh_loader.acquire_mesh_id(name),
|
|name|mesh_loader.acquire_mesh_id(name),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -284,6 +284,7 @@ impl EdgePool{
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum PhysicsMeshError{
|
pub enum PhysicsMeshError{
|
||||||
ZeroVertices,
|
ZeroVertices,
|
||||||
|
NoPhysicsGroups,
|
||||||
}
|
}
|
||||||
impl std::fmt::Display for PhysicsMeshError{
|
impl std::fmt::Display for PhysicsMeshError{
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
@ -404,7 +405,7 @@ impl TryFrom<&model::Mesh> for PhysicsMesh{
|
|||||||
faces,
|
faces,
|
||||||
verts,
|
verts,
|
||||||
},
|
},
|
||||||
complete_mesh:mesh_topologies.pop().unwrap(),
|
complete_mesh:mesh_topologies.pop().ok_or(PhysicsMeshError::NoPhysicsGroups)?,
|
||||||
submeshes:mesh_topologies,
|
submeshes:mesh_topologies,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user