<!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 & texture<br>
model = vtkOBJReader::New();<br>
model->SetFileName(filename);<br>
<br>
if(readableFile(textureName))<br>
{<br>
vtkPNGReader* png1 = vtkPNGReader::New();<br>
png1->SetFileName("train_02463_1.png");<br>
texture = vtkTexture::New();<br>
texture->SetInputConnection(png1->GetOutputPort());<br>
texture->InterpolateOn();<br>
}<br>
<br>
// ...<br>
// then I create the actor, and finally set the texture to the actor<br>
<br>
vtkActor* actor = vtkActor::New();<br>
vtkPolyDataMapper* mapper = vtkPolyDataMapper::New();<br>
mapper->SetInput(model->GetOutput());<br>
actor->SetMapper(mapper);<br>
<br>
if(texture)<br>
actor->SetTexture(texture);<br>
<br>
Then, for accessing the (x,y,z) and (R,G,B) values for each model
vertex:<br>
<br>
vtkPoints *inPts = model->GetOutput()->GetPoints(); <br>
vtkIdType numPts = model->GetOutput()->GetNumberOfPoints();<br>
double x[3];<br>
<br>
if (numPts < 1)<br>
{<br>
// vtkErrorMacro(<<"No vertices in the model!");<br>
return;<br>
}<br>
<br>
<br>
for (vtkIdType ptId=0; ptId < numPts; ptId++)<br>
{<br>
inPts->GetPoint(ptId, x);<br>
//cout << ptId << ") " << x[0] << ", "
<< x[1] << ", " << x[2] << endl;<br>
<br>
// getting texture values<br>
// --> and I have no idea how to get these values...<br>
} <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>