[vtkusers] Transparency

David.Pont at ForestResearch.co.nz David.Pont at ForestResearch.co.nz
Thu Feb 13 15:29:15 EST 2003


Hi Sylvian,
  Do you want to make the sphere transparent, so you will see the
background through it? Take a look at vtkActor->GetProperty()-SetOpacity.
Dave Pont


|--------+--------------------------------->
|        |          BERT Sylvain           |
|        |          <bert at esigetel.fr>     |
|        |          Sent by:               |
|        |          vtkusers-admin at public.k|
|        |          itware.com             |
|        |                                 |
|        |                                 |
|        |          14/02/2003 00:23       |
|        |          Please respond to bert |
|        |                                 |
|--------+--------------------------------->
  >------------------------------------------------------------------------------------------------------------|
  |                                                                                                            |
  |      To:     vtkusers at public.kitware.com                                                                   |
  |      cc:                                                                                                   |
  |      Subject:     [vtkusers] Transparency                                                                  |
  >------------------------------------------------------------------------------------------------------------|




Hi all, i have the following vtk code which is very simple. It's a red
Sphere on a white background.
Does anyone know what can i do to have the background transparent ? (The
transparency works only with W2000 et XP).
It's very important for me.
Thanks a  lot !

Sylvain


#include "vtkSphereSource.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"
#include "vtkRenderWindow.h"
#include "vtkRenderer.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkWin32OpenGLRenderWindow.h"
#include "windows.h"
#include "winuser.h"


void main ()
{

  // create sphere geometry
  vtkSphereSource *sphere = vtkSphereSource::New();
  sphere->SetRadius(1.0);
  sphere->SetThetaResolution(18);
  sphere->SetPhiResolution(18);

  // map to graphics library
  vtkPolyDataMapper *map = vtkPolyDataMapper::New();
  map->SetInput(sphere->GetOutput());

  // actor coordinates geometry, properties, transformation
  vtkActor *aSphere = vtkActor::New();
  aSphere->SetMapper(map);
  aSphere->GetProperty()->SetColor(1,0,0); // sphere color blue

  // a renderer and render window
  vtkRenderer *ren1 = vtkRenderer::New();
  vtkRenderWindow *renWin = vtkRenderWindow::New();
  renWin->AddRenderer(ren1);
  //renWin->SetFullScreen(true);

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

  // add the actor to the scene
  ren1->AddActor(aSphere);
  ren1->SetBackground(1,1,1); // Background color white

  // render an image (lights and cameras are created automatically)
  renWin->Render();

  // begin mouse interaction
  iren->Start();
}



_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at: <
http://public.kitware.com/cgi-bin/vtkfaq>
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers







More information about the vtkusers mailing list