[vtkusers] rotating a cube

Mike Jackson imikejackson at gmail.com
Tue Mar 7 08:19:05 EST 2006


If I am understanding you correctly, you have a "model" ( a cube in  
this case ) that you would like to rotate about the models center.  
THis is how I achieve this.

Say I have some PolyData that defines my bounds. To put a "Bounding  
Box" around it I do the following:

//Read is an STLReader;
double   _bounds[6];
double   _center[3];

reader->GetOutput()->GetBounds(_bounds);
reader->GetOutput()->GetCenter(_center);
_center[0] *= -1.0; _center[1] *= -1.0; _center[2]  *= -1.0;
vtkActor *_boundingBoxActor = vtkActor::New();
vtkOutlineSource *outline = vtkOutlineSource::New();
outline->SetBounds(bounds);
outline->Update();

vtkPolyDataMapper *outlineMapper = vtkPolyDataMapper::New();
outlineMapper->SetInput(outline->GetOutput() );
_boundingBoxActor->SetMapper(outlineMapper);

// Here is your Answer......
_boundingBoxActor->SetPosition(_center);
///Then just add the actor to your scene....



On Mar 7, 2006, at 2:10 AM, Jessica Weiner wrote:

> How can I rotate a cube actor around its own axis like a see-saw? I  
> tried
> RotateZ but it changes the center position of the actor as well. I  
> want to
> be able to rotate the cube _without_ changing its center.
>
> Any ideas?
>
> Thanks.
> Jess
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/ 
> Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers

--------
Mike Jackson
imikejackson <at> gmail <dot> com






More information about the vtkusers mailing list