<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<font face="Calibri">this works fine for getting the texture values.
But then, how can I get the RGB values from the vtkTexture object?
looks like there's no way to access the loaded texture<br>
bets regards<br>
a.<br>
</font><br>
Bj&ouml;rn Zehner wrote:
<blockquote cite="mid:fbd332db1280.48cf8e50@ufz.de" type="cite">Hi
Andrea,<br>
&nbsp;<br>
I am not very VTK professional an I have not tried this before. But
from what I see vtkObjReader-&gt;GetOutput() returns a pointer to
vtkPolyData. As vtkPolyData is derived from vtkDataSet you can call
myVtkDataSet-&gt;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>
&nbsp;<br>
Kind regards,<br>
Bjoern<br>
  <br>
----- Urspr&uuml;ngliche Nachricht -----<br>
Von: Andrea Bottino <a class="moz-txt-link-rfc2396E" href="mailto:andrea.bottino@polito.it">&lt;andrea.bottino@polito.it&gt;</a><br>
Datum: Montag, 15. September 2008, 17:05<br>
Betreff: [vtkusers] How to get texture values for a vertex?<br>
An: <a class="moz-txt-link-abbreviated" href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a><br>
  <br>
&gt; <br>
&gt; <span><br>
  <p><br>
&gt; <br>
&gt; <br>
&gt;
  <table>
    <tbody>
      <tr>
        <td text="#000000" bgcolor="#ffffff">
        <p><br>
&gt; <font face="Calibri">Hi all,<br>
&gt; <br>
&gt; I have an .obj model with an associated texture, and I need to
access<br>
&gt; vertex coordinates as well as their RGB values. However, I'm
blocked on<br>
&gt; the last point. Here's my code:<br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; // loading the obj model &amp; texture<br>
&gt; <br>
&gt; &nbsp;&nbsp;&nbsp; model = vtkOBJReader::New();<br>
&gt; <br>
&gt; &nbsp;&nbsp;&nbsp; model-&gt;SetFileName(filename);<br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; &nbsp;&nbsp;&nbsp; if(readableFile(textureName))<br>
&gt; <br>
&gt; &nbsp;&nbsp;&nbsp; {<br>
&gt; <br>
&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; vtkPNGReader* png1 = vtkPNGReader::New();<br>
&gt; <br>
&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; png1-&gt;SetFileName("train_02463_1.png");<br>
&gt; <br>
&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; texture = vtkTexture::New();<br>
&gt; <br>
&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; texture-&gt;SetInputConnection(png1-&gt;GetOutputPort());<br>
&gt; <br>
&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; texture-&gt;InterpolateOn();<br>
&gt; <br>
&gt; &nbsp;&nbsp;&nbsp; }<br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; // ...<br>
&gt; <br>
&gt; // then I create the actor, and finally set the texture to the
actor<br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; &nbsp;&nbsp; vtkActor* actor = vtkActor::New();<br>
&gt; <br>
&gt; &nbsp;&nbsp; vtkPolyDataMapper* mapper = vtkPolyDataMapper::New();<br>
&gt; <br>
&gt; &nbsp;&nbsp; mapper-&gt;SetInput(model-&gt;GetOutput());<br>
&gt; <br>
&gt; &nbsp;&nbsp; actor-&gt;SetMapper(mapper);<br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; &nbsp;&nbsp; if(texture)<br>
&gt; <br>
&gt; &nbsp;&nbsp;&nbsp; actor-&gt;SetTexture(texture);<br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; Then, for accessing the (x,y,z) and (R,G,B) values for each model<br>
&gt; vertex:<br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; &nbsp; vtkPoints *inPts = model-&gt;GetOutput()-&gt;GetPoints();&nbsp; <br>
&gt; <br>
&gt; &nbsp; vtkIdType numPts = model-&gt;GetOutput()-&gt;GetNumberOfPoints();<br>
&gt; <br>
&gt; &nbsp; double x[3];<br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; &nbsp; if (numPts &lt; 1)<br>
&gt; <br>
&gt; &nbsp; {<br>
&gt; <br>
&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // vtkErrorMacro(&lt;&lt;"No vertices in the model!");<br>
&gt; <br>
&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return;<br>
&gt; <br>
&gt; &nbsp; }<br>
&gt; <br>
&gt; &nbsp;&nbsp;&nbsp; <br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; &nbsp; for (vtkIdType ptId=0; ptId &lt; numPts; ptId++)<br>
&gt; <br>
&gt; &nbsp; {<br>
&gt; <br>
&gt; &nbsp; &nbsp;&nbsp;&nbsp; inPts-&gt;GetPoint(ptId, x);<br>
&gt; <br>
&gt; &nbsp; &nbsp;&nbsp;&nbsp; //cout &lt;&lt; ptId &lt;&lt; ") " &lt;&lt; x[0] &lt;&lt; ",
"<br>
&gt; &lt;&lt; x[1] &lt;&lt; ", " &lt;&lt; x[2] &lt;&lt; endl;<br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; &nbsp;&nbsp;&nbsp; // getting texture values<br>
&gt; <br>
&gt; &nbsp;&nbsp; //&nbsp; --&gt; and I have no idea how to get these values...<br>
&gt; <br>
&gt; &nbsp; }&nbsp; <br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; best regards,<br>
&gt; <br>
&gt; a.<br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; </font><br>
&gt; </p>
        <pre class="moz-signature" cols="72">-- 
&gt; Andrea Bottino
&gt; Politecnico di Torino, DAUIN
&gt; Corso Duca degli Abruzzi, 24
&gt; 10129 Torino ITALY
&gt; Tel +39 011 5647175 / Fax +39 011 5647099.
&gt; <a class="moz-txt-link-freetext" href="http://www.polito.it/cgvg">http://www.polito.it/cgvg</a>
&gt; </pre>
        <br>
&gt; </td>
      </tr>
    </tbody>
  </table>
  <br>
&gt; </p>
  </span><br>
&gt; &gt; _______________________________________________<br>
&gt; This is the private VTK discussion list.<br>
&gt; Please keep messages on-topic. Check the FAQ at: <br>
&gt; <a class="moz-txt-link-freetext" href="http://www.vtk.org/Wiki/VTK_FAQFollow">http://www.vtk.org/Wiki/VTK_FAQFollow</a> this link to <br>
&gt; subscribe/unsubscribe:<a class="moz-txt-link-freetext" href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
  <br>
-------------------------------------------------------------------------
  <br>
Dr. Bjoern Zehner <br>
UFZ Centre for Environmental Research Leipzig-Halle <br>
Permoserstrasse 15 <br>
04318 Leipzig <br>
Germany <br>
<a class="moz-txt-link-freetext" href="http://www.ufz.de/index.php?en=5673">http://www.ufz.de/index.php?en=5673</a> <br>
Tel: ++49 (341) 235 1979 <br>
Fax: ++49 (341) 235 1939<br>
  <br>
  <pre wrap="">
<hr size="4" width="90%">

No virus found in this incoming message.
Checked by AVG - <a class="moz-txt-link-freetext" href="http://www.avg.com">http://www.avg.com</a> 
Version: 8.0.169 / Virus Database: 270.6.21/1672 - Release Date: 15/09/2008 9.21

  </pre>
</blockquote>
<br>
<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>