getting there
This commit is contained in:
parent
7dfb421016
commit
f6d5972743
13
src/lib.rs
13
src/lib.rs
@ -1,8 +1,21 @@
|
|||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
|
|
||||||
mod rbx;
|
mod rbx;
|
||||||
|
mod mesh;
|
||||||
mod primitives;
|
mod primitives;
|
||||||
|
|
||||||
|
pub mod data{
|
||||||
|
pub struct RobloxMeshBytes(Vec<u8>);
|
||||||
|
impl RobloxMeshBytes{
|
||||||
|
pub fn new(bytes:Vec<u8>)->Self{
|
||||||
|
Self(bytes)
|
||||||
|
}
|
||||||
|
pub fn cursor(self)->std::io::Cursor<Vec<u8>>{
|
||||||
|
std::io::Cursor::new(self.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct Dom(rbx_dom_weak::WeakDom);
|
pub struct Dom(rbx_dom_weak::WeakDom);
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
4
src/mesh.rs
Normal file
4
src/mesh.rs
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
pub fn convert(roblox_mesh_bytes:crate::data::RobloxMeshBytes)->Result<strafesnet_common::model::Mesh,rbx_mesh::mesh::Error>{
|
||||||
|
let versioned_mesh=rbx_mesh::read_versioned(roblox_mesh_bytes.cursor())?;
|
||||||
|
//generate that mesh boi
|
||||||
|
}
|
109
src/rbx.rs
109
src/rbx.rs
@ -396,11 +396,6 @@ type RobloxPartDescription=[Option<RobloxFaceTextureDescription>;6];
|
|||||||
type RobloxWedgeDescription=[Option<RobloxFaceTextureDescription>;5];
|
type RobloxWedgeDescription=[Option<RobloxFaceTextureDescription>;5];
|
||||||
type RobloxCornerWedgeDescription=[Option<RobloxFaceTextureDescription>;5];
|
type RobloxCornerWedgeDescription=[Option<RobloxFaceTextureDescription>;5];
|
||||||
#[derive(Clone,Eq,Hash,PartialEq)]
|
#[derive(Clone,Eq,Hash,PartialEq)]
|
||||||
struct RobloxMeshPartDescription{
|
|
||||||
render:RenderConfigId,
|
|
||||||
mesh:model::MeshId,
|
|
||||||
}
|
|
||||||
#[derive(Clone,Eq,Hash,PartialEq)]
|
|
||||||
enum RobloxBasePartDescription{
|
enum RobloxBasePartDescription{
|
||||||
Sphere(RobloxPartDescription),
|
Sphere(RobloxPartDescription),
|
||||||
Part(RobloxPartDescription),
|
Part(RobloxPartDescription),
|
||||||
@ -414,7 +409,11 @@ enum Shape{
|
|||||||
}
|
}
|
||||||
enum MeshAvailability{
|
enum MeshAvailability{
|
||||||
Immediate,
|
Immediate,
|
||||||
Deferred,
|
Deferred(RenderConfigId),
|
||||||
|
}
|
||||||
|
struct DeferredModelDeferredAttributes{
|
||||||
|
render:RenderConfigId,
|
||||||
|
model:ModelDeferredAttributes,
|
||||||
}
|
}
|
||||||
struct ModelDeferredAttributes{
|
struct ModelDeferredAttributes{
|
||||||
mesh:model::MeshId,
|
mesh:model::MeshId,
|
||||||
@ -422,6 +421,12 @@ struct ModelDeferredAttributes{
|
|||||||
color:model::Color4,//transparency is in here
|
color:model::Color4,//transparency is in here
|
||||||
transform:Planar64Affine3,
|
transform:Planar64Affine3,
|
||||||
}
|
}
|
||||||
|
struct ModelOwnedAttributes{
|
||||||
|
mesh:model::MeshId,
|
||||||
|
attributes:attr::CollisionAttributes,
|
||||||
|
color:model::Color4,//transparency is in here
|
||||||
|
transform:Planar64Affine3,
|
||||||
|
}
|
||||||
struct GetAttributesArgs{
|
struct GetAttributesArgs{
|
||||||
name:Box<str>,
|
name:Box<str>,
|
||||||
can_collide:bool,
|
can_collide:bool,
|
||||||
@ -436,19 +441,12 @@ where
|
|||||||
AcquireRenderConfigId:FnMut(Option<&str>)->model::RenderConfigId,
|
AcquireRenderConfigId:FnMut(Option<&str>)->model::RenderConfigId,
|
||||||
AcquireMeshId:FnMut(&str)->model::MeshId,
|
AcquireMeshId:FnMut(&str)->model::MeshId,
|
||||||
{
|
{
|
||||||
let mut modes_builder=ModesBuilder::default();
|
|
||||||
|
|
||||||
let mut deferred_models_deferred_attributes=Vec::new();
|
let mut deferred_models_deferred_attributes=Vec::new();
|
||||||
let mut primitive_models_deferred_attributes=Vec::new();
|
let mut primitive_models_deferred_attributes=Vec::new();
|
||||||
let mut primitive_meshes=Vec::new();
|
let mut primitive_meshes=Vec::new();
|
||||||
let mut mesh_id_from_description=HashMap::new();
|
let mut mesh_id_from_description=HashMap::new();
|
||||||
|
|
||||||
let mut unique_attributes=Vec::new();
|
|
||||||
let mut attributes_id_from_attributes=HashMap::new();
|
|
||||||
|
|
||||||
let mut wormhole_in_model_to_id=HashMap::new();
|
|
||||||
let mut wormhole_id_to_out_model=HashMap::new();
|
|
||||||
|
|
||||||
//just going to leave it like this for now instead of reworking the data structures for this whole thing
|
//just going to leave it like this for now instead of reworking the data structures for this whole thing
|
||||||
let textureless_render_group=acquire_render_config_id(None);
|
let textureless_render_group=acquire_render_config_id(None);
|
||||||
|
|
||||||
@ -516,6 +514,7 @@ where
|
|||||||
|
|
||||||
let (availability,mesh_id)=match shape{
|
let (availability,mesh_id)=match shape{
|
||||||
Shape::Primitive(primitive_shape)=>{
|
Shape::Primitive(primitive_shape)=>{
|
||||||
|
//TODO: TAB TAB
|
||||||
//use the biggest one and cut it down later...
|
//use the biggest one and cut it down later...
|
||||||
let mut part_texture_description:RobloxPartDescription=[None,None,None,None,None,None];
|
let mut part_texture_description:RobloxPartDescription=[None,None,None,None,None,None];
|
||||||
temp_objects.clear();
|
temp_objects.clear();
|
||||||
@ -694,7 +693,10 @@ where
|
|||||||
object.properties.get("MeshId"),
|
object.properties.get("MeshId"),
|
||||||
object.properties.get("TextureID"),
|
object.properties.get("TextureID"),
|
||||||
){
|
){
|
||||||
(MeshAvailability::Deferred,acquire_mesh_id(mesh_asset_id.as_ref()))
|
(
|
||||||
|
MeshAvailability::Deferred(acquire_render_config_id(Some(texture_asset_id.as_ref()))),
|
||||||
|
acquire_mesh_id(mesh_asset_id.as_ref()),
|
||||||
|
)
|
||||||
}else{
|
}else{
|
||||||
panic!("Mesh has no Mesh or Texture");
|
panic!("Mesh has no Mesh or Texture");
|
||||||
},
|
},
|
||||||
@ -711,12 +713,76 @@ where
|
|||||||
};
|
};
|
||||||
match availability{
|
match availability{
|
||||||
MeshAvailability::Immediate=>primitive_models_deferred_attributes.push(model_deferred_attributes),
|
MeshAvailability::Immediate=>primitive_models_deferred_attributes.push(model_deferred_attributes),
|
||||||
MeshAvailability::Deferred=>deferred_models_deferred_attributes.push(model_deferred_attributes),
|
MeshAvailability::Deferred(render)=>deferred_models_deferred_attributes.push(DeferredModelDeferredAttributes{
|
||||||
|
render,
|
||||||
|
model:model_deferred_attributes
|
||||||
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let primitive_models=primitive_models_deferred_attributes.into_iter().enumerate().map(|(model_id,mut model_owned_attributes)|{
|
PartialMap1{
|
||||||
|
primitive_meshes,
|
||||||
|
primitive_models_deferred_attributes,
|
||||||
|
deferred_models_deferred_attributes,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct PartialMap1{
|
||||||
|
primitive_meshes:Vec<model::Mesh>,
|
||||||
|
primitive_models_deferred_attributes:Vec<ModelDeferredAttributes>,
|
||||||
|
deferred_models_deferred_attributes:Vec<DeferredModelDeferredAttributes>,
|
||||||
|
}
|
||||||
|
impl PartialMap1{
|
||||||
|
pub fn add_meshpart_meshes_and_calculate_attributes<AcquireRenderConfigId>(
|
||||||
|
self,
|
||||||
|
meshpart_meshes:impl IntoIterator<Item=(model::MeshId,crate::data::RobloxMeshBytes)>,
|
||||||
|
)->PartialMap2
|
||||||
|
where
|
||||||
|
AcquireRenderConfigId:FnMut(Option<&str>)->model::RenderConfigId,
|
||||||
|
{
|
||||||
|
//calculate attributes
|
||||||
|
let mut modes_builder=ModesBuilder::default();
|
||||||
|
let mut unique_attributes=Vec::new();
|
||||||
|
let mut attributes_id_from_attributes=HashMap::new();
|
||||||
|
|
||||||
|
let mut wormhole_in_model_to_id=HashMap::new();
|
||||||
|
let mut wormhole_id_to_out_model=HashMap::new();
|
||||||
|
|
||||||
|
//decode roblox meshes
|
||||||
|
//generate mesh_id map based on meshes that failed to load
|
||||||
|
let mut meshes=meshpart_meshes.into_iter().flat_map(|(old_mesh_id,roblox_mesh_bytes)|{
|
||||||
|
Ok((old_mesh_id,crate::mesh::convert(roblox_mesh_bytes)?))
|
||||||
|
}).collect();
|
||||||
|
//now that the meshes are loaded, these models can be generated
|
||||||
|
let models_owned_attributes=self.deferred_models_deferred_attributes.into_iter().map(|deferred_model_deferred_attributes|{
|
||||||
|
let render=deferred_model_deferred_attributes.render;//what does this do?
|
||||||
|
ModelDeferredAttributes{
|
||||||
|
mesh:deferred_model_deferred_attributes.model.mesh,
|
||||||
|
deferred_attributes:deferred_model_deferred_attributes.model.deferred_attributes,
|
||||||
|
color:deferred_model_deferred_attributes.model.color,
|
||||||
|
transform:deferred_model_deferred_attributes.model.transform,
|
||||||
|
}
|
||||||
|
}).chain(self.primitive_models_deferred_attributes.into_iter())
|
||||||
|
.enumerate().map(|(model_id,model_deferred_attributes)|{
|
||||||
|
let model_id=model::ModelId::new(model_id as u32);
|
||||||
|
ModelOwnedAttributes{
|
||||||
|
mesh:model_deferred_attributes.mesh,
|
||||||
|
attributes:get_attributes(
|
||||||
|
&model_deferred_attributes.deferred_attributes.name,
|
||||||
|
model_deferred_attributes.deferred_attributes.can_collide,
|
||||||
|
model_deferred_attributes.deferred_attributes.velocity,
|
||||||
|
model_id,
|
||||||
|
&mut modes_builder,
|
||||||
|
&mut wormhole_in_model_to_id,
|
||||||
|
&mut wormhole_id_to_out_model,
|
||||||
|
),
|
||||||
|
color:model_deferred_attributes.color,
|
||||||
|
transform:model_deferred_attributes.transform,
|
||||||
|
}
|
||||||
|
}).collect();
|
||||||
|
let models=models_owned_attributes.into_iter().enumerate().map(|(model_id,mut model_owned_attributes)|{
|
||||||
|
//TODO: TAB
|
||||||
let model_id=model::ModelId::new(model_id as u32);
|
let model_id=model::ModelId::new(model_id as u32);
|
||||||
//update attributes with wormhole id
|
//update attributes with wormhole id
|
||||||
//TODO: errors/prints
|
//TODO: errors/prints
|
||||||
@ -747,21 +813,22 @@ where
|
|||||||
attributes:attributes_id,
|
attributes:attributes_id,
|
||||||
}
|
}
|
||||||
}).collect();
|
}).collect();
|
||||||
PartialMap1{
|
PartialMap2{
|
||||||
meshes:primitive_meshes,
|
meshes,
|
||||||
models:primitive_models,
|
models,
|
||||||
modes:modes_builder.build(),
|
modes:modes_builder.build(),
|
||||||
attributes:unique_attributes,
|
attributes:unique_attributes,
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct PartialMap1{
|
pub struct PartialMap2{
|
||||||
meshes:Vec<model::Mesh>,
|
meshes:Vec<model::Mesh>,
|
||||||
models:Vec<model::Model>,
|
models:Vec<model::Model>,
|
||||||
modes:gameplay_modes::Modes,
|
modes:gameplay_modes::Modes,
|
||||||
attributes:Vec<strafesnet_common::gameplay_attributes::CollisionAttributes>,
|
attributes:Vec<strafesnet_common::gameplay_attributes::CollisionAttributes>,
|
||||||
}
|
}
|
||||||
impl PartialMap1{
|
impl PartialMap2{
|
||||||
pub fn add_render_configs_and_textures(
|
pub fn add_render_configs_and_textures(
|
||||||
self,
|
self,
|
||||||
render_configs:impl IntoIterator<Item=(model::RenderConfigId,model::RenderConfig)>,
|
render_configs:impl IntoIterator<Item=(model::RenderConfigId,model::RenderConfig)>,
|
||||||
|
Loading…
Reference in New Issue
Block a user