[vtkusers] problem with gouraud shading

Alia aks01 at doc.ic.ac.uk
Mon Sep 16 13:37:29 EDT 2002


hello

I'm trying to gouraud shade a surface, but all I seem to manage is flat
shading.  This was working ok in the tcl code I was using previously,
but I've re-written it in C++ and as far as I can see they're both about
the same, except for the shading problem.

I'd appreciate a pointer if I'm just doing something trivial wrong.
C++ code fragment enclosed.

Many thanks

Alia
//**********************************************************************
  	// create a rendering window, renderer #& interactor
	vtkRenderer *ren = vtkRenderer::New();
	vtkRenderWindow* renWindow = vtkRenderWindow::New();
	renWindow->AddRenderer(ren);
	vtkRenderWindowInteractor *RWInteractor =
      	vtkRenderWindowInteractor::New();
	RWInteractor->SetRenderWindow(renWindow);

	// read in object file for surface
	vtkOBJReader *reader = vtkOBJReader::New();
	reader->SetFileName(myobj.c_str());

	vtkPolyDataNormals* normals1 = vtkPolyDataNormals::New();
	normals1->SetInput(reader->GetOutput());

	//create actor
	vtkActor* faceActor = vtkActor::New();

	faceActor->GetProperty()->SetOpacity(1);
	faceActor->GetProperty()->SetInterpolationToGouraud();
	faceActor->GetProperty()->SetRepresentationToSurface ();
	faceActor->GetProperty()->SetColor (215, 215, 237);

          vtkTransformPolyDataFilter* warp =  vtkTransformPolyDataFilter::New();
	  warp->SetInput(normals1->GetOutput());

   	  warp->SetTransform(mytpstArray[1]);
	  lastwarp = warp;
	  warp->Update();

	  vtkPolyDataMapper* mapper = vtkPolyDataMapper::New();
          mapper->SetInput(warp->GetOutput());
   	  mapper->Update();

	  faceActor->SetMapper(mapper);
	  ren->AddActor(faceActor);
	  renWindow->SetSize(700, 700);
	  renWindow->Render();
//**********************************************************************





More information about the vtkusers mailing list