| 37 | using namespace slg; |
| 38 | |
| 39 | void CompiledScene::CompileCamera() { |
| 40 | wasCameraCompiled = true; |
| 41 | |
| 42 | //SLG_LOG("Compile Camera"); |
| 43 | |
| 44 | //-------------------------------------------------------------------------- |
| 45 | // Camera definition |
| 46 | //-------------------------------------------------------------------------- |
| 47 | |
| 48 | const Camera *sceneCamera = scene->camera; |
| 49 | |
| 50 | // Initialize CameraBase |
| 51 | |
| 52 | camera.base.yon = sceneCamera->clipYon; |
| 53 | camera.base.hither = sceneCamera->clipHither; |
| 54 | camera.base.shutterOpen = sceneCamera->shutterOpen; |
| 55 | camera.base.shutterClose = sceneCamera->shutterClose; |
| 56 | camera.base.volumeIndex = sceneCamera->volume ? |
| 57 | scene->matDefs.GetMaterialIndex(sceneCamera->volume) : NULL_INDEX; |
| 58 | |
| 59 | if (sceneCamera->motionSystem) { |
| 60 | if (sceneCamera->motionSystem->interpolatedTransforms.size() > CAMERA_MAX_INTERPOLATED_TRANSFORM) |
| 61 | throw runtime_error("Too many interpolated transformations in camera motion system: " + |
| 62 | ToString(sceneCamera->motionSystem->interpolatedTransforms.size())); |
| 63 | |
| 64 | for (u_int i = 0; i < sceneCamera->motionSystem->interpolatedTransforms.size(); ++i) { |
| 65 | const InterpolatedTransform &it = sceneCamera->motionSystem->interpolatedTransforms[i]; |
| 66 | |
| 67 | // Here, I assume that luxrays::ocl::InterpolatedTransform and |
| 68 | // luxrays::InterpolatedTransform are the same |
| 69 | camera.base.interpolatedTransforms[i] = *((const luxrays::ocl::InterpolatedTransform *)&it); |
| 70 | } |
| 71 | |
| 72 | camera.base.motionSystem.interpolatedTransformFirstIndex = 0; |
| 73 | camera.base.motionSystem.interpolatedTransformLastIndex = sceneCamera->motionSystem->interpolatedTransforms.size() - 1; |
| 74 | } else { |
| 75 | camera.base.motionSystem.interpolatedTransformFirstIndex = NULL_INDEX; |
| 76 | camera.base.motionSystem.interpolatedTransformLastIndex = NULL_INDEX; |
| 77 | } |
| 78 | |
| 79 | // Initialize Camera specific data |
| 80 | |
| 81 | switch (sceneCamera->GetType()) { |
| 82 | case Camera::ORTHOGRAPHIC: { |
| 83 | const OrthographicCamera *orthoCamera = (OrthographicCamera *)sceneCamera; |
| 84 | cameraType = slg::ocl::ORTHOGRAPHIC; |
| 85 | |
| 86 | memcpy(camera.base.rasterToCamera.m.m, orthoCamera->GetRasterToCameraMatrix().m, 4 * 4 * sizeof(float)); |
| 87 | memcpy(camera.base.cameraToWorld.m.m, orthoCamera->GetCameraToWorldMatrix().m, 4 * 4 * sizeof(float)); |
| 88 | |
| 89 | camera.ortho.projCamera.lensRadius = orthoCamera->lensRadius; |
| 90 | camera.ortho.projCamera.focalDistance = orthoCamera->focalDistance; |
| 91 | |
| 92 | enableCameraOculusRiftBarrel = false; |
| 93 | if (orthoCamera->enableClippingPlane) { |
| 94 | enableCameraClippingPlane = true; |
| 95 | ASSIGN_VECTOR(camera.ortho.projCamera.clippingPlaneCenter, orthoCamera->clippingPlaneCenter); |
| 96 | ASSIGN_VECTOR(camera.ortho.projCamera.clippingPlaneNormal, orthoCamera->clippingPlaneNormal); |
nothing calls this directly
no test coverage detected