summaryrefslogtreecommitdiff
path: root/engine/src/object.rs
diff options
context:
space:
mode:
Diffstat (limited to 'engine/src/object.rs')
-rw-r--r--engine/src/object.rs26
1 files changed, 25 insertions, 1 deletions
diff --git a/engine/src/object.rs b/engine/src/object.rs
index 11ba7e6..c3d82d0 100644
--- a/engine/src/object.rs
+++ b/engine/src/object.rs
@@ -5,6 +5,8 @@ use crate::opengl::shader::{
Shader,
};
use crate::renderer::Renderable;
+use crate::transform::Transform;
+use crate::vector::Vec3;
use crate::vertex::Vertex;
#[derive(Debug)]
@@ -12,6 +14,7 @@ pub struct Object
{
id: Id,
renderable: Renderable,
+ transform: Transform,
}
impl Object
@@ -53,7 +56,13 @@ impl Object
let renderable = Renderable::new(shader_program, vertices);
- Ok(Self { id, renderable })
+ let transform = Transform::new();
+
+ Ok(Self {
+ id,
+ renderable,
+ transform,
+ })
}
/// Returns the object ID.
@@ -63,10 +72,25 @@ impl Object
self.id
}
+ pub fn translate(&mut self, translation: Vec3<f32>)
+ {
+ self.transform.set_translation(translation);
+ }
+
+ pub fn scale(&mut self, scaling: Vec3<f32>)
+ {
+ self.transform.set_scaling(scaling);
+ }
+
pub(crate) fn renderable(&self) -> &Renderable
{
&self.renderable
}
+
+ pub(crate) fn transform(&self) -> &Transform
+ {
+ &self.transform
+ }
}
/// Object error