engine: re-enable moving lights in demo app
parent
5d318b1875
commit
4d39aee4f5
|
@ -156,8 +156,9 @@ impl Main {
|
|||
impl<'a> ecs::System <'a> for Main {
|
||||
type SystemData = ( ecs::ReadWriteGlobal<'a, render::SceneInfo>
|
||||
, ecs::ReadGlobal<'a, Time>
|
||||
, ecs::ReadWriteComponent<'a, Transform>
|
||||
);
|
||||
fn run(&mut self, (scene_info, time): Self::SystemData) {
|
||||
fn run(&mut self, (scene_info, time, transforms): Self::SystemData) {
|
||||
let position = (time.get().instant() / 10.0) * 3.14 * 2.0;
|
||||
|
||||
let camera = cgm::Point3::new(
|
||||
|
@ -175,16 +176,17 @@ impl<'a> ecs::System <'a> for Main {
|
|||
scene_info.get().camera = camera;
|
||||
scene_info.get().view = view;
|
||||
|
||||
//rm.light_mut(&light1).as_mut().unwrap().position = cgm::Vector3::new(
|
||||
// -0.0 + (position*3.0).sin() * 4.0,
|
||||
// -0.0 + (position*4.0).cos() * 4.0,
|
||||
// -0.0 + (position*2.0).sin() * 3.0,
|
||||
//);
|
||||
//rm.light_mut(&light2).as_mut().unwrap().position = cgm::Vector3::new(
|
||||
// -0.0 + (position*3.0).cos() * 4.0,
|
||||
// -0.0 + (position*4.0).sin() * 4.0,
|
||||
// -0.0 + (position*2.0).cos() * 3.0,
|
||||
//);
|
||||
*transforms.get_mut(self.light1).unwrap() = Transform::at(
|
||||
-0.0 + (position*3.0).sin() * 4.0,
|
||||
-0.0 + (position*4.0).cos() * 4.0,
|
||||
-0.0 + (position*2.0).sin() * 3.0,
|
||||
);
|
||||
|
||||
*transforms.get_mut(self.light2).unwrap() = Transform::at(
|
||||
-0.0 + (position*3.0).cos() * 4.0,
|
||||
-0.0 + (position*4.0).sin() * 4.0,
|
||||
-0.0 + (position*2.0).cos() * 3.0,
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -198,8 +200,8 @@ fn main() {
|
|||
log::info!("Starting...");
|
||||
|
||||
let mut p = Processor::new(&world);
|
||||
p.add_system(renderer);
|
||||
p.add_system(main);
|
||||
p.add_system(renderer);
|
||||
|
||||
let start = time::Instant::now();
|
||||
world.set_global(Time{
|
||||
|
|
|
@ -39,7 +39,7 @@ impl Omni {
|
|||
// M. Krystek. 1985. "An algorithm to calculate correlated color temperature"
|
||||
// Color Research & Application, 10 (1), 38–40.
|
||||
pub fn test() -> Self {
|
||||
Self::with_color(color::XYZ::new(234.7*10.0, 214.1*10.0, 207.9*10.0))
|
||||
Self::with_color(color::XYZ::new(234.7*100.0, 214.1*100.0, 207.9*100.0))
|
||||
}
|
||||
|
||||
pub fn with_color(color: color::XYZ) -> Self{
|
||||
|
|
|
@ -18,6 +18,7 @@ use std::sync::Arc;
|
|||
use std::collections::BTreeMap;
|
||||
|
||||
use cgmath as cgm;
|
||||
use cgmath::SquareMatrix;
|
||||
|
||||
use winit::{
|
||||
dpi::LogicalSize,
|
||||
|
@ -113,7 +114,11 @@ impl<'a> ecs::System<'a> for Renderer {
|
|||
|
||||
impl Renderer {
|
||||
pub fn initialize(world: &mut ecs::World) -> Self {
|
||||
world.set_global(Status{
|
||||
world.set_global(SceneInfo {
|
||||
camera: cgm::Point3::new(0.0, 0.0, 0.0),
|
||||
view: cgm::Matrix4::identity(),
|
||||
});
|
||||
world.set_global(Status {
|
||||
closed: false,
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue