10#include "utility/example_shared.h"
12#include <nv/index/icamera.h>
13#include <nv/index/iconfig_settings.h>
14#include <nv/index/ifont.h>
15#include <nv/index/ilabel.h>
17#include <nv/index/icamera.h>
18#include <nv/index/icircle.h>
19#include <nv/index/icone.h>
20#include <nv/index/iconfig_settings.h>
21#include <nv/index/icylinder.h>
22#include <nv/index/idepth_offset.h>
23#include <nv/index/idistributed_data_access.h>
24#include <nv/index/iellipse.h>
25#include <nv/index/iellipsoid.h>
26#include <nv/index/iicon.h>
27#include <nv/index/iindex.h>
28#include <nv/index/iindex_debug_configuration.h>
29#include <nv/index/ilabel.h>
30#include <nv/index/ilight.h>
31#include <nv/index/iline_set.h>
32#include <nv/index/imaterial.h>
33#include <nv/index/ipath.h>
34#include <nv/index/iplane.h>
35#include <nv/index/ipoint_set.h>
36#include <nv/index/ipolygon.h>
37#include <nv/index/iscene.h>
38#include <nv/index/isession.h>
39#include <nv/index/isphere.h>
40#include <nv/index/itexture.h>
41#include <nv/index/itexture_filter_mode.h>
42#include <nv/index/iviewport.h>
44#include <nv/index/app/idata_analysis_and_processing.h>
45#include <nv/index/app/iimage_importer.h>
46#include <nv/index/app/index_connect.h>
47#include <nv/index/app/string_dict.h>
49#include "utility/app_rendering_context.h"
50#include "utility/canvas_utility.h"
57 public nv::index::app::Index_connect
77 virtual bool evaluate_options(nv::index::app::String_dict& sdict) CPP11_OVERRIDE;
80 mi::neuraylib::INetwork_configuration* network_configuration,
81 nv::index::app::String_dict& options) CPP11_OVERRIDE
86 const bool is_unittest = nv::index::app::get_bool(options.get(
"unittest"));
89 info_cout(
"NETWORK: disabled networking mode.", options);
90 network_configuration->set_mode(mi::neuraylib::INetwork_configuration:
:MODE_OFF);
94 return initialize_networking_as_default_udp(network_configuration, options);
103 const mi::neuraylib::Tag& camera_tag,
104 mi::neuraylib::IDice_transaction* dice_transaction)
const;
106 void localize_scene_element()
const;
109 nv::index::IViewport_list* filter_enabled_viewport_index_list();
113 bool render_one_frame(mi::Sint32 frame_idx);
127 void create_views()
const;
134 void create_light_material_instance(
135 nv::index::IScene* scene_edit,
136 mi::neuraylib::IDice_transaction* dice_transaction,
137 std::map<std::string, mi::neuraylib::Tag>& light_mat_tag_map)
const;
138 mi::neuraylib::Tag get_valid_light_mat_tag_by_name(
139 const std::map<std::string, mi::neuraylib::Tag>& light_mat_tag_map,
140 const std::string& light_mat_name)
const;
141 void add_scene_defaut_light(
142 nv::index::IScene* scene_edit,
143 const std::map<std::string, mi::neuraylib::Tag>& light_mat_tag_map,
144 mi::neuraylib::IDice_transaction* dice_transaction);
145 void add_scene_group_simple_geometry(
146 nv::index::IScene* scene_edit,
147 const std::map<std::string, mi::neuraylib::Tag>& light_mat_tag_map,
148 mi::neuraylib::IDice_transaction* dice_transaction);
149 void add_scene_group_planes(
150 nv::index::IScene* scene_edit,
151 const std::map<std::string, mi::neuraylib::Tag>& light_mat_tag_map,
152 mi::neuraylib::IDice_transaction* dice_transaction);
153 void add_scene_group_raster(
154 nv::index::IScene* scene_edit,
155 const std::map<std::string, mi::neuraylib::Tag>& light_mat_tag_map,
156 mi::neuraylib::IDice_transaction* dice_transaction);
157 void add_scene_group_paths(
158 nv::index::IScene* scene_edit,
159 const std::map<std::string, mi::neuraylib::Tag>& light_mat_tag_map,
160 mi::neuraylib::IDice_transaction* dice_transaction);
161 void add_scene_group_labels(
162 nv::index::IScene* scene_edit,
163 const std::map<std::string, mi::neuraylib::Tag>& light_mat_tag_map,
164 mi::neuraylib::IDice_transaction* dice_transaction);
165 void add_scene_group_icons(
166 nv::index::IScene* scene_edit,
167 const std::map<std::string, mi::neuraylib::Tag>& light_mat_tag_map,
168 mi::neuraylib::IDice_transaction* dice_transaction);
172 void setup_scene(mi::neuraylib::IDice_transaction* dice_transaction);
175 bool setup_main_host();
178 mi::neuraylib::Tag m_session_tag;
180 mi::base::Handle<nv::index::ICluster_configuration> m_cluster_configuration;
182 mi::base::Handle<nv::index::app::canvas_infrastructure::IIndex_image_file_canvas> m_image_file_canvas;
184 std::string m_outfname;
186 std::string m_verify_image_path_base;
187 std::string m_font_fpath;
188 std::string m_iconfile;
189 std::vector<bool> m_enable_view_idx_vec;
191 mi::neuraylib::Tag m_camera_tag;
193 mi::neuraylib::Tag m_simple_geo_group_node_tag;
195 mi::neuraylib::Tag m_plane_tag;
197 mi::neuraylib::Tag m_raster_circle1_tag;
199 mi::neuraylib::Tag m_raster_ellipses1_tag;
201 mi::neuraylib::Tag m_path3d_1_tag;
203 mi::neuraylib::Tag m_label2d_tag;
205 mi::neuraylib::Tag m_polygon_group_tag;
206 mi::base::Handle<nv::index::IViewport_list> m_viewport_list;
219 mi::Sint32 frame_idx = 0;
223 const bool is_success = render_one_frame(frame_idx);
229 localize_scene_element();
234 const bool is_success = render_one_frame(frame_idx);
246 const std::string com_name = sdict.get(
"command:",
"<unknown_command>");
247 m_is_unittest = nv::index::app::get_bool(sdict.get(
"unittest",
"false"));
250 sdict.insert(
"dice::verbose",
"2");
253 m_outfname = sdict.get(
"outfname");
254 m_verify_image_path_base = sdict.get(
"verify_image_path_base");
255 m_enable_view_idx_vec = get_bool_vec_from_string(sdict.get(
"enable_vidx_vec"));
256 m_font_fpath = sdict.get(
"font_fpath");
257 m_iconfile = sdict.get(
"iconfile");
259 info_cout(
"running " + com_name, sdict);
260 info_cout(
"outfname = [" + m_outfname +
261 "], verify_image_path_base = [" + m_verify_image_path_base +
262 "], dice::verbose = " + sdict.get(
"dice::verbose"), sdict);
265 if (sdict.is_defined(
"h"))
268 <<
"info: Usage: " << com_name <<
" [option]\n"
270 <<
" print out this message\n"
272 <<
" [-dice::verbose severity_level]\n"
273 <<
" verbose severity level (3 is info). (default: " + sdict.get(
"dice::verbose")
276 <<
" [-font_fpath FONT_FILE_PATH]\n"
277 <<
" font file path. (default: " << sdict.get(
"font_fpath") <<
")\n"
279 <<
" [-icon_file ICON_FILE_PATH]\n"
280 <<
" Specify an icon file. (default: [" << sdict.get(
"iconfile") <<
"])\n"
282 <<
" [-outfname string]\n"
283 <<
" output ppm file base name. When empty, no output.\n"
284 <<
" A frame number and extension (.ppm) will be added.\n"
285 <<
" (default: [" << sdict.get(
"outfname") <<
"])\n"
287 <<
" [-verify_image_path_base image path basename]\n"
288 <<
" when image_fname path basename exist, verify the rendering images.\n"
289 <<
" (default: [" << sdict.get(
"verify_image_path_base") <<
"])\n"
291 <<
" [-unittest bool]\n"
292 <<
" when true, unit test mode. "
293 <<
"(default: [" << sdict.get(
"unittest") <<
"])\n"
295 <<
" [-enable_vidx_vec enabled_vector]\n"
296 <<
" Specify which viewport is enabled by a bool vector.\n"
297 <<
" (default: [" << sdict.get(
"enable_vidx_vec") <<
"])"
307void Multi_view_shape::setup_camera(
308 const mi::neuraylib::Tag& camera_tag,
309 mi::neuraylib::IDice_transaction* dice_transaction)
const
313 mi::base::Handle<nv::index::IPerspective_camera> cam(
314 dice_transaction->edit<nv::index::IPerspective_camera>(camera_tag));
317 const mi::math::Vector<mi::Float32, 3> from(500.0f, 1500.0f, 250.0f);
318 mi::math::Vector<mi::Float32, 3> dir ( 0.0f, -0.9f, 0.2f);
319 const mi::math::Vector<mi::Float32, 3> up ( 0.0f, -0.2f, -1.0f);
322 cam->set(from, dir, up);
323 cam->set_aperture(0.033f);
324 cam->set_aspect(1.0f);
325 cam->set_focal(0.03f);
326 cam->set_clip_min(2.0f);
327 cam->set_clip_max(1000.0f);
331void Multi_view_shape::localize_scene_element()
const
337 const mi::Size view_idx = 1;
340 mi::base::Handle<nv::index::IViewport> viewport(m_viewport_list->get(view_idx));
343 mi::base::Handle<mi::neuraylib::IScope> cur_scope(viewport->get_scope());
347 mi::base::Handle<mi::neuraylib::IDice_transaction> dice_transaction(
348 cur_scope->create_transaction<mi::neuraylib::IDice_transaction>());
353 mi::Sint32 ret_localize = 1;
354 ret_localize = dice_transaction->localize(m_simple_geo_group_node_tag,
355 mi::neuraylib::IDice_transaction:
:LOCAL_SCOPE);
357 ret_localize = dice_transaction->localize(m_plane_tag,
358 mi::neuraylib::IDice_transaction:
:LOCAL_SCOPE);
360 ret_localize = dice_transaction->localize(m_raster_circle1_tag,
361 mi::neuraylib::IDice_transaction:
:LOCAL_SCOPE);
363 ret_localize = dice_transaction->localize(m_label2d_tag,
364 mi::neuraylib::IDice_transaction:
:LOCAL_SCOPE);
368 mi::base::Handle<nv::index::ITransformed_scene_group> simple_geometry_group_node(
369 dice_transaction->edit<nv::index::ITransformed_scene_group>(m_simple_geo_group_node_tag));
370 check_success(simple_geometry_group_node.is_valid_interface());
371 mi::math::Matrix<mi::Float32, 4, 4> transform_mat(
372 1.0f, 0.0f, 0.0f, 0.0f,
373 0.0f, 1.0f, 0.0f, 0.0f,
374 0.0f, 0.0f, 1.0f, 0.0f,
375 200.0f - 100.0f, 200.0f, 600.0f, 1.0f
377 simple_geometry_group_node->set_transform(transform_mat);
379 mi::base::Handle<nv::index::IPlane> plane(
380 dice_transaction->edit<nv::index::IPlane>(m_plane_tag));
381 plane->set_extent(mi::math::Vector<mi::Float32,2>(600.0f - 100.0f, 800.0f - 200.0f));
383 mi::base::Handle<nv::index::ICircle> circle(
384 dice_transaction->edit<nv::index::ICircle>(m_raster_circle1_tag));
386 circle->set_enabled(
false);
388 mi::base::Handle<nv::index::ILabel_2D> label_2d(
389 dice_transaction->edit<nv::index::ILabel_2D>(m_label2d_tag));
391 label_2d->set_text(
"View 1: transform + disable some");
394 dice_transaction->commit();
399 const mi::Size view_idx = 2;
402 mi::base::Handle<nv::index::IViewport> viewport(m_viewport_list->get(view_idx));
405 mi::base::Handle<mi::neuraylib::IScope> cur_scope(viewport->get_scope());
409 mi::base::Handle<mi::neuraylib::IDice_transaction> dice_transaction(
410 cur_scope->create_transaction<mi::neuraylib::IDice_transaction>());
415 mi::Sint32 ret_localize = 1;
416 ret_localize = dice_transaction->localize(m_raster_ellipses1_tag,
417 mi::neuraylib::IDice_transaction:
:LOCAL_SCOPE);
419 ret_localize = dice_transaction->localize(m_path3d_1_tag,
420 mi::neuraylib::IDice_transaction:
:LOCAL_SCOPE);
422 ret_localize = dice_transaction->localize(m_label2d_tag,
423 mi::neuraylib::IDice_transaction:
:LOCAL_SCOPE);
425 ret_localize = dice_transaction->localize(m_polygon_group_tag,
426 mi::neuraylib::IDice_transaction:
:LOCAL_SCOPE);
429 mi::base::Handle<nv::index::IEllipse> ellipse(
430 dice_transaction->edit<nv::index::IEllipse>(m_raster_ellipses1_tag));
432 ellipse->set_enabled(
false);
434 mi::base::Handle<nv::index::IPath_3D> path1(
435 dice_transaction->edit<nv::index::IPath_3D>(m_path3d_1_tag));
436 path1->set_radius(20.0f);
438 mi::base::Handle<nv::index::ILabel_2D> label_2d(
439 dice_transaction->edit<nv::index::ILabel_2D>(m_label2d_tag));
441 label_2d->set_text(
"View 2: changed ellipse/path/polygon");
443 mi::base::Handle<nv::index::ITransformed_scene_group> polygon_group_node(
444 dice_transaction->edit<nv::index::ITransformed_scene_group>(m_polygon_group_tag));
446 polygon_group_node->set_enabled(
false);
448 dice_transaction->commit();
453 const mi::Size view_idx = 3;
456 mi::base::Handle<nv::index::IViewport> viewport(m_viewport_list->get(view_idx));
459 mi::base::Handle<mi::neuraylib::IScope> cur_scope(viewport->get_scope());
463 mi::base::Handle<mi::neuraylib::IDice_transaction> dice_transaction(
464 cur_scope->create_transaction<mi::neuraylib::IDice_transaction>());
471 dice_transaction->commit();
476 const mi::Size view_idx = 0;
479 mi::base::Handle<nv::index::IViewport> viewport(m_viewport_list->get(view_idx));
482 mi::base::Handle<mi::neuraylib::IScope> cur_scope(viewport->get_scope());
486 mi::base::Handle<mi::neuraylib::IDice_transaction> dice_transaction(
487 cur_scope->create_transaction<mi::neuraylib::IDice_transaction>());
494 dice_transaction->commit();
499nv::index::IViewport_list* Multi_view_shape::filter_enabled_viewport_index_list()
501 mi::base::Handle<nv::index::IViewport_list> new_viewport_list;
503 mi::base::Handle<mi::neuraylib::IDice_transaction> dice_transaction(create_transaction());
504 assert(dice_transaction.is_valid_interface());
506 assert(m_session_tag.is_valid());
507 mi::base::Handle<const nv::index::ISession> session(
508 dice_transaction->access<nv::index::ISession>(m_session_tag));
509 assert(session.is_valid_interface());
512 new_viewport_list = session->create_viewport_list();
514 dice_transaction->commit();
518 const mi::Size nb_views = m_viewport_list->size();
520 std::stringstream sstr;
521 mi::Size nb_enabled = 0;
522 for (mi::Size i = 0; i < nb_views; ++i)
524 if (m_enable_view_idx_vec[i])
527 mi::base::Handle<nv::index::IViewport> vp (m_viewport_list->get(i));
528 new_viewport_list->append(vp.get());
533 new_viewport_list->set_advisory_enabled(m_viewport_list->get_advisory_enabled());
535 if (nb_enabled == nb_views)
537 INFO_LOG <<
"All views are enabled.";
541 INFO_LOG <<
"Filtered views. Enabled: " << sstr.str();
544 new_viewport_list->retain();
545 return new_viewport_list.get();
549bool Multi_view_shape::render_one_frame(mi::Sint32 frame_idx)
555 std::string fname =
"";
556 if (!(m_outfname.empty()))
558 fname = get_output_file_name(m_outfname, frame_idx);
563 m_image_file_canvas->set_rgba_file_name(fname.c_str());
566 m_viewport_list->set_advisory_enabled(
true);
568 mi::base::Handle<nv::index::IViewport_list> cur_viewport_list(
569 filter_enabled_viewport_index_list());
572 mi::base::Handle<nv::index::IFrame_results_list> frame_results_list(
573 m_index_rendering->render(
575 m_image_file_canvas.get(),
576 cur_viewport_list.get()));
579 if (frame_results_list->size() == 0)
581 ERROR_LOG <<
"IIndex_rendering rendering call has no results.";
586 for (mi::Size i = 0; i < frame_results_list->size(); ++i)
588 mi::base::Handle<nv::index::IFrame_results>
589 frame_results(frame_results_list->get(i));
592 const mi::base::Handle<nv::index::IError_set> err_set(frame_results->get_error_set());
594 if (err_set->any_errors())
596 std::ostringstream os;
598 const mi::base::Handle<nv::index::IError_set> err_set(frame_results->get_error_set());
599 const mi::Uint32 nb_err = err_set->get_nb_errors();
600 for (mi::Uint32 e = 0; e < nb_err; ++e)
602 if (e != 0) os <<
'\n';
603 const mi::base::Handle<nv::index::IError> err(err_set->get_error(e));
604 os << err->get_error_string();
607 ERROR_LOG <<
"IIndex_rendering rendering call failed with the following error(s): " <<
'\n'
615 if (!(m_verify_image_path_base.empty()))
617 const std::string ref_img_fpath = get_output_file_name(m_verify_image_path_base, frame_idx);
618 if (!(verify_canvas_result(get_application_layer_interface(),
619 m_image_file_canvas.get(), ref_img_fpath, get_options())))
629void Multi_view_shape::create_views()
const
637 mi::base::Handle<mi::neuraylib::IDice_transaction> dice_transaction(
638 m_global_scope->create_transaction<mi::neuraylib::IDice_transaction>());
641 mi::base::Handle<const nv::index::ISession> session(
642 dice_transaction->access<nv::index::ISession>(m_session_tag));
647 mi::base::Handle<nv::index::IViewport> viewport(session->create_viewport());
650 const mi::math::Vector<mi::Sint32, 2> viewport_pos( 0, 256);
651 const mi::math::Vector<mi::Sint32, 2> viewport_size(256, 256);
653 viewport->set_position(viewport_pos);
654 viewport->set_size(viewport_size);
655 viewport->set_scope(m_global_scope.get());
657 m_viewport_list->append(viewport.get());
662 mi::base::Handle<nv::index::IViewport> viewport(session->create_viewport());
665 mi::neuraylib::IScope* parent = 0;
666 mi::Uint8 privacy_level = 1;
667 bool is_temp =
false;
668 mi::base::Handle<mi::neuraylib::IScope> local_scope(m_database->create_scope(parent, privacy_level, is_temp));
671 const mi::math::Vector<mi::Sint32, 2> viewport_pos( 256, 256);
672 const mi::math::Vector<mi::Sint32, 2> viewport_size(256, 256);
674 viewport->set_position(viewport_pos);
675 viewport->set_size(viewport_size);
676 viewport->set_scope(local_scope.get());
678 m_viewport_list->append(viewport.get());
683 mi::base::Handle<nv::index::IViewport> viewport(session->create_viewport());
686 mi::neuraylib::IScope* parent = 0;
687 mi::Uint8 privacy_level = 1;
688 bool is_temp =
false;
689 mi::base::Handle<mi::neuraylib::IScope> local_scope(m_database->create_scope(parent, privacy_level, is_temp));
692 const mi::math::Vector<mi::Sint32, 2> viewport_pos( 0, 0);
693 const mi::math::Vector<mi::Sint32, 2> viewport_size(256, 256);
695 viewport->set_position(viewport_pos);
696 viewport->set_size(viewport_size);
697 viewport->set_scope(local_scope.get());
699 m_viewport_list->append(viewport.get());
704 mi::base::Handle<nv::index::IViewport> viewport(session->create_viewport());
707 mi::neuraylib::IScope* parent = 0;
708 mi::Uint8 privacy_level = 1;
709 bool is_temp =
false;
710 mi::base::Handle<mi::neuraylib::IScope> local_scope(m_database->create_scope(parent, privacy_level, is_temp));
713 const mi::math::Vector<mi::Sint32, 2> viewport_pos( 256, 0);
714 const mi::math::Vector<mi::Sint32, 2> viewport_size(256, 256);
716 viewport->set_position(viewport_pos);
717 viewport->set_size(viewport_size);
718 viewport->set_scope(local_scope.get());
720 m_viewport_list->append(viewport.get());
723 dice_transaction->commit();
727void Multi_view_shape::create_light_material_instance(
728 nv::index::IScene* scene_edit,
729 mi::neuraylib::IDice_transaction* dice_transaction,
730 std::map<std::string, mi::neuraylib::Tag>& light_mat_tag_map)
const
732 assert(scene_edit != 0);
733 assert(dice_transaction != 0);
734 assert(light_mat_tag_map.empty());
738 mi::base::Handle<nv::index::IDirectional_headlight> default_light(
739 scene_edit->create_attribute<nv::index::IDirectional_headlight>());
742 default_light->set_direction(mi::math::Vector<mi::Float32, 3>(1.0f, -1.0f, -1.0f));
743 const mi::math::Color color_intensity(1.0f, 1.0f, 1.0f, 1.0f);
744 default_light->set_intensity(color_intensity);
746 const mi::neuraylib::Tag default_light_tag = dice_transaction->store_for_reference_counting(default_light.get());
749 light_mat_tag_map[
"default_light"] = default_light_tag;
753 mi::base::Handle<nv::index::IDirectional_headlight> headlight(
754 scene_edit->create_attribute<nv::index::IDirectional_headlight>());
757 headlight->set_direction(mi::math::Vector<mi::Float32, 3>(1.0f, -1.0f, -1.0f));
758 const mi::math::Color color_intensity(1.0f, 1.0f, 1.0f, 1.0f);
759 headlight->set_intensity(color_intensity);
761 const mi::neuraylib::Tag headlight_tag = dice_transaction->store_for_reference_counting(headlight.get());
764 light_mat_tag_map[
"headlight"] = headlight_tag;
768 mi::base::Handle<nv::index::IDirectional_light> dirlight(
769 scene_edit->create_attribute<nv::index::IDirectional_light>());
772 dirlight->set_direction(mi::math::Vector<mi::Float32, 3>(-1.0f, 0.0f, 0.0f));
773 const mi::math::Color color_intensity(1.0f, 1.0f, 1.0f, 1.0f);
774 dirlight->set_intensity(color_intensity);
776 const mi::neuraylib::Tag dirlight_tag = dice_transaction->store_for_reference_counting(dirlight.get());
779 light_mat_tag_map[
"dirlight"] = dirlight_tag;
784 std::vector<std::string> matname_vec;
785 matname_vec.push_back(
"mat_red");
786 matname_vec.push_back(
"mat_green");
787 matname_vec.push_back(
"mat_blue");
788 matname_vec.push_back(
"mat_yellow");
789 matname_vec.push_back(
"mat_white");
790 matname_vec.push_back(
"mat_pink");
791 matname_vec.push_back(
"mat_exotic");
793 std::vector<mi::math::Color> ambient_vec;
794 ambient_vec.push_back(mi::math::Color(0.3f, 0.0f, 0.0f, 1.0f));
795 ambient_vec.push_back(mi::math::Color(0.0f, 0.3f, 0.0f, 1.0f));
796 ambient_vec.push_back(mi::math::Color(0.0f, 0.0f, 0.3f, 1.0f));
797 ambient_vec.push_back(mi::math::Color(0.6f, 0.6f, 0.0f, 1.0f));
798 ambient_vec.push_back(mi::math::Color(0.3f, 0.3f, 0.3f, 1.0f));
799 ambient_vec.push_back(mi::math::Color(1.0f, 0.0f, 1.0f, 1.0f));
800 ambient_vec.push_back(mi::math::Color(0.5f, 0.0f, 0.0f, 1.0f));
802 std::vector<mi::math::Color> diffuse_vec;
803 diffuse_vec.push_back(mi::math::Color(0.4f, 0.0f, 0.0f, 1.0f));
804 diffuse_vec.push_back(mi::math::Color(0.0f, 0.4f, 0.0f, 1.0f));
805 diffuse_vec.push_back(mi::math::Color(0.0f, 0.0f, 0.4f, 1.0f));
806 diffuse_vec.push_back(mi::math::Color(0.3f, 0.3f, 0.0f, 1.0f));
807 diffuse_vec.push_back(mi::math::Color(0.4f, 0.4f, 0.4f, 1.0f));
808 diffuse_vec.push_back(mi::math::Color(0.4f, 0.4f, 0.0f, 1.0f));
809 diffuse_vec.push_back(mi::math::Color(0.0f, 0.5f, 0.0f, 1.0f));
811 std::vector<mi::math::Color> specular_vec;
812 specular_vec.push_back(mi::math::Color(0.4f, 0.4f, 0.4f, 1.0f));
813 specular_vec.push_back(mi::math::Color(0.4f, 0.4f, 0.4f, 1.0f));
814 specular_vec.push_back(mi::math::Color(0.4f, 0.4f, 0.4f, 1.0f));
815 specular_vec.push_back(mi::math::Color(0.4f, 0.4f, 0.4f, 1.0f));
816 specular_vec.push_back(mi::math::Color(0.4f, 0.4f, 0.4f, 1.0f));
817 specular_vec.push_back(mi::math::Color(0.4f, 0.4f, 0.4f, 1.0f));
818 specular_vec.push_back(mi::math::Color(0.0f, 0.0f, 1.0f, 1.0f));
820 std::vector<mi::Float32> shiness_vec;
821 shiness_vec.push_back(100.0f);
822 shiness_vec.push_back(100.0f);
823 shiness_vec.push_back(100.0f);
824 shiness_vec.push_back(100.0f);
825 shiness_vec.push_back(100.0f);
826 shiness_vec.push_back(100.0f);
827 shiness_vec.push_back(100.0f);
829 assert(matname_vec.size() == ambient_vec.size());
830 assert(matname_vec.size() == diffuse_vec.size());
831 assert(matname_vec.size() == specular_vec.size());
832 assert(matname_vec.size() == shiness_vec.size());
835 for (mi::Size i = 0; i < matname_vec.size(); ++i)
837 mi::base::Handle<nv::index::IPhong_gl> phong_1(scene_edit->create_attribute<nv::index::IPhong_gl>());
840 phong_1->set_ambient(ambient_vec[i]);
841 phong_1->set_diffuse(diffuse_vec[i]);
842 phong_1->set_specular(specular_vec[i]);
843 phong_1->set_shininess(shiness_vec[i]);
844 const mi::neuraylib::Tag phong_1_tag
845 = dice_transaction->store_for_reference_counting(phong_1.get());
848 if (light_mat_tag_map.find(matname_vec[i]) != light_mat_tag_map.end())
850 ERROR_LOG <<
"Duplicated mat name: " << matname_vec[i];
853 light_mat_tag_map[matname_vec[i]] = phong_1_tag;
859mi::neuraylib::Tag Multi_view_shape::get_valid_light_mat_tag_by_name(
860 const std::map<std::string, mi::neuraylib::Tag>& light_mat_tag_map,
861 const std::string& light_mat_name)
const
863 if (light_mat_tag_map.find(light_mat_name) == light_mat_tag_map.end())
865 ERROR_LOG <<
"Cannot find light/mat name: " << light_mat_name;
868 const mi::neuraylib::Tag tag = light_mat_tag_map.find(light_mat_name)->second;
869 assert(tag.is_valid());
875void Multi_view_shape::add_scene_defaut_light(
876 nv::index::IScene* scene_edit,
877 const std::map<std::string, mi::neuraylib::Tag>& light_mat_tag_map,
878 mi::neuraylib::IDice_transaction* dice_transaction)
880 const mi::neuraylib::Tag default_light_tag = get_valid_light_mat_tag_by_name(light_mat_tag_map,
"default_light");
881 scene_edit->append(default_light_tag, dice_transaction);
885void Multi_view_shape::add_scene_group_simple_geometry(
886 nv::index::IScene* scene_edit,
887 const std::map<std::string, mi::neuraylib::Tag>& light_mat_tag_map,
888 mi::neuraylib::IDice_transaction* dice_transaction)
891 mi::base::Handle<nv::index::ITransformed_scene_group> simple_geometry_group_node(
892 scene_edit->create_scene_group<nv::index::ITransformed_scene_group>());
893 check_success(simple_geometry_group_node.is_valid_interface());
894 mi::math::Matrix<mi::Float32, 4, 4> transform_mat(
895 1.0f, 0.0f, 0.0f, 0.0f,
896 0.0f, 1.0f, 0.0f, 0.0f,
897 0.0f, 0.0f, 1.0f, 0.0f,
898 200.0f, 200.0f, 600.0f, 1.0f
900 simple_geometry_group_node->set_transform(transform_mat);
903 simple_geometry_group_node->append(get_valid_light_mat_tag_by_name(light_mat_tag_map,
"headlight"), dice_transaction);
906 simple_geometry_group_node->append(get_valid_light_mat_tag_by_name(light_mat_tag_map,
"mat_red"), dice_transaction);
909 std::vector<mi::neuraylib::Tag> sphere_tag_vec;
912 mi::base::Handle<nv::index::ITransformed_scene_group> group_spheres(
913 scene_edit->create_scene_group<nv::index::ITransformed_scene_group>());
918 std::vector<mi::math::Vector<mi::Float32, 3> > center_vec;
919 center_vec.push_back(mi::math::Vector<mi::Float32, 3>( 0.0f, 0.0f, 0.0f));
920 center_vec.push_back(mi::math::Vector<mi::Float32, 3>(-100.0f, -100.0f, 0.0f));
921 center_vec.push_back(mi::math::Vector<mi::Float32, 3>( -60.0f, -100.0f, 0.0f));
922 center_vec.push_back(mi::math::Vector<mi::Float32, 3>( -20.0f, -100.0f, 0.0f));
923 center_vec.push_back(mi::math::Vector<mi::Float32, 3>( 20.0f, -100.0f, 0.0f));
924 center_vec.push_back(mi::math::Vector<mi::Float32, 3>( 60.0f, -100.0f, 0.0f));
925 center_vec.push_back(mi::math::Vector<mi::Float32, 3>( 100.0f, 0.0f, 0.0f));
927 std::vector<mi::Float32> radius_vec;
928 radius_vec.push_back(50.0f);
929 radius_vec.push_back(10.0f);
930 radius_vec.push_back(12.0f);
931 radius_vec.push_back(14.0f);
932 radius_vec.push_back(16.0f);
933 radius_vec.push_back(18.0f);
934 radius_vec.push_back(25.0f);
935 assert(center_vec.size() == radius_vec.size());
936 assert(center_vec.size() == 7);
938 for (mi::Size i = 0; i < center_vec.size(); ++i)
940 mi::base::Handle<nv::index::ISphere> sphere(
941 scene_edit->create_shape<nv::index::ISphere>());
942 sphere->set_center(center_vec[i]);
943 sphere->set_radius(radius_vec[i]);
945 const mi::neuraylib::Tag sphere_tag
946 = dice_transaction->store_for_reference_counting(sphere.get());
948 sphere_tag_vec.push_back(sphere_tag);
952 simple_geometry_group_node->append(get_valid_light_mat_tag_by_name(light_mat_tag_map,
"mat_green"), dice_transaction);
953 simple_geometry_group_node->append(sphere_tag_vec[0], dice_transaction);
954 simple_geometry_group_node->append(get_valid_light_mat_tag_by_name(light_mat_tag_map,
"mat_red"), dice_transaction);
955 simple_geometry_group_node->append(sphere_tag_vec[1], dice_transaction);
956 simple_geometry_group_node->append(sphere_tag_vec[2], dice_transaction);
957 simple_geometry_group_node->append(sphere_tag_vec[3], dice_transaction);
958 simple_geometry_group_node->append(sphere_tag_vec[4], dice_transaction);
959 simple_geometry_group_node->append(sphere_tag_vec[5], dice_transaction);
963 simple_geometry_group_node->append(get_valid_light_mat_tag_by_name(light_mat_tag_map,
"mat_exotic"), dice_transaction);
965 simple_geometry_group_node->append(get_valid_light_mat_tag_by_name(light_mat_tag_map,
"dirlight"), dice_transaction);
967 simple_geometry_group_node->append(sphere_tag_vec[6], dice_transaction);
969 simple_geometry_group_node->append(get_valid_light_mat_tag_by_name(light_mat_tag_map,
"mat_blue"), dice_transaction);
971 simple_geometry_group_node->append(get_valid_light_mat_tag_by_name(light_mat_tag_map,
"headlight"), dice_transaction);
973 simple_geometry_group_node->append(get_valid_light_mat_tag_by_name(light_mat_tag_map,
"mat_yellow"), dice_transaction);
976 mi::base::Handle<nv::index::IEllipsoid> ellipsoid(
977 scene_edit->create_shape<nv::index::IEllipsoid>());
978 ellipsoid->set_center(mi::math::Vector<mi::Float32, 3>(200.0f, 0.0f, 0.0f));
980 mi::math::Vector<mi::Float32, 3> a(55.0f, 0.0f, 0.0f);
981 mi::math::Vector<mi::Float32, 3> b( 0.0f, 35.0f, 0.0f);
982 mi::Float32 c = 35.0f;
983 ellipsoid->set_semi_axes(a, b, c);
985 const mi::neuraylib::Tag ellipsoid_tag
986 = dice_transaction->store_for_reference_counting(ellipsoid.get());
988 simple_geometry_group_node->append(ellipsoid_tag, dice_transaction);
994 mi::base::Handle<nv::index::ITransformed_scene_group> group_cylinders(
995 scene_edit->create_scene_group<nv::index::ITransformed_scene_group>());
997 mi::math::Matrix<mi::Float32, 4, 4> transform_mat(
998 1.0f, 0.0f, 0.0f, 0.0f,
999 0.0f, 1.0f, 0.0f, 0.0f,
1000 0.0f, 0.0f, 1.0f, 0.0f,
1001 100.0f, 200.0f, 150.0f, 1.0f
1003 group_cylinders->set_transform(transform_mat);
1006 group_cylinders->append(get_valid_light_mat_tag_by_name(light_mat_tag_map,
"mat_green"), dice_transaction);
1007 mi::base::Handle<nv::index::ICylinder> capped_cylinder(
1008 scene_edit->create_shape<nv::index::ICylinder>());
1009 capped_cylinder->set_bottom(mi::math::Vector<mi::Float32, 3>(50.0f, 0.0f, 90.0f));
1010 capped_cylinder->set_top(mi::math::Vector<mi::Float32, 3>(220.0f, 0.0f, 40.0f));
1011 capped_cylinder->set_radius(15.0f);
1012 capped_cylinder->set_capped(
true);
1013 const mi::neuraylib::Tag capped_cylinder_tag
1014 = dice_transaction->store_for_reference_counting(capped_cylinder.get());
1016 group_cylinders->append(capped_cylinder_tag, dice_transaction);
1019 group_cylinders->append(get_valid_light_mat_tag_by_name(light_mat_tag_map,
"mat_blue"), dice_transaction);
1021 mi::base::Handle<nv::index::ICylinder> uncapped_cylinder(
1022 scene_edit->create_shape<nv::index::ICylinder>());
1023 uncapped_cylinder->set_bottom(mi::math::Vector<mi::Float32, 3>(0.0f, 75.0f, 0.0f));
1024 uncapped_cylinder->set_top(mi::math::Vector<mi::Float32, 3>(250.0f, 75.0f, 0.0f));
1025 uncapped_cylinder->set_radius(30.0f);
1026 uncapped_cylinder->set_capped(
false);
1027 const mi::neuraylib::Tag uncapped_cylinder_tag
1028 = dice_transaction->store_for_reference_counting(uncapped_cylinder.get());
1030 group_cylinders->append(uncapped_cylinder_tag, dice_transaction);
1033 group_cylinders->append(get_valid_light_mat_tag_by_name(light_mat_tag_map,
"mat_red"), dice_transaction);
1035 mi::base::Handle<nv::index::ICone> cone(
1036 scene_edit->create_shape<nv::index::ICone>());
1037 cone->set_center(mi::math::Vector<mi::Float32, 3>(250.0f, 75.0f, 0.0f));
1038 cone->set_tip(mi::math::Vector<mi::Float32, 3>(300.0f, 75.0f, 0.0f));
1039 cone->set_radius(30.0f);
1040 cone->set_capped(
true);
1042 const mi::neuraylib::Tag cone_tag
1043 = dice_transaction->store_for_reference_counting(cone.get());
1045 group_cylinders->append(cone_tag, dice_transaction);
1047 const mi::neuraylib::Tag group_cylinders_tag
1048 = dice_transaction->store_for_reference_counting(group_cylinders.get());
1050 simple_geometry_group_node->append(group_cylinders_tag, dice_transaction);
1053 m_simple_geo_group_node_tag =
1054 dice_transaction->store_for_reference_counting(simple_geometry_group_node.get());
1057 scene_edit->append(m_simple_geo_group_node_tag, dice_transaction);
1061void Multi_view_shape::add_scene_group_planes(
1062 nv::index::IScene* scene_edit,
1063 const std::map<std::string, mi::neuraylib::Tag>& light_mat_tag_map,
1064 mi::neuraylib::IDice_transaction* dice_transaction)
1067 mi::base::Handle<nv::index::ITransformed_scene_group> group_plane(
1068 scene_edit->create_scene_group<nv::index::ITransformed_scene_group>());
1071 group_plane->append(get_valid_light_mat_tag_by_name(light_mat_tag_map,
"headlight"), dice_transaction);
1072 group_plane->append(get_valid_light_mat_tag_by_name(light_mat_tag_map,
"mat_red"), dice_transaction);
1074 mi::base::Handle<nv::index::ITexture_filter_mode> tex_filter(
1075 scene_edit->create_attribute<nv::index::ITexture_filter_mode_nearest_neighbor>());
1077 mi::neuraylib::Tag tex_filter_tag = dice_transaction->store_for_reference_counting(tex_filter.get());
1079 group_plane->append(tex_filter_tag, dice_transaction);
1082 mi::base::Handle<nv::index::app::data_analysis_and_processing::IData_analysis_and_processing> processing(
1083 get_application_layer_interface()->get_api_component<nv::index::app::data_analysis_and_processing::IData_analysis_and_processing>());
1087 mi::base::Handle<nv::index::IDistributed_compute_technique> tex(
1088 processing->get_sample_tool_set()->create_checker_board_2d_technique(
1089 mi::math::Vector<mi::Float32, 2>(320.0f, 320.0f),
1090 nv::index::IDistributed_compute_destination_buffer_2d_texture:
:FORMAT_RGBA_FLOAT32,
1091 mi::math::Color(0.9f, 0.2f, 0.15f, 0.7f),
1092 mi::math::Color(0.2f, 0.2f, 0.8f, 1.0f)));
1095 const mi::neuraylib::Tag tex_tag = dice_transaction->store_for_reference_counting(tex.get());
1097 group_plane->append(tex_tag, dice_transaction);
1100 mi::base::Handle<nv::index::IPlane> plane(
1101 scene_edit->create_shape<nv::index::IPlane>());
1102 plane->set_point( mi::math::Vector<mi::Float32,3>(200.0f, -100.0f, 300.0f));
1103 plane->set_normal(mi::math::Vector<mi::Float32,3>(1.0f, 1.0f, 1.0f));
1104 plane->set_up( mi::math::Vector<mi::Float32,3>(-1.0f, 1.0f, 0.0f));
1105 plane->set_extent(mi::math::Vector<mi::Float32,2>(600.0f, 800.0f));
1108 dice_transaction->store_for_reference_counting(plane.get());
1110 group_plane->append(m_plane_tag, dice_transaction);
1112 const mi::neuraylib::Tag group_plane_tag
1113 = dice_transaction->store_for_reference_counting(group_plane.get());
1115 scene_edit->append(group_plane_tag, dice_transaction);
1119void Multi_view_shape::add_scene_group_raster(
1120 nv::index::IScene* scene_edit,
1121 const std::map<std::string, mi::neuraylib::Tag>& light_mat_tag_map,
1122 mi::neuraylib::IDice_transaction* dice_transaction)
1125 mi::base::Handle<nv::index::ITransformed_scene_group> raster_group_node(
1126 scene_edit->create_scene_group<nv::index::ITransformed_scene_group>());
1128 mi::math::Matrix<mi::Float32, 4, 4> transform_mat(
1129 1.0f, 0.0f, 0.0f, 0.0f,
1130 0.0f, 1.0f, 0.0f, 0.0f,
1131 0.0f, 0.0f, 1.0f, 0.0f,
1132 100.0f, 100.0f, 100.0f, 1.0f
1134 raster_group_node->set_transform(transform_mat);
1137 raster_group_node->append(get_valid_light_mat_tag_by_name(light_mat_tag_map,
"headlight"), dice_transaction);
1142 mi::base::Handle<nv::index::ITransformed_scene_group> group_lines_points_node(
1143 scene_edit->create_scene_group<nv::index::ITransformed_scene_group>());
1144 check_success(group_lines_points_node.is_valid_interface());
1145 mi::math::Matrix<mi::Float32, 4, 4> transform_mat(
1146 1.0f, 0.0f, 0.0f, 0.0f,
1147 0.0f, 1.0f, 0.0f, 0.0f,
1148 0.0f, 0.0f, 1.0f, 0.0f,
1149 50.0f, 0.0f, 100.0f, 1.0f
1151 group_lines_points_node->set_transform(transform_mat);
1154 raster_group_node->append(get_valid_light_mat_tag_by_name(light_mat_tag_map,
"mat_white"), dice_transaction);
1158 std::vector<mi::math::Vector<mi::Float32,3> > pos_vec;
1159 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(30.0f, 50.0f, 10.0f));
1160 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(34.0f, 51.0f, 40.0f));
1161 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(39.0f, 58.0f, 70.0f));
1162 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(50.0f, 62.0f, 100.0f));
1163 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(53.0f, 70.0f, 140.0f));
1164 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(55.0f, 50.0f, 190.0f));
1165 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(70.0f, 51.0f, 240.0f));
1166 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(90.0f, 58.0f, 370.0f));
1167 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(91.0f, 62.0f, 500.0f));
1168 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(93.0f, 70.0f, 640.0f));
1170 std::vector<mi::math::Color> col_vec;
1171 col_vec.push_back(mi::math::Color(1.0f, 0.0f, 0.0f, 1.0f));
1172 col_vec.push_back(mi::math::Color(0.0f, 1.0f, 0.0f, 1.0f));
1173 col_vec.push_back(mi::math::Color(0.0f, 0.0f, 1.0f, 1.0f));
1174 col_vec.push_back(mi::math::Color(1.0f, 1.0f, 0.0f, 1.0f));
1175 col_vec.push_back(mi::math::Color(0.0f, 1.0f, 1.0f, 1.0f));
1176 col_vec.push_back(mi::math::Color(1.0f, 0.0f, 0.0f, 1.0f));
1177 col_vec.push_back(mi::math::Color(1.0f, 0.0f, 0.0f, 1.0f));
1178 col_vec.push_back(mi::math::Color(1.0f, 0.0f, 0.0f, 1.0f));
1179 col_vec.push_back(mi::math::Color(1.0f, 0.0f, 0.0f, 1.0f));
1180 col_vec.push_back(mi::math::Color(1.0f, 0.0f, 0.0f, 1.0f));
1182 std::vector<mi::Float32> rad_vec;
1183 for (mi::Size i = 0; i < pos_vec.size(); ++i)
1185 rad_vec.push_back(2.0f);
1188 assert(pos_vec.size() == col_vec.size());
1189 assert(pos_vec.size() == rad_vec.size());
1191 mi::base::Handle<nv::index::IPoint_set> point_set(
1192 scene_edit->create_shape<nv::index::IPoint_set>());
1194 point_set->set_point_style(nv::index::IPoint_set:
:SHADED_CIRCLE);
1195 point_set->set_vertices(&pos_vec[0], pos_vec.size());
1196 point_set->set_colors( &col_vec[0], col_vec.size());
1197 point_set->set_radii( &rad_vec[0], rad_vec.size());
1199 const mi::neuraylib::Tag point_set_tag
1200 = dice_transaction->store_for_reference_counting(point_set.get());
1202 raster_group_node->append(point_set_tag, dice_transaction);
1206 raster_group_node->append(get_valid_light_mat_tag_by_name(light_mat_tag_map,
"mat_blue"), dice_transaction);
1209 std::vector<mi::math::Vector<mi::Float32,3> > pos_vec;
1210 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(30.0f, 50.0f, 10.0f));
1211 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(34.0f, 51.0f, 40.0f));
1212 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(34.0f, 51.0f, 40.0f));
1213 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(39.0f, 58.0f, 70.0f));
1214 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(39.0f, 58.0f, 70.0f));
1215 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(50.0f, 62.0f, 100.0f));
1216 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(50.0f, 62.0f, 100.0f));
1217 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(53.0f, 70.0f, 140.0f));
1218 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(53.0f, 70.0f, 140.0f));
1219 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(55.0f, 50.0f, 190.0f));
1220 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(55.0f, 50.0f, 190.0f));
1221 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(70.0f, 51.0f, 240.0f));
1222 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(70.0f, 51.0f, 240.0f));
1223 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(90.0f, 58.0f, 370.0f));
1224 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(90.0f, 58.0f, 370.0f));
1225 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(91.0f, 62.0f, 500.0f));
1226 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(91.0f, 62.0f, 500.0f));
1227 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(93.0f, 70.0f, 640.0f));
1228 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(40.0f, 60.0f, 15.0f));
1229 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(44.0f, 61.0f, 45.0f));
1230 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(44.0f, 61.0f, 45.0f));
1231 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(59.0f, 68.0f, 75.0f));
1232 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(59.0f, 68.0f, 75.0f));
1233 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(60.0f, 70.0f, 109.0f));
1234 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(60.0f, 70.0f, 109.0f));
1235 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(60.0f, 75.0f, 141.0f));
1236 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(60.0f, 75.0f, 141.0f));
1237 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(60.0f, 80.0f, 196.0f));
1238 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(60.0f, 80.0f, 196.0f));
1239 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(80.0f, 81.0f, 242.0f));
1240 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(80.0f, 81.0f, 242.0f));
1241 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(100.0f, 88.0f, 393.0f));
1242 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(100.0f, 88.0f, 393.0f));
1243 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(101.0f, 82.0f, 530.0f));
1244 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(101.0f, 82.0f, 530.0f));
1245 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(108.0f, 90.0f, 655.0f));
1246 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(108.0f, 90.0f, 655.0f));
1247 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(113.0f, 109.0f, 685.0f));
1248 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(113.0f, 109.0f, 685.0f));
1249 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(129.0f, 115.0f, 688.0f));
1252 mi::base::Handle<nv::index::ILine_set> line_set(scene_edit->create_shape<nv::index::ILine_set>());
1255 line_set->set_line_type(nv::index::ILine_set:
:LINE_TYPE_SEGMENTS);
1256 line_set->set_line_style(nv::index::ILine_set:
:LINE_STYLE_DASHED);
1257 line_set->set_lines(&pos_vec[0], pos_vec.size());
1259 std::vector<mi::math::Color> col_vec;
1260 std::vector<mi::Float32> width_vec;
1261 for (mi::Size i = 0; i < pos_vec.size(); ++i)
1263 col_vec.push_back(mi::math::Color(1.0f, 0.0f, 0.0f, 1.0f));
1264 width_vec.push_back(2.0f);
1266 line_set->set_colors(&col_vec[0], col_vec.size()/2);
1267 line_set->set_widths(&width_vec[0], width_vec.size());
1269 const mi::neuraylib::Tag line_set_tag
1270 = dice_transaction->store_for_reference_counting(line_set.get());
1272 INFO_LOG <<
"line_set_tag: " << line_set_tag;
1274 raster_group_node->append(line_set_tag, dice_transaction);
1278 raster_group_node->append(get_valid_light_mat_tag_by_name(light_mat_tag_map,
"dirlight"), dice_transaction);
1280 raster_group_node->append(get_valid_light_mat_tag_by_name(light_mat_tag_map,
"mat_blue"), dice_transaction);
1283 mi::math::Vector<mi::Float32,3> pos(120.0f, 120.0f, 120.0f);
1284 mi::Float32 rad = 20.0f;
1286 mi::base::Handle<nv::index::IPoint_set> point_large(
1287 scene_edit->create_shape<nv::index::IPoint_set>());
1289 point_large->set_point_style(nv::index::IPoint_set:
:SHADED_CIRCLE);
1290 point_large->set_vertices(&pos, 1);
1291 point_large->set_radii( &rad, 1);
1293 const mi::neuraylib::Tag point_large_tag
1294 = dice_transaction->store_for_reference_counting(point_large.get());
1296 raster_group_node->append(point_large_tag, dice_transaction);
1300 raster_group_node->append(get_valid_light_mat_tag_by_name(light_mat_tag_map,
"mat_white"), dice_transaction);
1303 std::vector<mi::math::Vector<mi::Float32,3> > pos_vec;
1304 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(10.0f, 60.0f, 10.0f));
1305 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(30.0f, 50.0f, 10.0f));
1306 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(80.0f, 40.0f, 10.0f));
1308 std::vector<mi::math::Color> col_vec;
1309 col_vec.push_back(mi::math::Color(1.0f, 0.0f, 0.0f, 1.0f));
1310 col_vec.push_back(mi::math::Color(0.0f, 1.0f, 0.0f, 1.0f));
1311 col_vec.push_back(mi::math::Color(0.0f, 0.0f, 1.0f, 1.0f));
1313 std::vector<mi::Float32> rad_vec;
1314 for (mi::Size i = 0; i < pos_vec.size(); ++i)
1316 rad_vec.push_back(10.0f);
1319 mi::base::Handle<nv::index::IPoint_set> point_set(
1320 scene_edit->create_shape<nv::index::IPoint_set>());
1322 point_set->set_point_style(nv::index::IPoint_set:
:FLAT_TRIANGLE);
1323 point_set->set_vertices(&pos_vec[0], pos_vec.size());
1324 point_set->set_colors( &col_vec[0], col_vec.size());
1325 point_set->set_radii( &rad_vec[0], rad_vec.size());
1327 const mi::neuraylib::Tag point_set_tag
1328 = dice_transaction->store_for_reference_counting(point_set.get());
1330 raster_group_node->append(point_set_tag, dice_transaction);
1337 mi::base::Handle<nv::index::ITransformed_scene_group> circle_ellipses_group_node(
1338 scene_edit->create_scene_group<nv::index::ITransformed_scene_group>());
1339 check_success(circle_ellipses_group_node.is_valid_interface());
1340 mi::math::Matrix<mi::Float32, 4, 4> transform_mat(
1341 1.0f, 0.0f, 0.0f, 0.0f,
1342 0.0f, 1.0f, 0.0f, 0.0f,
1343 0.0f, 0.0f, 1.0f, 0.0f,
1344 300.0f, 500.0f, 100.0f, 1.0f
1346 circle_ellipses_group_node->set_transform(transform_mat);
1349 raster_group_node->append(get_valid_light_mat_tag_by_name(light_mat_tag_map,
"headlight"), dice_transaction);
1351 raster_group_node->append(get_valid_light_mat_tag_by_name(light_mat_tag_map,
"mat_white"), dice_transaction);
1354 std::vector<mi::neuraylib::Tag> circle_and_ellipses_tag_vec;
1357 std::vector<mi::math::Vector<mi::Float32,3> > pos_vec;
1358 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(300.0f, 50.0f, 90.0f));
1359 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(100.0f, 450.0f, 350.0f));
1360 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(440.0f, 450.0f, 56.0f));
1361 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(440.0f, 450.0f, 56.0f));
1363 std::vector<mi::Float32> rad_vec;
1364 rad_vec.push_back(20.0f);
1365 rad_vec.push_back( 8.0f);
1366 rad_vec.push_back(10.0f);
1367 rad_vec.push_back( 5.0f);
1369 std::vector<mi::math::Color> col_vec;
1370 col_vec.push_back(mi::math::Color(1.0f, 1.0f, 0.0f, 1.0f));
1371 col_vec.push_back(mi::math::Color(1.0f, 0.0f, 1.0f, 1.0f));
1372 col_vec.push_back(mi::math::Color(1.0f, 0.0f, 0.5f, 1.0f));
1373 col_vec.push_back(mi::math::Color(1.0f, 0.0f, 0.0f, 1.0f));
1375 std::vector<mi::Float32> width_vec;
1376 width_vec.push_back(0.75f);
1377 width_vec.push_back(2.75f);
1378 width_vec.push_back(5.75f);
1379 width_vec.push_back(1.0f);
1381 std::vector<mi::math::Color> fill_col_vec;
1382 fill_col_vec.push_back(mi::math::Color(0.0f, 1.0f, 1.0f, 0.66f));
1383 fill_col_vec.push_back(mi::math::Color(0.0f, 1.0f, 0.0f, 0.75f));
1384 fill_col_vec.push_back(mi::math::Color(1.0f, 0.5f, 0.0f, 1.0f));
1385 fill_col_vec.push_back(mi::math::Color(1.0f, 1.0f, 0.0f, 1.0f));
1387 assert(pos_vec.size() == rad_vec.size());
1388 assert(pos_vec.size() == col_vec.size());
1389 assert(pos_vec.size() == width_vec.size());
1390 assert(pos_vec.size() == fill_col_vec.size());
1392 for (mi::Size i = 0; i < pos_vec.size(); ++i)
1394 mi::base::Handle<nv::index::ICircle> circle(
1395 scene_edit->create_shape<nv::index::ICircle>());
1398 circle->set_geometry(pos_vec[i], rad_vec[i]);
1399 circle->set_outline_style(col_vec[i], width_vec[i]);
1400 circle->set_fill_style(fill_col_vec[i], nv::index::ICircle:
:FILL_SOLID);
1402 const mi::neuraylib::Tag circle_tag
1403 = dice_transaction->store_for_reference_counting(circle.get());
1406 circle_and_ellipses_tag_vec.push_back(circle_tag);
1411 std::vector<mi::math::Vector<mi::Float32,3> > pos_vec;
1412 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(30.0f, 50.0f, -50.0f));
1413 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(50.0f, 100.0f, 50.0f));
1414 pos_vec.push_back(mi::math::Vector<mi::Float32,3>(150.0f, 100.0f, 200.0f));
1416 std::vector<mi::Float32> rad_x_vec;
1417 rad_x_vec.push_back(15.0f);
1418 rad_x_vec.push_back(40.0f);
1419 rad_x_vec.push_back(40.0f);
1421 std::vector<mi::Float32> rad_y_vec;
1422 rad_y_vec.push_back(20.0f);
1423 rad_y_vec.push_back(20.0f);
1424 rad_y_vec.push_back(10.0f);
1426 std::vector<mi::Float32> rot_vec;
1427 rot_vec.push_back(0.2f);
1428 rot_vec.push_back(0.15f);
1429 rot_vec.push_back(0.785f);
1431 std::vector<mi::math::Color> line_col_vec;
1432 line_col_vec.push_back(mi::math::Color(1.0f, 0.0f, 0.0f, 1.0f));
1433 line_col_vec.push_back(mi::math::Color(0.0f, 0.0f, 1.0f, 1.0f));
1434 line_col_vec.push_back(mi::math::Color(0.0f, 1.0f, 1.0f, 1.0f));
1436 std::vector<mi::Float32> width_vec;
1437 width_vec.push_back(2.0);
1438 width_vec.push_back(3.0);
1439 width_vec.push_back(15.0);
1441 std::vector<mi::math::Color> fill_col_vec;
1442 fill_col_vec.push_back(mi::math::Color(1.0f, 1.0f, 0.0f, 1.0f));
1443 fill_col_vec.push_back(mi::math::Color(1.0f, 1.0f, 1.0f, 0.5f));
1444 fill_col_vec.push_back(mi::math::Color(1.0f, 1.0f, 1.0f, 0.0f));
1446 assert(pos_vec.size() == rad_x_vec.size());
1447 assert(pos_vec.size() == rad_y_vec.size());
1448 assert(pos_vec.size() == rot_vec.size());
1449 assert(pos_vec.size() == line_col_vec.size());
1450 assert(pos_vec.size() == width_vec.size());
1451 assert(pos_vec.size() == fill_col_vec.size());
1453 for (mi::Size i = 0; i < pos_vec.size(); ++i)
1455 mi::base::Handle<nv::index::IEllipse> ellipse(
1456 scene_edit->create_shape<nv::index::IEllipse>());
1459 ellipse->set_geometry(pos_vec[i], rad_x_vec[i], rad_y_vec[i], rot_vec[i]);
1460 ellipse->set_outline_style(line_col_vec[i], width_vec[i]);
1461 ellipse->set_fill_style(fill_col_vec[i], nv::index::IEllipse:
:FILL_SOLID);
1463 const mi::neuraylib::Tag ellipse_tag
1464 = dice_transaction->store_for_reference_counting(ellipse.get());
1467 circle_and_ellipses_tag_vec.push_back(ellipse_tag);
1474 mi::base::Handle<nv::index::IDepth_offset> depth_offset_attr(
1475 scene_edit->create_attribute<nv::index::IDepth_offset>());
1477 depth_offset_attr->set_depth_offset(10.0f);
1478 const mi::neuraylib::Tag depth_offset_attr_tag
1479 = dice_transaction->store_for_reference_counting(depth_offset_attr.get());
1483 raster_group_node->append(circle_and_ellipses_tag_vec[0], dice_transaction);
1485 raster_group_node->append(circle_and_ellipses_tag_vec[1], dice_transaction);
1487 raster_group_node->append(circle_and_ellipses_tag_vec[2], dice_transaction);
1489 raster_group_node->append(depth_offset_attr_tag, dice_transaction);
1491 raster_group_node->append(circle_and_ellipses_tag_vec[3], dice_transaction);
1493 raster_group_node->append(circle_and_ellipses_tag_vec[4], dice_transaction);
1495 raster_group_node->append(circle_and_ellipses_tag_vec[5], dice_transaction);
1497 raster_group_node->append(circle_and_ellipses_tag_vec[6], dice_transaction);
1499 m_raster_circle1_tag = circle_and_ellipses_tag_vec[0];
1500 m_raster_ellipses1_tag = circle_and_ellipses_tag_vec[4];
1507 mi::base::Handle<nv::index::ITransformed_scene_group> group_polygons(
1508 scene_edit->create_scene_group<nv::index::ITransformed_scene_group>());
1510 mi::math::Matrix<mi::Float32, 4, 4> transform_mat(
1511 1.0f, 0.0f, 0.0f, 0.0f,
1512 0.0f, 1.0f, 0.0f, 0.0f,
1513 0.0f, 0.0f, 1.0f, 0.0f,
1514 0.0f, 0.0f, 0.0f, 1.0f
1516 group_polygons->set_transform(transform_mat);
1519 group_polygons->append(get_valid_light_mat_tag_by_name(light_mat_tag_map,
"headlight"), dice_transaction);
1521 group_polygons->append(get_valid_light_mat_tag_by_name(light_mat_tag_map,
"mat_white"), dice_transaction);
1523 const mi::Size
NB_POLY = 4;
1524 std::vector<mi::math::Vector<mi::Float32, 3> > center_vec;
1525 center_vec.push_back(mi::math::Vector<mi::Float32, 3>(90.0f, 50.0f, 150.0f));
1526 center_vec.push_back(mi::math::Vector<mi::Float32, 3>(129.0f, 300.0f, 50.0f));
1527 center_vec.push_back(mi::math::Vector<mi::Float32, 3>(200.0f, 150.0f, 200.0f));
1528 center_vec.push_back(mi::math::Vector<mi::Float32, 3>(530.0f, 50.0f, 340.0f));
1530 std::vector<mi::math::Vector<mi::Float32, 2> > vtx_vec
[NB_POLY];
1531 vtx_vec[0].push_back(mi::math::Vector<mi::Float32, 2>(20.0f, 20.0f));
1532 vtx_vec[0].push_back(mi::math::Vector<mi::Float32, 2>(20.0f, 60.0f));
1533 vtx_vec[0].push_back(mi::math::Vector<mi::Float32, 2>(-20.0f, 60.0f));
1534 vtx_vec[0].push_back(mi::math::Vector<mi::Float32, 2>(-20.0f, 20.0f));
1535 vtx_vec[0].push_back(mi::math::Vector<mi::Float32, 2>(-60.0f, 20.0f));
1536 vtx_vec[0].push_back(mi::math::Vector<mi::Float32, 2>(-60.0f, -20.0f));
1537 vtx_vec[0].push_back(mi::math::Vector<mi::Float32, 2>(-20.0f, -20.0f));
1538 vtx_vec[0].push_back(mi::math::Vector<mi::Float32, 2>(-20.0f, -60.0f));
1539 vtx_vec[0].push_back(mi::math::Vector<mi::Float32, 2>(20.0f, -60.0f));
1540 vtx_vec[0].push_back(mi::math::Vector<mi::Float32, 2>(20.0f, -20.0f));
1541 vtx_vec[0].push_back(mi::math::Vector<mi::Float32, 2>(60.0f, -20.0f));
1542 vtx_vec[0].push_back(mi::math::Vector<mi::Float32, 2>(60.0f, 20.0f));
1544 vtx_vec[1].push_back(mi::math::Vector<mi::Float32, 2>(0.0f, 60.0f));
1545 vtx_vec[1].push_back(mi::math::Vector<mi::Float32, 2>(-20.0f, 20.0f));
1546 vtx_vec[1].push_back(mi::math::Vector<mi::Float32, 2>(-60.0f, 20.0f));
1547 vtx_vec[1].push_back(mi::math::Vector<mi::Float32, 2>(-25.0f, 0.0f));
1548 vtx_vec[1].push_back(mi::math::Vector<mi::Float32, 2>(-40.0f, -40.0f));
1549 vtx_vec[1].push_back(mi::math::Vector<mi::Float32, 2>(0.0f, -20.0f));
1550 vtx_vec[1].push_back(mi::math::Vector<mi::Float32, 2>(40.0f, -40.0f));
1551 vtx_vec[1].push_back(mi::math::Vector<mi::Float32, 2>(25.0f, 0.0f));
1552 vtx_vec[1].push_back(mi::math::Vector<mi::Float32, 2>(60.0f, 20.0f));
1553 vtx_vec[1].push_back(mi::math::Vector<mi::Float32, 2>(20.0f, 20.0f));
1555 vtx_vec[2].push_back(mi::math::Vector<mi::Float32, 2>(0.0f, 40.0f));
1556 vtx_vec[2].push_back(mi::math::Vector<mi::Float32, 2>(-20.0f, 0.0f));
1557 vtx_vec[2].push_back(mi::math::Vector<mi::Float32, 2>(0.0f, -40.0f));
1558 vtx_vec[2].push_back(mi::math::Vector<mi::Float32, 2>(20.0f, 0.0f));
1560 vtx_vec[3].push_back(mi::math::Vector<mi::Float32, 2>(0.0f, 20.0f));
1561 vtx_vec[3].push_back(mi::math::Vector<mi::Float32, 2>(-20.0f, 60.0f));
1562 vtx_vec[3].push_back(mi::math::Vector<mi::Float32, 2>(-60.0f, 60.0f));
1563 vtx_vec[3].push_back(mi::math::Vector<mi::Float32, 2>(-30.0f, 0.0f));
1564 vtx_vec[3].push_back(mi::math::Vector<mi::Float32, 2>(-60.0f, -60.0f));
1565 vtx_vec[3].push_back(mi::math::Vector<mi::Float32, 2>(-20.0f, -60.0f));
1566 vtx_vec[3].push_back(mi::math::Vector<mi::Float32, 2>(0.0f, -20.0f));
1567 vtx_vec[3].push_back(mi::math::Vector<mi::Float32, 2>(20.0f, -60.0f));
1568 vtx_vec[3].push_back(mi::math::Vector<mi::Float32, 2>(60.0f, -60.0f));
1569 vtx_vec[3].push_back(mi::math::Vector<mi::Float32, 2>(30.0f, 0.0f));
1570 vtx_vec[3].push_back(mi::math::Vector<mi::Float32, 2>(60.0f, 60.0f));
1571 vtx_vec[3].push_back(mi::math::Vector<mi::Float32, 2>(20.0f, 60.0f));
1574 for (mi::Size i = 0; i <
NB_POLY; ++i)
1576 for (mi::Size j = 0; j < vtx_vec[i].size(); ++j)
1578 vtx_vec[i][j] = 0.25f * vtx_vec[i][j];
1582 std::vector<mi::math::Color> line_color_vec;
1583 line_color_vec.push_back(mi::math::Color(1.0f, 1.0f, 0.5f, 1.0f));
1584 line_color_vec.push_back(mi::math::Color(1.0f, 0.5f, 0.5f, 1.0f));
1585 line_color_vec.push_back(mi::math::Color(1.0f, 1.0f, 1.0f, 1.0f));
1586 line_color_vec.push_back(mi::math::Color(0.7f, 0.7f, 1.0f, 1.0f));
1588 std::vector<mi::Float32> line_width_vec;
1589 line_width_vec.push_back(3.0f);
1590 line_width_vec.push_back(2.5f);
1591 line_width_vec.push_back(3.5f);
1592 line_width_vec.push_back(1.7f);
1594 std::vector<mi::math::Color> fill_color_vec;
1595 fill_color_vec.push_back(mi::math::Color(0.0f, 1.0f, 0.0f, 1.0f));
1596 fill_color_vec.push_back(mi::math::Color(1.0f, 0.0f, 0.0f, 1.0f));
1597 fill_color_vec.push_back(mi::math::Color(0.0f, 0.0f, 1.0f, 1.0f));
1598 fill_color_vec.push_back(mi::math::Color(1.0f, 1.0f, 0.5f, 1.0f));
1604 for (mi::Size i = 0; i < center_vec.size(); ++i)
1606 mi::base::Handle<nv::index::IPolygon> polygon(
1607 scene_edit->create_shape<nv::index::IPolygon>());
1608 check_success((polygon->set_geometry(&(vtx_vec[i][0]), vtx_vec[i].size(), center_vec[i])));
1609 polygon->set_fill_style(fill_color_vec[i], nv::index::IPolygon:
:FILL_SOLID);
1611 const mi::neuraylib::Tag polygon_tag = dice_transaction->store_for_reference_counting(polygon.get());
1613 group_polygons->append(polygon_tag, dice_transaction);
1617 m_polygon_group_tag = dice_transaction->store_for_reference_counting(group_polygons.get());
1619 raster_group_node->append(m_polygon_group_tag, dice_transaction);
1622 const mi::neuraylib::Tag raster_group_node_tag
1623 = dice_transaction->store_for_reference_counting(raster_group_node.get());
1625 scene_edit->append(raster_group_node_tag, dice_transaction);
1629void Multi_view_shape::add_scene_group_paths(
1630 nv::index::IScene* scene_edit,
1631 const std::map<std::string, mi::neuraylib::Tag>& light_mat_tag_map,
1632 mi::neuraylib::IDice_transaction* dice_transaction)
1635 mi::base::Handle<nv::index::ITransformed_scene_group> group_paths(
1636 scene_edit->create_scene_group<nv::index::ITransformed_scene_group>());
1638 mi::math::Matrix<mi::Float32, 4, 4> transform_mat(
1639 1.0f, 0.0f, 0.0f, 0.0f,
1640 0.0f, 1.0f, 0.0f, 0.0f,
1641 0.0f, 0.0f, 1.0f, 0.0f,
1642 160.0f, 150.0f, 300.0f, 1.0f
1644 group_paths->set_transform(transform_mat);
1647 group_paths->append(get_valid_light_mat_tag_by_name(light_mat_tag_map,
"headlight"), dice_transaction);
1649 group_paths->append(get_valid_light_mat_tag_by_name(light_mat_tag_map,
"mat_blue"), dice_transaction);
1651 group_paths->append(get_valid_light_mat_tag_by_name(light_mat_tag_map,
"mat_green"), dice_transaction);
1653 group_paths->append(get_valid_light_mat_tag_by_name(light_mat_tag_map,
"mat_red"), dice_transaction);
1655 mi::base::Handle<nv::index::IPath_style> path_style_linear(
1656 scene_edit->create_attribute<nv::index::IPath_style>());
1658 path_style_linear->set_interpolation(nv::index::IPath_style:
:INTERPOLATION_LINEAR);
1660 const mi::neuraylib::Tag path_style_linear_tag = dice_transaction->store_for_reference_counting(path_style_linear.get());
1662 group_paths->append(path_style_linear_tag, dice_transaction);
1665 std::vector<mi::math::Vector<mi::Float32,3> > point_vec;
1666 point_vec.push_back(mi::math::Vector<mi::Float32,3>(130.0f, 250.0f, 10.0f));
1667 point_vec.push_back(mi::math::Vector<mi::Float32,3>(134.0f, 251.0f, 40.0f));
1668 point_vec.push_back(mi::math::Vector<mi::Float32,3>(139.0f, 258.0f, 70.0f));
1669 point_vec.push_back(mi::math::Vector<mi::Float32,3>(150.0f, 262.0f, 100.0f));
1670 point_vec.push_back(mi::math::Vector<mi::Float32,3>(153.0f, 270.0f, 140.0f));
1671 point_vec.push_back(mi::math::Vector<mi::Float32,3>(155.0f, 250.0f, 190.0f));
1672 point_vec.push_back(mi::math::Vector<mi::Float32,3>(170.0f, 251.0f, 240.0f));
1673 point_vec.push_back(mi::math::Vector<mi::Float32,3>(190.0f, 258.0f, 370.0f));
1674 point_vec.push_back(mi::math::Vector<mi::Float32,3>(191.0f, 262.0f, 500.0f));
1675 point_vec.push_back(mi::math::Vector<mi::Float32,3>(193.0f, 270.0f, 640.0f));
1677 std::vector<mi::Uint32> mat_vec;
1678 mat_vec.push_back(2);
1679 mat_vec.push_back(1);
1680 mat_vec.push_back(0);
1681 mat_vec.push_back(2);
1682 mat_vec.push_back(2);
1683 mat_vec.push_back(1);
1684 mat_vec.push_back(1);
1685 mat_vec.push_back(0);
1686 mat_vec.push_back(2);
1687 mat_vec.push_back(1);
1689 mi::base::Handle<nv::index::IPath_3D> path1(
1690 scene_edit->create_shape<nv::index::IPath_3D>());
1692 path1->set_radius(10.0f);
1693 path1->set_points(&(point_vec[0]), point_vec.size());
1694 path1->set_color_map_indexes(&(mat_vec[0]), mat_vec.size());
1697 m_path3d_1_tag = dice_transaction->store_for_reference_counting(path1.get());
1699 group_paths->append(m_path3d_1_tag, dice_transaction);
1701 const mi::neuraylib::Tag group_paths_tag = dice_transaction->store_for_reference_counting(group_paths.get());
1703 scene_edit->append(group_paths_tag, dice_transaction);
1707void Multi_view_shape::add_scene_group_labels(
1708 nv::index::IScene* scene_edit,
1709 const std::map<std::string, mi::neuraylib::Tag>& light_mat_tag_map,
1710 mi::neuraylib::IDice_transaction* dice_transaction)
1713 mi::base::Handle<nv::index::ITransformed_scene_group> group_labels(
1714 scene_edit->create_scene_group<nv::index::ITransformed_scene_group>());
1716 mi::math::Matrix<mi::Float32, 4, 4> transform_mat(
1717 1.0f, 0.0f, 0.0f, 0.0f,
1718 0.0f, 1.0f, 0.0f, 0.0f,
1719 0.0f, 0.0f, 1.0f, 0.0f,
1720 0.0f, 0.0f, 0.0f, 1.0f
1722 group_labels->set_transform(transform_mat);
1725 mi::base::Handle<nv::index::IFont> font(scene_edit->create_attribute<nv::index::IFont>());
1728 if (font->set_file_name(m_font_fpath.c_str()))
1730 INFO_LOG <<
"set the font path [" << m_font_fpath <<
"]";
1734 ERROR_LOG <<
"Can not find the font path [" << m_font_fpath <<
"], "
1735 <<
"the rendering result may not correct.";
1737 font->set_font_resolution(64.0f);
1738 const mi::neuraylib::Tag font_tag = dice_transaction->store_for_reference_counting(font.get());
1740 group_labels->append(font_tag, dice_transaction);
1743 mi::base::Handle<nv::index::ILabel_layout> label_layout(
1744 scene_edit->create_attribute<nv::index::ILabel_layout>());
1746 label_layout->set_padding(10.0f);
1747 label_layout->set_color(mi::math::Color(1.0f, 1.0f, 1.0f, 1.0f), mi::math::Color(1.0f, 1.0f, 1.0f, 0.157f));
1748 const mi::neuraylib::Tag label_layout_tag =
1749 dice_transaction->store_for_reference_counting(label_layout.get());
1751 group_labels->append(label_layout_tag, dice_transaction);
1754 mi::base::Handle<nv::index::ILabel_2D> label_2d(scene_edit->create_shape<nv::index::ILabel_2D>());
1756 label_2d->set_text(
"Global scope view");
1757 const mi::math::Vector<mi::Float32, 3> label_2d_position(-40.0f, 000.0f, 570.0f);
1758 const mi::math::Vector<mi::Float32, 2> right_2d(1.0f, 0.0f);
1759 const mi::math::Vector<mi::Float32, 2> up_2d (0.0f, 1.0f);
1760 label_2d->set_geometry(label_2d_position, right_2d, up_2d, 30.0f, -1.0f);
1762 dice_transaction->store_for_reference_counting(label_2d.get());
1765 group_labels->append(m_label2d_tag, dice_transaction);
1768 mi::base::Handle<nv::index::ILabel_layout> label_layout2(
1769 scene_edit->create_attribute<nv::index::ILabel_layout>());
1771 label_layout2->set_padding(0.0f);
1772 label_layout2->set_color(mi::math::Color(0.46f, 0.73f, 0.0f, 1.0f), mi::math::Color(0.0f, 0.0f, 0.0f, 0.0f));
1773 const mi::neuraylib::Tag label_layout2_tag =
1774 dice_transaction->store_for_reference_counting(label_layout2.get());
1776 group_labels->append(label_layout2_tag, dice_transaction);
1779 mi::base::Handle<nv::index::ILabel_3D> label_3d(scene_edit->create_shape<nv::index::ILabel_3D>());
1781 label_3d->set_text(
"NVIDIA IndeX");
1782 const mi::math::Vector<mi::Float32, 3> label_3d_position(550.0f, 200.0f, 150.0f);
1783 const mi::math::Vector<mi::Float32, 3> right_3d(1.0f, 0.0f, 0.0f);
1784 const mi::math::Vector<mi::Float32, 3> up_3d (0.0f, 0.0f, -1.0f);
1785 label_3d->set_geometry(label_3d_position, right_3d, up_3d, 50.0f, 400.0f);
1786 const mi::neuraylib::Tag label_3d_tag = dice_transaction->store_for_reference_counting(label_3d.get());
1788 group_labels->append(label_3d_tag, dice_transaction);
1790 const mi::neuraylib::Tag group_labels_tag =
1791 dice_transaction->store_for_reference_counting(group_labels.get());
1793 scene_edit->append(group_labels_tag, dice_transaction);
1797void Multi_view_shape::add_scene_group_icons(
1798 nv::index::IScene* scene_edit,
1799 const std::map<std::string, mi::neuraylib::Tag>& light_mat_tag_map,
1800 mi::neuraylib::IDice_transaction* dice_transaction)
1803 mi::base::Handle<nv::index::ITransformed_scene_group> group_icons(
1804 scene_edit->create_scene_group<nv::index::ITransformed_scene_group>());
1806 mi::math::Matrix<mi::Float32, 4, 4> transform_mat(
1807 1.0f, 0.0f, 0.0f, 0.0f,
1808 0.0f, 1.0f, 0.0f, 0.0f,
1809 0.0f, 0.0f, 1.0f, 0.0f,
1810 0.0f, 0.0f, 0.0f, 1.0f
1812 group_icons->set_transform(transform_mat);
1815 mi::base::Handle<nv::index::ITexture> tex(
1816 scene_edit->create_attribute<nv::index::ITexture>());
1819 mi::base::Handle<nv::index::app::image::IImage_importer> image_importer(
1820 get_application_layer_interface()->get_api_component<nv::index::app::image::IImage_importer>());
1822 mi::base::Handle<mi::neuraylib::ICanvas> canvas(
1823 image_importer->create_canvas_from_file(m_iconfile.c_str()));
1827 check_success(tex->set_pixel_data(canvas.get(), nv::index::ITexture:
:RGBA_FLOAT32));
1829 const mi::neuraylib::Tag tex_tag =
1830 dice_transaction->store_for_reference_counting(tex.get());
1832 group_icons->append(tex_tag, dice_transaction);
1836 mi::base::Handle<nv::index::IIcon_3D> icon_3d(
1837 scene_edit->create_shape<nv::index::IIcon_3D>());
1839 const mi::math::Vector<mi::Float32, 3> position(-150.0f, 700.0f, 400.0f);
1840 const mi::math::Vector<mi::Float32, 3> right_vector(0.0f, -1.0f, 0.0f);
1841 const mi::math::Vector<mi::Float32, 3> up_vector (0.0f, 0.0f, -1.0f);
1842 icon_3d->set_geometry(position, right_vector, up_vector, 44.0f, 180.0f);
1843 const mi::neuraylib::Tag icon_3d_tag =
1844 dice_transaction->store_for_reference_counting(icon_3d.get());
1846 group_icons->append(icon_3d_tag, dice_transaction);
1851 mi::base::Handle<nv::index::IIcon_2D> icon_2d(
1852 scene_edit->create_shape<nv::index::IIcon_2D>());
1854 const mi::math::Vector<mi::Float32, 3> position(520.0f, 0.0f, 80.0f);
1855 const mi::math::Vector<mi::Float32, 2> right_vector(1.0f, 0.0f);
1856 const mi::math::Vector<mi::Float32, 2> up_vector (0.0f, 1.0f);
1857 icon_2d->set_geometry(position, right_vector, up_vector, 44.0f, 180.0f);
1858 const mi::neuraylib::Tag icon_2d_tag =
1859 dice_transaction->store_for_reference_counting(icon_2d.get());
1861 group_icons->append(icon_2d_tag, dice_transaction);
1864 const mi::neuraylib::Tag group_icons_tag =
1865 dice_transaction->store_for_reference_counting(group_icons.get());
1867 scene_edit->append(group_icons_tag, dice_transaction);
1871void Multi_view_shape::setup_scene(mi::neuraylib::IDice_transaction* dice_transaction)
1876 mi::base::Handle<const nv::index::ISession> session(
1877 dice_transaction->access<
const nv::index::ISession>(m_session_tag));
1881 mi::base::Handle<nv::index::IScene> scene_edit(
1882 dice_transaction->edit<nv::index::IScene>(session->get_scene()));
1885 std::map<std::string, mi::neuraylib::Tag> light_mat_tag_map;
1886 create_light_material_instance(scene_edit.get(), dice_transaction, light_mat_tag_map);
1889 add_scene_defaut_light(scene_edit.get(), light_mat_tag_map, dice_transaction);
1890 add_scene_group_simple_geometry(scene_edit.get(), light_mat_tag_map, dice_transaction);
1891 add_scene_group_planes(scene_edit.get(), light_mat_tag_map, dice_transaction);
1892 add_scene_group_raster(scene_edit.get(), light_mat_tag_map, dice_transaction);
1893 add_scene_group_paths( scene_edit.get(), light_mat_tag_map, dice_transaction);
1894 add_scene_group_labels(scene_edit.get(), light_mat_tag_map, dice_transaction);
1895 add_scene_group_icons( scene_edit.get(), light_mat_tag_map, dice_transaction);
1899 const mi::math::Bbox<mi::Float32, 3> region_of_interest(
1900 -1000.0f, -1000.0f, -1000.0f,
1901 1300.0f, 1300.0f, 1300.0f
1903 scene_edit->set_clipped_bounding_box(region_of_interest);
1906 mi::math::Matrix<mi::Float32, 4, 4> transform_mat(
1907 1.0f, 0.0f, 0.0f, 0.0f,
1908 0.0f, 1.0f, 0.0f, 0.0f,
1909 0.0f, 0.0f, 1.0f, 0.0f,
1910 0.0f, 0.0f, 0.0f, 1.0f
1913 scene_edit->set_transform_matrix(transform_mat);
1916 mi::base::Handle< nv::index::IPerspective_camera > cam(
1917 scene_edit->create_camera<nv::index::IPerspective_camera>());
1919 m_camera_tag = dice_transaction->store(cam.get());
1923 setup_camera(m_camera_tag, dice_transaction);
1926 scene_edit->set_camera(m_camera_tag);
1930bool Multi_view_shape::setup_main_host()
1933 m_cluster_configuration =
1934 get_index_interface()->get_api_component<nv::index::ICluster_configuration>();
1935 check_success(m_cluster_configuration.is_valid_interface());
1938 m_image_file_canvas = create_image_file_canvas(get_application_layer_interface());
1943 check_success(is_local_host_joined(m_cluster_configuration.get()));
1946 mi::base::Handle<mi::neuraylib::IDice_transaction> dice_transaction(
1947 m_global_scope->create_transaction<mi::neuraylib::IDice_transaction>());
1953 m_index_session->create_session(dice_transaction.get());
1955 mi::base::Handle<const nv::index::ISession> session(
1956 dice_transaction->access<nv::index::ISession>(
1961 m_viewport_list = session->create_viewport_list();
1966 setup_scene(dice_transaction.get());
1968 dice_transaction->commit();
1971 const mi::math::Vector<mi::Uint32, 2> buffer_resolution(512, 512);
1972 m_image_file_canvas->set_resolution(buffer_resolution);
1974 INFO_LOG <<
"Initialization complete.";
1981int main(
int argc,
const char* argv[])
1983 nv::index::app::String_dict sdict;
1984 sdict.insert(
"dice::verbose",
"4");
1985 sdict.insert(
"font_fpath",
"/usr/share/fonts/dejavu/DejaVuSans.ttf");
1986 sdict.insert(
"iconfile",
"../create_icons/nvidia_logo.ppm");
1987 sdict.insert(
"outfname",
"frame_multi_view_shape");
1988 sdict.insert(
"verify_image_path_base",
"");
1989 sdict.insert(
"unittest",
"0");
1990 sdict.insert(
"enable_vidx_vec",
"1 1 1 1");
1993 sdict.insert(
"dice::network::mode",
"OFF");
1996 sdict.insert(
"index::config::set_monitor_performance_values",
"true");
1997 sdict.insert(
"index::service",
"rendering_and_compositing");
1998 sdict.insert(
"index::cuda_debug_checks",
"false");
2001 sdict.insert(
"index::app::components::application_layer::component_name_list",
2002 "canvas_infrastructure image io data_analysis_and_processing" );
2006 multi_view_shape.initialize(argc, argv, sdict);
2010 const mi::Sint32 exit_code = multi_view_shape.
launch();
2011 INFO_LOG <<
"Shutting down ...";
virtual bool initialize_networking(mi::neuraylib::INetwork_configuration *network_configuration, nv::index::app::String_dict &options) CPP11_OVERRIDE
virtual bool evaluate_options(nv::index::app::String_dict &sdict) CPP11_OVERRIDE
virtual ~Multi_view_shape()
int main(int argc, const char *argv[])
#define check_success(expr)