update common
This commit is contained in:
parent
69f08061ed
commit
777ee3439c
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -101,7 +101,7 @@ checksum = "151665d9be52f9bb40fc7966565d39666f2d1e69233571b71b87791c7e0528b3"
|
||||
[[package]]
|
||||
name = "id"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.itzana.me/Quaternions/id?rev=faca9fb6a8eb0c7f0e2796fbfad9eac16875cbd6#faca9fb6a8eb0c7f0e2796fbfad9eac16875cbd6"
|
||||
source = "git+https://git.itzana.me/Quaternions/id?rev=1f710976cc786c8853dab73d6e1cee53158deeb0#1f710976cc786c8853dab73d6e1cee53158deeb0"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -420,7 +420,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "strafesnet_common"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.itzana.me/StrafesNET/common?rev=ec59d251d2c9f3a6e719dc47924b6ea998ad7bc3#ec59d251d2c9f3a6e719dc47924b6ea998ad7bc3"
|
||||
source = "git+https://git.itzana.me/StrafesNET/common?rev=03868552c24efe64097be27348e0ccbd12b2cd37#03868552c24efe64097be27348e0ccbd12b2cd37"
|
||||
dependencies = [
|
||||
"glam",
|
||||
"id",
|
||||
|
@ -12,4 +12,4 @@ rbx_binary = "0.7.4"
|
||||
rbx_dom_weak = "2.7.0"
|
||||
rbx_reflection_database = "0.2.10"
|
||||
rbx_xml = "0.13.3"
|
||||
strafesnet_common = { git = "https://git.itzana.me/StrafesNET/common", rev = "ec59d251d2c9f3a6e719dc47924b6ea998ad7bc3" }
|
||||
strafesnet_common = { git = "https://git.itzana.me/StrafesNET/common", rev = "03868552c24efe64097be27348e0ccbd12b2cd37" }
|
||||
|
@ -1,4 +1,4 @@
|
||||
use strafesnet_common::model::{Color4,TextureCoordinate,IndexedModel,IndexedGraphicsGroup,IndexedPhysicsGroup,IndexedVertex,PolygonGroupId,PolygonGroup::PolygonList,IndexedVertexList,PositionId,TextureCoordinateId,NormalId,ColorId,VertexId,RenderGroupId};
|
||||
use strafesnet_common::model::{Color4,TextureCoordinate,Mesh,IndexedGraphicsGroup,IndexedPhysicsGroup,IndexedVertex,PolygonGroupId,PolygonGroup,PolygonList,IndexedVertexList,PositionId,TextureCoordinateId,NormalId,ColorId,VertexId,RenderConfigId};
|
||||
use strafesnet_common::integer::Planar64Vec3;
|
||||
|
||||
#[derive(Debug)]
|
||||
@ -126,7 +126,7 @@ const CORNERWEDGE_DEFAULT_NORMALS:[Planar64Vec3;5]=[
|
||||
Planar64Vec3::int( 0,-1, 0),//CornerWedge::Bottom
|
||||
Planar64Vec3::int( 0, 0,-1),//CornerWedge::Front
|
||||
];
|
||||
pub fn unit_sphere(render:RenderGroupId)->IndexedModel{
|
||||
pub fn unit_sphere(render:RenderConfigId)->Mesh{
|
||||
unit_cube(render)
|
||||
}
|
||||
#[derive(Default)]
|
||||
@ -139,7 +139,7 @@ impl CubeFaceDescription{
|
||||
self.0.into_iter().enumerate().filter_map(|v|v.1.map(|u|(v.0,u)))
|
||||
}
|
||||
}
|
||||
pub fn unit_cube(render:RenderGroupId)->IndexedModel{
|
||||
pub fn unit_cube(render:RenderConfigId)->Mesh{
|
||||
let mut t=CubeFaceDescription::default();
|
||||
t.insert(CubeFace::Right,FaceDescription::new_with_render_id(render));
|
||||
t.insert(CubeFace::Top,FaceDescription::new_with_render_id(render));
|
||||
@ -149,7 +149,7 @@ pub fn unit_cube(render:RenderGroupId)->IndexedModel{
|
||||
t.insert(CubeFace::Front,FaceDescription::new_with_render_id(render));
|
||||
generate_partial_unit_cube(t)
|
||||
}
|
||||
pub fn unit_cylinder(render:RenderGroupId)->IndexedModel{
|
||||
pub fn unit_cylinder(render:RenderConfigId)->Mesh{
|
||||
//lmao
|
||||
unit_cube(render)
|
||||
}
|
||||
@ -163,7 +163,7 @@ impl WedgeFaceDescription{
|
||||
self.0.into_iter().enumerate().filter_map(|v|v.1.map(|u|(v.0,u)))
|
||||
}
|
||||
}
|
||||
pub fn unit_wedge(render:RenderGroupId)->IndexedModel{
|
||||
pub fn unit_wedge(render:RenderConfigId)->Mesh{
|
||||
let mut t=WedgeFaceDescription::default();
|
||||
t.insert(WedgeFace::Right,FaceDescription::new_with_render_id(render));
|
||||
t.insert(WedgeFace::TopFront,FaceDescription::new_with_render_id(render));
|
||||
@ -182,7 +182,7 @@ impl CornerWedgeFaceDescription{
|
||||
self.0.into_iter().enumerate().filter_map(|v|v.1.map(|u|(v.0,u)))
|
||||
}
|
||||
}
|
||||
pub fn unit_cornerwedge(render:RenderGroupId)->IndexedModel{
|
||||
pub fn unit_cornerwedge(render:RenderConfigId)->Mesh{
|
||||
let mut t=CornerWedgeFaceDescription::default();
|
||||
t.insert(CornerWedgeFace::Right,FaceDescription::new_with_render_id(render));
|
||||
t.insert(CornerWedgeFace::TopBack,FaceDescription::new_with_render_id(render));
|
||||
@ -194,12 +194,12 @@ pub fn unit_cornerwedge(render:RenderGroupId)->IndexedModel{
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct FaceDescription{
|
||||
pub render:RenderGroupId,
|
||||
pub render:RenderConfigId,
|
||||
pub transform:glam::Affine2,
|
||||
pub color:Color4,
|
||||
}
|
||||
impl FaceDescription{
|
||||
pub fn new_with_render_id(render:RenderGroupId)->Self {
|
||||
pub fn new_with_render_id(render:RenderConfigId)->Self {
|
||||
Self{
|
||||
render,
|
||||
transform:glam::Affine2::IDENTITY,
|
||||
@ -209,7 +209,7 @@ impl FaceDescription{
|
||||
}
|
||||
//TODO: it's probably better to use a shared vertex buffer between all primitives and use indexed rendering instead of generating a unique vertex buffer for each primitive.
|
||||
//implementation: put all roblox primitives into one model.groups <- this won't work but I forget why
|
||||
pub fn generate_partial_unit_cube(face_descriptions:CubeFaceDescription)->IndexedModel{
|
||||
pub fn generate_partial_unit_cube(face_descriptions:CubeFaceDescription)->Mesh{
|
||||
let mut generated_pos=Vec::new();
|
||||
let mut generated_tex=Vec::new();
|
||||
let mut generated_normal=Vec::new();
|
||||
@ -246,7 +246,7 @@ pub fn generate_partial_unit_cube(face_descriptions:CubeFaceDescription)->Indexe
|
||||
generated_normal.push(CUBE_DEFAULT_NORMALS[face_id]);
|
||||
//push vertices as they are needed
|
||||
let group_id=PolygonGroupId::new(polygon_groups.len() as u32);
|
||||
polygon_groups.push(PolygonList(vec![IndexedVertexList::new(
|
||||
polygon_groups.push(PolygonGroup::PolygonList(PolygonList::new(vec![
|
||||
CUBE_DEFAULT_POLYS[face_id].map(|tup|{
|
||||
let pos=CUBE_DEFAULT_VERTICES[tup[0] as usize];
|
||||
let pos_index=if let Some(pos_index)=generated_pos.iter().position(|&p|p==pos){
|
||||
@ -268,14 +268,14 @@ pub fn generate_partial_unit_cube(face_descriptions:CubeFaceDescription)->Indexe
|
||||
generated_vertices.push(vertex);
|
||||
VertexId::new(vert_index as u32)
|
||||
}).to_vec(),
|
||||
)]));
|
||||
])));
|
||||
graphics_groups.push(IndexedGraphicsGroup{
|
||||
render:face_description.render,
|
||||
groups:vec![group_id],
|
||||
});
|
||||
physics_groups[0].groups.push(group_id);
|
||||
}
|
||||
IndexedModel{
|
||||
Mesh{
|
||||
unique_pos:generated_pos,
|
||||
unique_tex:generated_tex,
|
||||
unique_normal:generated_normal,
|
||||
@ -287,7 +287,7 @@ pub fn generate_partial_unit_cube(face_descriptions:CubeFaceDescription)->Indexe
|
||||
}
|
||||
}
|
||||
//don't think too hard about the copy paste because this is all going into the map tool eventually...
|
||||
pub fn generate_partial_unit_wedge(face_descriptions:WedgeFaceDescription)->IndexedModel{
|
||||
pub fn generate_partial_unit_wedge(face_descriptions:WedgeFaceDescription)->Mesh{
|
||||
let wedge_default_polys=vec![
|
||||
// right (1, 0, 0)
|
||||
vec![
|
||||
@ -359,7 +359,7 @@ pub fn generate_partial_unit_wedge(face_descriptions:WedgeFaceDescription)->Inde
|
||||
generated_normal.push(WEDGE_DEFAULT_NORMALS[face_id]);
|
||||
//push vertices as they are needed
|
||||
let group_id=PolygonGroupId::new(polygon_groups.len() as u32);
|
||||
polygon_groups.push(PolygonList(vec![IndexedVertexList::new(
|
||||
polygon_groups.push(PolygonGroup::PolygonList(PolygonList::new(vec![
|
||||
wedge_default_polys[face_id].iter().map(|tup|{
|
||||
let pos=CUBE_DEFAULT_VERTICES[tup[0] as usize];
|
||||
let pos_index=if let Some(pos_index)=generated_pos.iter().position(|&p|p==pos){
|
||||
@ -381,14 +381,14 @@ pub fn generate_partial_unit_wedge(face_descriptions:WedgeFaceDescription)->Inde
|
||||
generated_vertices.push(vertex);
|
||||
VertexId::new(vert_index as u32)
|
||||
}).collect()
|
||||
)]));
|
||||
])));
|
||||
graphics_groups.push(IndexedGraphicsGroup{
|
||||
render:face_description.render,
|
||||
groups:vec![group_id],
|
||||
});
|
||||
physics_groups[0].groups.push(group_id);
|
||||
}
|
||||
IndexedModel{
|
||||
Mesh{
|
||||
unique_pos:generated_pos,
|
||||
unique_tex:generated_tex,
|
||||
unique_normal:generated_normal,
|
||||
@ -400,7 +400,7 @@ pub fn generate_partial_unit_wedge(face_descriptions:WedgeFaceDescription)->Inde
|
||||
}
|
||||
}
|
||||
|
||||
pub fn generate_partial_unit_cornerwedge(face_descriptions:CornerWedgeFaceDescription)->IndexedModel{
|
||||
pub fn generate_partial_unit_cornerwedge(face_descriptions:CornerWedgeFaceDescription)->Mesh{
|
||||
let cornerwedge_default_polys=vec![
|
||||
// right (1, 0, 0)
|
||||
vec![
|
||||
@ -470,37 +470,36 @@ pub fn generate_partial_unit_cornerwedge(face_descriptions:CornerWedgeFaceDescri
|
||||
generated_normal.push(CORNERWEDGE_DEFAULT_NORMALS[face_id]);
|
||||
//push vertices as they are needed
|
||||
let group_id=PolygonGroupId::new(polygon_groups.len() as u32);
|
||||
polygon_groups.push(PolygonList(vec![IndexedVertexList::new(
|
||||
cornerwedge_default_polys[face_id].iter().map(|tup|{
|
||||
let pos=CUBE_DEFAULT_VERTICES[tup[0] as usize];
|
||||
let pos_index=if let Some(pos_index)=generated_pos.iter().position(|&p|p==pos){
|
||||
pos_index
|
||||
}else{
|
||||
//create new pos_index
|
||||
let pos_index=generated_pos.len();
|
||||
generated_pos.push(pos);
|
||||
pos_index
|
||||
} as u32;
|
||||
//always push vertex
|
||||
let vertex=IndexedVertex{
|
||||
pos:PositionId::new(pos_index),
|
||||
tex:TextureCoordinateId::new(tup[1]+4*transform_index),
|
||||
normal:NormalId::new(normal_index),
|
||||
color:ColorId::new(color_index),
|
||||
};
|
||||
let vert_index=generated_vertices.len();
|
||||
generated_vertices.push(vertex);
|
||||
VertexId::new(vert_index as u32)
|
||||
}).collect(),
|
||||
)],
|
||||
));
|
||||
polygon_groups.push(PolygonGroup::PolygonList(PolygonList::new(vec![
|
||||
cornerwedge_default_polys[face_id].iter().map(|tup|{
|
||||
let pos=CUBE_DEFAULT_VERTICES[tup[0] as usize];
|
||||
let pos_index=if let Some(pos_index)=generated_pos.iter().position(|&p|p==pos){
|
||||
pos_index
|
||||
}else{
|
||||
//create new pos_index
|
||||
let pos_index=generated_pos.len();
|
||||
generated_pos.push(pos);
|
||||
pos_index
|
||||
} as u32;
|
||||
//always push vertex
|
||||
let vertex=IndexedVertex{
|
||||
pos:PositionId::new(pos_index),
|
||||
tex:TextureCoordinateId::new(tup[1]+4*transform_index),
|
||||
normal:NormalId::new(normal_index),
|
||||
color:ColorId::new(color_index),
|
||||
};
|
||||
let vert_index=generated_vertices.len();
|
||||
generated_vertices.push(vertex);
|
||||
VertexId::new(vert_index as u32)
|
||||
}).collect(),
|
||||
])));
|
||||
graphics_groups.push(IndexedGraphicsGroup{
|
||||
render:face_description.render,
|
||||
groups:vec![group_id],
|
||||
});
|
||||
physics_groups[0].groups.push(group_id);
|
||||
}
|
||||
IndexedModel{
|
||||
Mesh{
|
||||
unique_pos:generated_pos,
|
||||
unique_tex:generated_tex,
|
||||
unique_normal:generated_normal,
|
||||
|
38
src/rbx.rs
38
src/rbx.rs
@ -7,7 +7,7 @@ use strafesnet_common::gameplay_style;
|
||||
use strafesnet_common::gameplay_attributes as attr;
|
||||
use strafesnet_common::integer::{Planar64,Planar64Vec3,Planar64Mat3,Planar64Affine3};
|
||||
use strafesnet_common::model::RenderConfig;
|
||||
use strafesnet_common::model::RenderGroupId;
|
||||
use strafesnet_common::model::RenderConfigId;
|
||||
use strafesnet_common::updatable::Updatable;
|
||||
|
||||
fn class_is_a(class: &str, superclass: &str) -> bool {
|
||||
@ -315,7 +315,7 @@ impl std::hash::Hash for RobloxTextureTransform{
|
||||
}
|
||||
#[derive(Clone,PartialEq)]
|
||||
struct RobloxFaceTextureDescription{
|
||||
render:RenderGroupId,
|
||||
render:RenderConfigId,
|
||||
color:glam::Vec4,
|
||||
transform:RobloxTextureTransform,
|
||||
}
|
||||
@ -355,16 +355,16 @@ enum RobloxBasePartDescription{
|
||||
CornerWedge(RobloxCornerWedgeDescription),
|
||||
}
|
||||
struct ModelOwnedAttributes{
|
||||
model:model::IndexedModelId,
|
||||
mesh:model::MeshId,
|
||||
attributes:attr::CollisionAttributes,
|
||||
color:model::Color4,//transparency is in here
|
||||
transform:Planar64Affine3,
|
||||
}
|
||||
pub fn convert(dom:rbx_dom_weak::WeakDom)->map::Map{
|
||||
pub fn convert(dom:rbx_dom_weak::WeakDom)->map::CompleteMap{
|
||||
let mut modes_builder=ModesBuilder::default();
|
||||
|
||||
let mut models1=Vec::new();
|
||||
let mut indexed_models=Vec::new();
|
||||
let mut meshes=Vec::new();
|
||||
let mut indexed_model_id_from_description=HashMap::new();
|
||||
|
||||
let mut unique_attributes=Vec::new();
|
||||
@ -376,8 +376,8 @@ pub fn convert(dom:rbx_dom_weak::WeakDom)->map::Map{
|
||||
//TODO: some sort of thing like RobloxResources that describes where to get each resource
|
||||
//this would be another dependency built for downloading resources to keep this one clean
|
||||
let mut unique_render_groups=vec![RenderConfig::default()];
|
||||
let mut render_id_from_asset_id=HashMap::<u64,RenderGroupId>::new();
|
||||
let textureless_render_group=RenderGroupId::new(0);
|
||||
let mut render_id_from_asset_id=HashMap::<u64,RenderConfigId>::new();
|
||||
let textureless_render_group=RenderConfigId::new(0);
|
||||
|
||||
let mut object_refs=Vec::new();
|
||||
let mut temp_objects=Vec::new();
|
||||
@ -511,7 +511,7 @@ pub fn convert(dom:rbx_dom_weak::WeakDom)->map::Map{
|
||||
let render_id=if let Some(&render_id)=render_id_from_asset_id.get(&asset_id.0){
|
||||
render_id
|
||||
}else{
|
||||
let render_id=RenderGroupId::new(unique_render_groups.len() as u32);
|
||||
let render_id=RenderConfigId::new(unique_render_groups.len() as u32);
|
||||
render_id_from_asset_id.insert(asset_id.0,render_id);
|
||||
unique_render_groups.push(RenderConfig::texture(asset_id.0));
|
||||
render_id
|
||||
@ -602,9 +602,9 @@ pub fn convert(dom:rbx_dom_weak::WeakDom)->map::Map{
|
||||
//push to existing texture model
|
||||
indexed_model_id
|
||||
}else{
|
||||
let indexed_model_id=model::IndexedModelId::new(indexed_models.len() as u32);
|
||||
let indexed_model_id=model::MeshId::new(meshes.len() as u32);
|
||||
indexed_model_id_from_description.insert(basepart_texture_description.clone(),indexed_model_id);//borrow checker going crazy
|
||||
indexed_models.push(match basepart_texture_description{
|
||||
meshes.push(match basepart_texture_description{
|
||||
RobloxBasePartDescription::Sphere(part_texture_description)
|
||||
|RobloxBasePartDescription::Cylinder(part_texture_description)
|
||||
|RobloxBasePartDescription::Part(part_texture_description)=>{
|
||||
@ -678,7 +678,7 @@ pub fn convert(dom:rbx_dom_weak::WeakDom)->map::Map{
|
||||
&mut wormhole_in_model_to_id,
|
||||
);
|
||||
models1.push(ModelOwnedAttributes{
|
||||
model:indexed_model_id,
|
||||
mesh:indexed_model_id,
|
||||
transform:model_transform,
|
||||
color:glam::vec4(color3.r as f32/255f32, color3.g as f32/255f32, color3.b as f32/255f32, 1.0-*transparency),
|
||||
attributes,
|
||||
@ -710,19 +710,17 @@ pub fn convert(dom:rbx_dom_weak::WeakDom)->map::Map{
|
||||
unique_attributes.push(model1.attributes);
|
||||
attributes_id
|
||||
};
|
||||
(model_id,model::Model{
|
||||
model:model1.model,
|
||||
model::Model{
|
||||
mesh:model1.mesh,
|
||||
transform:model1.transform,
|
||||
color:model1.color,
|
||||
attributes:attributes_id,
|
||||
})
|
||||
}
|
||||
}).collect();
|
||||
map::Map{
|
||||
textures:Vec::new(),//asset_id_from_texture_id.iter().map(|t|t.to_string()).collect(),
|
||||
indexed_models:indexed_models.into_iter().enumerate()
|
||||
.map(|(indexed_model_id,indexed_model)|
|
||||
(model::IndexedModelId::new(indexed_model_id as u32),indexed_model)
|
||||
).collect(),
|
||||
map::CompleteMap{
|
||||
textures:Vec::new(),
|
||||
render_configs:vec![RenderConfig::default()],//asset_id_from_texture_id.iter().map(|t|t.to_string()).collect(),
|
||||
meshes,
|
||||
models,
|
||||
modes:modes_builder.build(),
|
||||
attributes:unique_attributes,
|
||||
|
Loading…
Reference in New Issue
Block a user