mirror of
https://github.com/lisk77/comet.git
synced 2025-10-23 21:38:50 +00:00
feat: added 2D scene rendering and initialization of the texture atlas
This commit is contained in:
parent
878e220249
commit
780365aeb8
12 changed files with 280 additions and 122 deletions
|
|
@ -15,7 +15,7 @@ pub trait InnerSpace {
|
|||
|
||||
/// Representation of a 2D Vector
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Default)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct Vec2 {
|
||||
x: f32,
|
||||
|
|
@ -43,6 +43,14 @@ impl Vec2 {
|
|||
self.y
|
||||
}
|
||||
|
||||
pub fn set_x(&mut self, new_x: f32) {
|
||||
self.x = new_x;
|
||||
}
|
||||
|
||||
pub fn set_y(&mut self, new_y: f32) {
|
||||
self.y = new_y;
|
||||
}
|
||||
|
||||
pub fn length(&self) -> f32 {
|
||||
(self.x * self.x + self.y * self.y).sqrt()
|
||||
}
|
||||
|
|
@ -123,7 +131,7 @@ impl Mul<f32> for Vec2 {
|
|||
|
||||
/// Representation of a 3D Vector
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Default)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct Vec3 {
|
||||
pub x: f32,
|
||||
|
|
@ -161,6 +169,18 @@ impl Vec3 {
|
|||
self.z
|
||||
}
|
||||
|
||||
pub fn set_x(&mut self, new_x: f32) {
|
||||
self.x = new_x;
|
||||
}
|
||||
|
||||
pub fn set_y(&mut self, new_y: f32) {
|
||||
self.y = new_y;
|
||||
}
|
||||
|
||||
pub fn set_z(&mut self, new_z: f32) {
|
||||
self.z = new_z;
|
||||
}
|
||||
|
||||
pub fn into_quaternion(&self) -> Quat {
|
||||
Quat {
|
||||
s: 0.0,
|
||||
|
|
@ -418,7 +438,7 @@ impl Mul<f32> for Vec3 {
|
|||
|
||||
/// Representation of a 4D Vector
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Default)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct Vec4 {
|
||||
x: f32,
|
||||
|
|
@ -469,6 +489,22 @@ impl Vec4 {
|
|||
self.w
|
||||
}
|
||||
|
||||
pub fn set_x(&mut self, new_x: f32) {
|
||||
self.x = new_x;
|
||||
}
|
||||
|
||||
pub fn set_y(&mut self, new_y: f32) {
|
||||
self.y = new_y;
|
||||
}
|
||||
|
||||
pub fn set_z(&mut self, new_z: f32) {
|
||||
self.z = new_z;
|
||||
}
|
||||
|
||||
pub fn set_w(&mut self, new_w: f32) {
|
||||
self.w = new_w;
|
||||
}
|
||||
|
||||
pub fn xxxx(&self) -> Vec4 {
|
||||
Vec4 {
|
||||
x: self.x,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue