added more features back
This commit is contained in:
parent
b9d631d912
commit
348d7dce45
2 changed files with 65 additions and 70 deletions
13
src/main.rs
13
src/main.rs
|
@ -1,13 +1,12 @@
|
||||||
|
use crate::scene::*;
|
||||||
use bevy::{prelude::*, window::PresentMode};
|
use bevy::{prelude::*, window::PresentMode};
|
||||||
use crate::scene::{*};
|
|
||||||
|
|
||||||
mod scene;
|
|
||||||
mod offaxis;
|
mod offaxis;
|
||||||
|
mod scene;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.insert_resource(ClearColor(Color::rgb(0.0, 0.1, 0.9)))
|
.insert_resource(ClearColor(Color::rgb(0.0, 0.1, 0.9)))
|
||||||
|
|
||||||
// .insert_resource(WindowDescriptor{
|
// .insert_resource(WindowDescriptor{
|
||||||
// title: "PixSpace".to_string(),
|
// title: "PixSpace".to_string(),
|
||||||
// width: 1280.0,
|
// width: 1280.0,
|
||||||
|
@ -15,9 +14,9 @@ fn main() {
|
||||||
// present_mode: PresentMode::AutoVsync,
|
// present_mode: PresentMode::AutoVsync,
|
||||||
// ..Default::default()
|
// ..Default::default()
|
||||||
// })
|
// })
|
||||||
|
|
||||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
||||||
window: WindowDescriptor {
|
window: WindowDescriptor {
|
||||||
|
title: "PixSpace".to_string(),
|
||||||
width: 1280.0,
|
width: 1280.0,
|
||||||
height: 720.0,
|
height: 720.0,
|
||||||
present_mode: PresentMode::AutoVsync,
|
present_mode: PresentMode::AutoVsync,
|
||||||
|
@ -25,9 +24,9 @@ fn main() {
|
||||||
},
|
},
|
||||||
..default()
|
..default()
|
||||||
}))
|
}))
|
||||||
.add_plugins(DefaultPlugins)
|
// .add_plugins(DefaultPlugins)
|
||||||
.add_plugin(scene::BuildScenePlugin)
|
.add_plugin(scene::BuildScenePlugin)
|
||||||
// .add_startup_system(offaxis::camera_setup)
|
.add_startup_system(offaxis::camera_setup)
|
||||||
.add_system(bevy::window::close_on_esc)
|
.add_system(bevy::window::close_on_esc)
|
||||||
.add_system(cycle_msaa)
|
.add_system(cycle_msaa)
|
||||||
// .add_system_to_stage(
|
// .add_system_to_stage(
|
||||||
|
@ -40,8 +39,6 @@ fn main() {
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn cycle_msaa(input: Res<Input<KeyCode>>, mut msaa: ResMut<Msaa>) {
|
fn cycle_msaa(input: Res<Input<KeyCode>>, mut msaa: ResMut<Msaa>) {
|
||||||
if input.just_pressed(KeyCode::M) {
|
if input.just_pressed(KeyCode::M) {
|
||||||
if msaa.samples == 4 {
|
if msaa.samples == 4 {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
|
||||||
use bevy::render::primitives::Frustum;
|
|
||||||
use bevy::render::camera::{Camera, CameraProjection};
|
use bevy::render::camera::{Camera, CameraProjection};
|
||||||
|
use bevy::render::primitives::Frustum;
|
||||||
use bevy::render::view::VisibleEntities;
|
use bevy::render::view::VisibleEntities;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
|
@ -14,9 +14,7 @@ pub struct OffAxisProjection {
|
||||||
impl CameraProjection for OffAxisProjection {
|
impl CameraProjection for OffAxisProjection {
|
||||||
fn get_projection_matrix(&self) -> Mat4 {
|
fn get_projection_matrix(&self) -> Mat4 {
|
||||||
println!("Here we go!");
|
println!("Here we go!");
|
||||||
Mat4::orthographic_rh(
|
Mat4::orthographic_rh(-self.aspect, self.aspect, -1.0, 1.0, self.near, self.far)
|
||||||
-self.aspect, self.aspect, -1.0, 1.0, self.near, self.far
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// what to do on window resize
|
// what to do on window resize
|
||||||
|
@ -39,7 +37,11 @@ impl CameraProjection for OffAxisProjection {
|
||||||
|
|
||||||
impl Default for OffAxisProjection {
|
impl Default for OffAxisProjection {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self { near: 0.0, far: 1000.0, aspect: 1.0 }
|
Self {
|
||||||
|
near: 0.0,
|
||||||
|
far: 1000.0,
|
||||||
|
aspect: 1.0,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,8 +63,7 @@ pub fn camera_setup(mut commands: Commands) {
|
||||||
// position the camera like bevy would do by default for 2D:
|
// position the camera like bevy would do by default for 2D:
|
||||||
let transform = Transform::from_xyz(0.0, 0.0, projection.far - 0.1);
|
let transform = Transform::from_xyz(0.0, 0.0, projection.far - 0.1);
|
||||||
// frustum construction code copied from Bevy
|
// frustum construction code copied from Bevy
|
||||||
let view_projection =
|
let view_projection = projection.get_projection_matrix() * transform.compute_matrix().inverse();
|
||||||
projection.get_projection_matrix() * transform.compute_matrix().inverse();
|
|
||||||
|
|
||||||
let frustum = Frustum::from_view_projection(
|
let frustum = Frustum::from_view_projection(
|
||||||
&view_projection,
|
&view_projection,
|
||||||
|
@ -71,21 +72,18 @@ pub fn camera_setup(mut commands: Commands) {
|
||||||
projection.far,
|
projection.far,
|
||||||
);
|
);
|
||||||
|
|
||||||
print!("Setup {0}",line!());
|
print!("Setup {0}\n", line!());
|
||||||
|
|
||||||
// commands.spawn_bundle((
|
commands.spawn((
|
||||||
// camera,
|
camera,
|
||||||
// projection,
|
projection,
|
||||||
// frustum,
|
frustum,
|
||||||
// VisibleEntities::default(),
|
VisibleEntities::default(),
|
||||||
// transform,
|
transform,
|
||||||
// GlobalTransform::default(),
|
GlobalTransform::default(),
|
||||||
// // Camera2d,
|
));
|
||||||
// )
|
|
||||||
// );
|
|
||||||
|
|
||||||
print!("Setup {0}",line!());
|
|
||||||
|
|
||||||
|
print!("Setup {0}\t{1}\n", line!(), file!());
|
||||||
}
|
}
|
||||||
|
|
||||||
// fn main() {
|
// fn main() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue