strange things are afoot at the circle-K
This commit is contained in:
@@ -12,7 +12,8 @@ raw-window-handle = "0.3"
|
|||||||
smallvec = "1"
|
smallvec = "1"
|
||||||
tracing = { version = "0.1", default-features = false, features = ["std"] }
|
tracing = { version = "0.1", default-features = false, features = ["std"] }
|
||||||
typed-arena = "2.0.1"
|
typed-arena = "2.0.1"
|
||||||
serde = { version = "1", features = ["derive"], optional = true }
|
serde = "1.0.123"
|
||||||
|
serde_derive = "1.0.123"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
env_logger = "0.8.3"
|
env_logger = "0.8.3"
|
||||||
png = "0.16"
|
png = "0.16"
|
||||||
@@ -27,7 +28,7 @@ gilrs = "0.8.0"
|
|||||||
gfx-backend-vulkan = { version = "0.6", features = ["x11"] }
|
gfx-backend-vulkan = { version = "0.6", features = ["x11"] }
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
crossbeam = "0.8.0"
|
crossbeam = "0.8.0"
|
||||||
config = "0.10.1"
|
toml = "0.5.8"
|
||||||
|
|
||||||
cgmath = "0.18.0"
|
cgmath = "0.18.0"
|
||||||
rapier3d = { version = "0.5.0", features = ["simd-nightly", "parallel"] }
|
rapier3d = { version = "0.5.0", features = ["simd-nightly", "parallel"] }
|
||||||
|
|||||||
@@ -8,6 +8,11 @@ name = "ball.1"
|
|||||||
type = "PhysicsEntity"
|
type = "PhysicsEntity"
|
||||||
mesh = "ball.obj"
|
mesh = "ball.obj"
|
||||||
|
|
||||||
|
[entities.position]
|
||||||
|
x = 0.0
|
||||||
|
y = 0.0
|
||||||
|
z = 0.0
|
||||||
|
|
||||||
[[entities]]
|
[[entities]]
|
||||||
name = "camera.1"
|
name = "camera.1"
|
||||||
type = "Camera"
|
type = "Camera"
|
||||||
|
|||||||
@@ -5,6 +5,10 @@ extern crate lazy_static;
|
|||||||
extern crate tobj;
|
extern crate tobj;
|
||||||
extern crate winit_24;
|
extern crate winit_24;
|
||||||
extern crate env_logger;
|
extern crate env_logger;
|
||||||
|
extern crate toml;
|
||||||
|
#[macro_use]
|
||||||
|
extern crate serde_derive;
|
||||||
|
|
||||||
|
|
||||||
use std::f32::consts::PI;
|
use std::f32::consts::PI;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
@@ -42,7 +46,6 @@ use winit_24::{
|
|||||||
event::{self, WindowEvent},
|
event::{self, WindowEvent},
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::{ControlFlow, EventLoop},
|
||||||
};
|
};
|
||||||
use config::File;
|
|
||||||
|
|
||||||
use crate::camera::{Camera, CameraController};
|
use crate::camera::{Camera, CameraController};
|
||||||
use crate::components::{Collider, ImguiWindow, LoopState, Physics, Position};
|
use crate::components::{Collider, ImguiWindow, LoopState, Physics, Position};
|
||||||
@@ -55,7 +58,6 @@ use std::fs;
|
|||||||
use winit_24::event::{VirtualKeyCode, ElementState};
|
use winit_24::event::{VirtualKeyCode, ElementState};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use futures::FutureExt;
|
use futures::FutureExt;
|
||||||
use config::Config;
|
|
||||||
use log::LevelFilter;
|
use log::LevelFilter;
|
||||||
use crate::runtime::state::RuntimeState;
|
use crate::runtime::state::RuntimeState;
|
||||||
use winit_24::event_loop::EventLoopProxy;
|
use winit_24::event_loop::EventLoopProxy;
|
||||||
|
|||||||
@@ -2,10 +2,9 @@ use std::collections::HashMap;
|
|||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
use serde_derive::Deserialize;
|
||||||
|
|
||||||
use cgmath::{Euler, Quaternion};
|
use cgmath::{Euler, Quaternion, Deg};
|
||||||
use config::{Config, Value};
|
|
||||||
use config::File;
|
|
||||||
use legion::world::SubWorld;
|
use legion::world::SubWorld;
|
||||||
use legion::IntoQuery;
|
use legion::IntoQuery;
|
||||||
use legion::*;
|
use legion::*;
|
||||||
@@ -13,10 +12,10 @@ use nalgebra::Quaternion as naQuaternion;
|
|||||||
use rapier3d::dynamics::{IntegrationParameters, JointSet, RigidBodySet};
|
use rapier3d::dynamics::{IntegrationParameters, JointSet, RigidBodySet};
|
||||||
use rapier3d::geometry::{BroadPhase, ColliderSet, NarrowPhase};
|
use rapier3d::geometry::{BroadPhase, ColliderSet, NarrowPhase};
|
||||||
use rapier3d::pipeline::PhysicsPipeline;
|
use rapier3d::pipeline::PhysicsPipeline;
|
||||||
|
|
||||||
use crate::camera::{Camera, CameraController};
|
use crate::camera::{Camera, CameraController};
|
||||||
use crate::components::{Collider, LoopState, Mesh, Physics, Position};
|
use crate::components::{Collider, LoopState, Mesh, Physics, Position};
|
||||||
use crate::geometry::{load_obj, RawMesh};
|
use crate::geometry::{load_obj, RawMesh};
|
||||||
|
use std::io::Read;
|
||||||
|
|
||||||
pub struct EntityMeta {
|
pub struct EntityMeta {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
@@ -26,17 +25,42 @@ pub struct EntityMeta {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct RuntimeState {
|
pub struct RuntimeState {
|
||||||
config_db: Config,
|
config_db: TomlEntityContainer,
|
||||||
mesh_cache: HashMap<String, RawMesh>,
|
mesh_cache: HashMap<String, RawMesh>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
pub struct TomlPositionDescription {
|
||||||
|
pub x: f32,
|
||||||
|
pub y: f32,
|
||||||
|
pub z: f32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
pub struct TomlEntityDescription {
|
||||||
|
pub name: String,
|
||||||
|
#[serde(rename = "type")]
|
||||||
|
pub type_name: String,
|
||||||
|
pub mesh: Option<String>,
|
||||||
|
pub position: Option<TomlPositionDescription>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
pub struct TomlEntityContainer {
|
||||||
|
pub entities: Vec<TomlEntityDescription>,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
impl RuntimeState {
|
impl RuntimeState {
|
||||||
pub fn new() -> RuntimeState {
|
pub fn new() -> RuntimeState {
|
||||||
let mut settings = Config::default();
|
let mut file = fs::File::open("./conf/entity_spawns.toml").unwrap();
|
||||||
settings
|
let mut content = String::new();
|
||||||
// File::with_name(..) is shorthand for File::from(Path::new(..))
|
file.read_to_string(&mut content).unwrap();
|
||||||
.merge(File::with_name("conf/entity_spawns.toml"))
|
let mut settings : TomlEntityContainer = toml::from_str(content.as_str()).unwrap();
|
||||||
.unwrap();
|
// settings
|
||||||
|
// // File::with_name(..) is shorthand for File::from(Path::new(..))
|
||||||
|
// .merge(File::with_name("conf/entity_spawns.toml"))
|
||||||
|
// .unwrap();
|
||||||
|
|
||||||
RuntimeState {
|
RuntimeState {
|
||||||
config_db: settings,
|
config_db: settings,
|
||||||
@@ -50,24 +74,35 @@ impl RuntimeState {
|
|||||||
|
|
||||||
pub fn get_configured_entities(&mut self) -> Vec<EntityMeta> {
|
pub fn get_configured_entities(&mut self) -> Vec<EntityMeta> {
|
||||||
let mut out = Vec::new();
|
let mut out = Vec::new();
|
||||||
for entity in self.config_db.get_array("entities").unwrap() {
|
for entity in &self.config_db.entities {
|
||||||
let table = entity.into_table().unwrap();
|
|
||||||
|
|
||||||
let mesh = match table.get("mesh") {
|
let position = match &entity.position {
|
||||||
None => { None }
|
None => { None }
|
||||||
Some(v) => { Some(v.kind.to_string())}
|
Some(pos) => {
|
||||||
|
|
||||||
|
Some(Position {
|
||||||
|
x: pos.x,
|
||||||
|
y: pos.y,
|
||||||
|
z: pos.z,
|
||||||
|
rot: Euler {
|
||||||
|
x: Deg(0.0),
|
||||||
|
y: Deg(0.0),
|
||||||
|
z: Deg(0.0)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// let position = match table.get("position") {
|
// log::info!("{:?}", position);
|
||||||
// None => { None }
|
// log::info!("{:?}", entity);
|
||||||
// Some(v) => { Some(v.kind.to_string())}
|
// log::info!("{:?}", entity.into_table());
|
||||||
// };
|
// log::info!("{:?}", entity.into_array());
|
||||||
|
|
||||||
out.push(EntityMeta {
|
out.push(EntityMeta {
|
||||||
name: table.get("name").unwrap().kind.to_string(),
|
name: entity.name.clone(),
|
||||||
ent_type: table.get("type").unwrap().kind.to_string(),
|
ent_type: entity.type_name.clone(),
|
||||||
mesh: mesh,
|
mesh: entity.mesh.clone(),
|
||||||
position: None
|
position: position
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
out
|
out
|
||||||
|
|||||||
@@ -189,9 +189,9 @@ pub fn runtime_spawn(
|
|||||||
|
|
||||||
let light_entity: Entity = cmd.push((
|
let light_entity: Entity = cmd.push((
|
||||||
Position {
|
Position {
|
||||||
x: 0.0,
|
x: 5.0,
|
||||||
y: 0.0,
|
y: 10.0,
|
||||||
z: 0.0,
|
z: 5.0,
|
||||||
rot: Euler {
|
rot: Euler {
|
||||||
x: Deg(0.0),
|
x: Deg(0.0),
|
||||||
y: Deg(-25.0),
|
y: Deg(-25.0),
|
||||||
|
|||||||
Reference in New Issue
Block a user