[vtkusers] Ask help: About VTK Shade property

Ming George mgeorge72 at yahoo.com
Tue Oct 23 07:50:57 EDT 2001


Hi,
I tried to change shade style in the vtkProperty, 
void SetInterpolationToFlat ()
void SetInterpolationToGouraud ()
void SetInterpolationToPhong ()
     
I can see the effect from the objects like
vtkSphereSource, vtkCubeSource, but I can not see it
from the vtkConeSource. I don't understand why this
happen.   
      
Can any body help me?
      
Thanks
      
      
George
      
      
Following is a piece of code:
// A simple program to test the shade property of the
vtksouce object
// 
      
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkCubeSource.h"
#include "vtkConeSource.h"
#include "vtkSphereSource.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"
      
int main(void) {
// Create the renderwindow, renderer and interactor
vtkRenderer *ren1 = vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin->AddRenderer(ren1);
renWin->SetSize(600, 600);
vtkRenderWindowInteractor *iren =
vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
      
vtkSphereSource *sp[3]; 
vtkConeSource *co[3];
      
vtkPolyDataMapper *Mapper[6]; 
vtkActor          *Actor[6];
vtkProperty *Property[6]; 
      
// Create an object to display
for(int i=0;i<6;i++)
{
   if(i<3){
     sp[i] = vtkSphereSource::New();
     sp[i]->SetRadius(0.5);
     sp[i]->SetPhiResolution(12);
     sp[i]->SetThetaResolution(12);
     sp[i]->SetCenter(0.0, 0.0, 0.0);
     Mapper[i] = vtkPolyDataMapper::New();
     Mapper[i]->SetInput(sp[i]->GetOutput());
    }
    else {
     co[i]= vtkConeSource::New();
     co[i]->SetHeight(1.0);
     co[i]->SetRadius(0.5);
     co[i]->SetResolution(12);
     Mapper[i] = vtkPolyDataMapper::New();
     Mapper[i]->SetInput(co[i]->GetOutput());
    }
      
// Map the polygons to graphics data
      
    Property[i]=vtkProperty::New();
    Property[i]->SetColor(1.0, 0.0, 0.0);
// change the shade style;
    Property[i]->SetInterpolation(i%3);
      
// Create an actor for this graphics object
    Actor[i] = vtkActor::New();
    Actor[i]->SetMapper(Mapper[i]);
    Actor[i]->SetProperty(Property[i]);
    Actor[i]->SetPosition(1.0*(i%3), i/3, 0.0);
      
// Add the actor to the renderer
   ren1->AddActor(Actor[i]);
  }
      
// Set the background colour
//  ren1->SetBackground(0.03, 0.03, 0.09);
      
  renWin->Render();
      
//  Begin mouse interaction
 iren->Start();
      
}




__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com



More information about the vtkusers mailing list