Skip to content

Commit

Permalink
provide support for existing multitexture calls
Browse files Browse the repository at this point in the history
The old MapDataArrayTGoMultiTexture relied on
being able to lock dowwn a specific texture unit
which cannot be guaranteed as external code
or render passes may bne uising that texture unit.

Instead we support the method having the name of a texture
along with the matching ethod in vtkProperty to name
a texture. Between these two users can assign texture
coordinate arrays to specific textures.

Deprecated the old index and unit based methods.
Removed a no longer needed vtkTexture.h include
which may bite some folks who are using vtkTexture
but not including the header (which they shoudl do)
  • Loading branch information
martinken committed Feb 16, 2018
1 parent 4cb5951 commit bbc96ed
Show file tree
Hide file tree
Showing 25 changed files with 389 additions and 243 deletions.
1 change: 1 addition & 0 deletions Filters/Core/Testing/Cxx/TestTubeFilter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <vtkRenderWindowInteractor.h>
#include <vtkSmartPointer.h>
#include <vtkTestUtilities.h>
#include <vtkTexture.h>
#include <vtkTubeFilter.h>

namespace
Expand Down
1 change: 1 addition & 0 deletions Geovis/Core/Testing/Cxx/TestGlobeSource.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "vtkSmartPointer.h"
#include "vtkStdString.h"
#include "vtkTestUtilities.h"
#include "vtkTexture.h"
#include "vtkTransform.h"

#include <vtksys/SystemTools.hxx>
Expand Down
17 changes: 9 additions & 8 deletions Geovis/Core/vtkGeoTerrain.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkSmartPointer.h"
#include "vtkTexture.h"
#include "vtkTimerLog.h"
#include "vtkTransformFilter.h"
#include "vtkXMLPolyDataWriter.h"
Expand Down Expand Up @@ -341,11 +342,11 @@ void vtkGeoTerrain::AddActors(
sameTexture = (
!textureNode1 ||
actor->GetProperty()->GetNumberOfTextures() < 1 ||
actor->GetProperty()->GetTexture(vtkProperty::VTK_TEXTURE_UNIT_0) == textureNode1->GetTexture()
actor->GetProperty()->GetTexture("VTK_TEXTURE_UNIT_0") == textureNode1->GetTexture()
) && (
!textureNode2 ||
actor->GetProperty()->GetNumberOfTextures() < 2 ||
actor->GetProperty()->GetTexture(vtkProperty::VTK_TEXTURE_UNIT_1) == textureNode2->GetTexture()
actor->GetProperty()->GetTexture("VTK_TEXTURE_UNIT_1") == textureNode2->GetTexture()
);
}
else
Expand Down Expand Up @@ -387,17 +388,17 @@ void vtkGeoTerrain::AddActors(
if (multiTexturing && textureUnits > 1)
{
// Multi texturing
mapper->MapDataArrayToMultiTextureAttribute(vtkProperty::VTK_TEXTURE_UNIT_0,
mapper->MapDataArrayToMultiTextureAttribute("VTK_TEXTURE_UNIT_0",
"LatLong", vtkDataObject::FIELD_ASSOCIATION_POINTS);
textureNode1->GetTexture()->SetBlendingMode(vtkTexture::VTK_TEXTURE_BLENDING_MODE_REPLACE);
actor->GetProperty()->SetTexture(vtkProperty::VTK_TEXTURE_UNIT_0, textureNode1->GetTexture());
actor->GetProperty()->SetTexture("VTK_TEXTURE_UNIT_0", textureNode1->GetTexture());

if (textureNode2)
{
mapper->MapDataArrayToMultiTextureAttribute(vtkProperty::VTK_TEXTURE_UNIT_1,
mapper->MapDataArrayToMultiTextureAttribute("VTK_TEXTURE_UNIT_1",
"LatLong", vtkDataObject::FIELD_ASSOCIATION_POINTS);
textureNode2->GetTexture()->SetBlendingMode(vtkTexture::VTK_TEXTURE_BLENDING_MODE_ADD);
actor->GetProperty()->SetTexture(vtkProperty::VTK_TEXTURE_UNIT_1, textureNode2->GetTexture());
actor->GetProperty()->SetTexture("VTK_TEXTURE_UNIT_1", textureNode2->GetTexture());
}
}
else
Expand Down Expand Up @@ -438,11 +439,11 @@ void vtkGeoTerrain::AddActors(
sameTexture = (
!textureNode1 ||
actor->GetProperty()->GetNumberOfTextures() < 1 ||
actor->GetProperty()->GetTexture(vtkProperty::VTK_TEXTURE_UNIT_0) == textureNode1->GetTexture()
actor->GetProperty()->GetTexture("VTK_TEXTURE_UNIT_0") == textureNode1->GetTexture()
) && (
!textureNode2 ||
actor->GetProperty()->GetNumberOfTextures() < 2 ||
actor->GetProperty()->GetTexture(vtkProperty::VTK_TEXTURE_UNIT_1) == textureNode2->GetTexture()
actor->GetProperty()->GetTexture("VTK_TEXTURE_UNIT_1") == textureNode2->GetTexture()
);
}
else
Expand Down
1 change: 1 addition & 0 deletions IO/Export/vtkSingleVTPExporter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "vtkProperty.h"
#include "vtkRenderWindow.h"
#include "vtkRendererCollection.h"
#include "vtkTexture.h"
#include "vtkTransform.h"
#include "vtkTriangleFilter.h"
#include "vtkXMLPolyDataWriter.h"
Expand Down
1 change: 1 addition & 0 deletions IO/Import/vtkOBJImporterInternals.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "vtkProperty.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkTexture.h"
#include "vtksys/SystemTools.hxx"
#include "vtkTransform.h"

Expand Down
1 change: 1 addition & 0 deletions Rendering/Annotation/vtkLegendBoxActor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "vtkTexturedActor2D.h"
#include "vtkTextMapper.h"
#include "vtkTextProperty.h"
#include "vtkTexture.h"
#include "vtkTransform.h"
#include "vtkTransformPolyDataFilter.h"
#include "vtkViewport.h"
Expand Down
2 changes: 1 addition & 1 deletion Rendering/Core/Testing/Cxx/TestTStripsColorsTCoords.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ int TestTStripsColorsTCoords(int argc, char *argv[])
polyData->Delete();

vtkActor *actor = vtkActor::New();
actor->GetProperty()->SetTexture("texture",texture);
actor->GetProperty()->SetTexture("mytexture",texture);
texture->Delete();
actor->SetMapper(mapper);
mapper->Delete();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ int TestTStripsNormalsColorsTCoords(int argc, char *argv[])
polyData->Delete();

vtkActor *actor = vtkActor::New();
actor->GetProperty()->SetTexture("texture",texture);
actor->GetProperty()->SetTexture("mytexture",texture);
texture->Delete();
actor->SetMapper(mapper);
mapper->Delete();
Expand Down
2 changes: 1 addition & 1 deletion Rendering/Core/Testing/Cxx/TestTStripsNormalsTCoords.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ int TestTStripsNormalsTCoords(int argc, char *argv[])
polyData->Delete();

vtkActor *actor = vtkActor::New();
actor->GetProperty()->SetTexture("texture",texture);
actor->GetProperty()->SetTexture("mytexture",texture);
texture->Delete();
actor->SetMapper(mapper);
mapper->Delete();
Expand Down
2 changes: 1 addition & 1 deletion Rendering/Core/Testing/Cxx/TestTStripsTCoords.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ int TestTStripsTCoords(int argc, char *argv[])
polyData->Delete();

vtkActor *actor = vtkActor::New();
actor->GetProperty()->SetTexture("texture",texture);
actor->GetProperty()->SetTexture("mytexture",texture);
texture->Delete();
actor->SetMapper(mapper);
mapper->Delete();
Expand Down
14 changes: 13 additions & 1 deletion Rendering/Core/vtkPolyDataMapper.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,25 @@ void vtkPolyDataMapper::MapDataArrayToVertexAttribute(
vtkErrorMacro("Not implemented at this level...");
}

//----------------------------------------------------------------------------
#ifndef VTK_LEGACY_REMOVE
void vtkPolyDataMapper::MapDataArrayToMultiTextureAttribute(
int vtkNotUsed(unit),
const char* vtkNotUsed(dataArrayName),
int vtkNotUsed(fieldAssociation),
int vtkNotUsed(componentno)
)
{
VTK_LEGACY_BODY(vtkPolyDataMapper::MapDataArrayToMultiTextureAttribute, "VTK 8.2");
}
#endif

//----------------------------------------------------------------------------
void vtkPolyDataMapper::MapDataArrayToMultiTextureAttribute(
const char* vtkNotUsed(tname),
const char* vtkNotUsed(dataArrayName),
int vtkNotUsed(fieldAssociation),
int vtkNotUsed(componentno)
)
{
vtkErrorMacro("Not implemented at this level...");
}
Expand Down
13 changes: 11 additions & 2 deletions Rendering/Core/vtkPolyDataMapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

#include "vtkRenderingCoreModule.h" // For export macro
#include "vtkMapper.h"
#include "vtkTexture.h" // used to include texture unit enum.
//#include "vtkTexture.h" // used to include texture unit enum.

class vtkPolyData;
class vtkRenderer;
Expand Down Expand Up @@ -111,15 +111,24 @@ class VTKRENDERINGCORE_EXPORT vtkPolyDataMapper : public vtkMapper
* (vtkDataObject::FIELD_ASSOCIATION_CELLS).
* componentno indicates which component from the data array must be passed as
* the attribute. If -1, then all components are passed.
* Currently only point data is supported.
*/
virtual void MapDataArrayToVertexAttribute(
const char* vertexAttributeName,
const char* dataArrayName, int fieldAssociation, int componentno = -1);

// Specify a data array to use as the texture coordinate
// for a named texture. See vtkProperty.h for how to
// name textures.
virtual void MapDataArrayToMultiTextureAttribute(
int unit,
const char *textureName,
const char* dataArrayName, int fieldAssociation, int componentno = -1);

// deprecated in favor of the const char * signature
VTK_LEGACY(virtual void MapDataArrayToMultiTextureAttribute(
int unit,
const char* dataArrayName, int fieldAssociation, int componentno = -1));

/**
* Remove a vertex attribute mapping.
*/
Expand Down
Loading

0 comments on commit bbc96ed

Please sign in to comment.