Skip to content
Snippets Groups Projects
Commit 01f72698 authored by Johan Andruejol's avatar Johan Andruejol
Browse files

Update to VTK8.2

parent 71808c60
No related branches found
No related tags found
No related merge requests found
...@@ -12,7 +12,7 @@ endif(${${PROJECT_NAME}_ENABLE_VR}) ...@@ -12,7 +12,7 @@ endif(${${PROJECT_NAME}_ENABLE_VR})
include(imstkAddExternalProject) include(imstkAddExternalProject)
imstk_add_external_project( VTK imstk_add_external_project( VTK
GIT_REPOSITORY https://gitlab.kitware.com/vtk/vtk.git GIT_REPOSITORY https://gitlab.kitware.com/vtk/vtk.git
GIT_TAG v8.1.1 GIT_TAG v8.2.0
INSTALL_COMMAND ${SKIP_STEP_COMMAND} INSTALL_COMMAND ${SKIP_STEP_COMMAND}
CMAKE_ARGS CMAKE_ARGS
-DBUILD_EXAMPLES:BOOL=OFF -DBUILD_EXAMPLES:BOOL=OFF
...@@ -33,6 +33,7 @@ imstk_add_external_project( VTK ...@@ -33,6 +33,7 @@ imstk_add_external_project( VTK
-DVTK_RENDERING_BACKEND:STRING=OpenGL2 -DVTK_RENDERING_BACKEND:STRING=OpenGL2
-DVTK_WRAP_PYTHON:BOOL=OFF -DVTK_WRAP_PYTHON:BOOL=OFF
-DVTK_OPENVR_OBJECT_FACTORY:BOOL=OFF -DVTK_OPENVR_OBJECT_FACTORY:BOOL=OFF
-DVTK_LEGACY_REMOVE:BOOL=ON
DEPENDENCIES ${VTK_DEPENDENCIES} DEPENDENCIES ${VTK_DEPENDENCIES}
RELATIVE_INCLUDE_PATH "" RELATIVE_INCLUDE_PATH ""
#VERBOSE #VERBOSE
......
...@@ -35,6 +35,64 @@ Texture::getType() const ...@@ -35,6 +35,64 @@ Texture::getType() const
return m_type; return m_type;
} }
std::string
Texture::getTypeAsString() const
{
return Texture::getTypeAsString(m_type);
}
std::string
Texture::getTypeAsString(Type type)
{
switch (type)
{
case Type::DIFFUSE:
{
return "Diffuse";
}
case Type::NORMAL:
{
return "Normal";
}
case Type::ROUGHNESS:
{
return "Roughness";
}
case Type::METALNESS:
{
return "Metalness";
}
case Type::SUBSURFACE_SCATTERING:
{
return "Subsurface_scattering";
}
case Type::AMBIENT_OCCLUSION:
{
return "Ambient_Occlusion";
}
case Type::CAVITY:
{
return "Cavity";
}
case Type::IRRADIANCE_CUBEMAP:
{
return "Irradiance_Cubemap";
}
case Type::RADIANCE_CUBEMAP:
{
return "Radiance_Cubemap";
}
case Type::BRDF_LUT:
{
return "BRDF_LUT";
}
default:
{
return "None";
}
}
}
const std::string const std::string
Texture::getPath() const Texture::getPath() const
{ {
......
...@@ -69,6 +69,16 @@ public: ...@@ -69,6 +69,16 @@ public:
/// ///
Type getType() const; Type getType() const;
///
/// \brief Get type as a string
///
std::string getTypeAsString() const;
///
/// \brief Convert a Type into a string
///
static std::string getTypeAsString(Type type);
/// ///
/// \brief Get path /// \brief Get path
/// ///
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <vtkVertexGlyphFilter.h> #include <vtkVertexGlyphFilter.h>
#include <vtkSphereSource.h> #include <vtkSphereSource.h>
#include <vtkGlyph3D.h> #include <vtkGlyph3D.h>
#include <vtkVersion.h>
namespace imstk namespace imstk
{ {
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <vtkTexture.h> #include <vtkTexture.h>
#include <vtkProperty.h> #include <vtkProperty.h>
#include <vtkOpenGLPolyDataMapper.h> #include <vtkOpenGLPolyDataMapper.h>
#include <vtkVersion.h>
namespace imstk namespace imstk
{ {
...@@ -199,7 +200,13 @@ VTKSurfaceMeshRenderDelegate::initializeTextures(TextureManager<VTKTextureDelega ...@@ -199,7 +200,13 @@ VTKSurfaceMeshRenderDelegate::initializeTextures(TextureManager<VTKTextureDelega
*/ */
// Set texture // Set texture
m_actor->GetProperty()->SetTexture(currentUnit, textureDelegate->getTexture()); vtkSmartPointer<vtkTexture> currentTexture = textureDelegate->getTexture();
#if (VTK_MAJOR_VERSION <= 8 && VTK_MINOR_VERSION <= 1)
m_actor->GetProperty()->SetTexture(currentUnit, currentTexture);
#else
m_actor->GetProperty()->SetTexture(textureDelegate->getTextureName().c_str(), currentTexture);
#endif
currentUnit++; currentUnit++;
} }
} }
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
#include "imstkVTKCustomPolyDataMapper.h" #include "imstkVTKCustomPolyDataMapper.h"
#include "vtkVersion.h"
namespace imstk namespace imstk
{ {
vtkStandardNewMacro(VTKCustomPolyDataMapper); vtkStandardNewMacro(VTKCustomPolyDataMapper);
...@@ -218,7 +220,11 @@ VTKCustomPolyDataMapper::SetMapperShaderParameters( ...@@ -218,7 +220,11 @@ VTKCustomPolyDataMapper::SetMapperShaderParameters(
auto diffuseTexture = material->getTexture(Texture::Type::DIFFUSE); auto diffuseTexture = material->getTexture(Texture::Type::DIFFUSE);
if (diffuseTexture->getPath() != "" && textureCount < textures.size()) if (diffuseTexture->getPath() != "" && textureCount < textures.size())
{ {
#if (VTK_MAJOR_VERSION <= 8 && VTK_MINOR_VERSION <= 1)
auto texture = (vtkOpenGLTexture*)textures[currentTexture]; auto texture = (vtkOpenGLTexture*)textures[currentTexture];
#else
auto texture = (vtkOpenGLTexture*)textures[currentTexture].first;
#endif
helper.Program->SetUniformi("diffuseTexture", texture->GetTextureUnit()); helper.Program->SetUniformi("diffuseTexture", texture->GetTextureUnit());
renderWindow->DeactivateTexture(texture->GetTextureObject()); renderWindow->DeactivateTexture(texture->GetTextureObject());
currentTexture++; currentTexture++;
...@@ -227,7 +233,11 @@ VTKCustomPolyDataMapper::SetMapperShaderParameters( ...@@ -227,7 +233,11 @@ VTKCustomPolyDataMapper::SetMapperShaderParameters(
auto cubemapTexture = material->getTexture(Texture::Type::CUBEMAP); auto cubemapTexture = material->getTexture(Texture::Type::CUBEMAP);
if (cubemapTexture->getPath() != "" && textureCount < textures.size()) if (cubemapTexture->getPath() != "" && textureCount < textures.size())
{ {
#if (VTK_MAJOR_VERSION <= 8 && VTK_MINOR_VERSION < 2)
auto texture = (vtkOpenGLTexture*)textures[currentTexture]; auto texture = (vtkOpenGLTexture*)textures[currentTexture];
#else
auto texture = (vtkOpenGLTexture*)textures[currentTexture].first;
#endif
helper.Program->SetUniformi("cubemapTexture", texture->GetTextureUnit()); helper.Program->SetUniformi("cubemapTexture", texture->GetTextureUnit());
renderWindow->DeactivateTexture(texture->GetTextureObject()); renderWindow->DeactivateTexture(texture->GetTextureObject());
currentTexture++; currentTexture++;
......
...@@ -30,6 +30,12 @@ VTKTextureDelegate::getTexture() const ...@@ -30,6 +30,12 @@ VTKTextureDelegate::getTexture() const
return m_sourceTexture; return m_sourceTexture;
} }
const std::string&
VTKTextureDelegate::getTextureName() const
{
return m_textureName;
}
void void
VTKTextureDelegate::loadTexture(std::shared_ptr<Texture> texture) VTKTextureDelegate::loadTexture(std::shared_ptr<Texture> texture)
{ {
...@@ -39,6 +45,10 @@ VTKTextureDelegate::loadTexture(std::shared_ptr<Texture> texture) ...@@ -39,6 +45,10 @@ VTKTextureDelegate::loadTexture(std::shared_ptr<Texture> texture)
m_sourceTexture = vtkSmartPointer<vtkTexture>::New(); m_sourceTexture = vtkSmartPointer<vtkTexture>::New();
// Mangle an unique texture name from the texture type and texture path
std::string manglingSymbol = "::";
m_textureName = texture->getTypeAsString() + manglingSymbol + texture->getPath();
if (texture->getType() == Texture::Type::CUBEMAP) if (texture->getType() == Texture::Type::CUBEMAP)
{ {
std::string sideNames[6] = {"posx", "negx", "posy", "negy", "posz", "negz"}; std::string sideNames[6] = {"posx", "negx", "posy", "negy", "posz", "negz"};
......
...@@ -63,6 +63,13 @@ protected: ...@@ -63,6 +63,13 @@ protected:
/// ///
vtkSmartPointer<vtkTexture> getTexture() const; vtkSmartPointer<vtkTexture> getTexture() const;
///
/// \brief Return the VTK texture name
///
/// \returns VTK texture
///
const std::string& getTextureName() const;
/// ///
/// \brief Implementation of texture loading /// \brief Implementation of texture loading
/// ///
...@@ -70,6 +77,7 @@ protected: ...@@ -70,6 +77,7 @@ protected:
vtkSmartPointer<vtkTexture> m_sourceTexture; ///< VTK texture vtkSmartPointer<vtkTexture> m_sourceTexture; ///< VTK texture
std::string m_textureName; ///< VTK texture unique name
}; };
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment