summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@collabora.co.uk>2014-05-10 22:35:04 +0200
committerMarkus Mohrhard <markus.mohrhard@collabora.co.uk>2014-05-12 03:00:06 +0200
commitb53e1acde5130cab54ca064963c17683b69e8916 (patch)
tree4bd31719bb7bd66808d879774a934e972a96b00b /chart2
parent28e7d53826fd2eae8048173c46bdc4b33f7e7ba4 (diff)
keep camera calculations out of the rendering code
Change-Id: I7a26ce1881958a7465692174dd8ea793b593efad
Diffstat (limited to 'chart2')
-rw-r--r--chart2/source/view/inc/GL3DRenderer.hxx6
-rw-r--r--chart2/source/view/main/3DChartObjects.cxx2
-rw-r--r--chart2/source/view/main/GL3DRenderer.cxx44
3 files changed, 5 insertions, 47 deletions
diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index 8c574123e02e..9eb21b27a69b 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -113,14 +113,12 @@ struct Extrude3DInfo
struct CameraInfo
{
- bool useDefault;
glm::vec3 cameraPos;
glm::vec3 cameraOrg;
glm::vec3 cameraUp;
CameraInfo():
- useDefault(true),
- cameraUp(glm::vec3(0, 1, 0)) {}
+ cameraUp(glm::vec3(0, 0, 1)) {}
};
struct CoordinateAxisInfo
@@ -203,7 +201,7 @@ public:
void SetClickPos(Point aMPos);
void RenderClickPos(Point aMPos);
void SetSize(const Size& rSize);
- void SetCameraInfo(glm::vec3 pos, glm::vec3 direction, glm::vec3 up, bool useDefalut);
+ void SetCameraInfo(glm::vec3 pos, glm::vec3 direction, glm::vec3 up);
void CreateTextTexture(const BitmapEx& rBitmapEx, glm::vec3 vTopLeft,glm::vec3 vTopRight, glm::vec3 vBottomRight, glm::vec3 vBottomLeft);
void ProcessUnrenderedShape();
private:
diff --git a/chart2/source/view/main/3DChartObjects.cxx b/chart2/source/view/main/3DChartObjects.cxx
index a1fc5eef2227..08dab347b7ca 100644
--- a/chart2/source/view/main/3DChartObjects.cxx
+++ b/chart2/source/view/main/3DChartObjects.cxx
@@ -184,7 +184,7 @@ Camera::Camera(OpenGL3DRenderer* pRenderer):
void Camera::render()
{
- mpRenderer->SetCameraInfo(maPos, maDirection, maUp, false);
+ mpRenderer->SetCameraInfo(maPos, maDirection, maUp);
}
void Camera::zoom(sal_uInt32 /*nId*/)
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 4875241ebdeb..1c38333dc175 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -20,7 +20,6 @@
#include <StaticGeometry.h>
#include "glm/gtc/matrix_inverse.hpp"
-#define GL_PI 3.14159f
#define RGB_WHITE (0xFF | (0xFF << 8) | (0xFF << 16))
#define DEBUG_FBO 0
@@ -141,13 +140,8 @@ void OpenGL3DRenderer::LoadShaders()
CHECK_GL_ERROR();
}
-void OpenGL3DRenderer::SetCameraInfo(glm::vec3 pos, glm::vec3 direction, glm::vec3 up, bool useDefalut)
+void OpenGL3DRenderer::SetCameraInfo(glm::vec3 pos, glm::vec3 direction, glm::vec3 up)
{
- m_CameraInfo.useDefault = useDefalut;
- if (m_CameraInfo.useDefault)
- {
- return;
- }
m_CameraInfo.cameraPos = pos;
m_CameraInfo.cameraOrg = pos + direction;
m_CameraInfo.cameraUp = up;
@@ -1458,26 +1452,6 @@ void OpenGL3DRenderer::RenderClickPos(Point aMPos)
void OpenGL3DRenderer::CreateSceneBoxView()
{
- if (m_CameraInfo.useDefault)
- {
- float senceBoxWidth = m_SenceBox.maxXCoord - m_SenceBox.minXCoord;
- float senceBoxHeight = m_SenceBox.maxYCoord - m_SenceBox.minYCoord;
- float senceBoxDepth = m_SenceBox.maxZCoord - m_SenceBox.minZCoord;
- float distanceZ = m_SenceBox.maxZCoord + senceBoxWidth / 2 / tan(m_fViewAngle / 2 * GL_PI / 180.0f);
- float veriticalAngle = atan((float)m_iHeight / (float)m_iWidth);
- float distance = distanceZ / cos(veriticalAngle);
- float horizontalAngle = 0;
- m_fHeightWeight = senceBoxWidth * (float)m_iHeight / (float)m_iWidth / senceBoxHeight;
- m_SenceBox.maxYCoord *= m_fHeightWeight;
- m_SenceBox.minYCoord *= m_fHeightWeight;
- m_CameraInfo.cameraOrg = glm::vec3(m_SenceBox.minXCoord + senceBoxWidth / 2,
- m_SenceBox.minYCoord + senceBoxHeight * m_fHeightWeight/ 2,
- m_SenceBox.minZCoord + senceBoxDepth * 2);
- //update the camera position and org
- m_CameraInfo.cameraPos.x = m_CameraInfo.cameraOrg.x + distance * cos(veriticalAngle) * sin(horizontalAngle);
- m_CameraInfo.cameraPos.z = m_CameraInfo.cameraOrg.z + distance * cos(veriticalAngle) * cos(horizontalAngle);
- m_CameraInfo.cameraPos.y = m_CameraInfo.cameraOrg.y + distance * sin(veriticalAngle);
- }
m_3DView = glm::lookAt(m_CameraInfo.cameraPos, // Camera is at (0,0,3), in World Space
m_CameraInfo.cameraOrg, // and looks at the origin
m_CameraInfo.cameraUp // Head is up (set to 0,-1,0 to look upside-down)
@@ -1601,25 +1575,11 @@ int OpenGL3DRenderer::ProcessExtrude3DPickingBox()
}
return 0;
}
- //reset the camera by index
- //update the camera position and org
- float distance = 500;
- float veriticalAngle = GL_PI / 3.25f;
- float horizontalAngle = GL_PI / 6.0f;
+
extrude3DInfo = m_Extrude3DList[selectID];
extrude3DInfo.yTransform *= m_fHeightWeight;
extrude3DInfo.yScale *= m_fHeightWeight;
int reverse = 1;
- if (m_CameraInfo.useDefault)
- {
- m_CameraInfo.cameraOrg = glm::vec3(extrude3DInfo.xTransform + extrude3DInfo.xScale / 2,
- -extrude3DInfo.yTransform + extrude3DInfo.yScale *reverse,
- extrude3DInfo.zTransform + extrude3DInfo.xScale / 2);
-
- m_CameraInfo.cameraPos.x = m_CameraInfo.cameraOrg.x - distance * cos(veriticalAngle) * sin(horizontalAngle);
- m_CameraInfo.cameraPos.z = m_CameraInfo.cameraOrg.z + distance * cos(veriticalAngle) * cos(horizontalAngle);
- m_CameraInfo.cameraPos.y = m_CameraInfo.cameraOrg.y + distance * sin(horizontalAngle) * reverse;
- }
m_3DView = glm::lookAt(m_CameraInfo.cameraPos, // Camera is at (0,0,3), in World Space
m_CameraInfo.cameraOrg, // and looks at the origin
m_CameraInfo.cameraUp // Head is up (set to 0,-1,0 to look upside-down)