Compare commits

...

3 commits

Author SHA1 Message Date
yuni b87f792252 add choker AR avatar to Luna 2024-11-05 05:28:31 +01:00
yuni f3e70cef15 allow arbitrary number of ar avatars for npcs 2024-11-05 05:27:36 +01:00
yuni c195e91bef cargo fmt 2024-11-05 04:47:26 +01:00
9 changed files with 258 additions and 57 deletions

BIN
assets/models/ar_choker.bin Normal file

Binary file not shown.

View file

@ -0,0 +1,234 @@
{
"asset":{
"generator":"Khronos glTF Blender I/O v4.2.70",
"version":"2.0"
},
"scene":0,
"scenes":[
{
"name":"Scene",
"nodes":[
0
]
}
],
"nodes":[
{
"mesh":0,
"name":"Cylinder",
"rotation":[
0.2990456521511078,
0,
0,
0.9542388319969177
],
"scale":[
0.1190018355846405,
0.02275676839053631,
0.1190018355846405
],
"translation":[
0,
0.5599928498268127,
0.07695265114307404
]
}
],
"materials":[
{
"doubleSided":true,
"name":"Denim",
"pbrMetallicRoughness":{
"baseColorTexture":{
"index":0
},
"metallicFactor":0.7063491940498352,
"roughnessFactor":0.841269850730896
}
},
{
"doubleSided":true,
"name":"Metal",
"pbrMetallicRoughness":{
"baseColorFactor":[
0.6014198064804077,
0.6014198064804077,
0.6014198064804077,
1
],
"metallicFactor":0.9047619104385376,
"roughnessFactor":0.119047611951828
}
}
],
"meshes":[
{
"name":"Cylinder",
"primitives":[
{
"attributes":{
"POSITION":0,
"NORMAL":1,
"TEXCOORD_0":2
},
"indices":3,
"material":0
},
{
"attributes":{
"POSITION":4,
"NORMAL":5,
"TEXCOORD_0":6
},
"indices":7,
"material":1
}
]
}
],
"textures":[
{
"sampler":0,
"source":0
}
],
"images":[
{
"mimeType":"image/jpeg",
"name":"denim",
"uri":"textures/denim.jpg"
}
],
"accessors":[
{
"bufferView":0,
"componentType":5126,
"count":224,
"max":[
0.939642608165741,
1.2586437463760376,
1.084672451019287
],
"min":[
-0.9994356036186218,
-2.073982000350952,
-0.9989151358604431
],
"type":"VEC3"
},
{
"bufferView":1,
"componentType":5126,
"count":224,
"type":"VEC3"
},
{
"bufferView":2,
"componentType":5126,
"count":224,
"type":"VEC2"
},
{
"bufferView":3,
"componentType":5123,
"count":798,
"type":"SCALAR"
},
{
"bufferView":4,
"componentType":5126,
"count":63,
"max":[
1.0668237209320068,
0.6634414792060852,
1.251813292503357
],
"min":[
-1.0482804775238037,
-1.274949073791504,
0.17538878321647644
],
"type":"VEC3"
},
{
"bufferView":5,
"componentType":5126,
"count":63,
"type":"VEC3"
},
{
"bufferView":6,
"componentType":5126,
"count":63,
"type":"VEC2"
},
{
"bufferView":7,
"componentType":5123,
"count":168,
"type":"SCALAR"
}
],
"bufferViews":[
{
"buffer":0,
"byteLength":2688,
"byteOffset":0,
"target":34962
},
{
"buffer":0,
"byteLength":2688,
"byteOffset":2688,
"target":34962
},
{
"buffer":0,
"byteLength":1792,
"byteOffset":5376,
"target":34962
},
{
"buffer":0,
"byteLength":1596,
"byteOffset":7168,
"target":34963
},
{
"buffer":0,
"byteLength":756,
"byteOffset":8764,
"target":34962
},
{
"buffer":0,
"byteLength":756,
"byteOffset":9520,
"target":34962
},
{
"buffer":0,
"byteLength":504,
"byteOffset":10276,
"target":34962
},
{
"buffer":0,
"byteLength":336,
"byteOffset":10780,
"target":34963
}
],
"samplers":[
{
"magFilter":9729,
"minFilter":9987
}
],
"buffers":[
{
"byteLength":11116,
"uri":"ar_choker.bin"
}
]
}

View file

@ -29,7 +29,11 @@ fn main() -> std::io::Result<()> {
write!(&file, "[\n")?;
extract_scene(&mut file, "test", "src/blender/scene_test.blend")?;
extract_scene(&mut file, "workshop", "src/blender/scene_workshop.blend")?;
extract_scene(&mut file, "greenhouse", "src/blender/scene_greenhouse.blend")?;
extract_scene(
&mut file,
"greenhouse",
"src/blender/scene_greenhouse.blend",
)?;
write!(&file, "]\n")?;
}
Ok(())

BIN
src/blender/ar_choker.blend Normal file

Binary file not shown.

View file

@ -126,9 +126,7 @@ struct ParserState {
suit_integrity: f32,
light_brightness: f32,
light_color: Option<Color>,
ar_model: Option<String>,
ar_model2: Option<String>,
ar_model3: Option<String>,
ar_models: Vec<String>,
show_only_in_map_at_distance: Option<(f64, String)>,
}
impl Default for ParserState {
@ -190,9 +188,7 @@ impl Default for ParserState {
suit_integrity: 1.0,
light_brightness: 0.0,
light_color: None,
ar_model: None,
ar_model2: None,
ar_model3: None,
ar_models: vec![],
show_only_in_map_at_distance: None,
}
}
@ -693,13 +689,7 @@ pub fn load_defs(mut ew_spawn: EventWriter<SpawnEvent>) {
state.wants_matchvelocity_id = Some(id.to_string());
}
["armodel", asset_name] => {
state.ar_model = Some(asset_name.to_string());
}
["armodel_secondary", asset_name] => {
state.ar_model2 = Some(asset_name.to_string());
}
["armodel_tertiary", asset_name] => {
state.ar_model3 = Some(asset_name.to_string());
state.ar_models.push(asset_name.to_string());
}
["targeted", "yes"] => {
state.is_targeted_on_startup = true;
@ -1246,7 +1236,7 @@ fn spawn_entities(
..default()
});
}
if let Some(_) = state.ar_model {
if !state.ar_models.is_empty() {
actor.insert(hud::AugmentedRealityOverlayBroadcaster);
}
if state.is_player {
@ -1277,7 +1267,7 @@ fn spawn_entities(
}
actor_entity = actor.id();
if let Some(ar_asset_name) = &state.ar_model {
for ar_asset_name in &state.ar_models {
let mut entitycmd = commands.spawn((
hud::AugmentedRealityOverlay {
owner: actor_entity,
@ -1291,41 +1281,7 @@ fn spawn_entities(
NotShadowCaster,
NotShadowReceiver,
));
load_asset(ar_asset_name, &mut entitycmd, &*asset_server);
}
if let Some(ar_asset_name) = &state.ar_model2 {
let mut entitycmd = commands.spawn((
hud::AugmentedRealityOverlay {
owner: actor_entity,
scale: 1.0,
},
world::DespawnOnPlayerDeath,
SpatialBundle {
visibility: Visibility::Hidden,
..default()
},
NotShadowCaster,
NotShadowReceiver,
));
load_asset(ar_asset_name, &mut entitycmd, &*asset_server);
}
if let Some(ar_asset_name) = &state.ar_model3 {
let mut entitycmd = commands.spawn((
hud::AugmentedRealityOverlay {
owner: actor_entity,
scale: 1.0,
},
world::DespawnOnPlayerDeath,
SpatialBundle {
visibility: Visibility::Hidden,
..default()
},
NotShadowCaster,
NotShadowReceiver,
));
load_asset(ar_asset_name, &mut entitycmd, &*asset_server);
load_asset(ar_asset_name.as_str(), &mut entitycmd, &*asset_server);
}
if state.is_point_of_interest || state.is_moon || state.is_planet {

View file

@ -335,8 +335,9 @@ actor 700 -100 -1100 suitv2
id Luna
chatid Luna
armodel suit_ar_skirt
armodel_secondary suit_ar_nekomimi
armodel_tertiary suit_ar_bra
armodel suit_ar_nekomimi
armodel suit_ar_bra
armodel suit_ar_choker
angularmomentum 0 0 0
wants maxrotation 0
wants matchvelocitywith lunaplatform
@ -366,7 +367,7 @@ actor -55e3 31e3 0 suitv2
name "Yuni"
chatid Yuni
armodel suit_ar_skirt
armodel_secondary suit_ar_hoodie
armodel suit_ar_hoodie
rotationx 180
rotationy 90
wants matchvelocitywith thebe

View file

@ -50,7 +50,12 @@ pub const PLAYER_AR_AVATARS: &[(Avatar, &str, f32, &str)] = &[
(Avatar::Hoodie, "suit_ar_hoodie", 1.0, "Hoodie"),
(Avatar::HoodieUp, "suit_ar_hoodie_up", 1.0, "Hoodie Up"),
(Avatar::Skirt, "suit_ar_skirt", 1.0, "Skirt"),
(Avatar::SkirtTartan, "suit_ar_skirt_tartan", 1.0, "Tartan Skirt"),
(
Avatar::SkirtTartan,
"suit_ar_skirt_tartan",
1.0,
"Tartan Skirt",
),
(Avatar::Dress, "suit_ar_dress", 1.0, "Dress"),
(Avatar::Nekomimi, "suit_ar_nekomimi", 1.0, "Cat Ears"),
(Avatar::Wings, "suit_ar_wings", 1.0, "Wings"),

View file

@ -33,6 +33,7 @@ pub fn asset_name_to_path(name: &str) -> &'static str {
"suit_ar_armor" => "models/ar_armor.gltf#Scene0",
"suit_ar_bra" => "models/ar_bra.gltf#Scene0",
"suit_ar_chefhat" => "models/suit_v2/ar_chefhat.glb#Scene0",
"suit_ar_choker" => "models/ar_choker.gltf#Scene0",
"suit_ar_nekomimi" => "models/ar_nekomimi.gltf#Scene0",
"suit_ar_hoodie" => "models/ar_hoodie.gltf#Scene0",
"suit_ar_hoodie_up" => "models/ar_hoodie_up.gltf#Scene0",