Added sail boat

This commit is contained in:
Joshua Barretto 2021-09-01 23:48:50 +01:00
parent 4aa8a6bb42
commit bfbca3e517
13 changed files with 85 additions and 31 deletions

View File

@ -47,4 +47,26 @@
central: ("air_balloon.rudder"),
),
),
SailBoat: (
bone0: (
offset: (-6.5, -15.5, 0.0),
phys_offset: (0.0, 0.0, 0.0),
central: ("sail_boat.structure"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
phys_offset: (0.0, 0.0, 0.0),
central: ("empty"),
),
bone2: (
offset: (0.0, 0.0, 0.0),
phys_offset: (0.0, 0.0, 0.0),
central: ("empty"),
),
bone3: (
offset: (-1.5, -6.0, -5.0),
phys_offset: (0.0, 0.0, 0.0),
central: ("empty"),
),
),
})

BIN
assets/server/voxel/sail_boat/structure.vox (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -7,26 +7,26 @@
),
(
specifier: "world.shrub.jungle-bush-0",
center: (5, 5, 1),
center: (5, 5, 3),
),
(
specifier: "world.shrub.jungle-bush-1",
center: (5, 5, 1),
center: (5, 5, 2),
),
(
specifier: "world.shrub.jungle-bush-2",
center: (5, 5, 1),
center: (5, 5, 3),
),
(
specifier: "world.shrub.jungle-bush-3",
center: (5, 5, 1),
center: (5, 5, 3),
),
(
specifier: "world.shrub.jungle-bush-4",
center: (5, 5, 1),
center: (5, 5, 4),
),
(
specifier: "world.shrub.jungle-bush-5",
center: (5, 5, 1),
center: (5, 5, 5),
),
]

BIN
assets/world/shrub/jungle-bush-0.vox (Stored with Git LFS)

Binary file not shown.

BIN
assets/world/shrub/jungle-bush-1.vox (Stored with Git LFS)

Binary file not shown.

BIN
assets/world/shrub/jungle-bush-2.vox (Stored with Git LFS)

Binary file not shown.

BIN
assets/world/shrub/jungle-bush-3.vox (Stored with Git LFS)

Binary file not shown.

BIN
assets/world/shrub/jungle-bush-4.vox (Stored with Git LFS)

Binary file not shown.

BIN
assets/world/shrub/jungle-bush-5.vox (Stored with Git LFS)

Binary file not shown.

View File

@ -854,6 +854,7 @@ impl Body {
Body::Ship(ship) => match ship {
ship::Body::DefaultAirship => [0.0, 0.0, 10.0],
ship::Body::AirBalloon => [0.0, 0.0, 5.0],
ship::Body::SailBoat => [-2.0, -5.0, 4.0],
},
_ => [0.0, 0.0, 0.0],
}

View File

@ -1,13 +1,13 @@
use crate::{
comp::{Density, Mass},
consts::AIR_DENSITY,
consts::{AIR_DENSITY, WATER_DENSITY},
make_case_elim,
};
use rand::prelude::SliceRandom;
use serde::{Deserialize, Serialize};
use vek::Vec3;
pub const ALL_BODIES: [Body; 2] = [Body::DefaultAirship, Body::AirBalloon];
pub const ALL_BODIES: [Body; 3] = [Body::DefaultAirship, Body::AirBalloon, Body::SailBoat];
make_case_elim!(
body,
@ -16,6 +16,7 @@ make_case_elim!(
pub enum Body {
DefaultAirship = 0,
AirBalloon = 1,
SailBoat = 2,
}
);
@ -35,6 +36,7 @@ impl Body {
match self {
Body::DefaultAirship => "airship_human.structure",
Body::AirBalloon => "air_balloon.structure",
Body::SailBoat => "sail_boat.structure",
}
}
@ -42,15 +44,21 @@ impl Body {
match self {
Body::DefaultAirship => Vec3::new(25.0, 50.0, 40.0),
Body::AirBalloon => Vec3::new(25.0, 50.0, 40.0),
Body::SailBoat => Vec3::new(13.0, 31.0, 6.0),
}
}
fn balloon_vol(&self) -> f32 {
let spheroid_vol = |equat_d: f32, polar_d: f32| -> f32 {
(std::f32::consts::PI / 6.0) * equat_d.powi(2) * polar_d
};
let dim = self.dimensions();
spheroid_vol(dim.z, dim.y)
match self {
Body::DefaultAirship | Body::AirBalloon => {
let spheroid_vol = |equat_d: f32, polar_d: f32| -> f32 {
(std::f32::consts::PI / 6.0) * equat_d.powi(2) * polar_d
};
let dim = self.dimensions();
spheroid_vol(dim.z, dim.y)
},
_ => 0.0,
}
}
fn hull_vol(&self) -> f32 {
@ -66,15 +74,25 @@ impl Body {
Density(ratio * oak_density + (1.0 - ratio) * AIR_DENSITY)
}
pub fn density(&self) -> Density { Density(AIR_DENSITY) }
pub fn density(&self) -> Density {
match self {
Body::DefaultAirship | Body::AirBalloon => Density(AIR_DENSITY),
_ => Density(AIR_DENSITY * 0.75 + WATER_DENSITY * 0.25), // Most boats should be buoyant
}
}
pub fn mass(&self) -> Mass { Mass((self.hull_vol() + self.balloon_vol()) * self.density().0) }
pub fn can_fly(&self) -> bool {
match self {
Body::DefaultAirship | Body::AirBalloon => true,
_ => false,
}
}
pub fn has_water_thrust(&self) -> bool {
!self.can_fly() // TODO: Differentiate this more carefully
}
}
/// Terrain is 11.0 scale relative to small-scale voxels,

View File

@ -200,6 +200,8 @@ impl Body {
Body::QuadrupedLow(_) => Some(300.0 * self.mass().0),
Body::QuadrupedMedium(_) => Some(300.0 * self.mass().0),
Body::QuadrupedSmall(_) => Some(300.0 * self.mass().0),
Body::Ship(ship) if ship.has_water_thrust() => Some(500.0 * self.mass().0),
_ => None,
}
}

View File

@ -31,7 +31,9 @@ impl Skeleton for ShipSkeleton {
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
body: Self::Body,
) -> Offsets {
let bone0_mat = base_mat * Mat4::scaling_3d(1.0 / 11.0) * Mat4::<f32>::from(self.bone0);
let scale_mat = Mat4::scaling_3d(1.0 / 11.0);
let bone0_mat = base_mat * scale_mat * Mat4::<f32>::from(self.bone0);
*(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [
make_bone(bone0_mat),
@ -43,10 +45,12 @@ impl Skeleton for ShipSkeleton {
lantern: None,
// TODO: see quadruped_medium for how to animate this
mount_bone: Transform {
position: common::comp::Body::Ship(body)
.mountee_offset()
.into_tuple()
.into(),
position: (base_mat * scale_mat).mul_point(
common::comp::Body::Ship(body)
.mountee_offset()
.into_tuple()
.into(),
),
..Default::default()
},
}
@ -89,18 +93,22 @@ impl<'a> From<&'a Body> for SkeletonAttr {
bone0: match body {
DefaultAirship => (0.0, 0.0, 0.0),
AirBalloon => (0.0, 0.0, 0.0),
SailBoat => (0.0, 0.0, 0.0),
},
bone1: match body {
DefaultAirship => (-13.0, -25.0, 10.0),
AirBalloon => (0.0, 0.0, 0.0),
SailBoat => (0.0, 0.0, 0.0),
},
bone2: match body {
DefaultAirship => (13.0, -25.0, 10.0),
AirBalloon => (0.0, 0.0, 0.0),
SailBoat => (0.0, 0.0, 0.0),
},
bone3: match body {
DefaultAirship => (0.0, -27.5, 8.5),
AirBalloon => (0.0, -9.0, 8.0),
SailBoat => (0.0, 0.0, 0.0),
},
}
}