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: viewpt3d.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 ************************************************************************/
34 #ifndef _B3D_HMATRIX_HXX
35 #include <bf_goodies/hmatrix.hxx>
42 /*************************************************************************
44 |* enums fuer Projektion und Seitenverhaeltnis
46 \************************************************************************/
48 enum ProjectionType
{ PR_PARALLEL
, PR_PERSPECTIVE
};
49 enum AspectMapType
{ AS_NO_MAPPING
, AS_HOLD_SIZE
, AS_HOLD_X
, AS_HOLD_Y
};
51 /*************************************************************************
53 |* 3D-Viewport nach PHIGS
55 \************************************************************************/
60 Matrix4D aViewTf
; // die eigentliche Transformationsmatrix
61 Vector3D aVRP
; // View Reference Point
62 Vector3D aVPN
; // View Plane Normal
63 Vector3D aVUV
; // View Up Vector
64 Vector3D aPRP
; // Projection Reference Point(View-Koordinaten)
65 // bisher wird nur die Z-Koordinate beachtet
66 double fVPD
; // View Plane Distance
67 double fNearClipDist
; // Abstand der vorderen Clippingebene
68 double fFarClipDist
; // Abstand der hinteren Clippingebene
70 ProjectionType eProjection
; // Art der Projektion
71 AspectMapType eAspectMapping
; // Flag fuer Seitenverhaeltnis-Anpassung
72 // bei Ausgabe auf das Geraet
73 Rectangle aDeviceRect
; // Position und Groesse des Ausgabebereichs
77 double X
, Y
, W
, H
; // Position und Groesse des View-Windows
78 } aViewWin
; // in View-Koordinaten
80 Vector3D aViewPoint
; // Beobachterstandpunkt in Weltkoordinaten;
81 // wird mit der Transformation berechnet
82 BOOL bTfValid
; // Flag, ob Transformation gueltig ist
84 double fWRatio
; // Device/View-Seitenverhaeltnisse
87 virtual void MakeTransform(void);
92 void SetVRP(const Vector3D
& rNewVRP
);
93 void SetVPN(const Vector3D
& rNewVPN
);
94 void SetVUV(const Vector3D
& rNewVUV
);
95 void SetPRP(const Vector3D
& rNewPRP
);
96 void SetVPD(double fNewVPD
);
98 const Vector3D
& GetVRP() const { return aVRP
; }
99 const Vector3D
& GetVPN() const { return aVPN
; }
100 const Vector3D
& GetVUV() const { return aVUV
; }
101 const Vector3D
& GetPRP() const { return aPRP
; }
102 double GetVPD() const { return fVPD
; }
103 double GetNearClipDist() const { return fNearClipDist
; }
104 double GetFarClipDist() const { return fFarClipDist
; }
106 void SetProjection(ProjectionType ePrj
)
107 { eProjection
= ePrj
; bTfValid
= FALSE
; }
108 ProjectionType
GetProjection() const { return(eProjection
); }
110 void SetAspectMapping(AspectMapType eAsp
)
111 { eAspectMapping
= eAsp
; bTfValid
= FALSE
; }
112 AspectMapType
GetAspectMapping() { return eAspectMapping
; }
114 void SetViewWindow(double fX
, double fY
, double fW
, double fH
);
116 // View-Window genau um das mit rTransform transformierte Volumen legen
117 void FitViewToVolume(const Volume3D
& rVolume
, Matrix4D aTransform
);
119 void SetDeviceWindow(const Rectangle
& rRect
);
120 const Rectangle
& GetDeviceWindow() const { return aDeviceRect
; }
122 // Beobachterstandpunkt in Weltkoordinaten zurueckgeben
123 const Vector3D
& GetViewPoint();
125 // View-Transformationen
126 const Matrix4D
& GetViewTransform();
128 // Projektion und Mapping
129 Vector3D
& DoProjection(Vector3D
&) const;
130 Vector3D
MapToDevice(const Vector3D
&) const;
133 virtual void WriteData(SvStream
& rOut
) const;
134 virtual void ReadData(const SdrObjIOHeader
& rHead
, SvStream
& rIn
);
136 // Wird nur vom Stream-Operator gerufen
137 virtual void ReadData31(SvStream
& rIn
);
138 virtual void WriteData31(SvStream
& rOut
) const;
141 // FG: eigentlich sollten die Stream-Funktionen in der 3D-Engine nicht verwendet werden
142 // sondern WriteData und ReadData, da man insbesondere bei ReadData einen
143 // zusaetzlichen Parameter hat der die File-Revision enthaelt.
144 // Sie sind aus Kompatibilitaetsgruenden noch vorhanden.
145 SvStream
& operator<<(SvStream
& rOStream
, const Viewport3D
&);
146 SvStream
& operator>>(SvStream
& rIStream
, Viewport3D
&);
148 }//end of namespace binfilter
149 #endif // _VIEWPT3D_HXX