[vtkusers] vtkCollisionDetectionFilter with 2 vtkActor (line and palne)+translation
Goodwin Lawlor
goodwin.lawlor.lists at gmail.com
Fri Jun 13 13:05:01 EDT 2014
Hi Mark,
You should use a callback to color the plane etc.
Have a look at the example here:
https://github.com/glawlor/vtkbioeng/blob/master/Testing/Cxx/TestCollisionDetection.cxx
Feel feel to ask further if the code isn't clear.
hth
Goodwin
On Fri, Jun 13, 2014 at 3:47 PM, Mark Hervagault <mark.hervagault at gmail.com>
wrote:
> 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.
> _______________________________________________
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140613/98b70b04/attachment.html>
More information about the vtkusers
mailing list