1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: b3dtrans.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _B3D_B3DTRANS_HXX
32 #define _B3D_B3DTRANS_HXX
34 #ifndef _B3D_HMATRIX_HXX
35 #include "hmatrix.hxx"
38 // Zu verwendender DephRange des Z-Buffers
39 #define ZBUFFER_DEPTH_RANGE (256.0 * 256.0 * 256.0)
43 // Vorausdeklarationen
47 /*************************************************************************
49 |* Unterstuetzte Methoden, um das Seitenverhaeltnis einzuhalten
51 \************************************************************************/
60 /*************************************************************************
64 \************************************************************************/
66 enum Base3DProjectionType
68 Base3DProjectionTypeParallel
= 1,
69 Base3DProjectionTypePerspective
72 /*************************************************************************
74 |* Transformationen fuer alle 3D Ausgaben
76 \************************************************************************/
78 class B3dTransformationSet
81 // Object Matrix Object -> World
82 Matrix4D aObjectTrans
;
83 Matrix4D aInvObjectTrans
;
86 Matrix4D aOrientation
;
87 Matrix4D aInvOrientation
;
91 Matrix4D aInvProjection
;
96 // Speziell zum Umwandeln von Punkten Objekt -> Device
97 Matrix4D aObjectToDevice
;
99 // Transponierte Inverse fuer Vectortransformationen
100 Matrix4D aInvTransObjectToEye
;
102 // Transformation World->View
103 Matrix4D aMatFromWorldToView
;
104 Matrix4D aInvMatFromWorldToView
;
106 // Parameters for ViewportTransformation
110 // ViewPlane DeviceRectangle (vom Benutzer gesetzt)
116 // Near and far clipping planes
120 // Seitenverhaeltnis der 3D Abbildung (Y / X)
121 // default ist 1:1 -> 1.0
122 // Deaktivieren mit 0.0 als Wert
125 // Der gesetzte Ausgabebereich (in logischen Koordinaten)
126 // und der dazugehoerige sichtbare Bereich
127 Rectangle aViewportRectangle
;
128 Rectangle aVisibleRectangle
;
130 // Die tatsaechlich von CalcViewport gesetzten Abmessungen
131 // des sichtbaren Bereichs (in logischen Koordinaten)
134 // Methode zur Aufrechterhaltung des Seitenverhaeltnisses
135 // default ist Base3DRatioGrow
139 unsigned bPerspective
: 1;
140 unsigned bWorldToViewValid
: 1;
141 unsigned bInvTransObjectToEyeValid
: 1;
142 unsigned bObjectToDeviceValid
: 1;
143 unsigned bProjectionValid
: 1;
146 B3dTransformationSet();
148 // Zurueck auf Standard
152 void SetObjectTrans(Matrix4D
& rObj
);
153 const Matrix4D
& GetObjectTrans() { return aObjectTrans
; }
154 const Matrix4D
& GetInvObjectTrans() { return aInvObjectTrans
; }
157 #if ! defined ICC && ! defined __GNUC__
158 void SetOrientation(Vector3D
& aVRP
= Vector3D(0.0,0.0,1.0),
159 Vector3D
& aVPN
= Vector3D(0.0,0.0,1.0),
160 Vector3D
& aVUP
= Vector3D(0.0,1.0,0.0));
162 void SetOrientation(Vector3D aVRP
= Vector3D(0.0,0.0,1.0),
163 Vector3D aVPN
= Vector3D(0.0,0.0,1.0),
164 Vector3D aVUP
= Vector3D(0.0,1.0,0.0));
166 const Matrix4D
& GetOrientation() { return aOrientation
; }
167 const Matrix4D
& GetInvOrientation() { return aInvOrientation
; }
170 void SetProjection(Matrix4D
& mProject
);
171 const Matrix4D
& GetProjection();
172 const Matrix4D
& GetInvProjection();
175 const Matrix4D
& GetTexture() { return aTexture
; }
177 // Seitenverhaeltnis und Modus zu dessen Aufrechterhaltung
178 double GetRatio() { return fRatio
; }
179 void SetRatio(double fNew
=1.0);
180 Base3DRatio
GetRatioMode() { return eRatio
; }
182 // Parameter der ViewportTransformation
183 void SetDeviceRectangle(double fL
=-1.0, double fR
=1.0, double fB
=-1.0, double fT
=1.0,
184 BOOL bBroadCastChange
=TRUE
);
185 void SetDeviceVolume(const B3dVolume
& rVol
, BOOL bBroadCastChange
=TRUE
);
186 double GetDeviceRectangleWidth() const { return fRightBound
- fLeftBound
; }
187 double GetDeviceRectangleHeight() const { return fTopBound
- fBottomBound
; }
188 void SetFrontClippingPlane(double fF
=0.0);
189 double GetFrontClippingPlane() { return fNearBound
; }
190 void SetBackClippingPlane(double fB
=1.0);
191 double GetBackClippingPlane() { return fFarBound
; }
192 void SetPerspective(BOOL bNew
);
193 BOOL
GetPerspective() { return bPerspective
; }
194 void SetViewportRectangle(Rectangle
& rRect
, Rectangle
& rVisible
);
195 void SetViewportRectangle(Rectangle
& rRect
) { SetViewportRectangle(rRect
, rRect
); }
196 const Rectangle
& GetViewportRectangle() { return aViewportRectangle
; }
199 // Speziell zum Umwandeln von Punkten World -> View
200 const Matrix4D
& GetMatFromWorldToView();
201 const Matrix4D
& GetInvMatFromWorldToView();
203 // Bounds des Viewports lesen
204 const Vector3D
& GetScale();
205 const Vector3D
& GetTranslate();
207 // Direkter Zugriff auf verschiedene Transformationen
208 const Vector3D
WorldToEyeCoor(const Vector3D
& rVec
);
209 const Vector3D
EyeToWorldCoor(const Vector3D
& rVec
);
210 const Vector3D
ViewToEyeCoor(const Vector3D
& rVec
);
211 const Vector3D
WorldToViewCoor(const Vector3D
& rVec
);
212 const Vector3D
ObjectToWorldCoor(const Vector3D
& rVec
);
213 const Vector3D
ViewToObjectCoor(const Vector3D
& rVec
);
214 const Vector3D
ObjectToEyeCoor(const Vector3D
& rVec
);
216 void PostSetObjectTrans();
217 void PostSetOrientation();
218 void PostSetProjection();
219 void PostSetViewport();
221 void CalcMatFromWorldToView();
223 virtual void DeviceRectangleChange();
226 /*************************************************************************
230 |* Verwendet wird hier ein vereinfachtes System, bei dem der abzubildende
231 |* Punkt durch VRP repraesentiert wird
233 \************************************************************************/
235 class B3dViewport
: public B3dTransformationSet
238 Vector3D aVRP
; // View Reference Point
239 Vector3D aVPN
; // View Plane Normal
240 Vector3D aVUV
; // View Up Vector
245 void SetVUV(const Vector3D
& rNewVUV
);
246 void SetViewportValues(
247 const Vector3D
& rNewVRP
,
248 const Vector3D
& rNewVPN
,
249 const Vector3D
& rNewVUV
);
251 const Vector3D
& GetVRP() const { return aVRP
; }
252 const Vector3D
& GetVPN() const { return aVPN
; }
253 const Vector3D
& GetVUV() const { return aVUV
; }
256 void CalcOrientation();
259 /*************************************************************************
263 \************************************************************************/
265 class B3dCamera
: public B3dViewport
269 Vector3D aCorrectedPosition
;
274 unsigned bUseFocalLength
: 1;
277 B3dCamera(const Vector3D
& rPos
= Vector3D(0.0, 0.0, 1.0),
278 const Vector3D
& rLkAt
= Vector3D(0.0, 0.0, 0.0),
279 double fFocLen
= 35.0, double fBnkAng
= 0.0,
280 BOOL bUseFocLen
= FALSE
);
283 const Vector3D
& GetPosition() const { return aPosition
; }
284 const Vector3D
& GetLookAt() const { return aLookAt
; }
287 double GetFocalLength() const { return fFocalLength
; }
289 // Neigung links/rechts
290 double GetBankAngle() const { return fBankAngle
; }
293 BOOL
GetUseFocalLength() const { return (BOOL
)bUseFocalLength
; }
296 void CalcNewViewportValues();
297 BOOL
CalcFocalLength();
299 virtual void DeviceRectangleChange();
301 }//end of namespace binfilter
303 #endif // _B3D_B3DTRANS_HXX