Implemented scaling for instances

This commit is contained in:
Verox001 2025-05-04 12:55:12 +02:00
parent bdee0ceb3e
commit 7eacf0d0a5

View File

@ -25,15 +25,17 @@ struct RenderInstance {
position: cgmath::Vector3<f32>,
rotation: cgmath::Quaternion<f32>,
color: [f32; 3],
scale: f32
}
impl RenderInstance {
fn to_raw(&self) -> InstanceRaw {
let model = cgmath::Matrix4::from_translation(self.position)
* cgmath::Matrix4::from(self.rotation);
* cgmath::Matrix4::from(self.rotation)
* cgmath::Matrix4::from_scale(self.scale);
InstanceRaw {
model: model.into(),
color: self.color
color: self.color,
}
}
}
@ -228,6 +230,7 @@ impl<'a> State<'a> {
1 => [0.0, 0.0, 1.0],
_ => [0.5, 0.5, 0.5],
},
scale: 0.1,
}).collect::<Vec<_>>()
};
@ -275,6 +278,7 @@ impl<'a> State<'a> {
1 => [0.0, 0.0, 1.0],
_ => [0.5, 0.5, 0.5],
},
scale: 0.5,
}).collect()
};