[vtkusers] how to draw more than one object separately?

刘卓 polinzhuo at 163.com
Sat Dec 9 02:18:24 EST 2006


Deal All:

         I want to draw two objects in a window separately. After object A
rendered, and then object B is rendered. Need I have two vtkrenderer
objects? There are two rederer in my Routine, but only one is drawn. How to
resolve it ? My code below:

vtkSphereSource *pSphere;

vtkConeSource *pCone;

         pSphere = vtkSphereSource::New();

         pSphere->SetCenter( 10.0 , 0.0 , 0.0 );

         pSphere->SetRadius( 10.0 );

         pSphere->SetStartTheta( 0.0 );

         pSphere->SetEndTheta( 360.0 );

         pSphere->SetThetaResolution( 30.0 );

         pSphere->SetStartPhi( 0.0 );

         pSphere->SetEndPhi( 90.0 );

         pSphere->SetPhiResolution( 30.0 );

 

         pCone = vtkConeSource::New();

         pCone->SetCenter( -10.0 , 0.0 , 0.0 );

         pCone->SetRadius( 2.0 );

         pCone->SetHeight(10);

 

         vtkPolyDataMapper* mapMest1 = vtkPolyDataMapper::New();

         vtkPolyDataMapper* mapMest2 = vtkPolyDataMapper::New();

         mapMest1->SetInput(pSphere->GetOutput());

         mapMest2->SetInput(pCone->GetOutput());

         meshActor1 = vtkOpenGLActor::New();

         meshActor2 = vtkOpenGLActor::New();

         meshActor1->SetMapper(mapMest1);

         meshActor2->SetMapper(mapMest2);

         meshActor1->GetProperty()->SetColor(1,0,0);

         meshActor2->GetProperty()->SetColor(1,0,0);

         

         ren1= vtkOpenGLRenderer::New();

         ren2= vtkOpenGLRenderer::New();

         ren2->AddActor( meshActor2 );

         ren1->AddActor( meshActor1 );

 

         renWin = vtkWin32OpenGLRenderWindow::New();

         renWin->OpenGLInit();

 

         int wx=150;

         int wy=150;

         renWin->SetSize( wx, wy );

         

         renWin->AddRenderer(ren1);

         renWin->AddRenderer(ren2);

 

        iren = vtkRenderWindowInteractor::New();

         iren->SetRenderWindow(renWin);

         ren1->Render();

         ren2->Render();

         renWin->Render();

         iren->Start();

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20061209/ac996042/attachment.htm>


More information about the vtkusers mailing list