Fixed frustum culling
This commit is contained in:
+15
-9
@@ -3,6 +3,7 @@ extern crate glium;
|
||||
#[macro_use]
|
||||
extern crate verbose_log;
|
||||
extern crate model_converter;
|
||||
extern crate nalgebra as na;
|
||||
|
||||
use std::process::exit;
|
||||
use std::time::{Instant, Duration};
|
||||
@@ -97,7 +98,7 @@ fn main() {
|
||||
|
||||
for (name, mut model) in models {
|
||||
log!("Scaling model {}...", name);
|
||||
model.center_and_scale_from_box(&bbox);
|
||||
// model.center_and_scale_from_box(&bbox);
|
||||
|
||||
log!("\nBuilding textures for model {}...", name);
|
||||
|
||||
@@ -119,19 +120,21 @@ fn main() {
|
||||
let mut closed = false;
|
||||
|
||||
let mut camera = Camera::new(
|
||||
Vector3::new( 0.0, 0.0, 0.0),
|
||||
Vector3::new( 0.0, 0.0, 0.0),
|
||||
Vector3::new( 0.0, 1.0, 0.0),
|
||||
Vector3::new(1.0, 0.0, 0.0),
|
||||
Vector3::new(0.0, 0.0, 0.0),
|
||||
Vector3::new(0.0, 1.0, 0.0),
|
||||
);
|
||||
|
||||
camera.z_near = 0.0001;
|
||||
|
||||
use model_converter::camera::RenderCamera;
|
||||
|
||||
let mut controls: Box<Controls> = if matches.is_present("first person") {
|
||||
Box::new(FirstPersonControls::new())
|
||||
} else {
|
||||
Box::new(OrbitControls::new(
|
||||
Vector3::new(0.0, 0.0, 0.0),
|
||||
1.0,
|
||||
2.0,
|
||||
&mut camera
|
||||
))
|
||||
};
|
||||
@@ -175,11 +178,11 @@ fn main() {
|
||||
} => {
|
||||
|
||||
// Go back in world coordinates
|
||||
let position = camera.position * size as f32;
|
||||
let position = position + center;
|
||||
let position = camera.position;
|
||||
// let position = position + center;
|
||||
|
||||
let target = camera.target * size as f32;
|
||||
let target = target + center;
|
||||
let target = camera.target;
|
||||
// let target = target + center;
|
||||
|
||||
let up = camera.up;
|
||||
|
||||
@@ -191,12 +194,15 @@ fn main() {
|
||||
target.x(), target.y(), target.z());
|
||||
println!("\tUp: ({}, {}, {})",
|
||||
up.x(), up.y(), up.z());
|
||||
|
||||
}
|
||||
|
||||
_ => (),
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
controls.update(&mut camera, &renderer);
|
||||
renderer.render(&scene, &camera);
|
||||
let elapsed = as_millis(Instant::now().duration_since(before));
|
||||
|
||||
Reference in New Issue
Block a user