[vtkusers] vtkCollisionDetectionFilter with 2 vtkActor (line and palne)+translation
Mark Hervagault
mark.hervagault at gmail.com
Fri Jun 13 10:47:42 EDT 2014
Hi guys,
At the first. I would like to detect if a line collides with a actor (I took
plane some example).
I have the plane and the line. To see if the collision is detected, I would
like to change the color of my plane.
After, I would like translate the plane on this line...
How to detect a collision?
*My main:*
vtkPlaneSource planSource = new vtkPlaneSource();
planSource.SetCenter(0.0, 0.0, 0.0);
planSource.SetNormal(0.0, 0.0, 0.0);
planSource.Update();
vtkPolyData plan = planSource.GetOutput();
vtkPolyDataMapper mapper = new vtkPolyDataMapper();
mapper.ScalarVisibilityOn();
mapper.SetInputData(plan);
vtkActor actor = new vtkActor();
actor.SetMapper(mapper);
double origin[] = new double[3];
origin[0]=0.0;
origin[1]=0.0;
origin[2]=-3.0;
double p0[] = new double[3];
p0[0]=0.0;
p0[1]=0.0;
p0[2]=3.0;
vtkPoints pts= new vtkPoints();
pts.InsertNextPoint(origin);
pts.InsertNextPoint(p0);
vtkLine ligne = new vtkLine();
ligne.GetPointIds().SetId(0, 0);
ligne.GetPointIds().SetId(1, 1);
vtkCellArray lines = new vtkCellArray();
lines.InsertNextCell(ligne);
vtkPolyData line = new vtkPolyData();
line.SetPoints(pts);
line.SetLines(lines);
vtkPolyDataMapper mapper2 = new vtkPolyDataMapper();
mapper2.SetInputData(line);
vtkActor actorLigne = new vtkActor();
actorLigne.SetMapper(mapper2);
vtkRenderer renderer = new vtkRenderer();
vtkRenderWindow renWin = new vtkRenderWindow();
renWin.AddRenderer(renderer);
vtkRenderWindowInteractor renWinInt = new
vtkRenderWindowInteractor();
renWinInt.SetRenderWindow(renWin);
renderer.AddActor(actor);
renderer.AddActor(actorLigne);
renderer.SetBackground(.1,.2,.3);
renWin.Render();
renWin.Start();
renWinInt.Start();
--
View this message in context: http://vtk.1045678.n5.nabble.com/vtkCollisionDetectionFilter-with-2-vtkActor-line-and-palne-translation-tp5727475.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list