AlphaMask::BlendWith wants an AlphaMask parameter
[LibreOffice.git] / include / tools / b3dtrans.hxx
blob2f6752e0848ac85aa9de2989857ff93c06c6774d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_TOOLS_B3DTRANS_HXX
21 #define INCLUDED_TOOLS_B3DTRANS_HXX
23 #define ZBUFFER_DEPTH_RANGE (double(256L * 256L * 256L))
25 #include <basegfx/matrix/b3dhommatrix.hxx>
26 #include <tools/gen.hxx>
27 #include <basegfx/matrix/b2dhommatrix.hxx>
28 #include <basegfx/point/b3dpoint.hxx>
29 #include <basegfx/vector/b3dvector.hxx>
30 #include <tools/toolsdllapi.h>
32 /// Transformation sets for 3D output
33 class SAL_WARN_UNUSED TOOLS_DLLPUBLIC B3dTransformationSet
35 private:
36 // Object Matrix Object -> World
37 basegfx::B3DHomMatrix maObjectTrans;
38 basegfx::B3DHomMatrix maInvObjectTrans;
40 // Orientation Matrix
41 basegfx::B3DHomMatrix maOrientation;
42 basegfx::B3DHomMatrix maInvOrientation;
44 // Projection Matrix
45 basegfx::B3DHomMatrix maProjection;
46 basegfx::B3DHomMatrix maInvProjection;
48 // Texture Matrices
49 basegfx::B2DHomMatrix maTexture;
51 // Parameters for ViewportTransformation
52 basegfx::B3DVector maScale;
53 basegfx::B3DVector maTranslate;
55 // ViewPlane DeviceRectangle (user-defined)
56 double mfLeftBound;
57 double mfRightBound;
58 double mfBottomBound;
59 double mfTopBound;
61 // Aspect ratio of 3D transformation (Y / X)
62 // default: 1:1 -> 1.0
63 // Disable with value 0.0
64 double mfRatio;
66 // Viewport area in logical coordinates
67 tools::Rectangle maViewportRectangle;
68 // Visible area within viewport
69 tools::Rectangle maVisibleRectangle;
71 // Actual coordinates as set by CalcViewport
72 // of visible viewport area (logical coordinates)
73 tools::Rectangle maSetBound;
75 // Flags
76 bool mbPerspective : 1;
77 bool mbProjectionValid : 1;
79 public:
80 B3dTransformationSet();
81 virtual ~B3dTransformationSet();
83 B3dTransformationSet(B3dTransformationSet const &) = default;
84 B3dTransformationSet(B3dTransformationSet &&) = default;
85 B3dTransformationSet & operator =(B3dTransformationSet const &) = default;
86 B3dTransformationSet & operator =(B3dTransformationSet &&) = default;
88 void Reset();
90 /** Set the orientation
92 @param vVRP the View Reference Point (VRP)
93 @param vVPN the View Plane Normal (VPN)
94 @param vVUP the View Up Plane (VUP)
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));
101 // Projection
102 void SetProjection(const basegfx::B3DHomMatrix& mProject);
103 const basegfx::B3DHomMatrix& GetProjection();
105 // Texture
107 // aspect ratio accessors and the defined method of keeping defined aspect ratio
108 double GetRatio() const { return mfRatio; }
109 void SetRatio(double fNew);
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; }
116 void SetPerspective(bool bNew);
118 void SetViewportRectangle(tools::Rectangle const & rRect, tools::Rectangle const & rVisible);
119 void SetViewportRectangle(tools::Rectangle const & rRect) { SetViewportRectangle(rRect, rRect); }
121 void CalcViewport();
123 // Direct accessors for miscellaneous transformations
124 basegfx::B3DPoint WorldToEyeCoor(const basegfx::B3DPoint& rVec);
125 basegfx::B3DPoint EyeToWorldCoor(const basegfx::B3DPoint& rVec);
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));
143 protected:
144 void PostSetObjectTrans();
145 void PostSetOrientation();
146 void PostSetProjection();
148 virtual void DeviceRectangleChange();
151 /** Viewport for B3D
153 Uses a simplified model, in which a point is described using a View
154 Reference Point (VRP).
156 class SAL_WARN_UNUSED TOOLS_DLLPUBLIC B3dViewport : public B3dTransformationSet
158 private:
159 basegfx::B3DPoint aVRP; // View Reference Point
160 basegfx::B3DVector aVPN; // View Plane Normal
161 basegfx::B3DVector aVUV; // View Up Vector
163 public:
164 B3dViewport();
165 virtual ~B3dViewport() override;
167 B3dViewport(B3dViewport const &) = default;
168 B3dViewport(B3dViewport &&) = default;
169 B3dViewport & operator =(B3dViewport const &) = default;
170 B3dViewport & operator =(B3dViewport &&) = default;
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);
178 const basegfx::B3DPoint& GetVRP() const { return aVRP; }
179 const basegfx::B3DVector& GetVPN() const { return aVPN; }
180 const basegfx::B3DVector& GetVUV() const { return aVUV; }
182 protected:
183 void CalcOrientation();
186 // B3D camera
188 class SAL_WARN_UNUSED TOOLS_DLLPUBLIC B3dCamera final : public B3dViewport
190 public:
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;
197 B3dCamera(B3dCamera const &) = default;
198 B3dCamera(B3dCamera &&) = default;
199 B3dCamera & operator =(B3dCamera const &) = default;
200 B3dCamera & operator =(B3dCamera &&) = default;
202 private:
203 void CalcNewViewportValues();
204 void CalcFocalLength();
206 virtual void DeviceRectangleChange() override;
208 basegfx::B3DPoint aPosition;
209 basegfx::B3DVector aLookAt;
210 double fFocalLength;
211 double fBankAngle;
215 #endif
217 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */