[vtkusers] vtkOBJExporter and vtkOBJReader .obj files do not have colors

Catherine Peloquin peloquin at iastate.edu
Wed May 14 10:37:56 EDT 2008


Hello all,

I am using vtkOBJExporter and vtkOBJReader to save and load .obj files of
colored surfaces.  This works well, except that when I load in a saved .obj
file, all objects are white.  How can I maintain the colors, as well as the
objects' geometry, when I load in .obj files?

I save the files like so:
        vtkOBJExporter* vtkExporter = vtkOBJExporter::New();
        vtkExporter->SetRenderWindow(renderWindowName);
        vtkExporter->SetFilePrefix(filename.c_str());
        vtkExporter->Write();

And load files like so:
    vtkOBJReader* vtkReader = vtkOBJReader::New();
    vtkReader->SetFileName(filename.c_str());
    vtkReader->Update(); // force the VTK pipeline to update
    int nPoints = vtkReader->GetOutput()->GetNumberOfPoints();
    vtkContourNormals = vtkPolyDataNormals::New();
    vtkContourNormals->SetInput(vtkReader->GetOutput());
    vtkContourNormals->SetFeatureAngle(60.0);
    vtkContourMapper = vtkPolyDataMapper::New();
    vtkContourMapper->SetInput(vtkContourNormals->GetOutput());
    vtkContourMapper->ScalarVisibilityOff();
    //Then visualize the data

Thanks,
Catherine
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080514/87188c3c/attachment.htm>


More information about the vtkusers mailing list