<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
<font face="Calibri">Hi all,<br>
I have an .obj model with an associated texture, and I need to access
vertex coordinates as well as their RGB values. However, I'm blocked on
the last point. Here's my code:<br>
<br>
// loading the obj model &amp; texture<br>
&nbsp;&nbsp;&nbsp; model = vtkOBJReader::New();<br>
&nbsp;&nbsp;&nbsp; model-&gt;SetFileName(filename);<br>
<br>
&nbsp;&nbsp;&nbsp; if(readableFile(textureName))<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; vtkPNGReader* png1 = vtkPNGReader::New();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; png1-&gt;SetFileName("train_02463_1.png");<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; texture = vtkTexture::New();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; texture-&gt;SetInputConnection(png1-&gt;GetOutputPort());<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; texture-&gt;InterpolateOn();<br>
&nbsp;&nbsp;&nbsp; }<br>
<br>
// ...<br>
// then I create the actor, and finally set the texture to the actor<br>
<br>
&nbsp;&nbsp; vtkActor* actor = vtkActor::New();<br>
&nbsp;&nbsp; vtkPolyDataMapper* mapper = vtkPolyDataMapper::New();<br>
&nbsp;&nbsp; mapper-&gt;SetInput(model-&gt;GetOutput());<br>
&nbsp;&nbsp; actor-&gt;SetMapper(mapper);<br>
<br>
&nbsp;&nbsp; if(texture)<br>
&nbsp;&nbsp;&nbsp; actor-&gt;SetTexture(texture);<br>
<br>
Then, for accessing the (x,y,z) and (R,G,B) values for each model
vertex:<br>
<br>
&nbsp; vtkPoints *inPts = model-&gt;GetOutput()-&gt;GetPoints();&nbsp; <br>
&nbsp; vtkIdType numPts = model-&gt;GetOutput()-&gt;GetNumberOfPoints();<br>
&nbsp; double x[3];<br>
<br>
&nbsp; if (numPts &lt; 1)<br>
&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // vtkErrorMacro(&lt;&lt;"No vertices in the model!");<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return;<br>
&nbsp; }<br>
&nbsp;&nbsp;&nbsp; <br>
<br>
&nbsp; for (vtkIdType ptId=0; ptId &lt; numPts; ptId++)<br>
&nbsp; {<br>
&nbsp; &nbsp;&nbsp;&nbsp; inPts-&gt;GetPoint(ptId, x);<br>
&nbsp; &nbsp;&nbsp;&nbsp; //cout &lt;&lt; ptId &lt;&lt; ") " &lt;&lt; x[0] &lt;&lt; ", "
&lt;&lt; x[1] &lt;&lt; ", " &lt;&lt; x[2] &lt;&lt; endl;<br>
<br>
&nbsp;&nbsp;&nbsp; // getting texture values<br>
&nbsp;&nbsp; //&nbsp; --&gt; and I have no idea how to get these values...<br>
&nbsp; }&nbsp; <br>
<br>
<br>
best regards,<br>
a.<br>
<br>
<br>
</font>
<pre class="moz-signature" cols="72">-- 
Andrea Bottino
Politecnico di Torino, DAUIN
Corso Duca degli Abruzzi, 24
10129 Torino ITALY
Tel +39 011 5647175 / Fax +39 011 5647099.
<a class="moz-txt-link-freetext" href="http://www.polito.it/cgvg">http://www.polito.it/cgvg</a>
</pre>
</body>
</html>