Commit 55282449 authored by Michael Fogleman's avatar Michael Fogleman

Add TestOSPRayRendererType; add 't' command for OSPRay tests

parent 36878f3d
Pipeline #25098 passed with stage
......@@ -11,6 +11,7 @@ vtk_add_test_cxx(${vtk-module}CxxTests tests
TestOSPRayOrthographic.cxx,
TestOSPRayPass.cxx,
TestOSPRayRenderMesh.cxx,
TestOSPRayRendererType.cxx,
TestOSPRayScalarBar.cxx
TestOSPRayTime.cxx,
TestOSPRayWindow.cxx
......
/*=========================================================================
Program: Visualization Toolkit
Module: TestOSPRayRendererType.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// This test verifies that we can switch between scivis and pathtracer modes
//
// The command line arguments are:
// -I => run in interactive mode; unless this is used, the program will
// not allow interaction and exit
// In interactive mode it responds to the keys listed
// vtkOSPRayTestInteractor.h
#include "vtkTestUtilities.h"
#include "vtkActor.h"
#include "vtkCamera.h"
#include "vtkOpenGLRenderer.h"
#include "vtkOSPRayPass.h"
#include "vtkOSPRayRendererNode.h"
#include "vtkPolyDataMapper.h"
#include "vtkPolyDataNormals.h"
#include "vtkPLYReader.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkSmartPointer.h"
#include "vtkOSPRayTestInteractor.h"
int TestOSPRayRendererType(int argc, char* argv[])
{
vtkSmartPointer<vtkRenderWindowInteractor> iren = vtkSmartPointer<vtkRenderWindowInteractor>::New();
vtkSmartPointer<vtkRenderWindow> renWin = vtkSmartPointer<vtkRenderWindow>::New();
iren->SetRenderWindow(renWin);
vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
renWin->AddRenderer(renderer);
const char* fileName =
vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/bunny.ply");
vtkSmartPointer<vtkPLYReader> polysource = vtkSmartPointer<vtkPLYReader>::New();
polysource->SetFileName(fileName);
//TODO: ospray acts strangely without these such that Diff and Spec are not 0..255 instead of 0..1
vtkSmartPointer<vtkPolyDataNormals> normals = vtkSmartPointer<vtkPolyDataNormals>::New();
normals->SetInputConnection(polysource->GetOutputPort());
//normals->ComputePointNormalsOn();
//normals->ComputeCellNormalsOff();
vtkSmartPointer<vtkPolyDataMapper> mapper=vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(normals->GetOutputPort());
vtkSmartPointer<vtkActor> actor=vtkSmartPointer<vtkActor>::New();
renderer->AddActor(actor);
actor->SetMapper(mapper);
renderer->SetBackground(0.1,0.1,1.0);
renWin->SetSize(400,400);
renWin->Render();
vtkSmartPointer<vtkOSPRayPass> ospray=vtkSmartPointer<vtkOSPRayPass>::New();
vtkOSPRayRendererNode *ren = ospray->GetSceneGraph();
renderer->SetPass(ospray);
for (int i = 1; i<9; i++)
{
if (i%2)
{
cerr << "Render via scivis" << endl;
ren->SetRendererType("scivis", renderer);
}
else
{
cerr << "Render via pathtracer" << endl;
ren->SetRendererType("pathtracer", renderer);
}
renWin->Render();
}
vtkSmartPointer<vtkOSPRayTestInteractor> style =
vtkSmartPointer<vtkOSPRayTestInteractor>::New();
style->SetPipelineControlPoints((vtkOpenGLRenderer*)renderer.Get(), ospray, NULL);
iren->SetInteractorStyle(style);
style->SetCurrentRenderer(renderer);
iren->Start();
return 0;
}
......@@ -173,6 +173,20 @@ void vtkOSPRayTestInteractor::OnKeyPress()
this->GLRenderer->GetRenderWindow()->Render();
}
if(key == "t")
{
std::string type = vtkOSPRayRendererNode::GetRendererType(this->GLRenderer);
if (type == std::string("scivis"))
{
vtkOSPRayRendererNode::SetRendererType("pathtracer", this->GLRenderer);
}
else
{
vtkOSPRayRendererNode::SetRendererType("scivis", this->GLRenderer);
}
this->GLRenderer->GetRenderWindow()->Render();
}
if(key == "2")
{
int spp = vtkOSPRayRendererNode::GetSamplesPerPixel(this->GLRenderer);
......
......@@ -23,6 +23,7 @@
// l => turns on each light in the scene in turn
// I/i => increase/decrease the global light intensity scale
// D/d => increase/decrease the number of ambient occlusion samples
// t => change renderer type: scivis, pathtracer
#ifndef vtkOSPRayTestInteractor_h
#define vtkOSPRayTestInteractor_h
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment