This example renders a scene progressively.
#ifndef EXAMPLE_RENDER_TARGET_ADVANCED_H
#define EXAMPLE_RENDER_TARGET_ADVANCED_H
{
public:
{
m_width = width;
m_height = height;
}
~Tile() { delete[] m_data; }
{
mi::Float32* position = &m_data[(x_offset + y_offset * m_width) * 4];
position[0] = floats[0];
position[1] = floats[1];
position[2] = floats[2];
position[3] = floats[3];
}
{
mi::Float32* position = &m_data[(x_offset + y_offset * m_width) * 4];
floats[0] = position[0];
floats[1] = position[1];
floats[2] = position[2];
floats[3] = position[3];
}
const char* get_type() const { return "Color"; }
mi::Uint32 get_resolution_x()
const {
return m_width; }
mi::Uint32 get_resolution_y()
const {
return m_height; }
const void* get_data() const { return m_data; }
void* get_data() { return m_data; }
private:
};
{
public:
{
m_width = width;
m_height = height;
m_gamma = 1.0f;
m_tile = new Tile( width, height);
}
mi::Uint32 get_resolution_x()
const {
return m_width; }
mi::Uint32 get_resolution_y()
const {
return m_height; }
{
return m_tile.get();
}
{
return m_tile.get();
}
const char* get_type() const { return "Color"; }
void set_gamma(
mi::Float32 gamma) { m_gamma = gamma; }
private:
};
{
public:
{
m_canvas = new Canvas( width, height);
}
{ return 0; }
{
if( index > 0)
return 0;
return m_canvas.get();
}
{
if( index > 0)
return 0;
return m_canvas.get();
}
private:
};
#endif
Handle class template for interfaces, automatizing the lifetime control via reference counting.
Definition: handle.h:113
Mixin class template for deriving interface implementations.
Definition: interface_implement.h:41
Abstract interface for render target canvas parameters.
Definition: irender_target.h:106
Abstract interface for a canvas represented by a rectangular array of tiles.
Definition: icanvas.h:85
Abstract interface for a tile.
Definition: itile.h:36
virtual Uint32 retain() const =0
Increments the reference count.
unsigned int Uint32
32-bit unsigned integer.
Definition: types.h:49
float Float32
32-bit float.
Definition: types.h:51
Canvas_type
The type of a canvas in an mi::neuraylib::IRender_target_base.
Definition: irender_target.h:32
@ TYPE_UNDEFINED
not a valid canvas type
Definition: irender_target.h:62
@ TYPE_RESULT
"Color" (includes alpha) or "Rgb_fp" result
Definition: irender_target.h:33
#include <iomanip>
#include <iostream>
#include <sstream>
#include "example_shared.h"
#include "example_render_target_advanced.h"
{
check_success( rc->add_mdl_path( mdl_path) == 0);
check_success( rc->add_mdl_path( ".") == 0);
}
{
check_success( database.is_valid_interface());
database->get_global_scope());
scope->create_transaction());
check_success( transaction.is_valid_interface());
check_success( import_api.is_valid_interface());
import_api->import_elements( transaction.get(), uri->get_c_str()));
check_success( import_result->get_error_number() == 0);
scene->set_rootgroup( import_result->get_rootgroup());
scene->set_options( import_result->get_options());
scene->set_camera_instance( import_result->get_camera_inst());
transaction->store( scene.get(), "the_scene");
scene->create_render_context( transaction.get(), "iray"));
check_success( render_context.is_valid_interface());
scene = 0;
new Render_target( 512, 384));
mi::Sint32 result = render_context->render( transaction.get(), render_target.get(), 0);
check_success( result >= 0);
check_success( export_api.is_valid_interface());
std::ostringstream str;
str << "example_progressive_rendering_" << std::setw( 2) << std::setfill( '0') << i
<< ".png";
export_api->export_canvas( str.str().c_str(), canvas.get());
if( result > 0)
break;
}
render_context->pick( transaction.get(),
mi::Float32_2( 128, 192)));
std::cerr << "Picked objects:" << std::endl;
for(
mi::Uint32 i = 0; i < pick_array->get_length(); ++i) {
std::cerr << "Object " << i << ": \"" << pick_result->get_picked_object_name() << "\", "
<< "hit point (" << hit_point.x << ", " << hit_point.y << ", " << hit_point.z << "), "
<< "path \"" << pick_result->get_path( 0) << "\"";
mi::Uint32 path_length = pick_result->get_path_length();
std::cerr << ", \"" << pick_result->get_path( j) << "\"";
std::cerr << std::endl;
}
transaction->commit();
}
int main( int argc, char* argv[])
{
if( argc != 3) {
std::cerr << "Usage: example_progressive_rendering <scene_file> <mdl_path>" << std::endl;
keep_console_open();
return EXIT_FAILURE;
}
const char* scene_file = argv[1];
const char* mdl_path = argv[2];
check_success( neuray.is_valid_interface());
configuration( neuray.get(), mdl_path);
check_start_success( result);
rendering( neuray.get(), scene_file);
check_success( neuray->
shutdown() == 0);
neuray = 0;
check_success( unload());
keep_console_open();
return EXIT_SUCCESS;
}
Fixed-size math vector class template with generic operations.
Definition: vector.h:286
This interface is used to interact with the distributed database.
Definition: idatabase.h:293
This interface is used to export files.
Definition: iexport_api.h:38
This interface is used to import files.
Definition: iimport_api.h:100
This is an object representing the Iray library.
Definition: ineuray.h:44
virtual Sint32 shutdown(bool blocking=true)=0
Shuts down the library.
virtual base::IInterface * get_api_component(const base::Uuid &uuid) const =0
Returns an API component from the Iray SDK API.
virtual Sint32 start(bool blocking=true)=0
Starts the operation of the Iray library.
This interface is used to load plugins and to query information about loaded plugins.
Definition: iplugin_configuration.h:24
This interface is used to query and change the rendering configuration.
Definition: irendering_configuration.h:109
The scene is the top-level element describing a subset of DB elements to be rendered.
Definition: iscene.h:44
#define MI_BASE_DLL_FILE_EXT
The operating system specific default filename extension for shared libraries (DLLs)
Definition: config.h:340
Uint64 Size
Unsigned integral type that is large enough to hold the size of all types.
Definition: types.h:112
signed int Sint32
32-bit signed integer.
Definition: types.h:46