<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>Sorry to bump my own thread but I still can't get this to work.
For 2 identical cameras in terms of position and projection
transform, after adjusting the lights (or not) I get 2 different
renderings. <br>
</p>
<p>The only difference is I apply worldToCamera transform by setting
camera1->SetModelTransformMatrix(worldToCamera); whereas for
camera2 I transform the vtkVolume. In my understanding these
should be identical in terms of positioning something in camera
coordinate system. But the rendering is different (sample
attached as volume_vtk_7.0.0.jpg).<br>
</p>
<p>Weirdly enough if I render a cube instead of the volume, it works
with VTK 7.0.0 (attached actor_vtk_7.0.0.jpg). Same transform,
both cameras work. However, then same code rendering the cube
doesn't work with 6.3.0 (attached actor_vtk_6.3.0.jpg). Not that
I need to use 6.3.0. But I'm just at my wits end on what to try.<br>
</p>
<p>Can someone please have a look at my code and tell me how to get
camera1 to render properly? Thank you</p>
<p><br>
#include <vtkActor.h><br>
#include <vtkSmartPointer.h><br>
#include <vtkCubeSource.h><br>
#include <vtkPolyDataMapper.h><br>
#include <vtkRenderWindow.h><br>
#include <vtkRenderer.h><br>
#include <vtkRenderWindowInteractor.h><br>
#include <vtkCamera.h><br>
#include <vtkSphere.h><br>
#include <vtkSampleFunction.h><br>
#include <vtkImageShiftScale.h><br>
#include <vtkImageData.h><br>
#include <vtkPointData.h><br>
#include <vtkSmartVolumeMapper.h><br>
#include <vtkPiecewiseFunction.h><br>
#include <vtkVolumeProperty.h><br>
#include <vtkColorTransferFunction.h><br>
#include <vtkCommand.h><br>
#include <vtkMatrix4x4.h><br>
#include <vtkLightCollection.h><br>
#include <vtkLight.h><br>
#include <vtkTransform.h><br>
#include <iostream><br>
<br>
const double objectToWorld[16] = {<br>
0.976, 0, 0, -249.511,<br>
0, -0.976, 0, 249.224,<br>
0, 0, -2, -1251.5,<br>
0, 0, 0, 1 };<br>
<br>
const double worldToCamera[16] = {<br>
-0.965924, 0.00168586, 0.258819, 372.757,<br>
0.258819, -0.000451724, 0.965926, 1382.12,<br>
0.00174533, 0.999998, 0, 16.3087,<br>
0, 0, 0, 1};<br>
<br>
vtkSmartPointer<vtkActor> generateRectangle()<br>
{<br>
vtkSmartPointer<vtkCubeSource> cubeSource =
vtkSmartPointer<vtkCubeSource>::New();<br>
<br>
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();<br>
mapper->SetInputConnection(cubeSource->GetOutputPort());<br>
<br>
vtkSmartPointer<vtkActor> actor =
vtkSmartPointer<vtkActor>::New();<br>
actor->SetMapper(mapper);<br>
actor->SetScale(512, 512, 160);<br>
actor->SetPosition(256, 256, 80);<br>
vtkSmartPointer<vtkTransform> userTransform =
vtkSmartPointer<vtkTransform>::New();<br>
userTransform->SetMatrix(objectToWorld);<br>
actor->SetUserTransform(userTransform);<br>
return actor;<br>
}<br>
<br>
vtkSmartPointer<vtkVolume> generateVolume()<br>
{<br>
// Create a spherical implicit function.<br>
vtkSmartPointer<vtkSphere> sphere =
vtkSmartPointer<vtkSphere>::New();<br>
sphere->SetRadius(1);<br>
sphere->SetCenter(0.0, 0.0, 0.0);<br>
<br>
vtkSmartPointer<vtkSampleFunction> sampleFunction =
vtkSmartPointer<vtkSampleFunction>::New();<br>
sampleFunction->SetImplicitFunction(sphere);<br>
sampleFunction->SetOutputScalarTypeToFloat();<br>
sampleFunction->SetSampleDimensions(64, 64, 20);<br>
sampleFunction->SetModelBounds(-1.0, 1.0, -1.0, 1.0, -1.0,
1.0);<br>
sampleFunction->SetCapping(false);<br>
sampleFunction->SetComputeNormals(false);<br>
sampleFunction->SetScalarArrayName("values");<br>
sampleFunction->Update();<br>
<br>
vtkDataArray* a =
sampleFunction->GetOutput()->GetPointData()->GetScalars("values");<br>
double range[2];<br>
a->GetRange(range);<br>
<br>
vtkSmartPointer<vtkImageShiftScale> t =
vtkSmartPointer<vtkImageShiftScale>::New();<br>
t->SetInputConnection(sampleFunction->GetOutputPort());<br>
<br>
t->SetShift(-range[0]);<br>
double magnitude = range[1] - range[0];<br>
if (magnitude == 0.0)<br>
{<br>
magnitude = 1.0;<br>
}<br>
t->SetScale(255.0 / magnitude);<br>
t->SetOutputScalarTypeToUnsignedChar();<br>
t->Update();<br>
<br>
vtkSmartPointer<vtkImageData> imageData =
vtkSmartPointer<vtkImageData>::New();<br>
imageData->ShallowCopy(t->GetOutput());<br>
<br>
vtkSmartPointer<vtkSmartVolumeMapper> volumeMapper =
vtkSmartPointer<vtkSmartVolumeMapper>::New();<br>
volumeMapper->SetBlendModeToComposite(); // composite first<br>
volumeMapper->SetInputData(imageData);<br>
<br>
vtkSmartPointer<vtkVolumeProperty> volumeProperty =
vtkSmartPointer<vtkVolumeProperty>::New();<br>
volumeProperty->ShadeOff();<br>
volumeProperty->SetInterpolationType(VTK_LINEAR_INTERPOLATION);<br>
<br>
vtkSmartPointer<vtkPiecewiseFunction> compositeOpacity =
vtkSmartPointer<vtkPiecewiseFunction>::New();<br>
compositeOpacity->AddPoint(0.0, 0.0);<br>
compositeOpacity->AddPoint(80.0, 1.0);<br>
compositeOpacity->AddPoint(80.1, 0.0);<br>
compositeOpacity->AddPoint(255.0, 0.0);<br>
volumeProperty->SetScalarOpacity(compositeOpacity); //
composite first.<br>
<br>
vtkSmartPointer<vtkColorTransferFunction> color =
vtkSmartPointer<vtkColorTransferFunction>::New();<br>
color->AddRGBPoint(0.0, 0.0, 0.0, 1.0);<br>
color->AddRGBPoint(40.0, 1.0, 0.0, 0.0);<br>
color->AddRGBPoint(255.0, 1.0, 1.0, 1.0);<br>
volumeProperty->SetColor(color);<br>
<br>
vtkSmartPointer<vtkVolume> volume =
vtkSmartPointer<vtkVolume>::New();<br>
volume->SetMapper(volumeMapper);<br>
volume->SetProperty(volumeProperty);<br>
<br>
volume->SetScale(512, 512, 160);<br>
volume->SetPosition(256, 256, 80);<br>
<br>
vtkSmartPointer<vtkTransform> userTransform =
vtkSmartPointer<vtkTransform>::New();<br>
userTransform->SetMatrix(objectToWorld);<br>
volume->SetUserTransform(userTransform);<br>
return volume;<br>
}<br>
<br>
void assertArrayEquals(const double * a, const double * b, size_t
elements)<br>
{<br>
for (size_t i = 0; i < elements; ++i)<br>
{<br>
assert(a[i] - b[i] <=
std::numeric_limits<double>::epsilon());<br>
}<br>
}<br>
<br>
void assertVtkMatrixEquals(const vtkMatrix4x4 * a, const
vtkMatrix4x4 * b)<br>
{<br>
for (size_t i = 0; i < 4; ++i)<br>
{<br>
for (size_t j = 0; j < 4; ++j)<br>
{<br>
assert(fabs(a->GetElement(i, j) -
b->GetElement(i, j)) <
std::numeric_limits<double>::epsilon());<br>
}<br>
}<br>
}<br>
<br>
int main()<br>
{<br>
// camera1<br>
vtkSmartPointer<vtkCamera> camera1 =
vtkSmartPointer<vtkCamera>::New();<br>
camera1->SetPosition(0, 0, 1000);<br>
camera1->SetFocalPoint(0, 0, 0);<br>
camera1->SetViewUp(0, 1, 0);<br>
camera1->SetClippingRange(0.1, 5000);<br>
camera1->SetViewAngle(60);<br>
camera1->SetModelTransformMatrix(worldToCamera);<br>
<br>
//camera 2<br>
vtkSmartPointer<vtkCamera> camera2 =
vtkSmartPointer<vtkCamera>::New();<br>
camera2->SetPosition(0, 0, 1000);<br>
camera2->SetFocalPoint(0, 0, 0);<br>
camera2->SetViewUp(0, 1, 0);<br>
camera2->SetClippingRange(0.1, 5000);<br>
camera2->SetViewAngle(60);<br>
<br>
// renderer1 using camera1<br>
vtkSmartPointer<vtkRenderer> renderer1 =
vtkSmartPointer<vtkRenderer>::New();<br>
renderer1->SetViewport(0, 0, 0.5, 1);<br>
renderer1->SetActiveCamera(camera1); <br>
//renderer1->AddVolume(generateVolume());<br>
renderer1->AddActor(generateRectangle());<br>
<br>
// renderer2 using camera2<br>
vtkSmartPointer<vtkRenderer> renderer2 =
vtkSmartPointer<vtkRenderer>::New();<br>
renderer2->SetViewport(0.5, 0, 1, 1);<br>
vtkSmartPointer<vtkVolume> volume2 = generateVolume();<br>
vtkSmartPointer<vtkActor> rectangle2 =
generateRectangle();<br>
vtkSmartPointer<vtkTransform> objectToCameraTransform =
vtkSmartPointer<vtkTransform>::New();<br>
// Generate transform (worldToCamera * objectToWorld) and
apply it to the model<br>
objectToCameraTransform->SetMatrix(objectToWorld);<br>
objectToCameraTransform->PostMultiply();<br>
objectToCameraTransform->Concatenate(worldToCamera);<br>
objectToCameraTransform->Update();<br>
volume2->SetUserTransform(objectToCameraTransform);<br>
rectangle2->SetUserTransform(objectToCameraTransform);<br>
renderer2->SetActiveCamera(camera2);<br>
//renderer2->AddVolume(volume2);<br>
renderer2->AddActor(rectangle2);<br>
<br>
// window and interactor<br>
vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();<br>
renderWindow->SetSize(1024, 512);<br>
renderWindow->AddRenderer(renderer1);<br>
renderWindow->AddRenderer(renderer2);<br>
vtkSmartPointer<vtkRenderWindowInteractor>
renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();<br>
renderWindowInteractor->SetRenderWindow(renderWindow);<br>
<br>
// Attempt to Adjust lights<br>
renderWindow->Render();<br>
vtkLight * modifiedLight = dynamic_cast<vtkLight
*>(renderer1->GetLights()->GetItemAsObject(0));<br>
modifiedLight->SetLightTypeToHeadlight();<br>
modifiedLight->SetPosition(camera1->GetPosition());<br>
modifiedLight->SetFocalPoint(camera1->GetFocalPoint());<br>
// Above Doesn't work, Ok let's try this as well<br>
renderer1->UpdateLightsGeometryToFollowCamera();<br>
<br>
// Sanity check<br>
assertArrayEquals(camera1->GetPosition(),
camera2->GetPosition(), 3);<br>
assertArrayEquals(camera1->GetFocalPoint(),
camera2->GetFocalPoint(), 3);<br>
assertVtkMatrixEquals(camera1->GetProjectionTransformMatrix(renderer1),
camera2->GetProjectionTransformMatrix(renderer2));<br>
vtkSmartPointer<vtkLightCollection> lightCollection1 =
renderer1->GetLights();<br>
vtkSmartPointer<vtkLightCollection> lightCollection2 =
renderer2->GetLights();<br>
assert(lightCollection1->GetNumberOfItems() ==
lightCollection2->GetNumberOfItems());<br>
lightCollection1->InitTraversal();<br>
lightCollection2->InitTraversal();<br>
vtkSmartPointer<vtkLight> light1 =
lightCollection1->GetNextItem();<br>
vtkSmartPointer<vtkLight> light2 =
lightCollection2->GetNextItem();<br>
assertArrayEquals(light1->GetPosition(),
light2->GetPosition(), 3);<br>
assertArrayEquals(light1->GetTransformedPosition(),
light2->GetTransformedPosition(), 3);<br>
assertArrayEquals(light1->GetFocalPoint(),
light2->GetFocalPoint(), 3);<br>
assertArrayEquals(light1->GetTransformedFocalPoint(),
light1->GetTransformedFocalPoint(), 3);<br>
assertArrayEquals(light1->GetAmbientColor(),
light2->GetAmbientColor(), 3);<br>
assertArrayEquals(light1->GetSpecularColor(),
light2->GetSpecularColor(), 3);<br>
assertArrayEquals(light1->GetDiffuseColor(),
light2->GetDiffuseColor(), 3);<br>
<br>
renderWindow->Render();<br>
renderWindowInteractor->Start();<br>
<br>
return EXIT_SUCCESS;<br>
}<br>
</p>
<br>
<div class="moz-cite-prefix">On 08/05/2016 03:10 PM, Bud Bundy
wrote:<br>
</div>
<blockquote
cite="mid:90ec18eb-2f39-ef57-9361-5136b4c2cc8d@gmail.com"
type="cite">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<p>Thanks,</p>
<p>The light positions were indeed different, but making them the
same didn't fix it for me. Perhaps my fix is wrong?</p>
<p>void assertArrayEquals(const double * a, const double * b,
size_t elements)<br>
{<br>
for (size_t i = 0; i < elements; ++i)<br>
{<br>
assert(a[i] - b[i] <=
std::numeric_limits<double>::epsilon());<br>
}<br>
}<br>
</p>
<p> //previous int main() code ...<br>
</p>
<p> //setting lights before first call to Render() crashes
program, also describedh <a moz-do-not-send="true"
class="moz-txt-link-freetext"
href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/Lighting/Light">http://www.vtk.org/Wiki/VTK/Examples/Cxx/Lighting/Light</a><br>
</p>
<p> renderWindow->Render(); <br>
<br>
renderer2->RemoveAllLights();<br>
vtkSmartPointer<vtkLight> newLight =
vtkSmartPointer<vtkLight>::New();<br>
newLight->SetPosition(0, 0, 1000);<br>
renderer2->AddLight(newLight);<br>
<br>
//assert lighting is the same<br>
vtkSmartPointer<vtkLightCollection> lightCollection1 =
renderer1->GetLights();<br>
vtkSmartPointer<vtkLightCollection> lightCollection2 =
renderer2->GetLights();<br>
assert(lightCollection1->GetNumberOfItems() ==
lightCollection2->GetNumberOfItems());<br>
lightCollection1->InitTraversal();<br>
lightCollection2->InitTraversal();<br>
vtkSmartPointer<vtkLight> light1 =
lightCollection1->GetNextItem();<br>
vtkSmartPointer<vtkLight> light2 =
lightCollection2->GetNextItem();<br>
assertArrayEquals(light1->GetPosition(),
light2->GetPosition(), 3);<br>
assertArrayEquals(light1->GetTransformedPosition(),
light2->GetTransformedPosition(), 3);<br>
assertArrayEquals(light1->GetFocalPoint(),
light2->GetFocalPoint(), 3);<br>
assertArrayEquals(light1->GetTransformedFocalPoint(),
light1->GetTransformedFocalPoint(), 3);<br>
assertArrayEquals(light1->GetAmbientColor(),
light2->GetAmbientColor(), 3);<br>
assertArrayEquals(light1->GetSpecularColor(),
light2->GetSpecularColor(), 3);<br>
assertArrayEquals(light1->GetDiffuseColor(),
light2->GetDiffuseColor(), 3);<br>
<br>
renderWindow->Render();<br>
<br>
renderWindowInteractor->Start();</p>
<p><br>
</p>
<div class="moz-cite-prefix">On 08/05/16 14:10, David E DeMarle
wrote:<br>
</div>
<blockquote
cite="mid:CANjZAi-YCfuwQTo-w0XKMXrZP4Ox=DTS+xShOOcqu37Y+hxAEg@mail.gmail.com"
type="cite">
<p dir="ltr">I was just doing a very similar thing and noticed
that light positions are only updated with the set origin,
focal point and up. I ended up computing those for my intended
matrix and lighting then worked as expected. </p>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Aug 5, 2016 1:12 PM, "Bud Bundy"
<<a moz-do-not-send="true" href="mailto:budric@gmail.com">budric@gmail.com</a>>
wrote:<br type="attribution">
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I need to setup the camera to an arbitrary modelview
matrix I have in memory. I managed to get some code
working such that GetModelViewTransformMatrix() returns
the modelview I have/want. However the volume rendering is
sometimes blank, and I don't understand why because the
volume is in front of the camera. I managed to boil down
the problem to the following code below. camera1 and
camera2 have the same modelview transform, however the
rendering look very different (I've attached a screen
shot) - though not blank it's a lot dimmer.<br>
<br>
The code is loosely based on: <a moz-do-not-send="true"
href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/VolumeRendering/SmartVolumeMapper"
rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK/Ex<wbr>amples/Cxx/VolumeRendering/Sma<wbr>rtVolumeMapper</a><br>
<br>
I'm using VTK 7.0<br>
<br>
#include <vtkActor.h><br>
#include <vtkSmartPointer.h><br>
#include <vtkCubeSource.h><br>
#include <vtkPolyDataMapper.h><br>
#include <vtkRenderWindow.h><br>
#include <vtkRenderer.h><br>
#include <vtkRenderWindowInteractor.h><br>
#include <vtkCamera.h><br>
#include <vtkSphere.h><br>
#include <vtkSampleFunction.h><br>
#include <vtkImageShiftScale.h><br>
#include <vtkImageData.h><br>
#include <vtkPointData.h><br>
#include <vtkSmartVolumeMapper.h><br>
#include <vtkPiecewiseFunction.h><br>
#include <vtkVolumeProperty.h><br>
#include <vtkColorTransferFunction.h><br>
#include <vtkCommand.h><br>
#include <vtkMatrix4x4.h><br>
<br>
vtkSmartPointer<vtkVolume> generateVolume()<br>
{<br>
// Create a spherical implicit function.<br>
vtkSmartPointer<vtkSphere> sphere =
vtkSmartPointer<vtkSphere>::Ne<wbr>w();<br>
sphere->SetRadius(0.1);<br>
sphere->SetCenter(0.0, 0.0, 0.0);<br>
<br>
vtkSmartPointer<vtkSampleFunct<wbr>ion>
sampleFunction = vtkSmartPointer<vtkSampleFunct<wbr>ion>::New();<br>
sampleFunction->SetImplicitFun<wbr>ction(sphere);<br>
sampleFunction->SetOutputScala<wbr>rTypeToFloat();<br>
sampleFunction->SetSampleDimen<wbr>sions(64, 64,
20);<br>
sampleFunction->SetModelBounds<wbr>(-1.0, 1.0,
-1.0, 1.0, -1.0, 1.0);<br>
sampleFunction->SetCapping(fal<wbr>se);<br>
sampleFunction->SetComputeNorm<wbr>als(false);<br>
sampleFunction->SetScalarArray<wbr>Name("values");<br>
sampleFunction->Update();<br>
<br>
vtkDataArray* a = sampleFunction->GetOutput()->G<wbr>etPointData()->GetScalars("val<wbr>ues");<br>
double range[2];<br>
a->GetRange(range);<br>
<br>
vtkSmartPointer<vtkImageShiftS<wbr>cale> t =
vtkSmartPointer<vtkImageShiftS<wbr>cale>::New();<br>
t->SetInputConnection(sampleFu<wbr>nction->GetOutputPort());<br>
<br>
t->SetShift(-range[0]);<br>
double magnitude = range[1] - range[0];<br>
if (magnitude == 0.0)<br>
{<br>
magnitude = 1.0;<br>
}<br>
t->SetScale(255.0 / magnitude);<br>
t->SetOutputScalarTypeToUnsign<wbr>edChar();<br>
t->Update();<br>
<br>
vtkSmartPointer<vtkImageData> imageData =
vtkSmartPointer<vtkImageData>:<wbr>:New();<br>
imageData->ShallowCopy(t->GetO<wbr>utput());<br>
<br>
vtkSmartPointer<vtkSmartVolume<wbr>Mapper>
volumeMapper = vtkSmartPointer<vtkSmartVolume<wbr>Mapper>::New();<br>
volumeMapper->SetBlendModeToCo<wbr>mposite(); //
composite first<br>
volumeMapper->SetInputData(ima<wbr>geData);<br>
<br>
vtkSmartPointer<vtkVolumePrope<wbr>rty>
volumeProperty = vtkSmartPointer<vtkVolumePrope<wbr>rty>::New();<br>
volumeProperty->ShadeOff();<br>
volumeProperty->SetInterpolati<wbr>onType(VTK_LINEAR_<wbr>INTERPOLATION);<br>
<br>
vtkSmartPointer<vtkPiecewiseFu<wbr>nction>
compositeOpacity = vtkSmartPointer<vtkPiecewiseFu<wbr>nction>::New();<br>
compositeOpacity->AddPoint(0.0<wbr>, 0.0);<br>
compositeOpacity->AddPoint(80.<wbr>0, 1.0);<br>
compositeOpacity->AddPoint(80.<wbr>1, 0.0);<br>
compositeOpacity->AddPoint(255<wbr>.0, 0.0);<br>
volumeProperty->SetScalarOpaci<wbr>ty(compositeOpacity);
// composite first.<br>
<br>
vtkSmartPointer<vtkColorTransf<wbr>erFunction>
color = vtkSmartPointer<vtkColorTransf<wbr>erFunction>::New();<br>
color->AddRGBPoint(0.0, 0.0, 0.0, 1.0);<br>
color->AddRGBPoint(40.0, 1.0, 0.0, 0.0);<br>
color->AddRGBPoint(255.0, 1.0, 1.0, 1.0);<br>
volumeProperty->SetColor(color<wbr>);<br>
<br>
vtkSmartPointer<vtkVolume> volume =
vtkSmartPointer<vtkVolume>::Ne<wbr>w();<br>
volume->SetMapper(volumeMapper<wbr>);<br>
volume->SetProperty(volumeProp<wbr>erty);<br>
<br>
vtkSmartPointer<vtkMatrix4x4>
volumeScaleTransform =
vtkSmartPointer<vtkMatrix4x4>:<wbr>:New();<br>
volumeScaleTransform->Identity<wbr>();<br>
volumeScaleTransform->SetEleme<wbr>nt(0, 0, 512);<br>
volumeScaleTransform->SetEleme<wbr>nt(1, 1, 512);<br>
volumeScaleTransform->SetEleme<wbr>nt(2, 2, 160);<br>
volume->SetUserMatrix(volumeSc<wbr>aleTransform);<br>
return volume;<br>
}<br>
<br>
int main()<br>
{<br>
// camera1<br>
vtkSmartPointer<vtkCamera> camera1 =
vtkSmartPointer<vtkCamera>::Ne<wbr>w();<br>
camera1->SetPosition(0, 0, 1000);<br>
camera1->SetFocalPoint(0, 0, 0);<br>
camera1->SetClippingRange(0.1, 5000);<br>
camera1->SetViewAngle(60);<br>
<br>
//camera 2<br>
vtkSmartPointer<vtkCamera> camera2 =
vtkSmartPointer<vtkCamera>::Ne<wbr>w();<br>
camera2->SetPosition(0, 0, 0); //I do
not want any additional translation that comes with
default (0,0,1) setting.<br>
camera2->SetFocalPoint(0, 0, -1); //setting
this to (0,0,0) causes whole modelview matrix to be 0,
regardless of what SetModelTransformMatrix() sets<br>
camera2->SetViewAngle(60);<br>
camera2->SetClippingRange(0.1, 5000);<br>
double modelViewTransform[16] = { 1, 0, 0, 0,<br>
0, 1, 0, 0,<br>
0, 0, 1, -1000,<br>
0, 0, 0, 1 };<br>
camera2->SetModelTransformMatr<wbr>ix(modelViewTransform);<br>
<br>
// renderer1 using camera1<br>
vtkSmartPointer<vtkRenderer> renderer1 =
vtkSmartPointer<vtkRenderer>::<wbr>New();<br>
renderer1->SetViewport(0, 0, 0.5, 1);<br>
renderer1->AddVolume(generateV<wbr>olume());<br>
renderer1->SetActiveCamera(cam<wbr>era1);<br>
<br>
// renderer2 using camera2<br>
vtkSmartPointer<vtkRenderer> renderer2 =
vtkSmartPointer<vtkRenderer>::<wbr>New();<br>
renderer2->SetViewport(0.5, 0, 1, 1);<br>
renderer2->AddVolume(generateV<wbr>olume());<br>
renderer2->SetActiveCamera(cam<wbr>era2);<br>
<br>
// assert model view matrices are the same<br>
vtkSmartPointer<vtkMatrix4x4>
vtkModelViewMatrix1 = renderer1->GetActiveCamera()-><wbr>GetModelViewTransformMatrix();<br>
vtkSmartPointer<vtkMatrix4x4>
vtkModelViewMatrix2 = renderer2->GetActiveCamera()-><wbr>GetModelViewTransformMatrix();<br>
for (int i = 0; i < 4; ++i)<br>
for (int j = 0; j < 4; ++j)<br>
assert(vtkModelViewMatrix1->Ge<wbr>tElement(i,
j) == vtkModelViewMatrix2->GetElemen<wbr>t(i, j));<br>
<br>
// window and interactor<br>
vtkSmartPointer<vtkRenderWindo<wbr>w>
renderWindow = vtkSmartPointer<vtkRenderWindo<wbr>w>::New();<br>
renderWindow->SetSize(1024, 512);<br>
renderWindow->AddRenderer(rend<wbr>erer1);<br>
renderWindow->AddRenderer(rend<wbr>erer2);<br>
vtkSmartPointer<vtkRenderWindo<wbr>wInteractor>
renderWindowInteractor = vtkSmartPointer<vtkRenderWindo<wbr>wInteractor>::New();<br>
renderWindowInteractor->SetRen<wbr>derWindow(renderWindow);<br>
<br>
renderWindow->Render();<br>
renderWindowInteractor->Start(<wbr>);<br>
<br>
return EXIT_SUCCESS;<br>
}<br>
<br>
<br>
Thank you very much.<br>
<br>
<br>
______________________________<wbr>_________________<br>
Powered by <a moz-do-not-send="true"
href="http://www.kitware.com" rel="noreferrer"
target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a
moz-do-not-send="true"
href="http://www.kitware.com/opensource/opensource.html"
rel="noreferrer" target="_blank">http://www.kitware.com/<wbr>opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a
moz-do-not-send="true"
href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer"
target="_blank">http://www.vtk.org/Wiki/VTK_<wbr>FAQ</a><br>
<br>
Search the list archives at: <a moz-do-not-send="true"
href="http://markmail.org/search/?q=vtkusers"
rel="noreferrer" target="_blank">http://markmail.org/search/?q=<wbr>vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a moz-do-not-send="true"
href="http://public.kitware.com/mailman/listinfo/vtkusers"
rel="noreferrer" target="_blank">http://public.kitware.com/<wbr>mailman/listinfo/vtkusers</a><br>
<br>
</blockquote>
</div>
</div>
</blockquote>
<br>
</blockquote>
<br>
</body>
</html>