[vtkusers] can vtkCompositeRenderManager handles transparency?

Tracy Hu tracy.hu at yahoo.com
Wed Sep 16 11:30:42 EDT 2009


I read from list that for vtkCompositeRenderManager, transparency can be handled by sorting the composition order, but I still can't find out how to sort the composition order? 

I wrote following code to distribute data, render and composite. transparent part doesn't show up. 

if vtkCompositeRenderManager can't handle transparency, is there a way to composite transparent rendered image from distributed nodes?

Thanks for help

Tracy

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

#include "vtkCompositeRenderManager.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkInteractorStyleTrackballCamera.h"
#include "vtkImageData.h"
#include "vtkSphereSource.h"
#include "vtkProperty.h"
#include "vtkMPIController.h"
#include "vtkDataSetMapper.h"
#include "vtkActor.h"
#include "vtkRenderWindow.h"
#include "vtkRenderer.h"
#include "vtkCamera.h"
#include "vtkDistributedDataFilter.h"
//distribute data into process, composite rendered image.
void process(vtkMultiProcessController* controller, void* vtkNotUsed(arg))
{
  int myId = controller->GetLocalProcessId();

  vtkCompositeRenderManager* manager = vtkCompositeRenderManager::New();

  vtkRenderer *ren = manager->MakeRenderer();
    ren->SetBackground(1.0, 1.0, 1.0);

  vtkRenderWindow* renWin = manager->MakeRenderWindow();
    renWin->AddRenderer(ren);
    renWin->SetSize(400, 300);
    if(myId == 0)
        renWin->SetPosition(400, 500);

  manager->SetRenderWindow(renWin);
  manager->SetController(controller);

  vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();
  iren->SetRenderWindow(renWin);

  vtkInteractorStyleTrackballCamera *style = vtkInteractorStyleTrackballCamera::New();
  iren->SetInteractorStyle(style);

  vtkSphereSource *sphere = vtkSphereSource::New();
  vtkDistributedDataFilter *dist = vtkDistributedDataFilter::New();
     dist->SetController(controller);
     dist->SetInputConnection(sphere->GetOutputPort());
  vtkDataSetMapper *sphereMapper = vtkDataSetMapper::New();
     sphereMapper->SetInputConnection(dist->GetOutputPort());
  vtkActor *sphereActor = vtkActor::New();
    sphereActor->SetMapper(sphereMapper);

  ren->AddActor(sphereActor);

  if(myId == 0)
  {
    sphereActor->GetProperty()->SetColor(1.0, 0.0, 1.0);
    sphereActor->GetProperty()->SetOpacity(0.5);
  }
  else
    sphereActor->GetProperty()->SetColor(0.0, 0.0, 1.0);
    
 if(myId==0)
 {
     renWin->Render();
     ren->ResetCamera();
     manager->StartInteractor();
     manager->StopServices();
 }
 else
 {
     manager->StartServices();
 }

  sphere->Delete();
  dist->Delete();
  sphereMapper->Delete();
  sphereActor->Delete();
  iren->Delete();
  style->Delete();
  renWin->Delete();
  manager->Delete();
}


int main( int argc, char* argv[] )
{
  
  vtkMPIController* controller = vtkMPIController::New();
  controller->Initialize(&argc, &argv);

  if (controller->IsA("vtkThreadedController"))
    {
    controller->SetNumberOfProcesses(2);
    } 
 
  int numProcs = controller->GetNumberOfProcesses();
 
  if (numProcs != 2)
    {
        cerr << "This example requires two processes." << endl;
    controller->Finalize();
    controller->Delete();
    return 1;
    }

  controller->SetSingleMethod(process, 0);
  controller->SingleMethodExecute();
  
  controller->Finalize();
  controller->Delete();
  
  return 0;
}




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


More information about the vtkusers mailing list