From 84f6349d95046317248d476d400525063c59be6a Mon Sep 17 00:00:00 2001
From: Ben Heasly <benjamin.heasly@gmail.com>
Date: Tue, 14 Feb 2017 15:45:28 -0500
Subject: [PATCH] use anonymous function to pass extra parameter to remodeler
 function

---
 .../CrytekSponza/rtbCrytekPBRTRemodeler.m       |  6 +++---
 .../CrytekSponza/rtbMakeCrytekSponza.m          | 17 ++++++++++-------
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/ExampleScenes/IsetbioExamples/CrytekSponza/rtbCrytekPBRTRemodeler.m b/ExampleScenes/IsetbioExamples/CrytekSponza/rtbCrytekPBRTRemodeler.m
index 89df104..bca27a3 100644
--- a/ExampleScenes/IsetbioExamples/CrytekSponza/rtbCrytekPBRTRemodeler.m
+++ b/ExampleScenes/IsetbioExamples/CrytekSponza/rtbCrytekPBRTRemodeler.m
@@ -1,4 +1,4 @@
-function nativeScene = rtbCrytekPBRTRemodeler(parentScene,nativeScene,mappings,names,conditionValues,conditionNumber)
+function nativeScene = rtbCrytekPBRTRemodeler(parentScene,nativeScene,mappings,names,conditionValues,conditionNumber,cameraInfo)
 
 % The function is called by the batch renderer when needed.  Various
 % parameters are passed in, like the mexximp scene, the native scene, and
@@ -24,8 +24,8 @@ sampler.setParameter('pixelsamples', 'integer', numSamples);
 
 camera =  nativeScene.find('Camera');
 camera.type = 'pinhole';
-camera.setParameter('filmdiag', 'float', 20);
-camera.setParameter('filmdistance', 'float', 20);
+camera.setParameter('filmdiag', 'float', cameraInfo.filmdiag);
+camera.setParameter('filmdistance', 'float', cameraInfo.filmdistance);
     
 %% Promote the area light mesh into an actual area light. 
 % Assign appropriate spectrum based on the conditionValues
diff --git a/ExampleScenes/IsetbioExamples/CrytekSponza/rtbMakeCrytekSponza.m b/ExampleScenes/IsetbioExamples/CrytekSponza/rtbMakeCrytekSponza.m
index 53d318d..7e2aa36 100644
--- a/ExampleScenes/IsetbioExamples/CrytekSponza/rtbMakeCrytekSponza.m
+++ b/ExampleScenes/IsetbioExamples/CrytekSponza/rtbMakeCrytekSponza.m
@@ -47,10 +47,17 @@ hints.recipeName = 'CrytekSponza';
 hints.renderer = 'PBRT';
 hints.batchRenderStrategy = RtbAssimpStrategy(hints);
 
+% camera params we need to share between the remodeler and iset, below
+cameraInfo.filmdiag = 20;
+cameraInfo.filmdistance = 20;
+
 % This function modifies general scene paraemters
 hints.batchRenderStrategy.remodelPerConditionAfterFunction = @rtbCrytekMexximpRemodeler;
+
 % This function modifies PBRT specific parameters
-hints.batchRenderStrategy.converter.remodelAfterMappingsFunction = @rtbCrytekPBRTRemodeler;
+%   append the cameraInfo to the expected RTB parameters
+pbrtRemodelerFunction = @(varargin) rtbCrytekPBRTRemodeler(varargin{:}, cameraInfo);
+hints.batchRenderStrategy.converter.remodelAfterMappingsFunction = pbrtRemodelerFunction;
 
 % Change the docker container to our version of PBRT-spectral
 hints.batchRenderStrategy.renderer.pbrt.dockerImage = 'vistalab/pbrt-v2-spectral';
@@ -145,12 +152,8 @@ radianceDataFiles = rtbBatchRender(nativeSceneFiles, ...
 
 %% View as an OI
 
-% TODO: Ideally, we want to use BuildOI here. Unfortunately, we don't have
-% the "oiParameters" structure anymore. In RTB4, this structure held
-% information about the film distance, diagonal, etc. We could then use
-% this information to fill in parameter info in the OI, such as the
-% F-number or the FOV. Now all that info is held in the remodeler. How
-% should we move that info out from the remodeler into the oi?
+% TODO: use cameraInfo struct to build correct optics for optical image,
+% below.
 
 renderingsFolder = rtbWorkingFolder( ...
     'folderName', 'renderings',...
-- 
GitLab