[vtkusers] Picking invisible object !

Sebastien Auclair sxa at fluent.com
Mon Jul 21 11:58:42 EDT 2003

This is what we did...

We are not using the interactor features (for different reasons...)
But we used the code in InteractorStyleTrackball for all the camera and
object movements...

The following is part of the code for managing the scaling on X axis of an
hexahedron when draging one of its edge.


void TKWidget3D::ActorEdgeScale(int x, int y, int oldX, int oldY)

double scale[3];
float origin[4];
TKCadObject* obj;
float ObjCenter [3];
double yf;
double scaleFactor, scaleFactor2;

double **rotate;

 if (m_currentRenderer == NULL)

 obj = m_EdgePickedActor;

 rotate = NULL;

// Prop3DTransform(obj,ObjCenter, 0, rotate, scale, false);

 float camPos[4];
 float newPickPt[4];
 float oldPickPt[4];
 float pickPos[4];
 float nrml[4];
 float pickDisp[4];
 float t;
 float IntersPt[4];
 float oldIntersPt[4];

 int FixedAxis = m_EdgePickedActor->GetEdgeResizeFixedAxis();
 if ( FixedAxis == 0){ // A transformation that can only take place on the X

  m_Picker->GetPickPosition (pickPos);

  origin[0] = pickPos[0];
  ComputeWorldToDisplay((pickPos[0]), (pickPos[1]), (pickPos[2] ),
  ComputeDisplayToWorld (double(x) , double(y), (pickDisp[2]), newPickPt);
  ComputeDisplayToWorld (double(oldX), double(oldY),  (pickDisp[2]) ,

  nrml[0] = 1;
  nrml[1] = 0;
  nrml[2] = 0;

  vtkPlane::GeneralizedProjectPoint  (newPickPt,pickPos, nrml, IntersPt);
  vtkPlane::GeneralizedProjectPoint  (oldPickPt,pickPos, nrml, oldIntersPt);


  scale[0] =  1 ;
  scale[1] = IntersPt[1] / oldIntersPt[1];
  scale[2] = IntersPt[2]/ oldIntersPt[2];


Note the usage of the m_testSphere which is suppose to stay behind the mouse
cursor and always move on the vtkPlane.
It stays on the plane but can't go as far as the mouse cursor...

Thanks for any help !

----- Original Message -----
From: "Charl P. Botha" <c.p.botha at ewi.tudelft.nl>
To: "VTK Users List" <vtkusers at vtk.org>
Sent: Monday, July 21, 2003 7:08 AM
Subject: Re: [vtkusers] Picking invisible object !

> On Mon, 2003-07-21 at 13:05, Sebastien Auclair wrote:
> > I need to allow the user to drag a picked object but not in X, Y
> > on the display plane.
> > For instance, he must be able to drag a cube on the World X axis only.
> > To do that, my approach so far is to create an invisible vtkPlane that i
> > to use to compute an intersection point with a ray i create based on
> > DisplayToWorld and the mouse coordinates.
> Why don't you just create a new vtkInteractorStyle class?  For instance,
> you could inherit from the vtkInteractorStyleTrackballActor and simply
> prevent the PAN mode from being entered, or the Pan() method from being
> called.
> This seems far simpler than what you're doing, unless I'm
> misunderstanding something.
> --
> charl p. botha http://cpbotha.net/ http://visualisation.tudelft.nl/
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers

More information about the vtkusers mailing list