10#include "utility/example_shared.h"
12#include <nv/index/icamera.h>
13#include <nv/index/icolormap.h>
14#include <nv/index/iconfig_settings.h>
15#include <nv/index/iindex.h>
16#include <nv/index/iindex_debug_configuration.h>
17#include <nv/index/ilight.h>
18#include <nv/index/imaterial.h>
19#include <nv/index/ipath.h>
20#include <nv/index/iplane.h>
21#include <nv/index/iscene.h>
22#include <nv/index/iscene_group.h>
23#include <nv/index/isession.h>
24#include <nv/index/itexture_filter_mode.h>
26#include <nv/index/ipath_query_results.h>
28#include <nv/index/app/index_connect.h>
29#include <nv/index/app/string_dict.h>
30#include <nv/index/app/idata_analysis_and_processing.h>
32#include "utility/canvas_utility.h"
87 bool operator()(
const mi::neuraylib::Tag & lhs,
const mi::neuraylib::Tag & rhs)
const
89 return lhs.id < rhs.id;
95 public nv::index::app::Index_connect
128 virtual bool evaluate_options(nv::index::app::String_dict& sdict) CPP11_OVERRIDE;
131 mi::neuraylib::INetwork_configuration* network_configuration,
132 nv::index::app::String_dict& options) CPP11_OVERRIDE
137 const bool is_unittest = nv::index::app::get_bool(options.get(
"unittest"));
140 info_cout(
"NETWORK: disabled networking mode.", options);
141 network_configuration->set_mode(mi::neuraylib::INetwork_configuration:
:MODE_OFF);
145 return initialize_networking_as_default_udp(network_configuration, options);
149 mi::Float32 evaluate_path(mi::Float32 x)
const;
150 mi::math::Color_struct jetmap(mi::Float32 v, mi::Float32 vmin, mi::Float32 vmax)
const;
152 nv::index::IColormap* create_colormap(nv::index::IScene* scene,
bool use_transparency)
const;
155 nv::index::IScene* scene_edit,
156 std::vector<mi::neuraylib::Tag>& path_tags,
157 std::map< mi::neuraylib::Tag, Test_tag_info, Tag_comp >& test_tag_info_map,
158 mi::neuraylib::IDice_transaction* dice_transaction)
const;
162 void setup_camera(nv::index::IPerspective_camera* cam)
const;
168 void setup_extreme_transformed_camera(nv::index::IPerspective_camera* cam)
const;
175 mi::math::Matrix<mi::Float32, 4, 4> get_extreme_transformed_matrix()
const;
180 nv::index::IFrame_results* render_frame(
const std::string& output_fname)
const;
183 mi::neuraylib::Tag m_session_tag;
185 mi::base::Handle<nv::index::ICluster_configuration> m_cluster_configuration;
187 mi::base::Handle<nv::index::app::canvas_infrastructure::IIndex_image_file_canvas> m_image_file_canvas;
189 std::string m_outfname;
191 std::string m_verify_image_fname;
192 bool m_supersampling;
193 bool m_is_large_translate;
194 Path_test_params m_path_test_params;
201 mi::Sint32 exit_code = 0;
205 mi::base::Handle<nv::index::IIndex_scene_query> iindex_query(
206 get_index_interface()->get_api_component<nv::index::IIndex_scene_query>());
209 m_cluster_configuration =
210 get_index_interface()->get_api_component<nv::index::ICluster_configuration>();
214 m_image_file_canvas = create_image_file_canvas(get_application_layer_interface());
219 check_success(is_local_host_joined(m_cluster_configuration.get()));
221 std::map< mi::neuraylib::Tag, Test_tag_info, Tag_comp > test_tag_info_map;
222 std::vector<mi::neuraylib::Tag> path_tags;
225 mi::base::Handle<mi::neuraylib::IDice_transaction> dice_transaction(
226 m_global_scope->create_transaction<mi::neuraylib::IDice_transaction>());
230 m_session_tag = m_index_session->create_session(dice_transaction.get());
232 mi::base::Handle<const nv::index::ISession> session(
233 dice_transaction->access<
const nv::index::ISession>(m_session_tag));
236 mi::base::Handle< nv::index::IScene > scene_edit(
237 dice_transaction->edit< nv::index::IScene >(session->get_scene()));
243 INFO_LOG <<
"Enable full-screen supersampling.";
244 mi::base::Handle<nv::index::IConfig_settings> config_settings(
245 dice_transaction->edit<nv::index::IConfig_settings>(session->get_config()));
248 config_settings->set_rendering_samples(16);
255 check_success(create_scene(scene_edit.get(), path_tags, test_tag_info_map, dice_transaction.get()));
260 mi::base::Handle< nv::index::IPerspective_camera > cam(
261 scene_edit->create_camera<nv::index::IPerspective_camera>());
264 mi::math::Vector<mi::Uint32, 2> buffer_resolution;
265 if (m_is_large_translate)
267 INFO_LOG <<
"large translate test mode.";
268 setup_extreme_transformed_camera(cam.get());
269 buffer_resolution = mi::math::Vector<mi::Uint32, 2>(1602, 934);
273 setup_camera(cam.get());
274 buffer_resolution = mi::math::Vector<mi::Uint32, 2>(1024, 1024);
276 const mi::neuraylib::Tag camera_tag = dice_transaction->store(cam.get());
279 m_image_file_canvas->set_resolution(buffer_resolution);
282 const mi::math::Bbox_struct< mi::Float32, 3 > xyz_roi_st = {
283 { -1000.0f, -1000.0f, -1000.0f, },
284 { 1000.0f, 1000.0f, 1000.0f, },
288 const mi::math::Bbox< mi::Float32, 3 > xyz_roi(xyz_roi_st);
290 scene_edit->set_clipped_bounding_box(xyz_roi_st);
294 mi::math::Matrix<mi::Float32, 4, 4> transform_mat(
295 1.0f, 0.0f, 0.0f, 0.0f,
296 0.0f, 1.0f, 0.0f, 0.0f,
297 0.0f, 0.0f, -1.0f, 0.0f,
298 0.0f, 0.0f, 0.0f, 1.0f
301 if (m_is_large_translate)
303 transform_mat = get_extreme_transformed_matrix();
306 scene_edit->set_transform_matrix(transform_mat);
308 INFO_LOG <<
"transformed: " << scene_edit->get_transform_matrix();
312 scene_edit->set_camera(camera_tag);
314 dice_transaction->commit();
320 const mi::Sint32 frame_idx = 0;
321 const std::string fname = get_output_file_name(m_outfname, frame_idx);
322 mi::base::Handle<nv::index::IFrame_results> frame_results(render_frame(fname));
323 const mi::base::Handle<nv::index::IError_set> err_set(frame_results->get_error_set());
324 if (err_set->any_errors())
326 std::ostringstream os;
329 const mi::Uint32 nb_err = err_set->get_nb_errors();
330 for (mi::Uint32 e = 0; e < nb_err; ++e)
332 if (e != 0) os <<
'\n';
333 const mi::base::Handle<nv::index::IError> err(err_set->get_error(e));
334 os << err->get_error_string();
337 ERROR_LOG <<
"IIndex_rendering rendering call failed with the following error(s): " <<
'\n'
345 mi::base::Handle<mi::neuraylib::IDice_transaction> dice_transaction(
346 m_global_scope->create_transaction<mi::neuraylib::IDice_transaction>());
349 mi::math::Vector_struct<mi::Uint32, 2> pick_location;
350 pick_location.x = 256;
351 pick_location.y = 314;
352 INFO_LOG <<
"Query pick location: " << pick_location;
353 mi::base::Handle<nv::index::IScene_pick_results> scene_pick_results(
354 iindex_query->pick(pick_location, m_image_file_canvas.get(), m_session_tag, dice_transaction.get()));
355 const mi::Uint32 nb_results = scene_pick_results->get_nb_results();
358 INFO_LOG <<
"Number of pick results: " << nb_results;
359 for(mi::Uint32 i=0; i<nb_results; ++i)
361 const mi::base::Handle<nv::index::IScene_pick_result> result(scene_pick_results->get_result(i));
362 const mi::math::Vector_struct<mi::Float32, 3>& intersection = result->get_intersection();
363 INFO_LOG <<
"Intersection no. " << i <<
"\n"
364 <<
"\t\t Element (tag) " << result->get_scene_element().id <<
"\n"
365 <<
"\t\t Sub index: " << result->get_scene_element_sub_index() <<
"\n"
366 <<
"\t\t Distance: " << result->get_distance() <<
"\n"
367 <<
"\t\t Position (local space): " << intersection <<
"\n"
368 <<
"\t\t Color (evaluated): " << result->get_color();
370 if(result->get_intersection_info_class() == nv::index::IPath_pick_result::IID() )
372 mi::base::Handle<const nv::index::IPath_pick_result> path_pick_result(
373 result->get_interface<
const nv::index::IPath_pick_result>());
374 if(path_pick_result.get())
376 INFO_LOG <<
"Path specific pick results:" <<
"\n"
377 <<
"\t\t Segment id: " << path_pick_result->get_segment();
383 const mi::Size nb_tags = path_tags.size();
384 for (mi::Size i = 0; i < nb_tags; ++i)
386 const mi::neuraylib::Tag path_scene_element_tag = path_tags[i];
387 check_success(test_tag_info_map.find(path_scene_element_tag) != test_tag_info_map.end());
388 const Test_tag_info tti = test_tag_info_map[path_scene_element_tag];
395 const mi::Uint32
LOOP_DELTA = 9;
396 for(mi::Uint32 index = 0; index < 100; index +=
LOOP_DELTA)
398 if(tti.
m_num_points <=
static_cast< mi::Sint32
>(index)){
399 WARN_LOG <<
"Note: expected the following warning: "
400 <<
"The index " << index <<
" is greater than the number of entries in the path "
401 <<
"(entry count: " << tti.
m_num_points <<
"). for tag: "
402 << path_scene_element_tag.id <<
", type: " << tti.
m_assoc_type
403 <<
" with access index: " << index <<
" in this test.";
407 mi::base::Handle<nv::index::IScene_lookup_result> lookup_result(iindex_query->entry_lookup(
409 path_scene_element_tag,
411 dice_transaction.get()));
414 if(!lookup_result.is_valid_interface())
416 WARN_LOG <<
"No entry available at path index: " << index;
417 INFO_LOG <<
"Please note, the path might simply have too few entries.";
423 if(lookup_result->get_intersection_info_class() == nv::index::IPath_lookup_result::IID())
425 mi::base::Handle<const nv::index::IPath_lookup_result> path_lookup_result(
426 lookup_result->get_interface<
const nv::index::IPath_lookup_result>());
427 if(path_lookup_result.get())
429 INFO_LOG <<
"Path specific lookup results:";
430 INFO_LOG <<
"\t Tag id: " << path_scene_element_tag.id;
431 INFO_LOG <<
"\t Entry index: " << index;
432 INFO_LOG <<
"\t Vertex: " << path_lookup_result->get_vertex();
433 INFO_LOG <<
"\t Color index: " << path_lookup_result->get_radius();
434 INFO_LOG <<
"\t Color: " << path_lookup_result->get_color();
435 INFO_LOG <<
"\t Color index: " << path_lookup_result->get_color_index();
442 if (!(verify_canvas_result(get_application_layer_interface(),
443 m_image_file_canvas.get(), m_verify_image_fname, get_options())))
450 dice_transaction->commit();
460 const std::string com_name = sdict.get(
"command:",
"<unknown_command>");
461 m_is_unittest = nv::index::app::get_bool(sdict.get(
"unittest",
"false"));
465 if (nv::index::app::get_bool(sdict.get(
"is_call_from_test",
"false")))
467 sdict.insert(
"is_dump_comparison_image_when_failed",
"0");
469 sdict.insert(
"outfname",
"");
470 sdict.insert(
"dice::verbose",
"2");
473 m_outfname = sdict.get(
"outfname",
"");
474 m_verify_image_fname = sdict.get(
"verify_image_fname");
475 m_supersampling = nv::index::app::get_bool(sdict.get(
"supersampling",
"false"));
476 m_is_large_translate = nv::index::app::get_bool(sdict.get(
"is_large_translate",
"false"));
478 m_path_test_params.
num_points = nv::index::app::get_uint32(sdict.get(
"num_samples",
""));
479 m_path_test_params.
use_colormap = nv::index::app::get_bool( sdict.get(
"use_colormap",
"false"));
480 m_path_test_params.
use_rgba = nv::index::app::get_bool( sdict.get(
"use_rgba",
"false"));
481 m_path_test_params.
npr_mode = nv::index::app::get_bool( sdict.get(
"npr_mode",
"false"));
482 m_path_test_params.
test_transparency = nv::index::app::get_bool( sdict.get(
"test_transparency",
"false"));
483 m_path_test_params.
upsampling = nv::index::app::get_bool( sdict.get(
"upsampling",
"false"));
484 m_path_test_params.
up_factor = nv::index::app::get_uint32(sdict.get(
"up_factor",
"2"));
485 m_path_test_params.
up_tension = nv::index::app::get_float32(sdict.get(
"up_tension",
"0"));
487 info_cout(std::string(
"running ") + com_name, sdict);
488 info_cout(std::string(
"outfname = [") + m_outfname +
489 "], verify_image_fname = [" + m_verify_image_fname +
490 "], dice::verbose = " + sdict.get(
"dice::verbose"), sdict);
493 if(sdict.is_defined(
"h")){
495 <<
"info: Usage: " << com_name <<
" [option]\n"
497 <<
" printout this message\n"
498 <<
" [-dice::verbose severity_level]\n"
499 <<
" verbose severity level (3 is info.). (default: " + sdict.get(
"dice::verbose")
502 <<
" [-supersampling bool]\n"
503 <<
" when true then full screen supersampling is enabled."
504 <<
"(default: " << m_supersampling <<
")\n"
506 <<
" [-num_samples int]\n"
507 <<
" set the number of path samples for the test."
508 <<
"(default: " << m_path_test_params.
num_points <<
")\n"
510 <<
" [-use_colormap bool]\n"
511 <<
" enable/disable colormap source."
512 <<
"(default: " << m_path_test_params.
use_colormap <<
")\n"
514 <<
" [-use_rgba bool]\n"
515 <<
" enable/disable rgba array source."
516 <<
"(default: " << m_path_test_params.
use_rgba <<
")\n"
518 <<
" [-npr_mode bool]\n"
519 <<
" enable/disable non-photorealistic mode."
520 <<
"(default: " << m_path_test_params.
npr_mode <<
")\n"
522 <<
" [-test_transparency bool]\n"
523 <<
" enable/disable transparency test."
526 <<
" [-upsampling bool]\n"
527 <<
" enable/disable upsampling."
528 <<
"(default: " << m_path_test_params.
upsampling <<
")\n"
530 <<
" [-up_factor int]\n"
531 <<
" upsampling factor. Increase of the sampling rate factor."
532 <<
"(default: " << m_path_test_params.
up_factor <<
")\n"
534 <<
" [-up_tension float]\n"
535 <<
" upsampling tension. tension of the fitting curve [0.0, 1.0]."
536 <<
"(default: " << m_path_test_params.
up_tension <<
")\n"
538 <<
" [-is_large_translate bool]\n"
539 <<
" on/off large translation mode."
540 <<
"(default: " << m_is_large_translate <<
")\n"
542 <<
" [-outfname string]\n"
543 <<
" output ppm file base name. When empty, no output.\n"
544 <<
" A frame number and extension (.ppm) will be added.\n"
545 <<
" (default: [" << m_outfname <<
"])\n"
546 <<
" [-verify_image_fname [image_fname]]\n"
547 <<
" when image_fname exist, verify the rendering image. (default: ["
548 << m_verify_image_fname <<
"])\n"
550 <<
" [-unittest bool]\n"
551 <<
" when true, unit test mode (create smaller volume). "
552 <<
"(default: " << m_is_unittest <<
")"
560mi::Float32 Create_path::evaluate_path(mi::Float32 x)
const
562 return expf(-x) + 0.15f*cosf(3.f*
static_cast<mi::Float32
>(MI_PI)*x/4.f);
566mi::math::Color_struct Create_path::jetmap(mi::Float32 v, mi::Float32 vmin, mi::Float32 vmax)
const
568 mi::math::Color_struct c = {1.f, 1.f, 1.f, 1.f};
577 if (v < (vmin + 0.25f * dv))
580 c.g = 4.f * (v - vmin) / dv;
582 else if (v < (vmin + 0.5f * dv))
585 c.b = 1.f + 4.f * (vmin + 0.25f * dv - v) / dv;
587 else if (v < (vmin + 0.75f * dv))
589 c.r = 4.f * (v - vmin - 0.5f * dv) / dv;
594 c.g = 1.f + 4.f * (vmin + 0.75f * dv - v) / dv;
602nv::index::IColormap* Create_path::create_colormap(nv::index::IScene* scene,
bool use_transparency)
const
604 const mi::Float32
MIN_TRANS = 0.2f;
605 const mi::Float32
MAX_TRANS = 0.9f;
607 nv::index::IColormap* colormap = scene->create_attribute<nv::index::IColormap>();
609 std::vector<mi::math::Color_struct> colormap_entries;
610 colormap_entries.resize(256);
611 for(mi::Uint32 i=0; i<256; ++i)
613 colormap_entries[i] = jetmap((
static_cast<mi::Float32
>(i)+0.5f)/256.f, 0.f, 1.f);
616 mi::Float32 t = (
static_cast<mi::Float32
>(i) + 0.5f)/256.f;
617 colormap_entries[i].a =
MIN_TRANS + (MAX_TRANS -
MIN_TRANS)*t;
622 colormap->set_colormap(&colormap_entries[0], colormap_entries.size());
627bool Create_path::create_scene(
628 nv::index::IScene* scene_edit,
629 std::vector<mi::neuraylib::Tag>& path_tags,
630 std::map< mi::neuraylib::Tag, Test_tag_info, Tag_comp >& test_tag_info_map,
631 mi::neuraylib::IDice_transaction* dice_transaction)
const
638 mi::base::Handle<nv::index::IDirectional_light> light_global(
639 scene_edit->create_attribute<nv::index::IDirectional_light>());
641 light_global->set_direction(mi::math::Vector<mi::Float32, 3>(0.5f, 0.f, 1.f));
642 const mi::neuraylib::Tag light_global_tag = dice_transaction->store_for_reference_counting(light_global.get());
644 scene_edit->append(light_global_tag, dice_transaction);
647 mi::base::Handle<nv::index::IPhong_gl> phong_1(scene_edit->create_attribute<nv::index::IPhong_gl>());
651 phong_1->set_ambient(mi::math::Color(0.75f, 0.75f, 0.75f, 1.0f));
652 phong_1->set_diffuse(mi::math::Color(0.0f, 0.0f, 0.0f, 1.0f));
653 phong_1->set_specular(mi::math::Color(0.0f, 0.0f, 0.0f, 1.0f));
654 phong_1->set_shininess(0);
658 phong_1->set_ambient(mi::math::Color(0.15f, 0.15f, 0.15f, 1.0f));
659 phong_1->set_diffuse(mi::math::Color(0.95f, 0.95f, 0.95f, 1.0f));
660 phong_1->set_specular(mi::math::Color(0.4f, 0.4f, 0.4f, 1.0f));
661 phong_1->set_shininess(85);
663 const mi::neuraylib::Tag phong_1_tag = dice_transaction->store_for_reference_counting(phong_1.get());
665 scene_edit->append(phong_1_tag, dice_transaction);
668 mi::base::Handle<nv::index::IColormap> colormap(create_colormap(scene_edit, m_path_test_params.
test_transparency));
670 const mi::neuraylib::Tag colormap_tag = dice_transaction->store_for_reference_counting(colormap.get());
672 scene_edit->append(colormap_tag, dice_transaction);
675 mi::math::Bbox< mi::Float32, 3 > path_bbox;
678 const mi::Uint32 num_points = m_path_test_params.
num_points;
681 nv::index::IPath_style::Color_source color_source;
683 color_source = nv::index::IPath_style:
:COLOR_SOURCE_BOTH;
685 color_source = nv::index::IPath_style:
:COLOR_SOURCE_COLORMAP_ONLY;
686 else if(m_path_test_params.
use_rgba)
687 color_source = nv::index::IPath_style:
:COLOR_SOURCE_RGBA_ONLY;
689 color_source = nv::index::IPath_style:
:COLOR_SOURCE_NONE;
693 std::vector<mi::math::Color_struct> colors;
694 colors.resize(num_points);
695 for(mi::Uint32 i=0; i<num_points; i++)
697 mi::Float32 g = (
static_cast<mi::Float32
>(i) + 0.5f)/
static_cast<mi::Float32
>(num_points);
698 mi::Float32 f = fabsf(2.0f*g - 1.0f);
700 colors[i].g = 1.f - f;
701 colors[i].b = 1.f - f;
706 mi::math::Matrix<mi::Float32, 4, 4> transform_mat(1.f);
707 transform_mat.translate(mi::math::Vector<mi::Float32, 3>(120.f, 0.f, 0.f));
708 mi::base::Handle<nv::index::ITransformed_scene_group> group_node(
709 scene_edit->create_scene_group<nv::index::ITransformed_scene_group>());
711 group_node->set_transform(transform_mat);
714 std::vector< mi::math::Vector_struct<mi::Float32, 3> > points;
715 points.resize(num_points);
716 for(mi::Uint32 i=0; i<num_points; i++)
718 points[i].y = ((
static_cast<mi::Float32
>(i) + 0.5f)/
static_cast<mi::Float32
>(num_points))*6.f;
719 points[i].x = evaluate_path(points[i].y);
722 path_bbox.insert(points[i]);
724 points[i].x = points[i].x*100.f - 80.f;
725 points[i].y = points[i].y*100.f + 10.f;
726 points[i].z *= 100.f;
728 path_bbox.insert(points[i]);
732 std::vector<mi::Uint32> colormap_ids;
733 colormap_ids.resize(num_points);
734 for(mi::Uint32 i=0; i<num_points; i++){
735 colormap_ids[i] = (mi::Uint32) (255.f*((
static_cast<mi::Float32
>(i)+0.5f)/
736 static_cast<mi::Float32
>(num_points)));
741 mi::base::Handle<nv::index::IPath_style> path_style1(scene_edit->create_attribute<nv::index::IPath_style>());
743 path_style1->set_interpolation(nv::index::IPath_style:
:INTERPOLATION_LINEAR);
744 path_style1->set_color_source(color_source);
746 const mi::neuraylib::Tag path_style1_tag = dice_transaction->store_for_reference_counting(path_style1.get());
748 group_node->append(path_style1_tag, dice_transaction);
750 mi::base::Handle<nv::index::IPath_3D> path1(scene_edit->create_shape<nv::index::IPath_3D>());
754 path1->set_radius(15.f);
757 path1->set_points(&points[0], num_points);
760 path1->set_color_map_indexes(&colormap_ids[0], num_points);
761 path1->set_colors(&colors[0], num_points);
764 const mi::neuraylib::Tag path1_tag = dice_transaction->store_for_reference_counting(path1.get());
766 group_node->append(path1_tag, dice_transaction);
768 path_tags.push_back(path1_tag);
769 test_tag_info_map[path1_tag] =
Test_tag_info(
"IPath_3D", num_points);
774 mi::base::Handle<nv::index::IPath_style> path_style2(scene_edit->create_attribute<nv::index::IPath_style>());
776 path_style2->set_interpolation(nv::index::IPath_style:
:INTERPOLATION_SEGMENT);
777 path_style2->set_color_source(color_source);
779 const mi::neuraylib::Tag path2_style_tag =
780 dice_transaction->store_for_reference_counting(path_style2.get());
782 group_node->append(path2_style_tag, dice_transaction);
784 mi::base::Handle<nv::index::IPath_3D> path2(scene_edit->create_shape<nv::index::IPath_3D>());
788 path2->set_radius(12.0f);
791 for(mi::Uint32 i=0; i<num_points; i++){
793 path_bbox.insert(points[i]);
796 path2->set_points(&points[0], num_points);
799 path2->set_color_map_indexes(&colormap_ids[0], num_points);
800 path2->set_colors(&colors[0], num_points);
803 const mi::neuraylib::Tag path2_tag = dice_transaction->store_for_reference_counting(path2.get());
805 group_node->append(path2_tag, dice_transaction);
807 path_tags.push_back(path2_tag);
808 test_tag_info_map[path2_tag] =
Test_tag_info(
"IPath_3D", num_points);
813 mi::base::Handle<nv::index::IPath_style> path_style3(scene_edit->create_attribute<nv::index::IPath_style>());
815 path_style3->set_interpolation(nv::index::IPath_style:
:INTERPOLATION_NEAREST);
816 path_style3->set_color_source(color_source);
818 const mi::neuraylib::Tag path3_style_tag = dice_transaction->store_for_reference_counting(path_style3.get());
820 group_node->append(path3_style_tag, dice_transaction);
822 mi::base::Handle<nv::index::IPath_3D> path3(scene_edit->create_shape<nv::index::IPath_3D>());
826 path3->set_radius(7.0f);
829 for(mi::Uint32 i=0; i<num_points; i++){
831 path_bbox.insert(points[i]);
834 path3->set_points(&points[0], num_points);
837 path3->set_color_map_indexes(&colormap_ids[0], num_points);
838 path3->set_colors(&colors[0], num_points);
841 const mi::neuraylib::Tag path3_tag = dice_transaction->store_for_reference_counting(path3.get());
843 group_node->append(path3_tag, dice_transaction);
845 path_tags.push_back(path3_tag);
846 test_tag_info_map[path3_tag] =
Test_tag_info(
"IPath_3D", num_points);
852 mi::math::Vector<mi::Float32, 3> plane_point(-500.f, -100.f, 150.0f);
853 mi::math::Vector<mi::Float32, 3> plane_normal(0.f, 0.f, 1.f);
854 mi::math::Vector<mi::Float32, 3> plane_up(0.f, 1.f, 0.f);
855 mi::math::Vector<mi::Float32, 2> plane_extent(1200.0f, 800.0f);
857 mi::base::Handle<nv::index::ITexture_filter_mode> tex_filter(
858 scene_edit->create_attribute<nv::index::ITexture_filter_mode_nearest_neighbor>());
860 mi::neuraylib::Tag tex_filter_tag = dice_transaction->store_for_reference_counting(tex_filter.get());
862 group_node->append(tex_filter_tag, dice_transaction);
865 mi::base::Handle<nv::index::app::data_analysis_and_processing::IData_analysis_and_processing> processing(
866 get_application_layer_interface()->get_api_component<nv::index::app::data_analysis_and_processing::IData_analysis_and_processing>());
870 mi::base::Handle<nv::index::IDistributed_compute_technique> mapping(
871 processing->get_sample_tool_set()->create_checker_board_2d_technique(
873 nv::index::IDistributed_compute_destination_buffer_2d_texture:
:FORMAT_RGBA_FLOAT32,
874 mi::math::Color(0.9f, 0.2f, 0.15f, 0.7f),
875 mi::math::Color(0.2f, 0.2f, 0.8f, 1.0f)));
878 mi::neuraylib::Tag mapping_tag = dice_transaction->store_for_reference_counting(mapping.get());
881 group_node->append(mapping_tag, dice_transaction);
883 mi::base::Handle<nv::index::IPlane> plane(scene_edit->create_shape<nv::index::IPlane>());
885 plane->set_point(plane_point);
886 plane->set_normal(plane_normal);
887 plane->set_up(plane_up);
888 plane->set_extent(plane_extent);
890 mi::neuraylib::Tag plane_tag = dice_transaction->store_for_reference_counting(plane.get());
892 group_node->append(plane_tag, dice_transaction);
894 path_tags.push_back(plane_tag);
898 const mi::neuraylib::Tag group_node_tag = dice_transaction->store_for_reference_counting(group_node.get());
900 scene_edit->append(group_node_tag, dice_transaction);
902 INFO_LOG <<
"Bounding box of the vertices that create the paths: " << path_bbox;
909void Create_path::setup_camera(nv::index::IPerspective_camera* cam)
const
914 const mi::math::Vector< mi::Float32, 3 > from( 234.0f, 604.0f, 500.0f);
915 const mi::math::Vector< mi::Float32, 3 > to ( 255.0f, 255.0f, -255.0f);
916 const mi::math::Vector< mi::Float32, 3 > up ( 0.0f, 1.0f, 0.0f);
917 mi::math::Vector<mi::Float32, 3> viewdir = to - from;
920 cam->set(from, viewdir, up);
921 cam->set_aperture(0.033f);
922 cam->set_aspect(1.0f);
923 cam->set_focal(0.03f);
924 cam->set_clip_min(10.0f);
925 cam->set_clip_max(5000.0f);
929void Create_path::setup_extreme_transformed_camera(nv::index::IPerspective_camera* cam)
const
945 mi::math::Vector< mi::Float32, 3 >
const from( 1805060.125f + 8192.0f, 9978520.0f + 16384.0f, 16384.0f);
946 mi::math::Vector< mi::Float32, 3 >
const to ( 1805060.125f + 8192.0f, 9978520.0f + 8292.0f, -256.0f);
947 mi::math::Vector< mi::Float32, 3 >
const up ( 0.0f, 1.0f, 0.0f);
948 mi::math::Vector<mi::Float32, 3> viewdir = to - from;
951 cam->set(from, viewdir, up);
952 cam->set_aperture(0.033f);
953 cam->set_aspect(1.71520f);
954 cam->set_focal(0.03f);
955 cam->set_clip_min(124.485f);
956 cam->set_clip_max(17585.6f);
958 INFO_LOG <<
"A camera set up using a large matrix.";
962mi::math::Matrix<mi::Float32, 4, 4> Create_path::get_extreme_transformed_matrix()
const
970 mi::math::Matrix<mi::Float32, 4, 4> transform_mat(
971 20.61f, 0.0f, 0.0f, 0.0f,
972 0.0f, 20.61f, 0.0f, 0.0f,
973 0.0f, 0.0f, -4.0f, 0.0f,
974 1805060.0f, 9978520.0f, 0.0f, 1.0f
976 return transform_mat;
980nv::index::IFrame_results* Create_path::render_frame(
const std::string& output_fname)
const
985 m_image_file_canvas->set_rgba_file_name(output_fname.c_str());
989 mi::base::Handle<mi::neuraylib::IDice_transaction> dice_transaction(
990 m_global_scope->create_transaction<mi::neuraylib::IDice_transaction>());
993 m_index_session->update(m_session_tag, dice_transaction.get());
995 mi::base::Handle<nv::index::IFrame_results> frame_results(
996 m_index_rendering->render(
998 m_image_file_canvas.get(),
999 dice_transaction.get()));
1002 dice_transaction->commit();
1004 frame_results->retain();
1005 return frame_results.get();
1009int main(
int argc,
const char* argv[])
1011 nv::index::app::String_dict sdict;
1012 sdict.insert(
"dice::verbose",
"3");
1013 sdict.insert(
"outfname",
"frame_create_path");
1014 sdict.insert(
"verify_image_fname",
"");
1015 sdict.insert(
"unittest",
"0");
1016 sdict.insert(
"supersampling",
"0");
1017 sdict.insert(
"num_samples",
"40");
1018 sdict.insert(
"use_colormap",
"1");
1019 sdict.insert(
"use_rgba",
"0");
1020 sdict.insert(
"npr_mode",
"0");
1021 sdict.insert(
"test_transparency",
"0");
1022 sdict.insert(
"upsampling",
"0");
1023 sdict.insert(
"up_factor",
"2");
1024 sdict.insert(
"up_tension",
"0.0");
1025 sdict.insert(
"is_large_translate",
"0");
1026 sdict.insert(
"is_dump_comparison_image_when_failed",
"1");
1027 sdict.insert(
"is_call_from_test",
"0");
1030 sdict.insert(
"dice::network::mode",
"OFF");
1033 sdict.insert(
"index::config::set_monitor_performance_values",
"true");
1034 sdict.insert(
"index::service",
"rendering_and_compositing");
1035 sdict.insert(
"index::cuda_debug_checks",
"false");
1038 sdict.insert(
"index::app::components::application_layer::component_name_list",
1039 "canvas_infrastructure image io data_analysis_and_processing");
1043 create_path.initialize(argc, argv, sdict);
1047 const mi::Sint32 exit_code = create_path.
launch();
1048 INFO_LOG <<
"Shutting down ...";
virtual bool evaluate_options(nv::index::app::String_dict &sdict) CPP11_OVERRIDE
virtual bool initialize_networking(mi::neuraylib::INetwork_configuration *network_configuration, nv::index::app::String_dict &options) CPP11_OVERRIDE
bool operator()(const mi::neuraylib::Tag &lhs, const mi::neuraylib::Tag &rhs) const
Test_tag_info(const std::string &type_name, mi::Sint32 num_points)
Test_tag_info & operator=(const Test_tag_info &rhs)
Test_tag_info(const Test_tag_info &tti)
int main(int argc, const char *argv[])
#define check_success(expr)