Implemented scaling for instances
This commit is contained in:
parent
bdee0ceb3e
commit
7eacf0d0a5
@ -25,15 +25,17 @@ struct RenderInstance {
|
|||||||
position: cgmath::Vector3<f32>,
|
position: cgmath::Vector3<f32>,
|
||||||
rotation: cgmath::Quaternion<f32>,
|
rotation: cgmath::Quaternion<f32>,
|
||||||
color: [f32; 3],
|
color: [f32; 3],
|
||||||
|
scale: f32
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderInstance {
|
impl RenderInstance {
|
||||||
fn to_raw(&self) -> InstanceRaw {
|
fn to_raw(&self) -> InstanceRaw {
|
||||||
let model = cgmath::Matrix4::from_translation(self.position)
|
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 {
|
InstanceRaw {
|
||||||
model: model.into(),
|
model: model.into(),
|
||||||
color: self.color
|
color: self.color,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -228,6 +230,7 @@ impl<'a> State<'a> {
|
|||||||
1 => [0.0, 0.0, 1.0],
|
1 => [0.0, 0.0, 1.0],
|
||||||
_ => [0.5, 0.5, 0.5],
|
_ => [0.5, 0.5, 0.5],
|
||||||
},
|
},
|
||||||
|
scale: 0.1,
|
||||||
}).collect::<Vec<_>>()
|
}).collect::<Vec<_>>()
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -275,6 +278,7 @@ impl<'a> State<'a> {
|
|||||||
1 => [0.0, 0.0, 1.0],
|
1 => [0.0, 0.0, 1.0],
|
||||||
_ => [0.5, 0.5, 0.5],
|
_ => [0.5, 0.5, 0.5],
|
||||||
},
|
},
|
||||||
|
scale: 0.5,
|
||||||
}).collect()
|
}).collect()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user