implement collider/mass commands
This commit is contained in:
parent
349e38e848
commit
bb73b1ed1d
|
@ -12,6 +12,11 @@ actor 1000 20 300 monolith
|
||||||
rotationx 0.5
|
rotationx 0.5
|
||||||
angularmomentum 0.0 0.0 0.01
|
angularmomentum 0.0 0.0 0.01
|
||||||
|
|
||||||
|
actor 10 20 30 monolith
|
||||||
|
scale 2
|
||||||
|
rotationx 0.5
|
||||||
|
angularmomentum 0.0 0.0 0.01
|
||||||
|
|
||||||
actor 10000 2000 -3500 monolith
|
actor 10000 2000 -3500 monolith
|
||||||
scale 2
|
scale 2
|
||||||
rotationx 0.5
|
rotationx 0.5
|
||||||
|
@ -97,6 +102,8 @@ actor 10 -30 20 MeteorAceGT
|
||||||
vehicle yes
|
vehicle yes
|
||||||
thrust 70 13.7 9.4 0.5 20
|
thrust 70 13.7 9.4 0.5 20
|
||||||
engine ion
|
engine ion
|
||||||
|
collider sphere 2
|
||||||
|
mass 500
|
||||||
|
|
||||||
actor 10 0 70 suit
|
actor 10 0 70 suit
|
||||||
name Icarus
|
name Icarus
|
||||||
|
|
41
src/world.rs
41
src/world.rs
|
@ -87,6 +87,7 @@ pub fn setup(
|
||||||
RigidBody::Dynamic,
|
RigidBody::Dynamic,
|
||||||
AngularVelocity(Vec3::new(0.0, 0.0, 0.0)),
|
AngularVelocity(Vec3::new(0.0, 0.0, 0.0)),
|
||||||
Collider::cuboid(1.0, 1.0, 1.0),
|
Collider::cuboid(1.0, 1.0, 1.0),
|
||||||
|
ColliderDensity(200.0),
|
||||||
actor::Actor {
|
actor::Actor {
|
||||||
angular_momentum: Quat::IDENTITY,
|
angular_momentum: Quat::IDENTITY,
|
||||||
..default()
|
..default()
|
||||||
|
@ -255,6 +256,8 @@ struct ParserState {
|
||||||
warmup_seconds: f32,
|
warmup_seconds: f32,
|
||||||
engine_type: actor::EngineType,
|
engine_type: actor::EngineType,
|
||||||
oxygen: f32,
|
oxygen: f32,
|
||||||
|
mass: f32,
|
||||||
|
collider: Collider,
|
||||||
|
|
||||||
// Chat fields
|
// Chat fields
|
||||||
delay: f64,
|
delay: f64,
|
||||||
|
@ -295,6 +298,8 @@ impl Default for ParserState {
|
||||||
warmup_seconds: default_engine.warmup_seconds,
|
warmup_seconds: default_engine.warmup_seconds,
|
||||||
engine_type: default_engine.engine_type,
|
engine_type: default_engine.engine_type,
|
||||||
oxygen: nature::OXY_D,
|
oxygen: nature::OXY_D,
|
||||||
|
mass: 1.0,
|
||||||
|
collider: Collider::sphere(1.0),
|
||||||
|
|
||||||
delay: 0.0,
|
delay: 0.0,
|
||||||
text: "".to_string(),
|
text: "".to_string(),
|
||||||
|
@ -366,6 +371,13 @@ impl ParserState {
|
||||||
scene: asset_server.load(asset_name_to_path(self.model.as_str())),
|
scene: asset_server.load(asset_name_to_path(self.model.as_str())),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Physics Parameters
|
||||||
|
let fix_scale = 1.0 / self.model_scale.powf(3.0);
|
||||||
|
actor.insert(RigidBody::Dynamic);
|
||||||
|
actor.insert(self.collider.clone());
|
||||||
|
actor.insert(ColliderDensity(self.mass * fix_scale));
|
||||||
|
|
||||||
if self.is_lifeform {
|
if self.is_lifeform {
|
||||||
actor.insert(actor::LifeForm::default());
|
actor.insert(actor::LifeForm::default());
|
||||||
actor.insert(actor::Suit {
|
actor.insert(actor::Suit {
|
||||||
|
@ -392,8 +404,6 @@ impl ParserState {
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
actor.insert(RigidBody::Dynamic);
|
|
||||||
actor.insert(Collider::cuboid(1.0, 1.0, 1.0));
|
|
||||||
|
|
||||||
//info!("Spawning actor {} with model {} at {}/{}/{}",
|
//info!("Spawning actor {} with model {} at {}/{}/{}",
|
||||||
// self.name, self.model, self.pos.x, self.pos.y, self.pos.z);
|
// self.name, self.model, self.pos.x, self.pos.y, self.pos.z);
|
||||||
|
@ -550,6 +560,33 @@ pub fn load_defs(
|
||||||
["engine", "ion"] => {
|
["engine", "ion"] => {
|
||||||
state.engine_type = actor::EngineType::Ion;
|
state.engine_type = actor::EngineType::Ion;
|
||||||
}
|
}
|
||||||
|
["mass", value] => {
|
||||||
|
if let Ok(value_float) = value.parse::<f32>() {
|
||||||
|
state.mass = value_float;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
error!("Can't parse float: {line}");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
["collider", "sphere", radius] => {
|
||||||
|
if let Ok(radius_float) = radius.parse::<f32>() {
|
||||||
|
state.collider = Collider::sphere(radius_float);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
error!("Can't parse float: {line}");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
["collider", "capsule", height, radius] => {
|
||||||
|
if let (Ok(height_float), Ok(radius_float)) = (height.parse::<f32>(), radius.parse::<f32>()) {
|
||||||
|
state.collider = Collider::capsule(height_float, radius_float);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
error!("Can't parse float: {line}");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Parsing chats
|
// Parsing chats
|
||||||
["chat", chat_name] => {
|
["chat", chat_name] => {
|
||||||
|
|
Loading…
Reference in a new issue