Hi Andrea,<BR> <BR>I am not very VTK professional an I have not tried this before. But from what I see vtkObjReader->GetOutput() returns a pointer to vtkPolyData. As vtkPolyData is derived from vtkDataSet you can call myVtkDataSet->GetPointData() which returns a pointer to your vtkPointData; As vtkPointData is derived from vtkDataSetAttributes you can call GetTCoords() which should return a vtkDataArray that contains your texture coordinates. So far the theory ..... if it works you have to try, and may be there is a simpler solution!<BR> <BR>Kind regards,<BR>Bjoern<BR><BR>----- Ursprüngliche Nachricht -----<BR>Von: Andrea Bottino <andrea.bottino@polito.it><BR>Datum: Montag, 15. September 2008, 17:05<BR>Betreff: [vtkusers] How to get texture values for a vertex?<BR>An: vtkusers@vtk.org<BR><BR>> <BR>> <SPAN><BR>
<P><BR>> <BR>> <BR>>
<TABLE>
<TBODY>
<TR>
<TD bgColor=#ffffff text="#000000">
<P><BR>> <FONT face=Calibri>Hi all,<BR>> <BR>> I have an .obj model with an associated texture, and I need to access<BR>> vertex coordinates as well as their RGB values. However, I'm blocked on<BR>> the last point. Here's my code:<BR>> <BR>> <BR>> <BR>> // loading the obj model & texture<BR>> <BR>> model = vtkOBJReader::New();<BR>> <BR>> model->SetFileName(filename);<BR>> <BR>> <BR>> <BR>> if(readableFile(textureName))<BR>> <BR>> {<BR>> <BR>> vtkPNGReader* png1 = vtkPNGReader::New();<BR>> <BR>> png1->SetFileName("train_02463_1.png");<BR>> <BR>> texture = vtkTexture::New();<BR>> <BR>> texture->SetInputConnection(png1->GetOutputPort());<BR>> <BR>> texture->InterpolateOn();<BR>> <BR>> }<BR>> <BR>> <BR>> <BR>> // ...<BR>> <BR>> // then I create the actor, and finally set the texture to the actor<BR>> <BR>> <BR>> <BR>> vtkActor* actor = vtkActor::New();<BR>> <BR>> vtkPolyDataMapper* mapper = vtkPolyDataMapper::New();<BR>> <BR>> mapper->SetInput(model->GetOutput());<BR>> <BR>> actor->SetMapper(mapper);<BR>> <BR>> <BR>> <BR>> if(texture)<BR>> <BR>> actor->SetTexture(texture);<BR>> <BR>> <BR>> <BR>> Then, for accessing the (x,y,z) and (R,G,B) values for each model<BR>> vertex:<BR>> <BR>> <BR>> <BR>> vtkPoints *inPts = model->GetOutput()->GetPoints(); <BR>> <BR>> vtkIdType numPts = model->GetOutput()->GetNumberOfPoints();<BR>> <BR>> double x[3];<BR>> <BR>> <BR>> <BR>> if (numPts < 1)<BR>> <BR>> {<BR>> <BR>> // vtkErrorMacro(<<"No vertices in the model!");<BR>> <BR>> return;<BR>> <BR>> }<BR>> <BR>> <BR>> <BR>> <BR>> <BR>> for (vtkIdType ptId=0; ptId < numPts; ptId++)<BR>> <BR>> {<BR>> <BR>> inPts->GetPoint(ptId, x);<BR>> <BR>> //cout << ptId << ") " << x[0] << ", "<BR>> << x[1] << ", " << x[2] << endl;<BR>> <BR>> <BR>> <BR>> // getting texture values<BR>> <BR>> // --> and I have no idea how to get these values...<BR>> <BR>> } <BR>> <BR>> <BR>> <BR>> <BR>> <BR>> best regards,<BR>> <BR>> a.<BR>> <BR>> <BR>> <BR>> <BR>> <BR>> </FONT><BR>> <PRE class=moz-signature cols="72">-- <BR>> Andrea Bottino<BR>> Politecnico di Torino, DAUIN<BR>> Corso Duca degli Abruzzi, 24<BR>> 10129 Torino ITALY<BR>> Tel +39 011 5647175 / Fax +39 011 5647099.<BR>> http://www.polito.it/cgvg<BR>> </PRE><BR>> </TD></TR></TBODY></TABLE><BR>> </SPAN><BR>> > _______________________________________________<BR>> This is the private VTK discussion list.<BR>> Please keep messages on-topic. Check the FAQ at: <BR>> http://www.vtk.org/Wiki/VTK_FAQFollow this link to <BR>> subscribe/unsubscribe:http://www.vtk.org/mailman/listinfo/vtkusers<BR><BR>------------------------------------------------------------------------- <BR>Dr. Bjoern Zehner <BR>UFZ Centre for Environmental Research Leipzig-Halle <BR>Permoserstrasse 15 <BR>04318 Leipzig <BR>Germany <BR>http://www.ufz.de/index.php?en=5673 <BR>Tel: ++49 (341) 235 1979 <BR>Fax: ++49 (341) 235 1939<BR><BR></P>