use std::os::raw;
use cgmath::Matrix4;
use device::Device;
use geometry::Geometry;
use scene::{CommittedScene, Scene};
use sys::*;
use {BufferType, Format, GeometryType};
pub struct Instance<'a> {
device: &'a Device,
pub(crate) handle: RTCGeometry,
scene: &'a CommittedScene<'a>,
}
impl<'a> Instance<'a> {
pub fn unanimated(device: &'a Device, scene: &'a CommittedScene) -> Instance<'a> {
let h = unsafe { rtcNewGeometry(device.handle, GeometryType::INSTANCE) };
unsafe {
rtcSetGeometryInstancedScene(h, scene.scene.handle);
}
Instance {
device: device,
handle: h,
scene: scene,
}
}
pub fn set_transform(&mut self, transform: &Matrix4<f32>) {
let mat: &[f32; 16] = transform.as_ref();
unsafe {
rtcSetGeometryTransform(
self.handle,
0,
Format::FLOAT4X4_COLUMN_MAJOR,
mat.as_ptr() as *const raw::c_void,
);
}
}
}
unsafe impl<'a> Sync for Instance<'a> {}