search for problem with custom projection matrices
This commit is contained in:
parent
c3b852f312
commit
249187b698
4 changed files with 21 additions and 10 deletions
|
@ -20,7 +20,7 @@ mod viewer;
|
|||
|
||||
fn main() {
|
||||
App::new()
|
||||
.insert_resource(ClearColor(Color::rgb(0.0, 0.1, 0.9)))
|
||||
.insert_resource(ClearColor(Color::rgb(0.9, 0.9, 0.9)))
|
||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
||||
window: WindowDescriptor {
|
||||
title: "PixSpace".to_string(),
|
||||
|
|
|
@ -21,7 +21,7 @@ impl CameraProjection for OffAxisProjection {
|
|||
|
||||
println!("Here we go! {:?}",self);
|
||||
|
||||
Mat4::perspective_rh_gl(45.0_f32.to_radians(),
|
||||
Mat4::perspective_rh(45.0_f32.to_radians(),
|
||||
self.aspect,
|
||||
self.near,
|
||||
self.far)
|
||||
|
@ -49,7 +49,6 @@ impl Default for OffAxisProjection {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
pub fn make_projection_rh_from_frustum(left: f32, right: f32, bottom: f32, top: f32, near:f32, far:f32) -> Mat4
|
||||
{
|
||||
// based on OpenSceneGraph / glFrustum implementation
|
||||
|
@ -70,6 +69,8 @@ pub fn offaxis_camera_setup(mut commands: Commands) {
|
|||
|
||||
let projection = OffAxisProjection::default();
|
||||
|
||||
// let projection = PerspectiveProjection::default();
|
||||
|
||||
// position the camera like bevy would do by default for 2D:
|
||||
let transform = Transform::from_xyz(0.0, 0.0, projection.far - 0.1);
|
||||
|
||||
|
|
10
src/scene.rs
10
src/scene.rs
|
@ -96,18 +96,18 @@ pub fn build_scene(
|
|||
shadows_enabled: true,
|
||||
..default()
|
||||
},
|
||||
transform: Transform::from_xyz(4.0, 8.0, 4.0),
|
||||
transform: Transform::from_xyz(4.0, 8.0, -4.0),
|
||||
..default()
|
||||
});
|
||||
|
||||
|
||||
// camera
|
||||
|
||||
let mut cam = Camera3dBundle {
|
||||
transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
// let mut cam = Camera3dBundle {
|
||||
// transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
|
||||
..default()
|
||||
};
|
||||
// ..default()
|
||||
// };
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -35,7 +35,17 @@ pub fn simulate_viewer(mut query: Query<&mut Viewer>)
|
|||
for mut v in query.iter_mut() {
|
||||
//v.position += Vec3::Y * 0.005;
|
||||
v.alpha += 0.01;
|
||||
let radius = 0.5;
|
||||
v.position = Vec3::new(v.alpha.sin()*radius,v.alpha.cos()*radius,5.0);
|
||||
let radius = 1.5;
|
||||
v.position = Vec3::new(v.alpha.sin()*radius,v.alpha.cos()*radius + 1.0_f32,15.0);
|
||||
|
||||
let vm = Mat4::look_at_rh(v.position, Vec3::ZERO, Vec3::Y);
|
||||
|
||||
println!("{:?}",vm);
|
||||
|
||||
// view matrices should be orientation only
|
||||
let dir = Quat::from_mat4(&vm);
|
||||
|
||||
v.orientation = dir;
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue