Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/app/cycles_standalone.cpp
| Show First 20 Lines • Show All 127 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| options.scene = new Scene(options.scene_params, options.session->device); | options.scene = new Scene(options.scene_params, options.session->device); | ||||
| /* Read XML */ | /* Read XML */ | ||||
| xml_read_file(options.scene, options.filepath.c_str()); | xml_read_file(options.scene, options.filepath.c_str()); | ||||
| /* Camera width/height override? */ | /* Camera width/height override? */ | ||||
| if (!(options.width == 0 || options.height == 0)) { | if (!(options.width == 0 || options.height == 0)) { | ||||
| options.scene->camera->width = options.width; | options.scene->camera->set_screen_size_and_resolution(options.width, options.height, 1); | ||||
| options.scene->camera->height = options.height; | |||||
| } | } | ||||
| else { | else { | ||||
| options.width = options.scene->camera->width; | options.width = options.scene->camera->screen_width(); | ||||
| options.height = options.scene->camera->height; | options.height = options.scene->camera->screen_height(); | ||||
| } | } | ||||
| /* Calculate Viewplane */ | /* Calculate Viewplane */ | ||||
| options.scene->camera->compute_auto_viewplane(); | options.scene->camera->compute_auto_viewplane(); | ||||
| } | } | ||||
| static void session_init() | static void session_init() | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | static void display() | ||||
| options.session->draw(session_buffer_params(), draw_params); | options.session->draw(session_buffer_params(), draw_params); | ||||
| display_info(options.session->progress); | display_info(options.session->progress); | ||||
| } | } | ||||
| static void motion(int x, int y, int button) | static void motion(int x, int y, int button) | ||||
| { | { | ||||
| if (options.interactive) { | if (options.interactive) { | ||||
| Transform matrix = options.session->scene->camera->matrix; | Transform matrix = options.session->scene->camera->get_matrix(); | ||||
| /* Translate */ | /* Translate */ | ||||
| if (button == 0) { | if (button == 0) { | ||||
| float3 translate = make_float3(x * 0.01f, -(y * 0.01f), 0.0f); | float3 translate = make_float3(x * 0.01f, -(y * 0.01f), 0.0f); | ||||
| matrix = matrix * transform_translate(translate); | matrix = matrix * transform_translate(translate); | ||||
| } | } | ||||
| /* Rotate */ | /* Rotate */ | ||||
| else if (button == 2) { | else if (button == 2) { | ||||
| float4 r1 = make_float4((float)x * 0.1f, 0.0f, 1.0f, 0.0f); | float4 r1 = make_float4((float)x * 0.1f, 0.0f, 1.0f, 0.0f); | ||||
| matrix = matrix * transform_rotate(DEG2RADF(r1.x), make_float3(r1.y, r1.z, r1.w)); | matrix = matrix * transform_rotate(DEG2RADF(r1.x), make_float3(r1.y, r1.z, r1.w)); | ||||
| float4 r2 = make_float4(y * 0.1f, 1.0f, 0.0f, 0.0f); | float4 r2 = make_float4(y * 0.1f, 1.0f, 0.0f, 0.0f); | ||||
| matrix = matrix * transform_rotate(DEG2RADF(r2.x), make_float3(r2.y, r2.z, r2.w)); | matrix = matrix * transform_rotate(DEG2RADF(r2.x), make_float3(r2.y, r2.z, r2.w)); | ||||
| } | } | ||||
| /* Update and Reset */ | /* Update and Reset */ | ||||
| options.session->scene->camera->matrix = matrix; | options.session->scene->camera->set_matrix(matrix); | ||||
| options.session->scene->camera->need_update = true; | options.session->scene->camera->need_flags_update = true; | ||||
| options.session->scene->camera->need_device_update = true; | options.session->scene->camera->need_device_update = true; | ||||
| options.session->reset(session_buffer_params(), options.session_params.samples); | options.session->reset(session_buffer_params(), options.session_params.samples); | ||||
| } | } | ||||
| } | } | ||||
| static void resize(int width, int height) | static void resize(int width, int height) | ||||
| { | { | ||||
| options.width = width; | options.width = width; | ||||
| options.height = height; | options.height = height; | ||||
| if (options.session) { | if (options.session) { | ||||
| /* Update camera */ | /* Update camera */ | ||||
| options.session->scene->camera->width = width; | options.session->scene->camera->set_screen_size_and_resolution(width, height, 1); | ||||
| options.session->scene->camera->height = height; | |||||
| options.session->scene->camera->compute_auto_viewplane(); | options.session->scene->camera->compute_auto_viewplane(); | ||||
| options.session->scene->camera->need_update = true; | options.session->scene->camera->need_flags_update = true; | ||||
| options.session->scene->camera->need_device_update = true; | options.session->scene->camera->need_device_update = true; | ||||
| options.session->reset(session_buffer_params(), options.session_params.samples); | options.session->reset(session_buffer_params(), options.session_params.samples); | ||||
| } | } | ||||
| } | } | ||||
| static void keyboard(unsigned char key) | static void keyboard(unsigned char key) | ||||
| { | { | ||||
| Show All 16 Lines | static void keyboard(unsigned char key) | ||||
| } | } | ||||
| /* Interactive Mode */ | /* Interactive Mode */ | ||||
| else if (key == 'i') | else if (key == 'i') | ||||
| options.interactive = !(options.interactive); | options.interactive = !(options.interactive); | ||||
| /* Navigation */ | /* Navigation */ | ||||
| else if (options.interactive && (key == 'w' || key == 'a' || key == 's' || key == 'd')) { | else if (options.interactive && (key == 'w' || key == 'a' || key == 's' || key == 'd')) { | ||||
| Transform matrix = options.session->scene->camera->matrix; | Transform matrix = options.session->scene->camera->get_matrix(); | ||||
| float3 translate; | float3 translate; | ||||
| if (key == 'w') | if (key == 'w') | ||||
| translate = make_float3(0.0f, 0.0f, 0.1f); | translate = make_float3(0.0f, 0.0f, 0.1f); | ||||
| else if (key == 's') | else if (key == 's') | ||||
| translate = make_float3(0.0f, 0.0f, -0.1f); | translate = make_float3(0.0f, 0.0f, -0.1f); | ||||
| else if (key == 'a') | else if (key == 'a') | ||||
| translate = make_float3(-0.1f, 0.0f, 0.0f); | translate = make_float3(-0.1f, 0.0f, 0.0f); | ||||
| else if (key == 'd') | else if (key == 'd') | ||||
| translate = make_float3(0.1f, 0.0f, 0.0f); | translate = make_float3(0.1f, 0.0f, 0.0f); | ||||
| matrix = matrix * transform_translate(translate); | matrix = matrix * transform_translate(translate); | ||||
| /* Update and Reset */ | /* Update and Reset */ | ||||
| options.session->scene->camera->matrix = matrix; | options.session->scene->camera->set_matrix(matrix); | ||||
| options.session->scene->camera->need_update = true; | options.session->scene->camera->need_flags_update = true; | ||||
| options.session->scene->camera->need_device_update = true; | options.session->scene->camera->need_device_update = true; | ||||
| options.session->reset(session_buffer_params(), options.session_params.samples); | options.session->reset(session_buffer_params(), options.session_params.samples); | ||||
| } | } | ||||
| /* Set Max Bounces */ | /* Set Max Bounces */ | ||||
| else if (options.interactive && (key == '0' || key == '1' || key == '2' || key == '3')) { | else if (options.interactive && (key == '0' || key == '1' || key == '2' || key == '3')) { | ||||
| int bounce; | int bounce; | ||||
| Show All 10 Lines | switch (key) { | ||||
| case '3': | case '3': | ||||
| bounce = 3; | bounce = 3; | ||||
| break; | break; | ||||
| default: | default: | ||||
| bounce = 0; | bounce = 0; | ||||
| break; | break; | ||||
| } | } | ||||
| options.session->scene->integrator->max_bounce = bounce; | options.session->scene->integrator->set_max_bounce(bounce); | ||||
| /* Update and Reset */ | |||||
| options.session->scene->integrator->need_update = true; | |||||
| options.session->reset(session_buffer_params(), options.session_params.samples); | options.session->reset(session_buffer_params(), options.session_params.samples); | ||||
| } | } | ||||
| } | } | ||||
| #endif | #endif | ||||
| static int files_parse(int argc, const char *argv[]) | static int files_parse(int argc, const char *argv[]) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 214 Lines • Show Last 20 Lines | |||||