mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-04 17:38:10 +00:00
flip the objects to face the camera
This commit is contained in:
1 parent
23038489bb
commit
7679ca4e5b
3 files changed
+27
-6
No files matched your search
@@ -1,6 +1,6 @@
|
||||
use crate::assets::renderable_object::RenderableObject;
|
||||
use gl::types::*;
|
||||
use nalgebra::{Vector4, Rotation3, Translation3, Matrix4, Vector3};
|
||||
use nalgebra::{Vector4, Rotation3, Translation3, Matrix4, Vector3, RealField};
|
||||
use std::ffi::CString;
|
||||
use std::os::raw::c_char;
|
||||
use crate::opengl::wrapper::uniform::Uniform;
|
||||
@@ -51,6 +51,21 @@ impl PositionableObject {
|
||||
self.rotation.z = z;
|
||||
}
|
||||
|
||||
/// Add pi to x rotation
|
||||
pub fn flip_x(&mut self) {
|
||||
self.rotation.x += f32::pi();
|
||||
}
|
||||
|
||||
/// Add pi to y rotation
|
||||
pub fn flip_y(&mut self) {
|
||||
self.rotation.y += f32::pi();
|
||||
}
|
||||
|
||||
/// Add pi to z rotation
|
||||
pub fn flip_z(&mut self) {
|
||||
self.rotation.z += f32::pi();
|
||||
}
|
||||
|
||||
pub fn scale_nonuniform(&mut self, x: f32, y: f32, z: f32) {
|
||||
self.scale.x = x;
|
||||
self.scale.y = y;
|
||||
|
||||
@@ -142,8 +142,11 @@ impl RenderableObject {
|
||||
let width = rgba_image.width();
|
||||
let height = rgba_image.height();
|
||||
|
||||
let flat_samples = rgba_image.into_flat_samples();
|
||||
let pixel_data = flat_samples.samples.as_ptr() as *const c_void;
|
||||
//let flat_samples = rgba_image.into_flat_samples();
|
||||
//let pixel_data = flat_samples.samples.as_ptr() as *const c_void;
|
||||
|
||||
let img_data = rgba_image.into_raw();
|
||||
let pixel_data = img_data.as_ptr() as *const c_void;
|
||||
|
||||
self.texture.bind_as_texture_2d();
|
||||
|
||||
|
||||
@@ -279,8 +279,9 @@ impl PointCloudRenderer {
|
||||
|
||||
let mut positionable_object = PositionableObject::new(renderable_object);
|
||||
|
||||
positionable_object.translate(0.0, 0.0, 15.0);
|
||||
positionable_object.rotate(10.0, 8.0, 50.0);
|
||||
positionable_object.translate(-5.0, 0.0, 15.0);
|
||||
positionable_object.flip_y(); // flipping y and z rights the model.
|
||||
positionable_object.flip_z();
|
||||
positionable_object.scale_nonuniform(2.0, 1.0, 0.5);
|
||||
|
||||
self.renderable_objects.push(positionable_object);
|
||||
@@ -330,7 +331,9 @@ impl PointCloudRenderer {
|
||||
|
||||
let mut positionable_object = PositionableObject::new(renderable_object);
|
||||
|
||||
positionable_object.translate(6.0, 6.0, 20.0);
|
||||
positionable_object.translate(5.0, 2.0, 20.0);
|
||||
positionable_object.flip_y(); // flipping y and z rights the model.
|
||||
positionable_object.flip_z();
|
||||
positionable_object.scale(0.05);
|
||||
|
||||
self.renderable_objects.push(positionable_object);
|
||||
|
||||
Reference in new issue
Block a user