[vtkusers] VTK + OpenHaptics how can I attach OpenHaptics to the main loop
Prashanth Udupa
prashanth.udupa at gmail.com
Fri Nov 25 07:56:24 EST 2011
Suppose that you wanted to render a cube and touch it. Also suppose
that you wanted to show a sphere as cursor. The following code snippet
should give you an idea (I have not tested the code or even written a
complete one. But the following code should give you a rough idea)
// Construct a haptics cursor
vtkSphereSource* sphere = vtkSphereSource::New();
vtkPolyDataMapper* sphereMapper = vtkPolyDataMapper::New();
vtkOpenHapticsCursorActor* cursorActor = vtkOpenHapticsCursorActor::New();
sphereMapper->SetInput(sphere->GetOutput());
cursorActor->SetMapper(sphereMapper);
cursorActor->Scale(0.1, 0.1, 0.1);
// Construct a touchable object
vtkCubeSource* cube = vtkCubeSource::New();
vtkPolyDataMapper* cubeMapper = vtkPolyDataMapper::New();
vtkOpenHapticsActor* cubeActor = vtkOpenHapticsActor::New();
cubeMapper->SetInput(cube->GetOutput());
cubeActor->SetMapper(cubeMapper);
// Construct the rendering part
vtkOpenHapticsRenderer* ren = vtkOpenHapticsRenderer::New();
ren->AddActor(cubeActor);
ren->AddActor(cursorActor);
vtkRenderWindow* renWin = vtkRenderWindow::New();
renWin->AddRenderer(ren);
/ Prashanth
On Fri, Nov 25, 2011 at 4:58 PM, Harchet <padilla1957 at gmail.com> wrote:
> Thanks for the code, I think is very useful but I have alot of doubts in the
> way to use it, do you have any main.cpp or something like were I can see how
> do you call to the functions? Still I will try on my own.
>
> Thanks
>
> --
> View this message in context: http://vtk.1045678.n5.nabble.com/VTK-OpenHaptics-how-can-I-attach-OpenHaptics-to-the-main-loop-tp5013641p5022579.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
--
Thanks and Warm Regards,
Prashanth N Udupa
prashanth.udupa at gmail.com
http://www.prashanthudupa.com
http://www.facebook.com/prashanthudupa
More information about the vtkusers
mailing list