cleanup. bringing in ncollider
This commit is contained in:
150
src/main.rs
150
src/main.rs
@@ -24,7 +24,6 @@ mod framework;
|
||||
mod geometry;
|
||||
mod light;
|
||||
mod render;
|
||||
mod runtime;
|
||||
|
||||
/*
|
||||
|
||||
@@ -78,17 +77,6 @@ pub enum ShaderStage {
|
||||
Compute,
|
||||
}
|
||||
|
||||
/*
|
||||
window: winit::window::Window,
|
||||
event_loop: EventLoop<()>,
|
||||
instance: wgpu::Instance,
|
||||
size: winit::dpi::PhysicalSize<u32>,
|
||||
surface: wgpu::Surface,
|
||||
adapter: wgpu::Adapter,
|
||||
device: wgpu::Device,
|
||||
queue: wgpu::Queue,
|
||||
*/
|
||||
|
||||
// a component is any type that is 'static, sized, send and sync
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct Position {
|
||||
@@ -217,76 +205,9 @@ fn main() {
|
||||
// Load up the renderer (and the resources)
|
||||
let mut renderer = render::Renderer::init(window);
|
||||
|
||||
let untitled_mesh =
|
||||
renderer.load_mesh_to_buffer("./resources/monkey.obj");
|
||||
|
||||
// This could be used for relationships between entities...???
|
||||
let light_entity: Entity = world.push((
|
||||
cgmath::Point3 {
|
||||
x: 7.0 as f32,
|
||||
y: -5.0 as f32,
|
||||
z: 10.0 as f32,
|
||||
},
|
||||
renderer.create_light(),
|
||||
));
|
||||
|
||||
let light_entity: Entity = world.push((
|
||||
cgmath::Point3 {
|
||||
x: -5.0 as f32,
|
||||
y: 7.0 as f32,
|
||||
z: 10.0 as f32,
|
||||
},
|
||||
renderer.create_light(),
|
||||
));
|
||||
|
||||
let offset = cgmath::vec3(2.0, 2.0, 2.0);
|
||||
let transform = Decomposed {
|
||||
disp: offset.clone(),
|
||||
rot: Quaternion::from_axis_angle(offset.normalize(), Deg(50.0)),
|
||||
scale: 1.0,
|
||||
};
|
||||
|
||||
let mesh_entity: Entity = world.push((
|
||||
Position {
|
||||
x: 17.0,
|
||||
y: 15.0,
|
||||
z: 10.0,
|
||||
mx: cgmath::Matrix4::from(transform),
|
||||
},
|
||||
untitled_mesh,
|
||||
Color {
|
||||
r: 1.0,
|
||||
g: 0.5,
|
||||
b: 0.5,
|
||||
a: 1.0,
|
||||
},
|
||||
));
|
||||
|
||||
let plane_mesh =
|
||||
renderer.create_plane(7.0);
|
||||
|
||||
// let plane_entity: Entity = world.push((
|
||||
// Position {
|
||||
// x: 0.0,
|
||||
// y: 0.0,
|
||||
// z: 0.0,
|
||||
// mx: cgmath::Matrix4::identity(),
|
||||
// },
|
||||
// plane_mesh,
|
||||
// Color {
|
||||
// r: 1.0,
|
||||
// g: 0.5,
|
||||
// b: 0.5,
|
||||
// a: 1.0,
|
||||
// },
|
||||
// ));
|
||||
|
||||
|
||||
// Init, this wants the references to the buffers...
|
||||
let mut runtime = runtime::Runtime::init();
|
||||
entity_loading(&mut world, &mut renderer);
|
||||
|
||||
let mut resources = Resources::default();
|
||||
resources.insert(runtime);
|
||||
resources.insert(renderer);
|
||||
|
||||
// This is just an winit event loop
|
||||
@@ -372,3 +293,72 @@ fn main() {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
pub fn entity_loading(world: &mut World, renderer: &mut Renderer) {
|
||||
|
||||
let untitled_mesh =
|
||||
renderer.load_mesh_to_buffer("./resources/monkey.obj");
|
||||
|
||||
// This could be used for relationships between entities...???
|
||||
let light_entity: Entity = world.push((
|
||||
cgmath::Point3 {
|
||||
x: 7.0 as f32,
|
||||
y: -5.0 as f32,
|
||||
z: 10.0 as f32,
|
||||
},
|
||||
renderer.create_light(),
|
||||
));
|
||||
|
||||
let light_entity: Entity = world.push((
|
||||
cgmath::Point3 {
|
||||
x: -5.0 as f32,
|
||||
y: 7.0 as f32,
|
||||
z: 10.0 as f32,
|
||||
},
|
||||
renderer.create_light(),
|
||||
));
|
||||
|
||||
let offset = cgmath::vec3(2.0, 2.0, 2.0);
|
||||
let transform = Decomposed {
|
||||
disp: offset.clone(),
|
||||
rot: Quaternion::from_axis_angle(offset.normalize(), Deg(50.0)),
|
||||
scale: 1.0,
|
||||
};
|
||||
|
||||
let mesh_entity: Entity = world.push((
|
||||
Position {
|
||||
x: 17.0,
|
||||
y: 15.0,
|
||||
z: 10.0,
|
||||
mx: cgmath::Matrix4::from(transform),
|
||||
},
|
||||
untitled_mesh,
|
||||
Color {
|
||||
r: 1.0,
|
||||
g: 0.5,
|
||||
b: 0.5,
|
||||
a: 1.0,
|
||||
},
|
||||
));
|
||||
|
||||
let plane_mesh =
|
||||
renderer.create_plane(7.0);
|
||||
|
||||
let plane_entity: Entity = world.push((
|
||||
Position {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 0.0,
|
||||
mx: cgmath::Matrix4::identity(),
|
||||
},
|
||||
plane_mesh,
|
||||
Color {
|
||||
r: 1.0,
|
||||
g: 0.5,
|
||||
b: 0.5,
|
||||
a: 1.0,
|
||||
},
|
||||
));
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user