VB: SV: [vtkusers] Transformation of imported objects

johan.winell at dynamics.saab.se johan.winell at dynamics.saab.se
Mon Jul 9 03:06:11 EDT 2001


Hello again users and Prabhu,

In the attached code I get one(1) renderer, but in that renderer I don't
seem to get any actors(0). Nevertheless I import two 3DS-objects which
appear in the window. How can I get hold on the two obvious actors?

Best regards 

/Johan Winell

---CODE------------------------------------------

#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRendererCollection.h"
#include "vtkActorCollection.h"
#include "vtkTransform.h"
#include "vtkSTLReader.h"
#include "vtk3DSImporter.h"
#include "vtkPolyDataMapper.h"
#include "vtkCamera.h"

main ()
{

  int j, i;


  vtkRenderer *aren    = vtkRenderer::New();
  vtkRenderWindow *renWin  = vtkRenderWindow::New();
  renWin->AddRenderer(aren);
  renWin->SetSize(600, 300);
  vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
  iren->SetRenderWindow(renWin);
  
  vtk3DSImporter *plane = vtk3DSImporter::New();
  plane->ComputeNormalsOn();
  plane->SetFileName("f14.3ds");
  plane->SetRenderWindow(renWin);

  vtk3DSImporter *ship = vtk3DSImporter::New();
  ship->ComputeNormalsOn();
  //is an aircraft actually
  ship->SetFileName("p38.3ds");
  ship->SetRenderWindow(renWin);

  vtkTransform *shiptrans = vtkTransform::New();
  shiptrans->Translate(0,0,6);
 

  vtkRendererCollection *rencol;
  
  rencol = renWin->GetRenderers();
  rencol->InitTraversal();
  j = rencol->GetNumberOfItems();
  aren = rencol->GetNextItem();
  
  vtkActorCollection *actcol;

  actcol = aren->GetActors();
  actcol->InitTraversal();

  vtkActor *actor1;

  i = actcol->GetNumberOfItems();
  actor1 = actcol->GetLastActor();

  //ren1->GetActors()->GetNextItem()->SetUserTransform(shiptrans);
  //actor1->SetUserTransform(shiptrans);
  //i = actor1->GetNumberOfParts();

  printf ("%i %i\n",j,i);
  
  // updating input and Start rendering
  
  plane->Update();
  ship->Update();
  renWin->Render();
  iren->Start();

  // Clean up
  aren->Delete();
  renWin->Delete();
  iren->Delete();
  ship->Delete();
  rencol->Delete();
  actcol->Delete();
  actor1->Delete();
}

------------------------------------------------




More information about the vtkusers mailing list