LibreOffice Module tools (master) 1
b3dtrans.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#ifndef INCLUDED_TOOLS_B3DTRANS_HXX
21#define INCLUDED_TOOLS_B3DTRANS_HXX
22
23#define ZBUFFER_DEPTH_RANGE (double(256L * 256L * 256L))
24
26#include <tools/gen.hxx>
30#include <tools/toolsdllapi.h>
31
34{
35private:
36 // Object Matrix Object -> World
39
40 // Orientation Matrix
43
44 // Projection Matrix
47
48 // Texture Matrices
50
51 // Parameters for ViewportTransformation
54
55 // ViewPlane DeviceRectangle (user-defined)
59 double mfTopBound;
60
61 // Aspect ratio of 3D transformation (Y / X)
62 // default: 1:1 -> 1.0
63 // Disable with value 0.0
64 double mfRatio;
65
66 // Viewport area in logical coordinates
68 // Visible area within viewport
70
71 // Actual coordinates as set by CalcViewport
72 // of visible viewport area (logical coordinates)
74
75 // Flags
76 bool mbPerspective : 1;
78
79public:
81 virtual ~B3dTransformationSet();
82
85 B3dTransformationSet & operator =(B3dTransformationSet const &) = default;
86 B3dTransformationSet & operator =(B3dTransformationSet &&) = default;
87
88 void Reset();
89
96 void SetOrientation(
97 const basegfx::B3DPoint& rVRP = basegfx::B3DPoint(0.0,0.0,1.0),
98 const basegfx::B3DVector& rVPN = basegfx::B3DVector(0.0,0.0,1.0),
99 const basegfx::B3DVector& rVUP = basegfx::B3DVector(0.0,1.0,0.0));
100
101 // Projection
102 void SetProjection(const basegfx::B3DHomMatrix& mProject);
103 const basegfx::B3DHomMatrix& GetProjection();
104
105 // Texture
106
107 // aspect ratio accessors and the defined method of keeping defined aspect ratio
108 double GetRatio() const { return mfRatio; }
109 void SetRatio(double fNew);
110
111 // Parameters of ViewportTransformation
112 void SetDeviceRectangle(double fL=-1.0, double fR=1.0,
113 double fB=-1.0, double fT=1.0);
114 double GetDeviceRectangleWidth() const { return mfRightBound - mfLeftBound; }
115
116 void SetPerspective(bool bNew);
117
118 void SetViewportRectangle(tools::Rectangle const & rRect, tools::Rectangle const & rVisible);
119 void SetViewportRectangle(tools::Rectangle const & rRect) { SetViewportRectangle(rRect, rRect); }
120
121 void CalcViewport();
122
123 // Direct accessors for miscellaneous transformations
124 basegfx::B3DPoint WorldToEyeCoor(const basegfx::B3DPoint& rVec);
125 basegfx::B3DPoint EyeToWorldCoor(const basegfx::B3DPoint& rVec);
126
127 static void Frustum(
128 basegfx::B3DHomMatrix& rTarget,
129 double fLeft = -1.0, double fRight = 1.0,
130 double fBottom = -1.0, double fTop = 1.0,
131 double fNear = 0.001, double fFar = 1.0);
132 static void Ortho(
133 basegfx::B3DHomMatrix& rTarget,
134 double fLeft = -1.0, double fRight = 1.0,
135 double fBottom = -1.0, double fTop = 1.0,
136 double fNear = 0.0, double fFar = 1.0);
137 static void Orientation(
138 basegfx::B3DHomMatrix& rTarget,
139 const basegfx::B3DPoint& aVRP = basegfx::B3DPoint(0.0,0.0,1.0),
140 basegfx::B3DVector aVPN = basegfx::B3DVector(0.0,0.0,1.0),
141 basegfx::B3DVector aVUP = basegfx::B3DVector(0.0,1.0,0.0));
142
143protected:
144 void PostSetObjectTrans();
145 void PostSetOrientation();
146 void PostSetProjection();
147
148 virtual void DeviceRectangleChange();
149};
150
157{
158private:
159 basegfx::B3DPoint aVRP; // View Reference Point
160 basegfx::B3DVector aVPN; // View Plane Normal
161 basegfx::B3DVector aVUV; // View Up Vector
162
163public:
164 B3dViewport();
165 virtual ~B3dViewport() override;
166
167 B3dViewport(B3dViewport const &) = default;
169 B3dViewport & operator =(B3dViewport const &) = default;
170 B3dViewport & operator =(B3dViewport &&) = default;
171
172 void SetVUV(const basegfx::B3DVector& rNewVUV);
173 void SetViewportValues(
174 const basegfx::B3DPoint& rNewVRP,
175 const basegfx::B3DVector& rNewVPN,
176 const basegfx::B3DVector& rNewVUV);
177
178 const basegfx::B3DPoint& GetVRP() const { return aVRP; }
179 const basegfx::B3DVector& GetVPN() const { return aVPN; }
180 const basegfx::B3DVector& GetVUV() const { return aVUV; }
181
182protected:
183 void CalcOrientation();
184};
185
186// B3D camera
187
189{
190public:
191 B3dCamera(
192 const basegfx::B3DPoint& rPos = basegfx::B3DPoint(0.0, 0.0, 1.0),
193 const basegfx::B3DVector& rLkAt = basegfx::B3DVector(0.0, 0.0, 0.0),
194 double fFocLen = 35.0, double fBnkAng = 0.0);
195 virtual ~B3dCamera() override;
196
197 B3dCamera(B3dCamera const &) = default;
198 B3dCamera(B3dCamera &&) = default;
199 B3dCamera & operator =(B3dCamera const &) = default;
200 B3dCamera & operator =(B3dCamera &&) = default;
201
202private:
203 void CalcNewViewportValues();
204 void CalcFocalLength();
205
206 virtual void DeviceRectangleChange() override;
207
212
213};
214
215#endif
216
217/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
basegfx::B3DPoint aPosition
Definition: b3dtrans.hxx:208
double fBankAngle
Definition: b3dtrans.hxx:211
B3dCamera(B3dCamera &&)=default
double fFocalLength
Definition: b3dtrans.hxx:210
B3dCamera(B3dCamera const &)=default
basegfx::B3DVector aLookAt
Definition: b3dtrans.hxx:209
Transformation sets for 3D output.
Definition: b3dtrans.hxx:34
basegfx::B3DHomMatrix maInvProjection
Definition: b3dtrans.hxx:46
basegfx::B3DHomMatrix maObjectTrans
Definition: b3dtrans.hxx:37
tools::Rectangle maVisibleRectangle
Definition: b3dtrans.hxx:69
basegfx::B3DVector maTranslate
Definition: b3dtrans.hxx:53
B3dTransformationSet(B3dTransformationSet &&)=default
B3dTransformationSet(B3dTransformationSet const &)=default
tools::Rectangle maSetBound
Definition: b3dtrans.hxx:73
double GetDeviceRectangleWidth() const
Definition: b3dtrans.hxx:114
basegfx::B3DHomMatrix maProjection
Definition: b3dtrans.hxx:45
void SetViewportRectangle(tools::Rectangle const &rRect)
Definition: b3dtrans.hxx:119
basegfx::B3DVector maScale
Definition: b3dtrans.hxx:52
basegfx::B3DHomMatrix maOrientation
Definition: b3dtrans.hxx:41
basegfx::B2DHomMatrix maTexture
Definition: b3dtrans.hxx:49
double GetRatio() const
Definition: b3dtrans.hxx:108
basegfx::B3DHomMatrix maInvOrientation
Definition: b3dtrans.hxx:42
basegfx::B3DHomMatrix maInvObjectTrans
Definition: b3dtrans.hxx:38
tools::Rectangle maViewportRectangle
Definition: b3dtrans.hxx:67
Viewport for B3D.
Definition: b3dtrans.hxx:157
B3dViewport(B3dViewport const &)=default
basegfx::B3DVector aVUV
Definition: b3dtrans.hxx:161
const basegfx::B3DPoint & GetVRP() const
Definition: b3dtrans.hxx:178
basegfx::B3DPoint aVRP
Definition: b3dtrans.hxx:159
const basegfx::B3DVector & GetVPN() const
Definition: b3dtrans.hxx:179
basegfx::B3DVector aVPN
Definition: b3dtrans.hxx:160
const basegfx::B3DVector & GetVUV() const
Definition: b3dtrans.hxx:180
B3dViewport(B3dViewport &&)=default
Orientation
#define TOOLS_DLLPUBLIC
Definition: toolsdllapi.h:28
#define SAL_WARN_UNUSED