<!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örn Zehner wrote:
<blockquote cite="mid:fbd332db1280.48cf8e50@ufz.de" type="cite">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 <a class="moz-txt-link-rfc2396E" href="mailto:andrea.bottino@polito.it"><andrea.bottino@polito.it></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>
> <br>
> <span><br>
<p><br>
> <br>
> <br>
>
<table>
<tbody>
<tr>
<td text="#000000" bgcolor="#ffffff">
<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>
> </p>
<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>
<br>
> </td>
</tr>
</tbody>
</table>
<br>
> </p>
</span><br>
> > _______________________________________________<br>
> This is the private VTK discussion list.<br>
> Please keep messages on-topic. Check the FAQ at: <br>
> <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>
> 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>