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/ilight.h>
17#include <nv/index/imaterial.h>
18#include <nv/index/ipath.h>
19#include <nv/index/iplane.h>
20#include <nv/index/iscene.h>
21#include <nv/index/iscene_group.h>
22#include <nv/index/isession.h>
23#include <nv/index/itexture_filter_mode.h>
25#include <nv/index/ipath_query_results.h>
26#include <nv/index/iline_set_pick_result.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"
39 public nv::index::app::Index_connect
71 virtual bool evaluate_options(nv::index::app::String_dict& sdict) CPP11_OVERRIDE;
74 mi::neuraylib::INetwork_configuration* network_configuration,
75 nv::index::app::String_dict& options) CPP11_OVERRIDE
80 const bool is_unittest = nv::index::app::get_bool(options.get(
"unittest"));
83 info_cout(
"NETWORK: disabled networking mode.", options);
84 network_configuration->set_mode(mi::neuraylib::INetwork_configuration:
:MODE_OFF);
88 return initialize_networking_as_default_udp(network_configuration, options);
92 mi::Float32 evaluate_path(mi::Float32 x)
const;
93 mi::math::Color_struct jetmap(mi::Float32 v, mi::Float32 vmin, mi::Float32 vmax)
const;
94 nv::index::IColormap* create_colormap(nv::index::IScene* scene,
bool use_transparency)
const;
96 nv::index::IScene* scene_edit,
97 std::vector<mi::neuraylib::Tag>& path_tags,
98 mi::neuraylib::IDice_transaction* dice_transaction);
102 nv::index::IPerspective_camera* cam)
const;
107 void setup_extreme_transformed_camera(nv::index::IPerspective_camera* cam)
const;
112 mi::math::Matrix<mi::Float32, 4, 4> get_extreme_transformed_matrix()
const;
116 nv::index::IFrame_results* render_frame(
const std::string& output_fname)
const;
119 mi::neuraylib::Tag m_session_tag;
121 mi::base::Handle<nv::index::ICluster_configuration> m_cluster_configuration;
123 mi::base::Handle<nv::index::app::canvas_infrastructure::IIndex_image_file_canvas> m_image_file_canvas;
125 std::string m_outfname;
127 std::string m_verify_image_fname;
128 bool m_supersampling;
129 bool m_is_large_translate;
130 Path_test_params m_path_test_params;
136 mi::Sint32 exit_code = 0;
140 mi::base::Handle<nv::index::IIndex_scene_query> iindex_query(
141 get_index_interface()->get_api_component<nv::index::IIndex_scene_query>());
144 m_cluster_configuration = get_index_interface()->get_api_component<nv::index::ICluster_configuration>();
148 m_image_file_canvas = create_image_file_canvas(get_application_layer_interface());
153 check_success(is_local_host_joined(m_cluster_configuration.get()));
155 std::vector<mi::neuraylib::Tag> path_tags;
158 mi::base::Handle<mi::neuraylib::IDice_transaction> dice_transaction(
159 m_global_scope->create_transaction<mi::neuraylib::IDice_transaction>());
163 m_session_tag = m_index_session->create_session(dice_transaction.get());
165 mi::base::Handle< nv::index::ISession const > session(
166 dice_transaction->access< nv::index::ISession
const >(
170 mi::base::Handle< nv::index::IScene > scene_edit(
171 dice_transaction->edit<nv::index::IScene>(session->get_scene()));
177 INFO_LOG <<
"Enable supersampling.";
179 mi::base::Handle<nv::index::IConfig_settings> config_settings(
180 dice_transaction->edit<nv::index::IConfig_settings>(session->get_config()));
183 config_settings->set_rendering_samples(16);
190 check_success(create_scene(scene_edit.get(), path_tags, dice_transaction.get()));
195 mi::base::Handle< nv::index::IPerspective_camera > cam(
196 scene_edit->create_camera<nv::index::IPerspective_camera>());
199 mi::math::Vector<mi::Uint32, 2> buffer_resolution;
200 if (m_is_large_translate)
202 INFO_LOG <<
"large translate test mode.";
203 setup_extreme_transformed_camera(cam.get());
204 buffer_resolution = mi::math::Vector<mi::Uint32, 2>(1602, 934);
208 setup_camera(cam.get());
209 buffer_resolution = mi::math::Vector<mi::Uint32, 2>(1024, 1024);
211 const mi::neuraylib::Tag camera_tag = dice_transaction->store(cam.get());
214 m_image_file_canvas->set_resolution(buffer_resolution);
217 const mi::math::Bbox_struct< mi::Float32, 3 > xyz_roi_st = {
218 { -1000.0f, -1000.0f, -1000.0f, },
219 { 1000.0f, 1000.0f, 1000.0f, },
223 const mi::math::Bbox< mi::Float32, 3 > xyz_roi(xyz_roi_st);
225 scene_edit->set_clipped_bounding_box(xyz_roi_st);
229 mi::math::Matrix<mi::Float32, 4, 4> transform_mat(
230 1.0f, 0.0f, 0.0f, 0.0f,
231 0.0f, 1.0f, 0.0f, 0.0f,
232 0.0f, 0.0f, -1.0f, 0.0f,
233 0.0f, 0.0f, 0.0f, 1.0f
236 if(m_is_large_translate)
238 transform_mat = get_extreme_transformed_matrix();
241 scene_edit->set_transform_matrix(transform_mat);
243 INFO_LOG <<
"transformed: " << scene_edit->get_transform_matrix();
247 scene_edit->set_camera(camera_tag);
249 dice_transaction->commit();
255 const mi::Sint32 frame_idx = 0;
256 const std::string fname = get_output_file_name(m_outfname, frame_idx);
257 mi::base::Handle<nv::index::IFrame_results> frame_results(render_frame(fname));
258 const mi::base::Handle<nv::index::IError_set> err_set(frame_results->get_error_set());
259 if (err_set->any_errors())
261 std::ostringstream os;
262 const mi::Uint32 nb_err = err_set->get_nb_errors();
263 for (mi::Uint32 e = 0; e < nb_err; ++e)
265 if (e != 0) os <<
'\n';
266 const mi::base::Handle<nv::index::IError> err(err_set->get_error(e));
267 os << err->get_error_string();
270 ERROR_LOG <<
"IIndex_rendering rendering call failed with the following error(s): " <<
'\n'
278 mi::base::Handle<mi::neuraylib::IDice_transaction> dice_transaction(
279 m_global_scope->create_transaction<mi::neuraylib::IDice_transaction>());
282 mi::math::Vector_struct<mi::Uint32, 2> pick_location;
283 pick_location.x = 256;
284 pick_location.y = 314;
285 INFO_LOG <<
"Query pick location: " << pick_location;
286 mi::base::Handle<nv::index::IScene_pick_results> scene_pick_results(
287 iindex_query->pick(pick_location, m_image_file_canvas.get(), m_session_tag, dice_transaction.get()));
288 const mi::Uint32 nb_results = scene_pick_results->get_nb_results();
291 INFO_LOG <<
"Number of pick results: " << nb_results;
292 for (mi::Uint32 i = 0; i < nb_results; ++i)
294 const mi::base::Handle<nv::index::IScene_pick_result> result(scene_pick_results->get_result(i));
295 const mi::math::Vector_struct<mi::Float32, 3>& intersection = result->get_intersection();
296 INFO_LOG <<
"Intersection no. " << i <<
"\n"
297 <<
"\t\t Element (tag) " << result->get_scene_element().id <<
"\n"
298 <<
"\t\t Sub index: " << result->get_scene_element_sub_index() <<
"\n"
299 <<
"\t\t Distance: " << result->get_distance() <<
"\n"
300 <<
"\t\t Position (local space): " << intersection <<
"\n"
301 <<
"\t\t Color (evaluated): " << result->get_color();
303 if(result->get_intersection_info_class() == nv::index::IPath_pick_result::IID() )
305 mi::base::Handle<const nv::index::IPath_pick_result> path_pick_result(
306 result->get_interface<
const nv::index::IPath_pick_result>());
307 if(path_pick_result.get())
309 INFO_LOG <<
"Path specific pick results:" <<
"\n"
310 <<
"\t\t Segment id: " << path_pick_result->get_segment();
313 else if(result->get_intersection_info_class() == nv::index::ILine_set_pick_result::IID() )
315 mi::base::Handle<const nv::index::ILine_set_pick_result> path_pick_result(
316 result->get_interface<
const nv::index::ILine_set_pick_result>());
317 if(path_pick_result.get())
319 INFO_LOG <<
"Line set specific pick results:" <<
"\n"
320 <<
"\t\t Segment id: " << path_pick_result->get_segment();
326 const mi::Size nb_tags = path_tags.size();
327 for(mi::Size i = 0; i<nb_tags; ++i)
329 const mi::neuraylib::Tag path_scene_element_tag = path_tags[i];
336 const mi::Uint32
LOOP_DELTA = 9;
337 for(mi::Uint32 index = 0; index<100; index+
=LOOP_DELTA)
340 mi::base::Handle<nv::index::IScene_lookup_result> lookup_result(iindex_query->entry_lookup(
342 path_scene_element_tag,
344 dice_transaction.get()));
347 if(!lookup_result.is_valid_interface())
349 WARN_LOG <<
"No entry available at path index: " << index;
350 INFO_LOG <<
"Please note, the path might simply have too few entries.";
355 if(lookup_result->get_intersection_info_class() == nv::index::IPath_lookup_result::IID())
357 mi::base::Handle<const nv::index::IPath_lookup_result> path_lookup_result(
358 lookup_result->get_interface<
const nv::index::IPath_lookup_result>());
359 if(path_lookup_result.get())
361 INFO_LOG <<
"Path specific lookup results:";
362 INFO_LOG <<
"\t Tag id: " << path_scene_element_tag.id;
363 INFO_LOG <<
"\t Entry index: " << index;
364 INFO_LOG <<
"\t Vertex: " << path_lookup_result->get_vertex();
365 INFO_LOG <<
"\t Color index: " << path_lookup_result->get_radius();
366 INFO_LOG <<
"\t Color: " << path_lookup_result->get_color();
367 INFO_LOG <<
"\t Color index: " << path_lookup_result->get_color_index();
374 if (!(verify_canvas_result(get_application_layer_interface(),
375 m_image_file_canvas.get(), m_verify_image_fname, get_options())))
382 dice_transaction->commit();
392 const std::string com_name = sdict.get(
"command:",
"<unknown_command>");
393 m_is_unittest = nv::index::app::get_bool(sdict.get(
"unittest",
"false"));
397 if (nv::index::app::get_bool(sdict.get(
"is_call_from_test",
"false")))
399 sdict.insert(
"is_dump_comparison_image_when_failed",
"0");
401 sdict.insert(
"outfname",
"");
402 sdict.insert(
"dice::verbose",
"2");
405 m_outfname = sdict.get(
"outfname",
"");
406 m_verify_image_fname = sdict.get(
"verify_image_fname");
407 m_supersampling = nv::index::app::get_bool(sdict.get(
"supersampling",
"false"));
408 m_is_large_translate = nv::index::app::get_bool(sdict.get(
"is_large_translate",
"false"));
410 m_path_test_params.
num_points = nv::index::app::get_uint32(sdict.get(
"num_samples",
""));
411 m_path_test_params.
use_colormap = nv::index::app::get_bool( sdict.get(
"use_colormap",
"false"));
412 m_path_test_params.
use_rgba = nv::index::app::get_bool( sdict.get(
"use_rgba",
"false"));
414 m_path_test_params.
test_transparency = nv::index::app::get_bool( sdict.get(
"test_transparency",
"false"));
415 m_path_test_params.
upsampling = nv::index::app::get_bool( sdict.get(
"upsampling",
"false"));
416 m_path_test_params.
up_factor = nv::index::app::get_uint32(sdict.get(
"up_factor",
"2"));
417 m_path_test_params.
up_tension = nv::index::app::get_float32(sdict.get(
"up_tension",
"0"));
419 info_cout(std::string(
"running ") + com_name, sdict);
420 info_cout(std::string(
"outfname = [") + m_outfname +
421 "], verify_image_fname = [" + sdict.get(
"verify_image_fname") +
422 "], dice::verbose = " + sdict.get(
"dice::verbose"), sdict);
425 if(sdict.is_defined(
"h"))
428 <<
"info: Usage: " << com_name <<
" [option]\n"
430 <<
" printout this message\n"
431 <<
" [-dice::verbose severity_level]\n"
432 <<
" verbose severity level (3 is info.). (default: " + sdict.get(
"dice::verbose")
435 <<
" [-supersampling bool]\n"
436 <<
" when true then supersampling is enabled."
437 <<
"(default: " << m_supersampling <<
")\n"
439 <<
" [-num_samples int]\n"
440 <<
" set the number of path samples for the test."
441 <<
"(default: " << m_path_test_params.
num_points <<
")\n"
443 <<
" [-use_colormap bool]\n"
444 <<
" enable/disable colormap source."
445 <<
"(default: " << m_path_test_params.
use_colormap <<
")\n"
447 <<
" [-use_rgba bool]\n"
448 <<
" enable/disable rgba array source."
449 <<
"(default: " << m_path_test_params.
use_rgba <<
")\n"
451 <<
" [-test_transparency bool]\n"
452 <<
" enable/disable transparency test."
455 <<
" [-upsampling bool]\n"
456 <<
" enable/disable upsampling."
457 <<
"(default: " << m_path_test_params.
upsampling <<
")\n"
459 <<
" [-up_factor int]\n"
460 <<
" upsampling factor. Increase of the sampling rate factor."
461 <<
"(default: " << m_path_test_params.
up_factor <<
")\n"
463 <<
" [-up_tension float]\n"
464 <<
" upsampling tension. tension of the fitting curve [0.0, 1.0]."
465 <<
"(default: " << m_path_test_params.
up_tension <<
")\n"
467 <<
" [-is_large_translate bool]\n"
468 <<
" on/off large translation mode."
469 <<
"(default: " << m_is_large_translate <<
")\n"
471 <<
" [-outfname string]\n"
472 <<
" output ppm file base name. When empty, no output.\n"
473 <<
" A frame number and extension (.ppm) will be added.\n"
474 <<
" (default: [" << m_outfname <<
"])\n"
475 <<
" [-verify_image_fname [image_fname]]\n"
476 <<
" when image_fname exist, verify the rendering image. (default: ["
477 << m_verify_image_fname <<
"])\n"
479 <<
" [-unittest bool]\n"
480 <<
" when true, unit test mode (create smaller volume). "
481 <<
"(default: " << m_is_unittest <<
")"
489mi::Float32 Create_path_2d::evaluate_path(mi::Float32 x)
const
491 return exp(-x) + 0.15f*cosf(3.f*
static_cast<mi::Float32
>(MI_PI)*x/4.f);
495mi::math::Color_struct Create_path_2d::jetmap(mi::Float32 v, mi::Float32 vmin, mi::Float32 vmax)
const
497 mi::math::Color_struct c = {1.f, 1.f, 1.f, 1.f};
506 if (v < (vmin + 0.25f * dv))
509 c.g = 4.f * (v - vmin) / dv;
511 else if (v < (vmin + 0.5f * dv))
514 c.b = 1.f + 4.f * (vmin + 0.25f * dv - v) / dv;
516 else if (v < (vmin + 0.75f * dv))
518 c.r = 4.f * (v - vmin - 0.5f * dv) / dv;
523 c.g = 1.f + 4.f * (vmin + 0.75f * dv - v) / dv;
531nv::index::IColormap* Create_path_2d::create_colormap(nv::index::IScene* scene,
bool use_transparency)
const
533 const mi::Float32
MIN_TRANS = 0.2f;
534 const mi::Float32
MAX_TRANS = 0.9f;
536 nv::index::IColormap* colormap = scene->create_attribute<nv::index::IColormap>();
538 std::vector<mi::math::Color_struct> colormap_entries;
539 colormap_entries.resize(256);
540 for(mi::Uint32 i=0; i<256; ++i)
542 colormap_entries[i] = jetmap((i+0.5f)/256.f, 0.f, 1.f);
545 mi::Float32 t = (i + 0.5f)/256.f;
546 colormap_entries[i].a =
MIN_TRANS + (MAX_TRANS -
MIN_TRANS)*t;
552 colormap->set_colormap(&colormap_entries[0], colormap_entries.size());
557bool Create_path_2d::create_scene(
558 nv::index::IScene* scene_edit,
559 std::vector<mi::neuraylib::Tag>& path_tags,
560 mi::neuraylib::IDice_transaction* dice_transaction)
564 mi::base::Handle<nv::index::IDirectional_light> light_global(
565 scene_edit->create_attribute<nv::index::IDirectional_light>());
567 light_global->set_direction(mi::math::Vector<mi::Float32, 3>(0.5f, 0.f, 1.f));
568 const mi::neuraylib::Tag light_global_tag = dice_transaction->store_for_reference_counting(light_global.get());
570 scene_edit->append(light_global_tag, dice_transaction);
573 mi::base::Handle<nv::index::IPhong_gl> phong_1(scene_edit->create_attribute<nv::index::IPhong_gl>());
575 phong_1->set_ambient(mi::math::Color(0.15f, 0.15f, 0.15f, 1.0f));
576 phong_1->set_diffuse(mi::math::Color(0.95f, 0.95f, 0.95f, 1.0f));
577 phong_1->set_specular(mi::math::Color(0.4f, 0.4f, 0.4f, 1.0f));
578 phong_1->set_shininess(85);
580 const mi::neuraylib::Tag phong_1_tag = dice_transaction->store_for_reference_counting(phong_1.get());
582 scene_edit->append(phong_1_tag, dice_transaction);
585 mi::base::Handle<nv::index::IColormap> colormap(create_colormap(scene_edit, m_path_test_params.
test_transparency));
587 const mi::neuraylib::Tag colormap_tag = dice_transaction->store_for_reference_counting(colormap.get());
589 scene_edit->append(colormap_tag, dice_transaction);
592 mi::math::Bbox< mi::Float32, 3 > path_bbox;
595 const mi::Size num_points = m_path_test_params.
num_points;
598 nv::index::IPath_style::Color_source color_source;
600 color_source = nv::index::IPath_style:
:COLOR_SOURCE_BOTH;
602 color_source = nv::index::IPath_style:
:COLOR_SOURCE_COLORMAP_ONLY;
603 else if(m_path_test_params.
use_rgba)
604 color_source = nv::index::IPath_style:
:COLOR_SOURCE_RGBA_ONLY;
606 color_source = nv::index::IPath_style:
:COLOR_SOURCE_NONE;
610 std::vector<mi::math::Color_struct> colors;
611 colors.resize(num_points);
612 for(mi::Size i=0; i<num_points; i++)
614 mi::Float32 g = (i + 0.5f)/num_points;
615 mi::Float32 f = fabs(2*g - 1.f);
617 colors[i].g = 1.f - f;
618 colors[i].b = 1.f - f;
623 mi::math::Matrix<mi::Float32, 4, 4> transform_mat(1.f);
624 transform_mat.translate(mi::math::Vector<mi::Float32, 3>(120.f, 0.f, 0.f));
625 mi::base::Handle<nv::index::ITransformed_scene_group> group_node(
626 scene_edit->create_scene_group<nv::index::ITransformed_scene_group>());
628 group_node->set_transform(transform_mat);
631 std::vector< mi::math::Vector_struct<mi::Float32, 3> > points;
632 points.resize(num_points);
633 for(mi::Size i=0; i<num_points; i++)
635 points[i].y = ((i + 0.5f)/num_points)*6.f;
636 points[i].x = evaluate_path(points[i].y);
639 path_bbox.insert(points[i]);
641 points[i].x = points[i].x*100.f - 80.f;
642 points[i].y = points[i].y*100.f + 10.f;
643 points[i].z *= 100.f;
645 path_bbox.insert(points[i]);
649 mi::Float32 min_radius = 10.f, max_radius = 30.f;
650 std::vector<mi::Float32> radii;
651 radii.resize(num_points);
652 for(mi::Size i=0; i<num_points; i++)
654 mi::Float32 t = (i+0.5f)/(mi::Float32)num_points;
655 radii[i] = min_radius + 0.5f*(sinf(t*2.f*3.14159f)+1.f)*(max_radius - min_radius);
659 std::vector<mi::Uint32> colormap_ids;
660 colormap_ids.resize(num_points);
661 for(mi::Size i=0; i<num_points; i++){
662 colormap_ids[i] = (mi::Uint32) (255.f*((i+0.5f)/(mi::Float32)num_points));
667 mi::base::Handle<nv::index::IPath_style> path_style1(scene_edit->create_attribute<nv::index::IPath_style>());
669 path_style1->set_interpolation(nv::index::IPath_style:
:INTERPOLATION_LINEAR);
670 path_style1->set_color_source(color_source);
672 const mi::neuraylib::Tag path_style1_tag = dice_transaction->store_for_reference_counting(path_style1.get());
674 group_node->append(path_style1_tag, dice_transaction);
676 mi::base::Handle<nv::index::IPath_2D> path1(scene_edit->create_shape<nv::index::IPath_2D>());
680 path1->set_radius(15.f);
683 path1->set_points(&points[0],
static_cast<mi::Uint32
>(num_points));
686 path1->set_radii(&radii[0],
static_cast<mi::Uint32
>(num_points));
689 path1->set_color_map_indexes(&colormap_ids[0],
static_cast<mi::Uint32
>(num_points));
690 path1->set_colors(&colors[0],
static_cast<mi::Uint32
>(num_points));
693 const mi::neuraylib::Tag path1_tag = dice_transaction->store_for_reference_counting(path1.get());
695 group_node->append(path1_tag, dice_transaction);
696 path_tags.push_back(path1_tag);
701 mi::base::Handle<nv::index::IPath_style> path_style2(scene_edit->create_attribute<nv::index::IPath_style>());
703 path_style2->set_interpolation(nv::index::IPath_style:
:INTERPOLATION_SEGMENT);
704 path_style2->set_color_source(color_source);
706 const mi::neuraylib::Tag path2_style_tag =
707 dice_transaction->store_for_reference_counting(path_style2.get());
709 group_node->append(path2_style_tag, dice_transaction);
711 mi::base::Handle<nv::index::IPath_2D> path2(scene_edit->create_shape<nv::index::IPath_2D>());
715 path2->set_radius(12.0f);
718 for(mi::Size i=0; i<num_points; i++){
720 path_bbox.insert(points[i]);
723 path2->set_points(&points[0],
static_cast<mi::Uint32
>(num_points));
726 path2->set_radii(&radii[0],
static_cast<mi::Uint32
>(num_points));
729 path2->set_color_map_indexes(&colormap_ids[0],
static_cast<mi::Uint32
>(num_points));
730 path2->set_colors(&colors[0],
static_cast<mi::Uint32
>(num_points));
733 const mi::neuraylib::Tag path2_tag = dice_transaction->store_for_reference_counting(path2.get());
735 group_node->append(path2_tag, dice_transaction);
736 path_tags.push_back(path2_tag);
741 mi::base::Handle<nv::index::IPath_style> path_style3(scene_edit->create_attribute<nv::index::IPath_style>());
743 path_style3->set_interpolation(nv::index::IPath_style:
:INTERPOLATION_NEAREST);
744 path_style3->set_color_source(color_source);
746 const mi::neuraylib::Tag path3_style_tag = dice_transaction->store_for_reference_counting(path_style3.get());
748 group_node->append(path3_style_tag, dice_transaction);
750 mi::base::Handle<nv::index::IPath_2D> path3(scene_edit->create_shape<nv::index::IPath_2D>());
754 path3->set_radius(7.0f);
757 for(mi::Size i=0; i<num_points; i++){
759 path_bbox.insert(points[i]);
762 path3->set_points(&points[0],
static_cast<mi::Uint32
>(num_points));
765 path3->set_radii(&radii[0],
static_cast<mi::Uint32
>(num_points));
768 path3->set_color_map_indexes(&colormap_ids[0],
static_cast<mi::Uint32
>(num_points));
769 path3->set_colors(&colors[0],
static_cast<mi::Uint32
>(num_points));
772 const mi::neuraylib::Tag path3_tag = dice_transaction->store_for_reference_counting(path3.get());
774 group_node->append(path3_tag, dice_transaction);
775 path_tags.push_back(path3_tag);
781 mi::math::Vector<mi::Float32, 3> plane_point(-500.f, -100.f, 150.0f);
782 mi::math::Vector<mi::Float32, 3> plane_normal(0.f, 0.f, 1.f);
783 mi::math::Vector<mi::Float32, 3> plane_up(0.f, 1.f, 0.f);
784 mi::math::Vector<mi::Float32, 2> plane_extent(1200.0f, 800.0f);
786 mi::base::Handle<nv::index::ITexture_filter_mode> tex_filter(
787 scene_edit->create_attribute<nv::index::ITexture_filter_mode_nearest_neighbor>());
789 mi::neuraylib::Tag tex_filter_tag = dice_transaction->store_for_reference_counting(tex_filter.get());
791 group_node->append(tex_filter_tag, dice_transaction);
794 mi::base::Handle<nv::index::app::data_analysis_and_processing::IData_analysis_and_processing> processing(
795 get_application_layer_interface()->get_api_component<nv::index::app::data_analysis_and_processing::IData_analysis_and_processing>());
799 mi::base::Handle<nv::index::IDistributed_compute_technique> mapping(
800 processing->get_sample_tool_set()->create_checker_board_2d_technique(
802 nv::index::IDistributed_compute_destination_buffer_2d_texture:
:FORMAT_RGBA_FLOAT32,
803 mi::math::Color(0.9f, 0.2f, 0.15f, 0.7f),
804 mi::math::Color(0.2f, 0.2f, 0.8f, 1.0f)));
806 mi::neuraylib::Tag mapping_tag = dice_transaction->store_for_reference_counting(mapping.get());
808 group_node->append(mapping_tag, dice_transaction);
810 mi::base::Handle<nv::index::IPlane> plane(scene_edit->create_shape<nv::index::IPlane>());
812 plane->set_point(plane_point);
813 plane->set_normal(plane_normal);
814 plane->set_up(plane_up);
815 plane->set_extent(plane_extent);
817 mi::neuraylib::Tag plane_tag = dice_transaction->store_for_reference_counting(plane.get());
819 group_node->append(plane_tag, dice_transaction);
821 path_tags.push_back(plane_tag);
826 const mi::neuraylib::Tag group_node_tag = dice_transaction->store_for_reference_counting(group_node.get());
828 scene_edit->append(group_node_tag, dice_transaction);
830 INFO_LOG <<
"The bounding box of all vertices that are used to create the paths: " << path_bbox;
838void Create_path_2d::setup_camera(nv::index::IPerspective_camera* cam)
const
841 mi::math::Vector< mi::Float32, 3 >
const from( 234.0f, 604.0f, 500.0f);
842 mi::math::Vector< mi::Float32, 3 >
const to ( 255.0f, 255.0f, -255.0f);
843 mi::math::Vector< mi::Float32, 3 >
const up ( 0.0f, 1.0f, 0.0f);
844 mi::math::Vector<mi::Float32, 3> viewdir = to - from;
847 cam->set(from, viewdir, up);
848 cam->set_aperture(0.033f);
849 cam->set_aspect(1.0f);
850 cam->set_focal(0.03f);
851 cam->set_clip_min(10.0f);
852 cam->set_clip_max(5000.0f);
856void Create_path_2d::setup_extreme_transformed_camera(nv::index::IPerspective_camera* cam)
const
872 mi::math::Vector< mi::Float32, 3 >
const from( 1805060.125f + 8192.0f, 9978520.0f + 16384.0f, 16384.0f);
873 mi::math::Vector< mi::Float32, 3 >
const to ( 1805060.125f + 8192.0f, 9978520.0f + 8292.0f, -256.0f);
874 mi::math::Vector< mi::Float32, 3 >
const up ( 0.0f, 1.0f, 0.0f);
875 mi::math::Vector<mi::Float32, 3> viewdir = to - from;
878 cam->set(from, viewdir, up);
879 cam->set_aperture(0.033f);
880 cam->set_aspect(1.71520f);
881 cam->set_focal(0.03f);
882 cam->set_clip_min(124.485f);
883 cam->set_clip_max(17585.6f);
885 INFO_LOG <<
"Set camera extreme mode";
889mi::math::Matrix<mi::Float32, 4, 4> Create_path_2d::get_extreme_transformed_matrix()
const
897 mi::math::Matrix<mi::Float32, 4, 4> transform_mat(
898 20.61f, 0.0f, 0.0f, 0.0f,
899 0.0f, 20.61f, 0.0f, 0.0f,
900 0.0f, 0.0f, -4.0f, 0.0f,
901 1805060.0f, 9978520.0f, 0.0f, 1.0f
903 return transform_mat;
907nv::index::IFrame_results* Create_path_2d::render_frame(
const std::string& output_fname)
const
912 m_image_file_canvas->set_rgba_file_name(output_fname.c_str());
916 mi::base::Handle<mi::neuraylib::IDice_transaction> dice_transaction(
917 m_global_scope->create_transaction<mi::neuraylib::IDice_transaction>());
920 m_index_session->update(m_session_tag, dice_transaction.get());
922 mi::base::Handle<nv::index::IFrame_results> frame_results(
923 m_index_rendering->render(
925 m_image_file_canvas.get(),
926 dice_transaction.get()));
929 dice_transaction->commit();
931 frame_results->retain();
932 return frame_results.get();
936int main(
int argc,
const char* argv[])
938 nv::index::app::String_dict sdict;
939 sdict.insert(
"dice::verbose",
"3");
940 sdict.insert(
"outfname",
"frame_create_path_2d");
941 sdict.insert(
"verify_image_fname",
"");
942 sdict.insert(
"unittest",
"0");
943 sdict.insert(
"supersampling",
"0");
944 sdict.insert(
"num_samples",
"40");
945 sdict.insert(
"use_colormap",
"1");
946 sdict.insert(
"use_rgba",
"0");
947 sdict.insert(
"test_transparency",
"0");
948 sdict.insert(
"upsampling",
"0");
949 sdict.insert(
"up_factor",
"2");
950 sdict.insert(
"up_tension",
"0.0");
951 sdict.insert(
"is_large_translate",
"0");
952 sdict.insert(
"is_dump_comparison_image_when_failed",
"1");
953 sdict.insert(
"is_call_from_test",
"0");
957 sdict.insert(
"dice::network::mode",
"OFF");
960 sdict.insert(
"index::config::set_monitor_performance_values",
"true");
961 sdict.insert(
"index::service",
"rendering_and_compositing");
962 sdict.insert(
"index::cuda_debug_checks",
"false");
965 sdict.insert(
"index::app::components::application_layer::component_name_list",
966 "canvas_infrastructure image io data_analysis_and_processing");
970 create_path_2d.initialize(argc, argv, sdict);
974 const mi::Sint32 exit_code = create_path_2d.
launch();
975 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 ~Create_path_2d()
int main(int argc, const char *argv[])
#define check_success(expr)