[vtk-developers] OpenVR HTC Vive

Ricardo ricardo_morello at hotmail.com
Thu Jun 22 15:31:05 EDT 2017


Carlos, thanks for the answer!
I also forgot to mention that i reduced the cylinder's radius and height to
0.1, so it should not be inside the cylinder. I adjusted the tracking and
now there are no more blue lines, just the blue circle the HTC compositor
places. However, the cylinder is still not rendering in the scene. Here is
the example with OpenVR classes:

#include "stdafx.h"
#include <vtkCylinderSource.h>
#include <vtkPolyData.h>
#include <vtkSmartPointer.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkOpenVRRenderWindow.h>
#include <vtkOpenVRRenderer.h>
#include <vtkOpenVRRenderWindowInteractor.h>
#include <vtkOpenVRCamera.h>
#include "vtkAutoInit.h" 
VTK_MODULE_INIT(vtkRenderingOpenGL2); 
VTK_MODULE_INIT(vtkInteractionStyle);

int main(int, char *argv[])
{
	// Create a sphere
	vtkSmartPointer<vtkCylinderSource> cylinderSource =
		vtkSmartPointer<vtkCylinderSource>::New();
	cylinderSource->SetCenter(0.0, 0.0, 0.0);
	cylinderSource->SetRadius(0.1);
	cylinderSource->SetHeight(0.1);
	cylinderSource->SetResolution(100);

	// Create a mapper and actor
	vtkSmartPointer<vtkPolyDataMapper> mapper =
		vtkSmartPointer<vtkPolyDataMapper>::New();
	mapper->SetInputConnection(cylinderSource->GetOutputPort());
	vtkSmartPointer<vtkActor> actor =
		vtkSmartPointer<vtkActor>::New();
	actor->SetMapper(mapper);


        vtkSmartPointer< vtkOpenVRCamera > camera = 
                vtkSmartPointer<vtkOpenVRCamera>::New();

	//Create a renderer, render window, and interactor
	vtkSmartPointer<vtkOpenVRRenderer> renderer =
		vtkSmartPointer<vtkOpenVRRenderer>::New();

	renderer->SetActiveCamera(camera);

	vtkSmartPointer<vtkOpenVRRenderWindow> renderWindow =
		vtkSmartPointer<vtkOpenVRRenderWindow>::New();
	renderWindow->AddRenderer(renderer);
	vtkSmartPointer<vtkOpenVRRenderWindowInteractor> renderWindowInteractor =
		vtkSmartPointer<vtkOpenVRRenderWindowInteractor>::New();
	renderWindowInteractor->SetRenderWindow(renderWindow);

	// Add the actor to the scene
	renderer->AddActor(actor);
	renderer->SetBackground(.1, .3, .2); // Background color dark green

										 // Render and interact
	renderWindow->SetWindowName(argv[0]);
	renderWindow->Render();
	renderWindowInteractor->Start();

	return EXIT_SUCCESS;
}
The demo room app works normally, so there might be a mistake with the code
or the VS configuration, I'm not sure

Thanks!



--
View this message in context: http://vtk.1045678.n5.nabble.com/OpenVR-HTC-Vive-tp5743731p5743734.html
Sent from the VTK - Dev mailing list archive at Nabble.com.


More information about the vtk-developers mailing list