Compare commits

...

2 commits

9 changed files with 220 additions and 27 deletions

BIN
assets/models/asteroid1.bin Normal file

Binary file not shown.

View file

@ -0,0 +1,137 @@
{
"asset":{
"generator":"Khronos glTF Blender I/O v4.2.70",
"version":"2.0"
},
"scene":0,
"scenes":[
{
"name":"Scene",
"nodes":[
0
]
}
],
"nodes":[
{
"mesh":0,
"name":"Sphere"
}
],
"materials":[
{
"doubleSided":true,
"name":"Material",
"pbrMetallicRoughness":{
"baseColorTexture":{
"index":0
},
"metallicFactor":0.871999979019165,
"roughnessFactor":0.8320000171661377
}
}
],
"meshes":[
{
"name":"Mesh",
"primitives":[
{
"attributes":{
"POSITION":0,
"NORMAL":1,
"TEXCOORD_0":2
},
"indices":3,
"material":0
}
]
}
],
"textures":[
{
"sampler":0,
"source":0
}
],
"images":[
{
"mimeType":"image/jpeg",
"name":"mercury",
"uri":"textures/mercury.jpg"
}
],
"accessors":[
{
"bufferView":0,
"componentType":5126,
"count":2380,
"max":[
0.9240003824234009,
0.8952103853225708,
0.8966150283813477
],
"min":[
-0.9513141512870789,
-0.9362439513206482,
-0.8992546796798706
],
"type":"VEC3"
},
{
"bufferView":1,
"componentType":5126,
"count":2380,
"type":"VEC3"
},
{
"bufferView":2,
"componentType":5126,
"count":2380,
"type":"VEC2"
},
{
"bufferView":3,
"componentType":5123,
"count":11904,
"type":"SCALAR"
}
],
"bufferViews":[
{
"buffer":0,
"byteLength":28560,
"byteOffset":0,
"target":34962
},
{
"buffer":0,
"byteLength":28560,
"byteOffset":28560,
"target":34962
},
{
"buffer":0,
"byteLength":19040,
"byteOffset":57120,
"target":34962
},
{
"buffer":0,
"byteLength":23808,
"byteOffset":76160,
"target":34963
}
],
"samplers":[
{
"magFilter":9729,
"minFilter":9987
}
],
"buffers":[
{
"byteLength":99968,
"uri":"asteroid1.bin"
}
]
}

View file

@ -9,6 +9,7 @@
// + ▀████████████████████████████████████████████████████▀ // + ▀████████████████████████████████████████████████████▀
use blend::Blend; use blend::Blend;
use std::fs;
use std::fs::File; use std::fs::File;
use std::io::Write; use std::io::Write;
@ -27,13 +28,18 @@ fn main() -> std::io::Result<()> {
"// DO NOT MODIFY MANUALLY, CHANGES WILL BE OVERWRITTEN!\n" "// DO NOT MODIFY MANUALLY, CHANGES WILL BE OVERWRITTEN!\n"
)?; )?;
write!(&file, "[\n")?; write!(&file, "[\n")?;
extract_scene(&mut file, "test", "src/blender/scene_test.blend")?;
extract_scene(&mut file, "workshop", "src/blender/scene_workshop.blend")?; // find all scene_*.blend files and extract+export their scenes
extract_scene( for entry in fs::read_dir("src/blender")? {
&mut file, let path = entry?.path();
"greenhouse", if let Some(file_name) = path.file_name().and_then(|s| s.to_str()) {
"src/blender/scene_greenhouse.blend", if file_name.starts_with("scene_") && file_name.ends_with(".blend") {
)?; let scene_name = &file_name["scene_".len()..file_name.len() - ".blend".len()];
extract_scene(&mut file, scene_name, path.to_str().unwrap())?;
}
}
}
write!(&file, "]\n")?; write!(&file, "]\n")?;
} }
Ok(()) Ok(())

BIN
src/blender/asteroid1.blend Normal file

Binary file not shown.

Binary file not shown.

View file

@ -775,6 +775,7 @@ fn spawn_scenes(
// command: name "Midnight Cruiser" // command: name "Midnight Cruiser"
state.name = Some("Midnight Cruiser".to_string()); state.name = Some("Midnight Cruiser".to_string());
// Ensure consistent scale for this vehicle
// command: scale 5 // command: scale 5
state.model_scale = 5.0; state.model_scale = 5.0;
@ -808,6 +809,46 @@ fn spawn_scenes(
ew_spawn.send(SpawnEvent(state)); ew_spawn.send(SpawnEvent(state));
} }
"whale" => {
state.model = Some("whale".to_string());
// command: name "The Whale"
state.name = Some("The Whale".to_string());
// Ensure consistent scale for this vehicle
// command: scale 300
state.model_scale = 300.0;
// command: vehicle yes
state.is_vehicle = true;
// command: angularmomentum 0 0.015 0
state.angular_momentum = DVec3::new(0.0, 0.015, 0.0);
// command: collider handcrafted
state.collider_is_one_mesh_of_scene = true;
// command: thrust 2.45 0.48 0.33 5000000000000000 3
state.thrust_forward = 2.45;
state.thrust_back = 0.48;
state.thrust_sideways = 0.33;
state.reaction_wheels = 5000000000000000.0;
state.warmup_seconds = 3.0;
// command: engine ion
state.engine_type = actor::EngineType::Ion;
// command: camdistance 4000
state.camdistance = 4000.0;
// command: density 100000
state.density = 100000.0;
// command: pointofinterest yes
state.is_point_of_interest = true;
ew_spawn.send(SpawnEvent(state));
}
"shippingcontainer" => { "shippingcontainer" => {
state.model = Some("shippingcontainer".to_string()); state.model = Some("shippingcontainer".to_string());
@ -933,6 +974,21 @@ fn spawn_scenes(
ew_spawn.send(SpawnEvent(state)); ew_spawn.send(SpawnEvent(state));
} }
"asteroid1" => {
state.model = Some("asteroid1".to_string());
// command: name "Uncharted Asteroid"
state.name = Some("Uncharted Asteroid".to_string());
// command: collider mesh
state.collider_is_one_mesh_of_scene = true;
state.collider_is_mesh = true;
// command: density 5000
state.density = 5000.0;
ew_spawn.send(SpawnEvent(state));
}
_ => { _ => {
error!("Can't find template named `{template}' in cmd::spawn_scenes!"); error!("Can't find template named `{template}' in cmd::spawn_scenes!");
} }

View file

@ -1126,15 +1126,5 @@ actor 0 -44e3 0 clippy
collider mesh collider mesh
scale 5 scale 5
actor 110 0 2000 whale scene 110 0 2000 whale
relativeto busstopclippy3 relativeto busstopclippy3
name "The Whale"
vehicle yes
collider handcrafted
density 100000
camdistance 4000
scale 300
pointofinterest yes
angularmomentum 0 0.015 0
thrust 2.45 0.48 0.33 5000000000000000 3
engine ion

View file

@ -2,13 +2,6 @@
// DO NOT MODIFY MANUALLY, CHANGES WILL BE OVERWRITTEN! // DO NOT MODIFY MANUALLY, CHANGES WILL BE OVERWRITTEN!
[ [
("test", "cruiser", [0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [5.0, 5.0, 5.0]), ("test", "cruiser", [0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [5.0, 5.0, 5.0]),
("workshop", "frameflat", [0.0, 0.0, -21.541874], [0.0, 0.0, 0.0], [30.0, 30.0, 30.0]),
("workshop", "fueltank", [21.074543, -2.4312592, -4.7432747], [1.2519244, -0.0, -0.6819759], [8.0, 8.0, 8.0]),
("workshop", "lightorb", [-15.720036, -32.41476, 4.1765304], [0.0, 0.0, 0.0], [1.0, 1.0, 1.0]),
("workshop", "lightorb", [11.5042095, -21.65356, -4.566242], [0.0, 0.0, 0.0], [1.0, 1.0, 1.0]),
("workshop", "shippingcontainer", [-0.52376616, 12.351211, -2.6598575], [-0.11791781, -0.02345992, 1.5838965], [8.0, 8.0, 8.0]),
("workshop", "shippingcontainer", [-13.479424, 10.191104, -8.136984], [-0.05393797, -0.013098141, 1.7229813], [8.0, 8.0, 8.0]),
("workshop", "shippingcontainer", [12.42811, 14.157182, -4.2369785], [-0.02553346, 0.042504273, 1.5108364], [8.0, 8.0, 8.0]),
("greenhouse", "fueltank", [74.5485, 54.473938, 23.183126], [1.1660392, -0.0, -0.48993048], [8.0, 8.0, 8.0]), ("greenhouse", "fueltank", [74.5485, 54.473938, 23.183126], [1.1660392, -0.0, -0.48993048], [8.0, 8.0, 8.0]),
("greenhouse", "greenhouse", [56.82031, 0.0, 0.0], [0.0, -1.5707964, 0.0], [10.0, 10.0, 10.0]), ("greenhouse", "greenhouse", [56.82031, 0.0, 0.0], [0.0, -1.5707964, 0.0], [10.0, 10.0, 10.0]),
("greenhouse", "mirror", [0.0, -17.0, -10.0], [-0.07591219, 0.0049197352, 1.7143301], [10.0, 10.0, 10.0]), ("greenhouse", "mirror", [0.0, -17.0, -10.0], [-0.07591219, 0.0049197352, 1.7143301], [10.0, 10.0, 10.0]),
@ -29,4 +22,16 @@
("greenhouse", "mirror", [3.0, 0.0, -40.0], [-0.33143952, -7.651644e-10, 1.5707964], [10.0, 10.0, 10.0]), ("greenhouse", "mirror", [3.0, 0.0, -40.0], [-0.33143952, -7.651644e-10, 1.5707964], [10.0, 10.0, 10.0]),
("greenhouse", "mirror", [3.0, 0.0, 40.0], [0.34906584, -3.5681582e-9, 1.5707964], [10.0, 10.0, 10.0]), ("greenhouse", "mirror", [3.0, 0.0, 40.0], [0.34906584, -3.5681582e-9, 1.5707964], [10.0, 10.0, 10.0]),
("greenhouse", "mirrorrotating", [0.0, 17.0, 10.0], [0.0073764813, -0.009006099, 1.2773504], [10.0, 10.0, 10.0]), ("greenhouse", "mirrorrotating", [0.0, 17.0, 10.0], [0.0073764813, -0.009006099, 1.2773504], [10.0, 10.0, 10.0]),
("whale", "asteroid1", [963.7498, 317.89063, -427.3262], [0.0, 0.0, 0.0], [97.1964, 97.1964, 97.1964]),
("whale", "asteroid1", [563.7502, 566.54156, 199.60223], [2.9385161, -0.41958678, 0.31158477], [113.32049, 113.3205, 113.32049]),
("whale", "asteroid1", [-913.92633, -1697.3405, -265.4468], [2.9385161, -0.41958678, 0.31158477], [55.766037, 55.76604, 55.76603]),
("whale", "asteroid1", [485.89554, -1930.715, -1569.6847], [3.227998, -0.72288, 0.06756603], [81.41644, 81.416435, 81.41641]),
("whale", "whale", [0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [300.0, 300.0, 300.0]),
("workshop", "frameflat", [0.0, 0.0, -21.541874], [0.0, 0.0, 0.0], [30.0, 30.0, 30.0]),
("workshop", "fueltank", [21.074543, -2.4312592, -4.7432747], [1.2519244, -0.0, -0.6819759], [8.0, 8.0, 8.0]),
("workshop", "lightorb", [-15.720036, -32.41476, 4.1765304], [0.0, 0.0, 0.0], [1.0, 1.0, 1.0]),
("workshop", "lightorb", [11.5042095, -21.65356, -4.566242], [0.0, 0.0, 0.0], [1.0, 1.0, 1.0]),
("workshop", "shippingcontainer", [-0.52376616, 12.351211, -2.6598575], [-0.11791781, -0.02345992, 1.5838965], [8.0, 8.0, 8.0]),
("workshop", "shippingcontainer", [-13.479424, 10.191104, -8.136984], [-0.05393797, -0.013098141, 1.7229813], [8.0, 8.0, 8.0]),
("workshop", "shippingcontainer", [12.42811, 14.157182, -4.2369785], [-0.02553346, 0.042504273, 1.5108364], [8.0, 8.0, 8.0]),
] ]

View file

@ -42,8 +42,7 @@ pub fn asset_name_to_path(name: &str) -> &'static str {
"suit_ar_dress" => "models/ar_dress.gltf#Scene0", "suit_ar_dress" => "models/ar_dress.gltf#Scene0",
"suit_ar_wings" => "models/suit_v2/ar_wings.glb#Scene0", "suit_ar_wings" => "models/suit_v2/ar_wings.glb#Scene0",
"sus" => "models/sus.glb#Scene0", "sus" => "models/sus.glb#Scene0",
"asteroid1" => "models/asteroid.glb#Scene0", "asteroid1" => "models/asteroid1.gltf#Scene0",
"asteroid2" => "models/asteroid2.glb#Scene0",
"hollow_asteroid" => "models/hollow_asteroid.glb#Scene0", "hollow_asteroid" => "models/hollow_asteroid.glb#Scene0",
"moonlet" => "models/moonlet.glb#Scene0", "moonlet" => "models/moonlet.glb#Scene0",
"monolith" => "models/monolith_neon.glb#Scene0", "monolith" => "models/monolith_neon.glb#Scene0",