[vtkusers] Vertices with defined normal - visualization problem

amutka alan.mutka at gmail.com
Sun Dec 2 08:07:17 EST 2012


Dear All, 
i have problem with visualization of vtkPolyData which contains
points(vertices). If I set normals for each point then in visualization I
can see point only if the normal shows toward the camera. The backface
culling effect cannot be disabled what ever I do.
I have tried everything, changing the backface cooling parameters, adding
additional scalars, changing all possible vtkActor propery and mapper
parameters. Please help.

Here is a simple example...based on online example adding normals to
vertices
http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/PolyDataCellNormals

Here is my example...
........................................................
/vtkSmartPointer<vtkPoints> points =  vtkSmartPointer<vtkPoints>::New();
points->InsertNextPoint(1.0, 0.0, 0.0);
points->InsertNextPoint(0.0, 0.0, 0.0);
points->InsertNextPoint(0.0, 1.0, 0.0);

vtkSmartPointer<vtkCellArray>
cloudCells=vtkSmartPointer<vtkCellArray>::New();
for (vtkIdType i = 0; i < points->GetNumberOfPoints(); i++)
{
	  cloudCells->InsertNextCell(1, &i);
}
   
  *// Add the points to a polydata*
  vtkSmartPointer<vtkPolyData> polydata =
vtkSmartPointer<vtkPolyData>::New();
  polydata->SetPoints(points);
  polydata->SetVerts(cloudCells);/

*///NOW CREATE NORMALS*
  vtkSmartPointer<vtkDoubleArray> pointNormalsArray = 
    vtkSmartPointer<vtkDoubleArray>::New();
  pointNormalsArray->SetNumberOfComponents(3); //3d normals (ie x,y,z)
  pointNormalsArray->SetNumberOfTuples(polydata->GetNumberOfPoints());
 
*  // Construct the normal vectors*
/  double pN1[3] = {1.0, 0.0, 0.0};
  double pN2[3] = {0.0, 1.0, 0.0};
  double pN3[3] = {0.0, 0.0, 1.0};/
 
 * // Add the data to the normals array*
/  pointNormalsArray->SetTuple(0, pN1) ;
  pointNormalsArray->SetTuple(1, pN2) ;
  pointNormalsArray->SetTuple(2, pN3) ;/

*//ADD NORMALS TO POLYDATA*

/polydata->GetPointData()->SetNormals(pointNormalsArray);

  vtkPolyDataMapper * mapper = vtkPolyDataMapper::New();
  mapper->SetInput(polydata);
  mapper->SetColorModeToMapScalars();/
 

*  //RENDERING*

 / vtkActor * actor= vtkActor::New();
  actor->GetProperty()->SetColor(1,1,0);
  actor->SetMapper(mapper);
  actor->GetProperty()->SetOpacity(0.8);
 
   vtkRenderWindowInteractor * iren1 = vtkRenderWindowInteractor::New();
  vtkRenderer * ren1 = vtkRenderer::New();
  vtkRenderWindow * renWin = vtkRenderWindow::New();

  ren1->AddActor(actor);
  ren1->SetBackground(0,0,0);

  renWin->AddRenderer(ren1);
  iren1->SetRenderWindow(renWin);
  iren1->Initialize();
  iren1->Start();/






--
View this message in context: http://vtk.1045678.n5.nabble.com/Vertices-with-defined-normal-visualization-problem-tp5717365.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list