#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;
}

View File

@@ -42,9 +42,9 @@ public:
static std::vector<VdeExportPart> partsForExport(const RimGridView& view);
private:
static void partsForExport(const RimGridView* view, cvf::Collection<cvf::Part>* partCollection);
static QString gridCellSetTypeText(RivCellSetEnum cellSetType);
static bool isGrid(const cvf::Part* part);
static bool isPipe(const cvf::Part* part);
static bool isMeshLines(const cvf::Part* part);
};

View File

@@ -31,6 +31,14 @@ VdeExportPart::VdeExportPart(cvf::Part* part)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void VdeExportPart::setTextureImage(const cvf::TextureImage* textureImage)
{
m_textureImage = textureImage;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -111,6 +119,14 @@ const cvf::Part* VdeExportPart::part() const
return m_part.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const cvf::TextureImage* VdeExportPart::textureImage() const
{
return m_textureImage.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -126,3 +142,11 @@ float VdeExportPart::opacity() const
{
return m_opacity;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
VdeExportPart::Winding VdeExportPart::winding() const
{
return m_winding;
}

View File

@@ -21,6 +21,7 @@
#include "cvfBase.h"
#include "cvfObject.h"
#include "cvfPart.h"
#include "cvfTextureImage.h"
#include <QString>
@@ -47,6 +48,7 @@ public:
public:
VdeExportPart(cvf::Part* part);
void setTextureImage(const cvf::TextureImage* textureImage);
void setSourceObjectType(SourceObjectType sourceObjectType);
void setSourceObjectName(const QString& sourceObjectName);
void setSourceObjectCellSetType(const QString& sourceObjectCellSetType);
@@ -54,7 +56,9 @@ public:
void setOpacity(float opacity);
void setWinding(Winding winding);
const cvf::Part* part() const;
const cvf::Part* part() const;
const cvf::TextureImage* textureImage() const;
QString sourceObjectName() const;
QString sourceObjectCellSetType() const;
SourceObjectType sourceObjectType() const;
@@ -63,7 +67,8 @@ public:
Winding winding() const;
private:
cvf::cref<cvf::Part> m_part;
cvf::cref<cvf::Part> m_part;
cvf::cref<cvf::TextureImage> m_textureImage;
QString m_sourceObjectName;
QString m_sourceObjectCellSetType;