#168 Merged in parallel projection

This commit is contained in:
Jacob Støren
2016-08-16 23:20:33 +02:00
26 changed files with 9904 additions and 26 deletions

View File

@@ -41,6 +41,7 @@ ${CEE_CURRENT_LIST_DIR}RicComputeStatisticsFeature.h
${CEE_CURRENT_LIST_DIR}RicWellLogsImportFileFeature.h
${CEE_CURRENT_LIST_DIR}RicTogglePerspectiveViewFeature.h
${CEE_CURRENT_LIST_DIR}RicTileWindowsFeature.h
${CEE_CURRENT_LIST_DIR}RicTilePlotWindowsFeature.h
${CEE_CURRENT_LIST_DIR}RicShowPlotWindowFeature.h
@@ -92,6 +93,7 @@ ${CEE_CURRENT_LIST_DIR}RicCreateGridCaseGroupFeature.cpp
${CEE_CURRENT_LIST_DIR}RicNewStatisticsCaseFeature.cpp
${CEE_CURRENT_LIST_DIR}RicComputeStatisticsFeature.cpp
${CEE_CURRENT_LIST_DIR}RicTogglePerspectiveViewFeature.cpp
${CEE_CURRENT_LIST_DIR}RicTileWindowsFeature.cpp
${CEE_CURRENT_LIST_DIR}RicTilePlotWindowsFeature.cpp
${CEE_CURRENT_LIST_DIR}RicShowPlotWindowFeature.cpp

View File

@@ -0,0 +1,72 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicTogglePerspectiveViewFeature.h"
#include "RiuViewer.h"
#include "RimView.h"
#include "RiuMainWindow.h"
#include "RiaApplication.h"
#include <QAction>
CAF_CMD_SOURCE_INIT(RicTogglePerspectiveViewFeature, "RicTogglePerspectiveViewFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicTogglePerspectiveViewFeature::isCommandEnabled()
{
this->action(); // Retrieve the action to update the looks
return RiaApplication::instance()->activeReservoirView() && RiaApplication::instance()->activeReservoirView()->viewer();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicTogglePerspectiveViewFeature::onActionTriggered(bool isChecked)
{
if(RiaApplication::instance()->activeReservoirView() && RiaApplication::instance()->activeReservoirView()->viewer())
{
bool isPerspective = RiaApplication::instance()->activeReservoirView()->isPerspectiveView();
RiaApplication::instance()->activeReservoirView()->isPerspectiveView = !isPerspective;
RiaApplication::instance()->activeReservoirView()->viewer()->enableParallelProjection(isPerspective);
RiaApplication::instance()->activeReservoirView()->isPerspectiveView.uiCapability()->updateConnectedEditors();
this->action(); // Retrieve the action to update the looks
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicTogglePerspectiveViewFeature::setupActionLook(QAction* actionToSetup)
{
if(RiaApplication::instance()->activeReservoirView() && RiaApplication::instance()->activeReservoirView()->viewer())
{
if (RiaApplication::instance()->activeReservoirView()->isPerspectiveView())
{
actionToSetup->setText("Parallel View");
actionToSetup->setIcon(QIcon(":/Parallel16x16.png"));
return;
}
}
actionToSetup->setText("Perspective View");
actionToSetup->setIcon(QIcon(":/Perspective16x16.png"));
}

View File

@@ -0,0 +1,39 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016- Statoil ASA
// Copyright (C) 2016- Ceetron Solutions AS
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafCmdFeature.h"
//==================================================================================================
///
//==================================================================================================
class RicTogglePerspectiveViewFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
virtual bool isCommandEnabled();
virtual void onActionTriggered( bool isChecked );
virtual void setupActionLook( QAction* actionToSetup );
};

View File

@@ -135,12 +135,24 @@ void RivGridBoxGenerator::updateFromCamera(const cvf::Camera* camera)
std::vector<bool> faceVisibility(6, false);
for (size_t i = POS_X; i <= NEG_Z; i++)
{
bool isFaceVisible = false;
cvf::Vec3f sideNorm = sideNormalOutwards((FaceType)i);
cvf::Vec3d camToSide = camera->position() - pointOnSide((FaceType)i);
camToSide.normalize();
if (camera->projection() == cvf::Camera::PERSPECTIVE)
{
if (sideNorm.dot(cvf::Vec3f(camToSide)) < 0.0)
cvf::Vec3d camToSide = camera->position() - pointOnSide((FaceType)i);
camToSide.normalize();
isFaceVisible = sideNorm.dot(cvf::Vec3f(camToSide)) < 0.0;
}
else
{
cvf::Vec3d camToSide = camera->direction();
isFaceVisible = sideNorm.dot(cvf::Vec3f(camToSide)) > 0.0;
}
if (isFaceVisible)
{
m_gridBoxModel->addPart(m_gridBoxFaceParts[i].p());
faceVisibility[i] = true;

View File

@@ -35,6 +35,7 @@
#include <QFile>
#include <QTextStream>
#include "cvfUniform.h"
//--------------------------------------------------------------------------------------------------
@@ -196,6 +197,8 @@ void CellEdgeEffectGenerator::updateForShaderBasedRendering(cvf::Effect* effect)
cvf::ref<cvf::ShaderProgram> prog = shaderGen.generate();
eff->setShaderProgram(prog.p());
if(!m_disableLighting) prog->setDefaultUniform(new cvf::UniformFloat("u_ecLightPosition", cvf::Vec3f(0.5, 5.0, 7.0)));
// Set up textures
m_edgeTextureImage = new cvf::TextureImage;

View File

@@ -32,6 +32,7 @@
#include "cvfShaderSourceProvider.h"
#include "cvfTexture.h"
#include "cvfTexture2D_FF.h"
#include "cvfUniform.h"
@@ -81,6 +82,8 @@ void RivTernaryScalarMapperEffectGenerator::updateForShaderBasedRendering(cvf::E
cvf::ref<cvf::ShaderProgram> prog = gen.generate();
eff->setShaderProgram(prog.p());
if(!m_disableLighting) prog->setDefaultUniform(new cvf::UniformFloat("u_ecLightPosition", cvf::Vec3f(0.5, 5.0, 7.0)));
// Result mapping texture
m_textureImage = new cvf::TextureImage();

View File

@@ -75,11 +75,14 @@ RimView::RimView(void)
CAF_PDM_InitField(&showWindow, "ShowWindow", true, "Show 3D viewer", "", "", "");
showWindow.uiCapability()->setUiHidden(true);
CAF_PDM_InitField(&cameraPosition, "CameraPosition", cvf::Mat4d::IDENTITY, "", "", "", "");
cameraPosition.uiCapability()->setUiHidden(true);
CAF_PDM_InitField(&cameraPointOfInterest, "CameraPointOfInterest", cvf::Vec3d::ZERO, "", "", "", "");
cameraPointOfInterest.uiCapability()->setUiHidden(true);
CAF_PDM_InitField(&isPerspectiveView, "PerspectiveProjection", true, "Perspective Projection", "", "", "");
isPerspectiveView.uiCapability()->setUiHidden(true); // For now as this is experimental
double defaultScaleFactor = preferences->defaultScaleFactorZ;
CAF_PDM_InitField(&scaleZ, "GridZScale", defaultScaleFactor, "Z Scale", "", "Scales the scene in the Z direction", "");
@@ -216,7 +219,12 @@ void RimView::updateViewerWidget()
RiuMainWindow::instance()->setActiveViewer(m_viewer->layoutWidget());
if (isViewerCreated) m_viewer->mainCamera()->setViewMatrix(cameraPosition);
if(isViewerCreated)
{
m_viewer->mainCamera()->setViewMatrix(cameraPosition);
m_viewer->setPointOfInterest(cameraPointOfInterest());
m_viewer->enableParallelProjection(!isPerspectiveView());
}
m_viewer->mainCamera()->viewport()->setClearColor(cvf::Color4f(backgroundColor()));
this->updateGridBoxData();
@@ -322,6 +330,7 @@ void RimView::createDisplayModelAndRedraw()
{
setDefaultView();
cameraPosition = m_viewer->mainCamera()->viewMatrix();
cameraPointOfInterest = m_viewer->pointOfInterest();
}
}
@@ -360,6 +369,7 @@ void RimView::setupBeforeSave()
{
hasUserRequestedAnimation = m_viewer->isAnimationActive(); // JJS: This is not conceptually correct. The variable is updated as we go, and store the user intentions. But I guess that in practice...
cameraPosition = m_viewer->mainCamera()->viewMatrix();
cameraPointOfInterest = m_viewer->pointOfInterest();
setMdiWindowGeometry(RiuMainWindow::instance()->windowGeometryForViewer(m_viewer->layoutWidget()));
}

View File

@@ -25,6 +25,7 @@
#include "cafPdmField.h"
#include "cafPdmFieldCvfColor.h"
#include "cafPdmFieldCvfMat4d.h"
#include "cafPdmFieldCvfVec3d.h"
#include "cafPdmObject.h"
#include "RivCellSetEnum.h"
@@ -79,6 +80,7 @@ public:
caf::PdmField<bool> showWindow;
caf::PdmField<cvf::Mat4d> cameraPosition;
caf::PdmField<cvf::Vec3d> cameraPointOfInterest;
caf::PdmField<bool> isPerspectiveView;
caf::PdmField< cvf::Color3f > backgroundColor;

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 367 B

View File

@@ -61,6 +61,8 @@
<file>SummaryPlots16x16.png</file>
<file>SummaryCurve16x16.png</file>
<file>SummaryCurveFilter16x16.png</file>
<file>Parallel16x16.png</file>
<file>Perspective16x16.png</file>
</qresource>
<qresource prefix="/Shader/">

View File

@@ -514,6 +514,7 @@ void RiuMainWindow::createToolBars()
// View toolbar
m_viewToolBar = addToolBar(tr("View"));
m_viewToolBar->setObjectName(m_viewToolBar->windowTitle());
m_viewToolBar->addAction(cmdFeatureMgr->action("RicTogglePerspectiveViewFeature"));
m_viewToolBar->addAction(m_zoomAll);
m_viewToolBar->addAction(m_viewFromNorth);
m_viewToolBar->addAction(m_viewFromSouth);
@@ -723,7 +724,7 @@ void RiuMainWindow::slotRefreshViewActions()
updateScaleValue();
caf::CmdFeatureManager::instance()->refreshEnabledState(QStringList() << "RicLinkVisibleViewsFeature" << "RicTileWindowsFeature");
caf::CmdFeatureManager::instance()->refreshEnabledState(QStringList() << "RicLinkVisibleViewsFeature" << "RicTileWindowsFeature" << "RicTogglePerspectiveViewFeature");
}
//--------------------------------------------------------------------------------------------------

View File

@@ -183,6 +183,7 @@ RiuViewer::~RiuViewer()
m_rimView->uiCapability()->updateUiIconFromToggleField();
m_rimView->cameraPosition = m_mainCamera->viewMatrix();
m_rimView->cameraPointOfInterest = pointOfInterest();
}
delete m_infoLabel;
delete m_animationProgress;

View File

@@ -67,18 +67,18 @@ static const char light_AmbientDiffuse_inl[] =
" \n"
"varying vec3 v_ecPosition; \n"
"varying vec3 v_ecNormal; \n"
"uniform vec3 u_ecLightPosition; \n"
" \n"
"//-------------------------------------------------------------------------------------------------- \n"
"/// lightFragment() - Simple Headlight without Phong/specular component \n"
"/// lightFragment() - Simple Positional Headlight without Phong/specular component \n"
"/// \n"
"//-------------------------------------------------------------------------------------------------- \n"
"vec4 lightFragment(vec4 srcFragColor, float not_in_use_shadowFactor) \n"
"{ \n"
" const vec3 ecLightPosition = vec3(0.5, 5.0, 7.0); \n"
" const float ambientIntensity = 0.2; \n"
" \n"
" // Light vector (from point to light source) \n"
" vec3 L = normalize(ecLightPosition - v_ecPosition); \n"
" vec3 L = normalize(u_ecLightPosition - v_ecPosition); \n"
" \n"
" // Viewing vector (from point to eye) \n"
" // Since we are in eye space, the eye pos is at (0, 0, 0) \n"
@@ -101,7 +101,6 @@ cvf::String CommonShaderSources::light_AmbientDiffuse()
return cvf::String(light_AmbientDiffuse_inl);
}
//--------------------------------------------------------------------------------------------------
/// Static helper to configure polygon offset render state from enum
//--------------------------------------------------------------------------------------------------
@@ -283,11 +282,12 @@ void SurfaceEffectGenerator::updateForShaderBasedRendering(cvf::Effect* effect)
}
cvf::ref<cvf::ShaderProgram> shaderProg = gen.generate();
if (m_enableLighting) shaderProg->setDefaultUniform(new cvf::UniformFloat("u_ecLightPosition", cvf::Vec3f(0.5, 5.0, 7.0)));
cvf::ref<cvf::Effect> eff = effect;
eff->setShaderProgram(shaderProg.p());
eff->setUniform(new cvf::UniformFloat("u_color", m_color));
this->updateCommonEffect(effect);
}
@@ -443,6 +443,8 @@ void ScalarMapperEffectGenerator::updateForShaderBasedRendering(cvf::Effect* eff
cvf::ref<cvf::ShaderProgram> prog = gen.generate();
eff->setShaderProgram(prog.p());
if(!m_disableLighting) prog->setDefaultUniform(new cvf::UniformFloat("u_ecLightPosition", cvf::Vec3f(0.5, 5.0, 7.0)));
// Result mapping texture
m_textureImage = new cvf::TextureImage();

View File

@@ -189,7 +189,10 @@ bool caf::CeetronPlusNavigation::handleInputEvent(QInputEvent* inputEvent)
initializeRotationCenter();
if (m_isRotCenterInitialized)
{
QWheelEvent* we = static_cast<QWheelEvent*> ( inputEvent);
#if 0
int translatedMousePosX = we->x();
int translatedMousePosY = m_viewer->height() - we->y();
int delta = we->delta();
@@ -199,8 +202,13 @@ bool caf::CeetronPlusNavigation::handleInputEvent(QInputEvent* inputEvent)
ray = m_viewer->mainCamera()->rayFromWindowCoordinates(translatedMousePosX, translatedMousePosY);
else
ray = m_viewer->mainCamera()->rayFromWindowCoordinates((int)(1.0*translatedMousePosX), (int)(1.0*translatedMousePosY));
#endif
zoomAlongRay(ray.p(), delta);
int cvfEvPosX, cvfEvPosY;
cvfEventPos(we->x(), we->y(), &cvfEvPosX, &cvfEvPosY);
cvf::ref<cvf::Ray> ray = createZoomRay(cvfEvPosX, cvfEvPosY);
zoomAlongRay(ray.p(), we->delta());
}
isEventHandled = true;

View File

@@ -159,6 +159,43 @@ void caf::TrackBallBasedNavigation::zoomAlongRay(cvf::Ray* ray, int delta)
m_viewer->mainCamera()->setFromLookAt(newPos, newVrp, up );
m_viewer->updateParallelProjectionHeightFromMoveZoom(m_pointOfInterest);
m_viewer->updateParallelProjectionCameraPosFromPointOfInterestMove(m_pointOfInterest);
m_viewer->navigationPolicyUpdate();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void caf::TrackBallBasedNavigation::cvfEventPos(int qtX, int qtY, int* cvfX, int* cvfY)
{
*cvfX = qtX;
*cvfY = m_viewer->height() - qtY;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::Ray> caf::TrackBallBasedNavigation::createZoomRay(int cvfXPos, int cvfYPos)
{
cvf::ref<cvf::Ray> ray;
cvf::Camera* cam = m_viewer->mainCamera();
ray = cam->rayFromWindowCoordinates(cvfXPos, cvfYPos);
if (cam->projection() == cvf::Camera::ORTHO)
{
cvf::Vec3d camDir = cam->direction();
cvf::Plane focusPlane;
focusPlane.setFromPointAndNormal(m_pointOfInterest, -camDir);
cvf::Vec3d intersectionPoint;
ray->planeIntersect(focusPlane, &intersectionPoint);
cvf::ref<cvf::Ray> orthoZoomRay = new cvf::Ray();
orthoZoomRay->setOrigin(cam->position());
orthoZoomRay->setDirection((intersectionPoint - cam->position()).getNormalized());
ray = orthoZoomRay;
}
return ray;
}

View File

@@ -77,7 +77,10 @@ protected:
bool m_isNavigating;
bool m_hasMovedMouseDuringNavigation;
void cvfEventPos(int qtX, int qtY, int* x, int* y);
// Zooming towards cursor
cvf::ref<cvf::Ray> createZoomRay(int cvfXPos, int cvfYPos);
void zoomAlongRay( cvf::Ray* ray, int delta );
bool m_isZooming;
cvf::ref<cvf::Ray> m_zoomRay;

View File

@@ -45,6 +45,7 @@
#include "cvfDebugTimer.h"
#include "cvfDrawable.h"
#include "cvfDrawableGeo.h"
#include "cvfDynamicUniformSet.h"
#include "cvfHitItemCollection.h"
#include "cvfManipulatorTrackball.h"
#include "cvfModel.h"
@@ -59,6 +60,8 @@
#include "cvfScene.h"
#include "cvfTextureImage.h"
#include "cvfTransform.h"
#include "cvfUniform.h"
#include "cvfUniformSet.h"
#include "cvfqtOpenGLContext.h"
#include "cvfqtPerformanceInfoHud.h"
@@ -68,6 +71,34 @@
#include <QHBoxLayout>
#include <QInputEvent>
namespace caf
{
class GlobalViewerDynUniformSet: public cvf::DynamicUniformSet
{
public:
GlobalViewerDynUniformSet()
{
m_headlightPosition = new cvf::UniformFloat("u_ecLightPosition", cvf::Vec3f(0.5, 5.0, 7.0));
m_uniformSet = new cvf::UniformSet();
m_uniformSet->setUniform(m_headlightPosition.p());
}
virtual ~GlobalViewerDynUniformSet() {}
void setHeadLightPosition(const cvf::Vec3f posRelativeToCamera) { m_headlightPosition->set(posRelativeToCamera);}
virtual cvf::UniformSet* uniformSet() { return m_uniformSet.p(); }
virtual void update(cvf::Rendering* rendering){};
private:
cvf::ref<cvf::UniformSet> m_uniformSet;
cvf::ref<cvf::UniformFloat> m_headlightPosition;
};
}
std::list<caf::Viewer*> caf::Viewer::sm_viewers;
cvf::ref<cvf::OpenGLContextGroup> caf::Viewer::sm_openGLContextGroup;
@@ -98,9 +129,13 @@ caf::Viewer::Viewer(const QGLFormat& format, QWidget* parent)
// Needed to get keystrokes
setFocusPolicy(Qt::ClickFocus);
m_globalUniformSet = new GlobalViewerDynUniformSet();
m_mainCamera = new cvf::Camera;
m_mainCamera->setFromLookAt(cvf::Vec3d(0,0,-1), cvf::Vec3d(0,0,0), cvf::Vec3d(0,1,0));
m_renderingSequence = new cvf::RenderSequence();
m_renderingSequence->setDefaultFFLightPositional(cvf::Vec3f(0.5, 5.0, 7.0));
m_mainRendering = new cvf::Rendering();
m_animationControl = new caf::FrameAnimationControl(this);
@@ -141,6 +176,7 @@ void caf::Viewer::setupMainRendering()
{
m_mainRendering->setCamera(m_mainCamera.p());
m_mainRendering->setRenderQueueSorter(new cvf::RenderQueueSorterBasic(cvf::RenderQueueSorterBasic::EFFECT_ONLY));
m_mainRendering->addGlobalDynamicUniformSet(m_globalUniformSet.p());
// Set fixed function rendering if QGLFormat does not support directRendering
if (!this->format().directRendering())
@@ -265,11 +301,62 @@ void caf::Viewer::optimizeClippingPlanes()
cvf::BoundingBox bb = m_renderingSequence->boundingBox();
if (!bb.isValid()) return;
cvf::Vec3d eye, vrp, up;
m_mainCamera->toLookAt(&eye, &vrp, &up);
cvf::Vec3d eye = m_mainCamera->position();
cvf::Vec3d viewdir = m_mainCamera->direction();
cvf::Vec3d viewdir = (vrp - eye).getNormalized();
cvf::Vec3d bboxCorners[8];
bb.cornerVertices(bboxCorners);
// Find the distance to the bbox corners most behind and most in front of camera
double maxDistEyeToCornerAlongViewDir = -HUGE_VAL;
double minDistEyeToCornerAlongViewDir = HUGE_VAL;
for (int bcIdx = 0; bcIdx < 8; ++bcIdx )
{
double distEyeBoxCornerAlongViewDir = (bboxCorners[bcIdx] - eye)*viewdir;
if (distEyeBoxCornerAlongViewDir > maxDistEyeToCornerAlongViewDir)
{
maxDistEyeToCornerAlongViewDir = distEyeBoxCornerAlongViewDir;
}
if (distEyeBoxCornerAlongViewDir < minDistEyeToCornerAlongViewDir)
{
minDistEyeToCornerAlongViewDir = distEyeBoxCornerAlongViewDir; // Sometimes negative-> behind camera
}
}
double farPlaneDist = CVF_MIN(maxDistEyeToCornerAlongViewDir * 1.2, m_maxFarPlaneDistance);
// Near-plane:
bool isOrthoNearPlaneFollowingCamera = false;
double nearPlaneDist = HUGE_VAL;
// If we have perspective projection, set the near plane just in front of camera, and not behind
if (m_mainCamera->projection() == cvf::Camera::PERSPECTIVE || isOrthoNearPlaneFollowingCamera)
{
nearPlaneDist = CVF_MAX( m_minNearPlaneDistance, minDistEyeToCornerAlongViewDir);
if (m_navigationPolicy.notNull() && m_navigationPolicyEnabled)
{
double pointOfInterestDist = (eye - m_navigationPolicy->pointOfInterest()).length();
nearPlaneDist = CVF_MIN(nearPlaneDist, pointOfInterestDist*0.2);
}
}
else // Orthographic projection. Set to encapsulate the complete boundingbox, possibly setting a negative nearplane
{
if(minDistEyeToCornerAlongViewDir >= 0)
{
nearPlaneDist = CVF_MIN(0.8 * minDistEyeToCornerAlongViewDir, m_maxFarPlaneDistance);
}
else
{
nearPlaneDist = CVF_MAX(1.2 * minDistEyeToCornerAlongViewDir, -m_maxFarPlaneDistance);
}
}
#if 0
double distEyeBoxCenterAlongViewDir = (bb.center() - eye)*viewdir;
double farPlaneDist = distEyeBoxCenterAlongViewDir + bb.radius() * 1.2;
@@ -282,6 +369,7 @@ void caf::Viewer::optimizeClippingPlanes()
double pointOfInterestDist = (eye - m_navigationPolicy->pointOfInterest()).length();
nearPlaneDist = CVF_MIN(nearPlaneDist, pointOfInterestDist*0.2);
}
#endif
if (farPlaneDist <= nearPlaneDist) farPlaneDist = nearPlaneDist + 1.0;
@@ -536,7 +624,10 @@ void caf::Viewer::zoomAll()
cvf::Vec3d eye, vrp, up;
m_mainCamera->toLookAt(&eye, &vrp, &up);
m_mainCamera->fitView(bb, vrp-eye, up);
cvf::Vec3d newEye = m_mainCamera->computeFitViewEyePosition(bb, vrp-eye, up, 0.9, m_cameraFieldOfViewYDeg, m_mainCamera->viewport()->aspectRatio());
m_mainCamera->setFromLookAt(newEye, bb.center(), up);
updateParallelProjectionHeightFromMoveZoom(bb.center());
navigationPolicyUpdate();
}
@@ -946,6 +1037,11 @@ void caf::Viewer::enableParallelProjection(bool enableOrtho)
m_mainCamera->setProjectionAsOrtho(1.0, m_mainCamera->nearPlane(), m_mainCamera->farPlane());
this->updateParallelProjectionHeightFromMoveZoom(pointOfInterest);
// Set the light position behind us, far away from the scene
float sceneDepth = m_mainCamera->farPlane() - m_mainCamera->nearPlane();
this->m_renderingSequence->setDefaultFFLightPositional(cvf::Vec3f(0,0, 2 * sceneDepth));
m_globalUniformSet->setHeadLightPosition(cvf::Vec3f(0,0, 2 * sceneDepth));
this->update();
}
else if (!enableOrtho && m_mainCamera->projection() == cvf::Camera::ORTHO)
@@ -954,7 +1050,12 @@ void caf::Viewer::enableParallelProjection(bool enableOrtho)
// so we do not need to update the camera position based on orthoHeight and fieldOfView.
// We assume the camera is in a sensible position.
m_mainCamera->setProjectionAsPerspective(m_cameraFieldOfViewYDeg, m_mainCamera->nearPlane(), m_mainCamera->farPlane());
// Set dummy near and far plane. These wll be updated by the optimize clipping planes
m_mainCamera->setProjectionAsPerspective(m_cameraFieldOfViewYDeg, 0.1, 1.0);
this->m_renderingSequence->setDefaultFFLightPositional(cvf::Vec3f(0.5, 5.0, 7.0));
m_globalUniformSet->setHeadLightPosition(cvf::Vec3f(0.5, 5.0, 7.0));
this->update();
}
}
@@ -971,7 +1072,7 @@ double calculateOrthoHeight(double perspectiveViewAngleYDeg, double focusPlaneDi
///
//--------------------------------------------------------------------------------------------------
double calculateDistToPlaneOfInterest(double perspectiveViewAngleYDeg, double orthoHeight)
double calculateDistToPlaneOfOrthoHeight(double perspectiveViewAngleYDeg, double orthoHeight)
{
return orthoHeight / (2 * (cvf::Math::tan( cvf::Math::toRadians(0.5 * perspectiveViewAngleYDeg) )));
}
@@ -1009,8 +1110,9 @@ void caf::Viewer::updateParallelProjectionHeightFromMoveZoom(const cvf::Vec3d& p
if (!camera || camera->projection() != Camera::ORTHO) return;
// Negative distance can occur. If so, do not set a negative ortho.
double distToFocusPlane = distToPlaneOfInterest(camera, pointOfInterest);
double distToFocusPlane = cvf::Math::abs( distToPlaneOfInterest(camera, pointOfInterest));
double orthoHeight = calculateOrthoHeight(m_cameraFieldOfViewYDeg, distToFocusPlane);
@@ -1032,7 +1134,7 @@ void caf::Viewer::updateParallelProjectionCameraPosFromPointOfInterestMove(const
double orthoHeight = camera->frontPlaneFrustumHeight();
//Trace::show(String::number(orthoHeight));
double neededDistToFocusPlane = calculateDistToPlaneOfInterest(m_cameraFieldOfViewYDeg, orthoHeight);
double neededDistToFocusPlane = calculateDistToPlaneOfOrthoHeight(m_cameraFieldOfViewYDeg, orthoHeight);
Vec3d eye, vrp, up;
camera->toLookAt(&eye, &vrp, &up);

View File

@@ -73,6 +73,7 @@ class QInputEvent;
namespace caf
{
class GlobalViewerDynUniformSet;
class Viewer : public caf::OpenGLWidget
{
@@ -219,6 +220,10 @@ private:
caf::FrameAnimationControl* m_animationControl;
cvf::Collection<cvf::Scene> m_frameScenes;
cvf::Collection<cvf::Model> m_staticModels;
// Parallel projection light modification
cvf::ref<GlobalViewerDynUniformSet> m_globalUniformSet;
};
} // End namespace caf

View File

@@ -541,7 +541,7 @@ void WBTransparencySurfaceEffectGenerator::initStaticData()
m_depth->enableDepthWrite(false);
m_renderPassUniform = new UniformInt("isOpaquePass", 1);
m_cameraNearUniform = new UniformFloat("cameraNear", 0.01);
m_cameraNearUniform = new UniformFloat("cameraNear", 0.01f);
m_cameraFarUniform = new UniformFloat("cameraFar",1000);
}

View File

@@ -59,8 +59,10 @@ namespace cvf {
//------------------------------------------------------------------------------------------------
///
//------------------------------------------------------------------------------------------------
RenderSequence::RenderSequence()
RenderSequence::RenderSequence()
: m_defaultGlLightPosition(0.5, 5.0, 7.0, 1.0) // Positional Headlight right, up, back from camera
{
}
@@ -234,6 +236,25 @@ BoundingBox RenderSequence::boundingBox() const
}
//--------------------------------------------------------------------------------------------------
/// Todo: Replace with some renderstate object etc.
//--------------------------------------------------------------------------------------------------
void RenderSequence::setDefaultFFLightPositional(const Vec3f& position)
{
m_defaultGlLightPosition = Vec4f(position, 1.0);
}
//--------------------------------------------------------------------------------------------------
/// Todo: Replace with some renderstate object etc.
//--------------------------------------------------------------------------------------------------
void RenderSequence::setDefaultFFLightDirectional(const Vec3f& direction)
{
// The fourth value= 0.0 makes the light become a directional one,
// with direction from the position towards origo.
m_defaultGlLightPosition = Vec4f(-direction, 0.0);
}
//--------------------------------------------------------------------------------------------------
/// Get the performance info for the last rendering (last call to render()).
//--------------------------------------------------------------------------------------------------
@@ -291,7 +312,7 @@ void RenderSequence::deleteOrReleaseOpenGLResources(OpenGLContext* oglContext)
/// in this function, but rather the ones that are likely to have been set by our caller and that
/// are likely to affect our rendering.
//--------------------------------------------------------------------------------------------------
void RenderSequence::preRenderApplyExpectedOpenGLState(OpenGLContext* oglContext)
void RenderSequence::preRenderApplyExpectedOpenGLState(OpenGLContext* oglContext) const
{
CVF_CALLSITE_OPENGL(oglContext);
CVF_CHECK_OGL(oglContext);
@@ -341,8 +362,8 @@ void RenderSequence::preRenderApplyExpectedOpenGLState(OpenGLContext* oglContext
// TODO Work out a proper solution for this
// Should probably add some RenderState that encapsulates a light source
const Vec4f lightPosition(0.5f, 5.0f, 7.0f, 1.0f);
glLightfv(GL_LIGHT0, GL_POSITION, lightPosition.ptr());
glLightfv(GL_LIGHT0, GL_POSITION, m_defaultGlLightPosition.ptr());
const Vec3f spotDirection(0.0f, 0.0f, -1.0f);
glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, spotDirection.ptr());

View File

@@ -70,17 +70,21 @@ public:
BoundingBox boundingBox() const;
void setDefaultFFLightPositional(const Vec3f& position);
void setDefaultFFLightDirectional(const Vec3f& direction);
void render(OpenGLContext* oglContext);
const PerformanceInfo& performanceInfo() const;
void deleteOrReleaseOpenGLResources(OpenGLContext* oglContext);
private:
static void preRenderApplyExpectedOpenGLState(OpenGLContext* oglContext);
void preRenderApplyExpectedOpenGLState(OpenGLContext* oglContext) const;
private:
Collection<Rendering> m_renderings; // One rendering per render pass
PerformanceInfo m_performanceInfo; // Performance summary for this view
Vec4f m_defaultGlLightPosition; // Fixed function default setting for glLightfv(GL_LIGHT0, GL_POSITION, m_defaultGlLightPosition.ptr());
};
}

2
ResInsight_HOST.config Normal file
View File

@@ -0,0 +1,2 @@
// Add predefined macros for your project here. For example:
// #define THE_ANSWER 42

1
ResInsight_HOST.creator Normal file
View File

@@ -0,0 +1 @@
[General]

9407
ResInsight_HOST.files Normal file

File diff suppressed because it is too large Load Diff

139
ResInsight_HOST.includes Normal file
View File

@@ -0,0 +1,139 @@
ApplicationCode/Adm
ApplicationCode/Application
ApplicationCode/Commands
ApplicationCode/Commands/CrossSectionCommands
ApplicationCode/Commands/OctaveScriptCommands
ApplicationCode/Commands/OperationsUsingObjReferences
ApplicationCode/Commands/SummaryPlotCommands
ApplicationCode/Commands/ToggleCommands
ApplicationCode/Commands/ViewLink
ApplicationCode/Commands/WellLogCommands
ApplicationCode/Commands/WellPathCommands
ApplicationCode/FileInterface
ApplicationCode/GeoMech/GeoMechDataModel
ApplicationCode/GeoMech/GeoMechVisualization
ApplicationCode/GeoMech/OdbReader
ApplicationCode/ModelVisualization
ApplicationCode/ModelVisualization/GridBox
ApplicationCode/ProjectDataModel
ApplicationCode/ReservoirDataModel
ApplicationCode/ResultStatisticsCache
ApplicationCode/SocketInterface
ApplicationCode/UserInterface
ApplicationCode/WellPathImportSsihub
ApplicationCode/WellPathImportSsihubTestApp
Fwk/AppFwk/cafAnimControl
Fwk/AppFwk/cafCommand
Fwk/AppFwk/cafCommand/defaultfeatures
Fwk/AppFwk/cafPdmCvf
Fwk/AppFwk/cafPdmCvf/cafPdmCvf_UnitTests/gtest
Fwk/AppFwk/cafProjectDataModel
Fwk/AppFwk/cafProjectDataModel/cafPdmCore
Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests
Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/gtest
Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore
Fwk/AppFwk/cafProjectDataModel/cafPdmXml
Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/gtest
Fwk/AppFwk/cafProjectDataModel/cafProjectDataModel_UnitTests
Fwk/AppFwk/cafProjectDataModel/cafProjectDataModel_UnitTests/gtest
Fwk/AppFwk/cafTensor
Fwk/AppFwk/cafTests/cafTestApplication
Fwk/AppFwk/cafTests/cafTestCvfApplication
Fwk/AppFwk/cafUserInterface
Fwk/AppFwk/cafUserInterface/cafUserInterface_UnitTests/gtest
Fwk/AppFwk/cafViewer
Fwk/AppFwk/cafVizExtensions
Fwk/AppFwk/CommonCode
Fwk/VizFwk/LibCore
Fwk/VizFwk/LibFreeType
Fwk/VizFwk/LibGeometry
Fwk/VizFwk/LibGuiQt
Fwk/VizFwk/LibIo
Fwk/VizFwk/LibRegGrid2D
Fwk/VizFwk/LibRender
Fwk/VizFwk/LibRender/glew/GL
Fwk/VizFwk/LibStructGrid
Fwk/VizFwk/LibUtilities
Fwk/VizFwk/LibViewing
Fwk/VizFwk/ThirdParty/FreeType/builds/amiga/include/freetype/config
Fwk/VizFwk/ThirdParty/FreeType/builds/atari
Fwk/VizFwk/ThirdParty/FreeType/builds/unix
Fwk/VizFwk/ThirdParty/FreeType/builds/vms
Fwk/VizFwk/ThirdParty/FreeType/devel
Fwk/VizFwk/ThirdParty/FreeType/include
Fwk/VizFwk/ThirdParty/FreeType/include/freetype
Fwk/VizFwk/ThirdParty/FreeType/include/freetype/config
Fwk/VizFwk/ThirdParty/FreeType/include/freetype/internal
Fwk/VizFwk/ThirdParty/FreeType/include/freetype/internal/services
Fwk/VizFwk/ThirdParty/FreeType/src/autofit
Fwk/VizFwk/ThirdParty/FreeType/src/base
Fwk/VizFwk/ThirdParty/FreeType/src/bdf
Fwk/VizFwk/ThirdParty/FreeType/src/cache
Fwk/VizFwk/ThirdParty/FreeType/src/cff
Fwk/VizFwk/ThirdParty/FreeType/src/cid
Fwk/VizFwk/ThirdParty/FreeType/src/gxvalid
Fwk/VizFwk/ThirdParty/FreeType/src/gzip
Fwk/VizFwk/ThirdParty/FreeType/src/lzw
Fwk/VizFwk/ThirdParty/FreeType/src/otvalid
Fwk/VizFwk/ThirdParty/FreeType/src/pcf
Fwk/VizFwk/ThirdParty/FreeType/src/pfr
Fwk/VizFwk/ThirdParty/FreeType/src/psaux
Fwk/VizFwk/ThirdParty/FreeType/src/pshinter
Fwk/VizFwk/ThirdParty/FreeType/src/psnames
Fwk/VizFwk/ThirdParty/FreeType/src/raster
Fwk/VizFwk/ThirdParty/FreeType/src/sfnt
Fwk/VizFwk/ThirdParty/FreeType/src/smooth
Fwk/VizFwk/ThirdParty/FreeType/src/truetype
Fwk/VizFwk/ThirdParty/FreeType/src/type1
Fwk/VizFwk/ThirdParty/FreeType/src/type42
Fwk/VizFwk/ThirdParty/FreeType/src/winfonts
Fwk/VizFwk/ThirdParty/gtest
Fwk/VizFwk/Tools/Glsl2Include/src
OctavePlugin
ThirdParty/custom-opm-common/opm-common/opm/common/utility/platform_dependent
ThirdParty/custom-opm-parser/opm-parser/opm/json/cjson
ThirdParty/Ert/devel/libanalysis/include/ert/analysis
ThirdParty/Ert/devel/libanalysis/modules
ThirdParty/Ert/devel/libconfig/include/ert/config
ThirdParty/Ert/devel/libecl/include/ert/ecl
ThirdParty/Ert/devel/libecl_well/include/ert/ecl_well
ThirdParty/Ert/devel/libenkf/applications/ert_tui
ThirdParty/Ert/devel/libenkf/include/ert/enkf
ThirdParty/Ert/devel/libert_util/include/ert/util
ThirdParty/Ert/devel/libgeometry/include/ert/geometry
ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue
ThirdParty/Ert/devel/librms/include/ert/rms
ThirdParty/Ert/devel/libsched/applications/perturb_history
ThirdParty/Ert/devel/libsched/include/ert/sched
ThirdParty/Ert/devel/VisualStudio
ThirdParty/gtest
ThirdParty/Qwt/designer
ThirdParty/Qwt/examples/animation
ThirdParty/Qwt/examples/barchart
ThirdParty/Qwt/examples/bode
ThirdParty/Qwt/examples/controls
ThirdParty/Qwt/examples/cpuplot
ThirdParty/Qwt/examples/dials
ThirdParty/Qwt/examples/distrowatch
ThirdParty/Qwt/examples/event_filter
ThirdParty/Qwt/examples/friedberg
ThirdParty/Qwt/examples/itemeditor
ThirdParty/Qwt/examples/legends
ThirdParty/Qwt/examples/oscilloscope
ThirdParty/Qwt/examples/radio
ThirdParty/Qwt/examples/rasterview
ThirdParty/Qwt/examples/realtime
ThirdParty/Qwt/examples/refreshtest
ThirdParty/Qwt/examples/scatterplot
ThirdParty/Qwt/examples/spectrogram
ThirdParty/Qwt/examples/stockchart
ThirdParty/Qwt/examples/tvplot
ThirdParty/Qwt/playground/curvetracker
ThirdParty/Qwt/playground/graphicscale
ThirdParty/Qwt/playground/plotmatrix
ThirdParty/Qwt/playground/rescaler
ThirdParty/Qwt/playground/scaleengine
ThirdParty/Qwt/playground/svgmap
ThirdParty/Qwt/playground/timescale
ThirdParty/Qwt/src
ThirdParty/Qwt/textengines/mathml