[vtkusers] How to Set Rotation Center?
Ted Christiansen
ted at caept.com
Wed Sep 4 14:47:58 EDT 2002
Hello,
How can I set the center of rotation for a collection of actors?
Tried this and it didnt work as expected:
1. Use vtkPointPicker to get the point the user picked
2. Set this to the FocalPoint
It should center the model to this point and then all rotations via the
interactor are about this point. What am I missing?
Ted
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
void CFEvisGLView::SetViewCenter(CPoint point)
{
CRect viewdims;
// need to do a pick instead
// double coords[3];
double focalpoint[3];
DoPointPick(point, focalpoint);
vtkCamera *pCam = Renderer->GetActiveCamera();
// get view dimensions
GetClientRect(&viewdims);
// now we can actually modify the camera
pCam->SetFocalPoint(focalpoint[0], focalpoint[1], focalpoint[2]);
pCam->OrthogonalizeViewUp();
// reset state
m_state = STATE_NONE;
Invalidate(FALSE);
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
void CFEvisGLView::DoPointPick(CPoint point, double *coords)
{
vtkPointPicker *pointpicker;
vtkPoints *pickedpoints;
vtkDataSet *dataset;
vtkActorCollection *actors;
// create new point picker
pointpicker = vtkPointPicker::New();
// do pick operation (z=0)
pointpicker->Pick(point.x, point.y, 0, Renderer);
// get list of actors intersected
actors = pointpicker->GetActors();
// get list of points intersected (in same order as actors)
pickedpoints = pointpicker->GetPickedPositions();
// get id of point that was picked
if (pointpicker->GetPointId() != -1) {
// float fl[3];
pickedpoints->GetPoint(0, coords);
TRACE("%f %f %f\n", coords[0], coords[1], coords[2]);
dataset = pointpicker->GetDataSet();
if (dataset != NULL) {
// loop through actors, and find the matching component
// get value here using point id
}
}
}
More information about the vtkusers
mailing list