[vtkusers] help needed on translation

David Cole david.cole at kitware.com
Mon Apr 18 09:14:11 EDT 2005


You're only using one actor and rendering it six times with six 
different rotations. If you want six cones in your scene simultaneously, 
use six actors and just call render once at the end of the loop.

HTH,
David

Yaqian Fang wrote:

> Hi,
>
> I'm trying to create 6 cones each of which rotates 60 degrees.  The 
> result was they just flashed, then the first 5 were gone leaving the 
> last one in the scene.  Could anyone please help me have a look at the 
> following code and tell me where went wrong?
>
> Thank you.
>
> vtkActor *coneActor;
>
> vtkRenderer *ren1;
>
> vtkRenderWindow *renWin;
>
> vtkConeSource *cone;
>
> vtkRenderWindowInteractor* iren;
>
> void rotate ()
>
> {
>
>         coneActor-> SetOrientation(0, 0, 0);
>
>         ren1->ResetCameraClippingRange();
>
>         renWin->Render();
>
>         renWin->Render();
>
>         renWin-> EraseOff();
>
>         coneActor-> SetOrigin(6.11414, 1.27386, .015175);
>
>         coneActor-> SetOrigin(0, 0, 0);
>
>         coneActor-> SetPosition(0, 0, 0);
>
>         vtkTransform *cowTransform = vtkTransform::New();
>
>         cowTransform->Identity();
>
>         coneActor-> SetUserMatrix(cowTransform-> GetMatrix());
>
>         for (int idx=1; idx<=6; idx++)  {
>
>                 coneActor->RotateWXYZ(60,2.19574,-1.42455,-.0331036);
>
>                 coneActor->RotateY(60);
>
>                 renWin->Render();
>
>                 renWin->Render();
>
>         }
>
>         renWin-> EraseOn();
>
> }
>
> void main( int argc, char *argv[] )
>
> {
>
>         ren1 = vtkRenderer::New();
>
>         iren = vtkRenderWindowInteractor::New();
>
>         renWin = vtkRenderWindow::New();
>
>         cone = vtkConeSource::New();
>
>         coneActor = vtkActor::New();
>
>         renWin->AddRenderer(ren1);
>
>         iren->SetRenderWindow(renWin);
>
>         cone->SetResolution(3);
>
>         cone->SetHeight(1);
>
>         cone->SetRadius(0.25);
>
>         vtkPolyDataMapper *coneMapper = vtkPolyDataMapper::New();
>
>       coneMapper->SetInput(cone->GetOutput());
>
>       coneMapper->ScalarVisibilityOff();
>
>         coneActor->SetMapper(coneMapper);
>
>         ren1->AddActor(coneActor);
>
>         ren1->SetBackground( 0.1, 0.2, 0.4 );
>
>         renWin->SetSize(800,800);
>
>         renWin->Render();
>
>         renWin-> EraseOff();
>
>         rotate(); /*rotate*/
>
>         iren->Start();
>
>         cone->Delete();
>
>         coneMapper->Delete();
>
>         coneActor->Delete();
>
>         ren1->Delete();
>
>         renWin->Delete();
>
>         iren->Delete();
>
> }
>
>
> Regards,
>
> Yaqian
>
>------------------------------------------------------------------------
>
>_______________________________________________
>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
>  
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20050418/7e7563eb/attachment.htm>


More information about the vtkusers mailing list