Beispiel #1
0
static void blender_camera_init(BlenderCamera *bcam,
                                BL::RenderSettings& b_render)
{
	memset(bcam, 0, sizeof(BlenderCamera));

	bcam->type = CAMERA_PERSPECTIVE;
	bcam->zoom = 1.0f;
	bcam->pixelaspect = make_float2(1.0f, 1.0f);
	bcam->sensor_width = 32.0f;
	bcam->sensor_height = 18.0f;
	bcam->sensor_fit = BlenderCamera::AUTO;
	bcam->shuttertime = 1.0f;
	bcam->motion_position = Camera::MOTION_POSITION_CENTER;
	bcam->rolling_shutter_type = Camera::ROLLING_SHUTTER_NONE;
	bcam->rolling_shutter_duration = 0.1f;
	bcam->border.right = 1.0f;
	bcam->border.top = 1.0f;
	bcam->pano_viewplane.right = 1.0f;
	bcam->pano_viewplane.top = 1.0f;
	bcam->viewport_camera_border.right = 1.0f;
	bcam->viewport_camera_border.top = 1.0f;

	/* render resolution */
	bcam->full_width = render_resolution_x(b_render);
	bcam->full_height = render_resolution_y(b_render);

	/* pixel aspect */
	bcam->pixelaspect.x = b_render.pixel_aspect_x();
	bcam->pixelaspect.y = b_render.pixel_aspect_y();
}
void BlenderSync::sync_camera(BL::Object b_override, int width, int height)
{
	BlenderCamera bcam;
	blender_camera_init(&bcam, b_scene);

	/* pixel aspect */
	BL::RenderSettings r = b_scene.render();

	bcam.pixelaspect.x = r.pixel_aspect_x();
	bcam.pixelaspect.y = r.pixel_aspect_y();
	bcam.shuttertime = r.motion_blur_shutter();

	/* border */
	if(r.use_border()) {
		bcam.border.left = r.border_min_x();
		bcam.border.right = r.border_max_x();
		bcam.border.bottom = r.border_min_y();
		bcam.border.top = r.border_max_y();
	}

	/* camera object */
	BL::Object b_ob = b_scene.camera();

	if(b_override)
		b_ob = b_override;

	if(b_ob) {
		blender_camera_from_object(&bcam, b_ob);
		bcam.matrix = get_transform(b_ob.matrix_world());
	}

	/* sync */
	Camera *cam = scene->camera;
	blender_camera_sync(cam, &bcam, width, height);
}
void BlenderSync::sync_camera(BL::RenderSettings b_render, BL::Object b_override, int width, int height)
{
	BlenderCamera bcam;
	blender_camera_init(&bcam, b_render);

	/* pixel aspect */
	bcam.pixelaspect.x = b_render.pixel_aspect_x();
	bcam.pixelaspect.y = b_render.pixel_aspect_y();
	bcam.shuttertime = b_render.motion_blur_shutter();

	/* border */
	if(b_render.use_border()) {
		bcam.border.left = b_render.border_min_x();
		bcam.border.right = b_render.border_max_x();
		bcam.border.bottom = b_render.border_min_y();
		bcam.border.top = b_render.border_max_y();
	}

	/* camera object */
	BL::Object b_ob = b_scene.camera();

	if(b_override)
		b_ob = b_override;

	if(b_ob) {
		BL::Array<float, 16> b_ob_matrix;
		blender_camera_from_object(&bcam, b_engine, b_ob);
		b_engine.camera_model_matrix(b_ob, b_ob_matrix);
		bcam.matrix = get_transform(b_ob_matrix);
	}

	/* sync */
	Camera *cam = scene->camera;
	blender_camera_sync(cam, &bcam, width, height);
}
void BlenderSync::sync_camera(BL::RenderSettings& b_render,
                              BL::Object& b_override,
                              int width, int height,
                              const char *viewname)
{
	BlenderCamera bcam;
	blender_camera_init(&bcam, b_render);

	/* pixel aspect */
	bcam.pixelaspect.x = b_render.pixel_aspect_x();
	bcam.pixelaspect.y = b_render.pixel_aspect_y();
	bcam.shuttertime = b_render.motion_blur_shutter();

	BL::CurveMapping b_shutter_curve(b_render.motion_blur_shutter_curve());
	curvemapping_to_array(b_shutter_curve, bcam.shutter_curve, RAMP_TABLE_SIZE);

	PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
	bcam.motion_position =
	        (Camera::MotionPosition)get_enum(cscene,
	                                         "motion_blur_position",
	                                         Camera::MOTION_NUM_POSITIONS,
	                                         Camera::MOTION_POSITION_CENTER);
	bcam.rolling_shutter_type =
		(Camera::RollingShutterType)get_enum(cscene,
		                                     "rolling_shutter_type",
		                                     Camera::ROLLING_SHUTTER_NUM_TYPES,
		                                     Camera::ROLLING_SHUTTER_NONE);
	bcam.rolling_shutter_duration = RNA_float_get(&cscene, "rolling_shutter_duration");

	/* border */
	if(b_render.use_border()) {
		bcam.border.left = b_render.border_min_x();
		bcam.border.right = b_render.border_max_x();
		bcam.border.bottom = b_render.border_min_y();
		bcam.border.top = b_render.border_max_y();
	}

	/* camera object */
	BL::Object b_ob = b_scene.camera();

	if(b_override)
		b_ob = b_override;

	if(b_ob) {
		BL::Array<float, 16> b_ob_matrix;
		blender_camera_from_object(&bcam, b_engine, b_ob);
		b_engine.camera_model_matrix(b_ob, bcam.use_spherical_stereo, b_ob_matrix);
		bcam.matrix = get_transform(b_ob_matrix);
	}

	/* sync */
	Camera *cam = scene->camera;
	blender_camera_sync(cam, &bcam, width, height, viewname);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Sync rendered Camera from blender scene to Octane data
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void BlenderSync::sync_camera(BL::Object b_override, int width, int height) {
    Camera* cam     = scene->camera;
    Camera  prevcam = *cam;

    BL::RenderSettings r = b_scene.render();
    cam->pixelaspect.x   = r.pixel_aspect_x();
    cam->pixelaspect.y   = r.pixel_aspect_y();
    cam->use_border      = r.use_border();
    if(cam->use_border) {
        /* border render */
        cam->border.x = (uint32_t)(r.border_min_x() * (float)width);
        cam->border.y = (uint32_t)((1.0f - r.border_max_y()) * (float)height);
        cam->border.z = (uint32_t)(r.border_max_x() * (float)width);
        cam->border.w = (uint32_t)((1.0f - r.border_min_y()) * (float)height);
    }
    else {
        cam->border.x = 0;
        cam->border.y = 0;
        cam->border.z = 0;
        cam->border.w = 0;
    }
    if(cam->modified(prevcam)) cam->tag_update();

    BL::Object b_ob = b_scene.camera();
    if(b_override) b_ob = b_override;

    if(b_ob) {
        cam->matrix = scene->matrix * get_transform(b_ob.matrix_world());
        float2 offset = {0};
        cam->zoom = 1.0f;
        load_camera_from_object(cam, b_ob, width, height, offset);
        cam->is_hidden = (scene->use_viewport_hide ? b_ob.hide() : b_ob.hide_render());
    }
    else
        cam->is_hidden = true;

    if(cam->modified(prevcam)) cam->tag_update();
} //sync_camera()
Beispiel #6
0
void BlenderSync::sync_camera(BL::RenderSettings& b_render,
                              BL::Object& b_override,
                              int width, int height)
{
	BlenderCamera bcam;
	blender_camera_init(&bcam, b_render);

	/* pixel aspect */
	bcam.pixelaspect.x = b_render.pixel_aspect_x();
	bcam.pixelaspect.y = b_render.pixel_aspect_y();
	bcam.shuttertime = b_render.motion_blur_shutter();

	BL::CurveMapping b_shutter_curve(b_render.motion_blur_shutter_curve());
	curvemapping_to_array(b_shutter_curve, bcam.shutter_curve, RAMP_TABLE_SIZE);

	PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
	switch(RNA_enum_get(&cscene, "motion_blur_position")) {
		case 0:
			bcam.motion_position = Camera::MOTION_POSITION_START;
			break;
		case 1:
			bcam.motion_position = Camera::MOTION_POSITION_CENTER;
			break;
		case 2:
			bcam.motion_position = Camera::MOTION_POSITION_END;
			break;
		default:
			bcam.motion_position = Camera::MOTION_POSITION_CENTER;
			break;
	}

	switch(RNA_enum_get(&cscene, "rolling_shutter_type")) {
		case 0:
			bcam.rolling_shutter_type = Camera::ROLLING_SHUTTER_NONE;
			break;
		case 1:
			bcam.rolling_shutter_type = Camera::ROLLING_SHUTTER_TOP;
			break;
		default:
			bcam.rolling_shutter_type = Camera::ROLLING_SHUTTER_NONE;
			break;
	}
	bcam.rolling_shutter_duration = RNA_float_get(&cscene, "rolling_shutter_duration");

	/* border */
	if(b_render.use_border()) {
		bcam.border.left = b_render.border_min_x();
		bcam.border.right = b_render.border_max_x();
		bcam.border.bottom = b_render.border_min_y();
		bcam.border.top = b_render.border_max_y();
	}

	/* camera object */
	BL::Object b_ob = b_scene.camera();

	if(b_override)
		b_ob = b_override;

	if(b_ob) {
		BL::Array<float, 16> b_ob_matrix;
		blender_camera_from_object(&bcam, b_engine, b_ob);
		b_engine.camera_model_matrix(b_ob, b_ob_matrix);
		bcam.matrix = get_transform(b_ob_matrix);
	}

	/* sync */
	Camera *cam = scene->camera;
	blender_camera_sync(cam, &bcam, width, height);
}