1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "3DChartObjects.hxx"
namespace chart {
namespace opengl3D {
Renderable3DObject::Renderable3DObject(OpenGL3DRenderer* pRenderer, sal_uInt32 nId):
mpRenderer(pRenderer),
mnUniqueId(nId)
{
}
void Renderable3DObject::render()
{
(void) mnUniqueId;
}
Bar::Bar(OpenGL3DRenderer* pRenderer, const glm::mat4& rPosition, sal_Int32 aColor, sal_uInt32 nId)
: Renderable3DObject(pRenderer, nId)
, mbRoundedCorners(false)
, maPos(rPosition)
, maColor(aColor)
{
}
void Bar::render()
{
mpRenderer->AddShape3DExtrudeObject(mbRoundedCorners, (sal_Int32)maColor.GetColor(), 0xFFFFFF, maPos);
mpRenderer->EndAddShape3DExtrudeObject();
}
Line::Line(OpenGL3DRenderer* pRenderer, sal_uInt32 nId):
Renderable3DObject(pRenderer, nId)
{
}
void Line::render()
{
mpRenderer->AddShapePolygon3DObject(0, true, (sal_Int32)maLineColor.GetColor(), 0, 0);
mpRenderer->AddPolygon3DObjectPoint(maPosBegin.x, maPosBegin.y, maPosBegin.z);
mpRenderer->AddPolygon3DObjectPoint(maPosEnd.x, maPosEnd.y, maPosEnd.z);
mpRenderer->EndAddShapePolygon3DObject();
}
Text::Text(OpenGL3DRenderer* pRenderer, const OUString& /*rStr*/, sal_uInt32 nId):
Renderable3DObject(pRenderer, nId)
{
// TODO : convert OUString to BitmapEx.
}
void Text::render()
{
glm::vec3 dir2 = maTopRight - maTopLeft;
glm::vec3 bottomLeft = maBottomRight - dir2;
mpRenderer->CreateTextTexture(maText, maTopLeft, maTopRight, maBottomRight, bottomLeft);
}
Rectangle::Rectangle(OpenGL3DRenderer* pRenderer, sal_uInt32 nId):
Renderable3DObject(pRenderer, nId)
{
}
void Rectangle::render()
{
glm::vec3 dir1 = maBottomRight - maTopLeft;
glm::vec3 dir2 = maTopRight - maTopLeft;
glm::vec3 normal = glm::normalize(glm::cross(dir1, dir2));
mpRenderer->AddShapePolygon3DObject((sal_Int32)maColor.GetColor(), false, 0, 1, 0xFFFFFF);
glm::vec3 bottomLeft = maBottomRight - dir2;
//set polygon points and normals
mpRenderer->AddPolygon3DObjectPoint(maBottomRight.x, maBottomRight.y, maBottomRight.z);
mpRenderer->AddPolygon3DObjectNormalPoint(normal.x, normal.y, normal.z);
mpRenderer->AddPolygon3DObjectPoint(maTopRight.x, maTopRight.y, maTopRight.z);
mpRenderer->AddPolygon3DObjectNormalPoint(normal.x, normal.y, normal.z);
mpRenderer->AddPolygon3DObjectPoint(maTopLeft.x, maTopLeft.y, maTopLeft.z);
mpRenderer->AddPolygon3DObjectNormalPoint(normal.x, normal.y, normal.z);
mpRenderer->AddPolygon3DObjectPoint(bottomLeft.x, bottomLeft.y, bottomLeft.z);
mpRenderer->AddPolygon3DObjectNormalPoint(normal.x, normal.y, normal.z);
mpRenderer->EndAddPolygon3DObjectPoint();
mpRenderer->EndAddPolygon3DObjectNormalPoint();
//we should render the edge if the edge color is different from the fill color
if ((sal_Int32)maColor.GetColor() != (sal_Int32)maLineColor.GetColor())
{
mpRenderer->AddShapePolygon3DObject(0, true, (sal_Int32)maLineColor.GetColor(), 0, 0xFFFFFF);
mpRenderer->AddPolygon3DObjectPoint(maBottomRight.x, maBottomRight.y, maBottomRight.z);
mpRenderer->AddPolygon3DObjectPoint(maTopRight.x, maTopRight.y, maTopRight.z);
mpRenderer->AddPolygon3DObjectPoint(maTopLeft.x, maTopLeft.y, maTopLeft.z);
mpRenderer->AddPolygon3DObjectPoint(bottomLeft.x, bottomLeft.y, bottomLeft.z);
mpRenderer->EndAddPolygon3DObjectPoint();
}
mpRenderer->EndAddShapePolygon3DObject();
}
Camera::Camera(OpenGL3DRenderer* pRenderer):
Renderable3DObject(pRenderer, 0),
maPos(10,10,-10),
maUp(0, 1, 0),
maDirection(glm::vec3(0,0,0)-maPos)
{
}
void Camera::render()
{
mpRenderer->SetCameraInfo(maPos, maDirection, maUp, true);
}
void Camera::zoom(sal_uInt32 /*nId*/)
{
// TODO here
}
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|