6 #include "../core/interaction.h" 10 bool MeshRenderer::pick(uint32_t
id)
const {
11 return _material && _material->id() == id;
14 bool MeshRenderer::interact(
const Interaction &interaction) {
15 if (_interact_callback && pick(interaction.id)) {
16 _interact_callback(interaction);
22 MeshRenderer::MeshRenderer(
const std::shared_ptr<Mesh> &mesh,
23 const std::shared_ptr<MaterialRenderer> &material) {
28 MeshRenderer::MeshRenderer(
29 const std::shared_ptr<Mesh> &mesh, std::shared_ptr<const Material> material,
30 std::shared_ptr<const MaterialOverride> material_override)
32 material, material_override)) {}
34 MeshRenderer::~MeshRenderer() {}
37 _parent_pose = context.pose;
38 _material->renderSync(context);
39 _render_options_2 = _render_options;
43 _material->renderAsync(context);
45 context.render_list->push(_material->block());
46 context.render_list->push(_mesh, _render_options_2);
48 instance.setPose(_parent_pose.matrix().cast<
float>());
49 context.render_list->push(instance);
54 _render_options = options;
57 MeshRenderer::MeshRenderer(
const std::shared_ptr<Mesh> &mesh,
58 std::shared_ptr<const Material> material,
59 const Eigen::Isometry3d &pose)
64 MeshRenderer::MeshRenderer(
65 const std::shared_ptr<Mesh> &mesh, std::shared_ptr<const Material> material,
66 const std::function<
void(
const Interaction &)> &interact_callback)
68 _interact_callback = interact_callback;
71 const std::shared_ptr<Mesh> &MeshRenderer::mesh()
const {
return _mesh; }
73 const std::shared_ptr<MaterialRenderer> &MeshRenderer::materialRenderer() {
77 const RenderOptions &MeshRenderer::options()
const {
return _render_options; }
79 RenderOptions &MeshRenderer::options() {
return _render_options; }
82 _material->renderAsync(context);
84 context.render_list->push(_material->block());
85 context.render_list->push(_mesh, _render_options_2);
86 for (
auto &pose : _poses) {
88 instance.setPose(pose.matrix().cast<
float>());
89 context.render_list->push(instance);
94 InstancedMeshRenderer::InstancedMeshRenderer(
95 const std::shared_ptr<Mesh> &mesh, std::shared_ptr<const Material> material)
98 void InstancedMeshRenderer::clearInstances() { _poses.clear(); }
100 void InstancedMeshRenderer::addInstance(
const Eigen::Isometry3d &pose) {
101 _poses.push_back(pose);