[Libreoffice-commits] core.git: Branch 'feature/chart-3d-chart' - 2 commits - chart2/source

Markus Mohrhard markus.mohrhard at collabora.co.uk
Sat May 10 13:40:05 PDT 2014


 chart2/source/view/inc/GL3DRenderer.hxx    |    6 +--
 chart2/source/view/main/3DChartObjects.cxx |    2 -
 chart2/source/view/main/GL3DRenderer.cxx   |   50 +----------------------------
 3 files changed, 5 insertions(+), 53 deletions(-)

New commits:
commit 50ba86fab9e55c83b15a0509df25bec8da861b1e
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Sat May 10 22:35:37 2014 +0200

    no framebuffer support needed anymore
    
    Change-Id: I5e6830bbd87eb9465aeb87d7e5074c9192caa47e

diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 1c38333..412d401 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -184,12 +184,6 @@ void OpenGL3DRenderer::RenderTexture(GLuint TexID)
 
 void OpenGL3DRenderer::init()
 {
-    if (glewIsSupported("framebuffer_object") != GLEW_OK)
-    {
-        SAL_WARN("chart2.opengl", "GL stack has no framebuffer support");
-        return;
-    }
-
     glEnable(GL_TEXTURE_2D);
     glEnable(GL_CULL_FACE);
     glCullFace(GL_BACK);
commit 3069f08452c0595756ab1b3d0e9ba5f38dcfc5d5
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Sat May 10 22:35:04 2014 +0200

    keep camera calculations out of the rendering code
    
    Change-Id: I7a26ce1881958a7465692174dd8ea793b593efad

diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index 8c57412..9eb21b2 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 a1fc5ee..08dab34 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 4875241..1c38333 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)


More information about the Libreoffice-commits mailing list