I believe that there is a limit of one texture per vtkActor, which gives you two alternatives. Either you need to combine your 6 views into a single texture or you need to make each side of the cube a separate actor.<div>
<br></div><div>- Wes<br><br><div class="gmail_quote">2009/11/24 "André Rohde" <span dir="ltr"><<a href="mailto:Rohy@gmx.de">Rohy@gmx.de</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Dear Vtk Users,<br>
i´d like to map one texture to each side of a cube (6 sides = 6 different textures) from different arrays. (Only one Array in my Code yet)<br>
Mapping one texture to the cube works fine for me. But i don´t have an idea how this is gonna work for each side of a cube. The general idea behind my program is to take an specific amount of snapshots from a camera and generate an array/cube of this pictures in vtk.<br>
<br>
Here´s my Code:<br>
<br>
//First Array > Image Data should be mapped to the first side of the cube...<br>
vtkFloatArray *vtkArray = vtkFloatArray::New();<br>
vtkArray->SetNumberOfComponents(1);<br>
vtkArray->SetNumberOfTuples(1392*1040);<br>
<br>
unsigned indexInverted = 0;<br>
<br>
for(int k = 0; k < 1040; k++)<br>
{<br>
for(int l = 0; l < 1392; l++)<br>
{<br>
//pcFrame contains the ImageData from the Camera<br>
vtkArray->SetTuple1(indexInverted,pcFrame[((1392*1040)-(1392*(k+1)))+l]);<br>
indexInverted++;<br>
}<br>
}<br>
<br>
vtkImageData *myImage = vtkImageData::New();<br>
myImage->SetDimensions(1392,1040,1);<br>
myImage->SetSpacing(1,1,1);<br>
myImage->SetOrigin(0,0,0);<br>
myImage->SetNumberOfScalarComponents(1);<br>
myImage->SetScalarTypeToFloat();<br>
myImage->AllocateScalars();<br>
myImage->GetPointData()->SetScalars(vtkArray);<br>
<br>
int i;<br>
//Cube Coordinates<br>
static float x[8][3]={{0,0,0}, {1392,0,0}, {1392,1040,0}, {0,1040,0}, {0,0,700}, {1392,0,700}, {1392,1040,700}, {0,1040,700}};<br>
<br>
static vtkIdType pts[6][4]={{0,1,2,3},{4,5,6,7}, {0,1,5,4},{1,2,6,5}, {2,3,7,6}, {3,0,4,7}};<br>
<br>
// Color LookupTable<br>
vtkLookupTable *table = vtkLookupTable::New();<br>
table->SetTableRange(0,255);<br>
table->SetValueRange(0.0,1.0);<br>
table->SetSaturationRange(0.0,0.0);<br>
table->SetHueRange(0.0,0.0);<br>
table->SetAlphaRange(1.0,1.0);<br>
table->SetNumberOfColors(256);<br>
table->Build();<br>
<br>
<br>
// Create texture<br>
vtkTexture *atext = vtkTexture::New();<br>
atext->SetInput(myImage);<br>
atext->SetLookupTable(table);<br>
atext->InterpolateOff();<br>
<br>
// We'll create the building blocks of polydata including data attributes.<br>
vtkPolyData *cube = vtkPolyData::New();<br>
vtkPoints *points = vtkPoints::New();<br>
vtkCellArray *polys = vtkCellArray::New();<br>
vtkFloatArray *tCoords = vtkFloatArray::New();<br>
<br>
tCoords->SetNumberOfComponents(2);<br>
tCoords->InsertTuple2(0, 0, 0);<br>
tCoords->InsertTuple2(1, 1, 0);<br>
tCoords->InsertTuple2(2, 1, 1);<br>
tCoords->InsertTuple2(3, 0, 1);<br>
tCoords->InsertTuple2(4, 0, 0);<br>
tCoords->InsertTuple2(5, 1, 0);<br>
tCoords->InsertTuple2(6, 1, 1);<br>
tCoords->InsertTuple2(7, 0, 1);<br>
<br>
// Load the point, cell, and data attributes.<br>
for (i=0; i<8; i++) points->InsertPoint(i,x[i]);<br>
for (i=0; i<6; i++) polys->InsertNextCell(4,pts[i]);<br>
<br>
// We now assign the pieces to the vtkPolyData.<br>
cube->SetPoints(points);<br>
points->Delete();<br>
cube->SetPolys(polys);<br>
polys->Delete();<br>
cube->GetPointData()->SetTCoords(tCoords);<br>
tCoords->Delete();<br>
<br>
<br>
vtkPolyDataMapper *cubeMapper = vtkPolyDataMapper::New();<br>
cubeMapper->SetInput(cube);<br>
vtkActor *cubeActor = vtkActor::New();<br>
cubeActor->SetMapper(cubeMapper);<br>
cubeActor->SetTexture(atext);<br>
<br>
// The usual rendering stuff.<br>
vtkCamera *camera = vtkCamera::New();<br>
camera->SetPosition(1,1,1);<br>
camera->SetFocalPoint(0,0,0);<br>
<br>
vtkRenderer *renderer = vtkRenderer::New();<br>
vtkRenderWindow *renWin = vtkRenderWindow::New();<br>
renWin->AddRenderer(renderer);<br>
<br>
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();<br>
vtkWidget->SetRenderWindow(renWin);<br>
<br>
renderer->AddActor(cubeActor);<br>
renderer->SetActiveCamera(camera);<br>
renderer->ResetCamera();<br>
renderer->SetBackground(0.4,0.5,0.6);<br>
<br>
//interact with data<br>
renWin->Render();<br>
iren->Start();<br>
<br>
with kind regards<br>
Andy<br>
--<br>
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!<br>
Jetzt freischalten unter <a href="http://portal.gmx.net/de/go/maxdome01" target="_blank">http://portal.gmx.net/de/go/maxdome01</a><br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Wesley D. Turner, Ph.D.<br>Kitware, Inc.<br>Technical Leader<br>28 Corporate Drive<br>Clifton Park, NY 12065-8662<br>Phone: 518-881-4920<br>
</div>