#3343 Holo Lens : Add extraction of texture image

This commit is contained in:
Magne Sjaastad
2018-09-20 16:15:13 +02:00
parent 7adf7e1e31
commit e14a1300c5
4 changed files with 71 additions and 31 deletions

View File

@@ -35,38 +35,15 @@
#include "cafEffectGenerator.h"
#include "cvfPart.h"
#include "cvfRenderState.h"
#include "cvfRenderStateTextureBindings.h"
#include "cvfRenderState_FF.h"
#include "cvfScene.h"
#include "cvfTexture.h"
#include "cvfTexture2D_FF.h"
#include <QString>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicHoloLensExportImpl::partsForExport(const RimGridView* view, cvf::Collection<cvf::Part>* partCollection)
{
CVF_ASSERT(partCollection);
if (!view) return;
if (view->viewer())
{
cvf::Scene* scene = view->viewer()->mainScene();
if (scene)
{
cvf::Collection<cvf::Part> sceneParts;
scene->allParts(&sceneParts);
for (auto& scenePart : sceneParts)
{
if (RicHoloLensExportImpl::isGrid(scenePart.p()) || RicHoloLensExportImpl::isPipe(scenePart.p()))
{
partCollection->push_back(scenePart.p());
}
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -141,6 +118,32 @@ std::vector<VdeExportPart> RicHoloLensExportImpl::partsForExport(const RimGridVi
}
}
// Check if texture image is present
if (scenePart->effect())
{
{
auto textureBindings = dynamic_cast<cvf::RenderStateTextureBindings*>(
scenePart->effect()->renderStateOfType(cvf::RenderState::TEXTURE_BINDINGS));
if (textureBindings && textureBindings->bindingCount() > 0)
{
cvf::Texture* textureBinding = textureBindings->texture(0);
partForExport.setTextureImage(textureBinding->image());
}
}
{
auto textureMappingFF = dynamic_cast<cvf::RenderStateTextureMapping_FF*>(
scenePart->effect()->renderStateOfType(cvf::RenderState::TEXTURE_MAPPING_FF));
if (textureMappingFF && textureMappingFF->texture())
{
auto* texture = textureMappingFF->texture();
partForExport.setTextureImage(texture->image());
}
}
}
exportParts.push_back(partForExport);
}
else if (RicHoloLensExportImpl::isPipe(scenePart.p()))
@@ -284,3 +287,11 @@ bool RicHoloLensExportImpl::isPipe(const cvf::Part* part)
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicHoloLensExportImpl::isMeshLines(const cvf::Part* part)
{
return false;
}