Update ooo320-m1
[ooovba.git] / binfilter / inc / bf_goodies / b3dlight.hxx
blob610cf5d010615900513919ddcd7bca28bc5d76cd
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: b3dlight.hxx,v $
10 * $Revision: 1.4 $
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_B3DLIGHT_HXX
32 #define _B3D_B3DLIGHT_HXX
34 #ifndef _SVX_VECTOR3D_HXX
35 #include "vector3d.hxx"
36 #endif
38 #ifndef _SVX_MATRIL3D_HXX
39 #include "matril3d.hxx"
40 #endif
42 #ifndef _STREAM_HXX
43 #include <tools/stream.hxx>
44 #endif
46 namespace binfilter {
48 /*************************************************************************
50 |* Unterstuetzte Lichtquellen
52 \************************************************************************/
54 #define BASE3D_MAX_NUMBER_LIGHTS (8)
56 enum Base3DLightNumber
58 Base3DLight0 = 0,
59 Base3DLight1,
60 Base3DLight2,
61 Base3DLight3,
62 Base3DLight4,
63 Base3DLight5,
64 Base3DLight6,
65 Base3DLight7,
66 Base3DLightNone
69 /*************************************************************************
71 |* Basisklasse fuer Lichtquellen
73 \************************************************************************/
75 class B3dLight
77 private:
78 Color aAmbient;
79 Color aDiffuse;
80 Color aSpecular;
81 Vector3D aPosition;
82 Vector3D aPositionEye;
83 Vector3D aSpotDirection;
84 Vector3D aSpotDirectionEye;
85 UINT16 nSpotExponent;
86 double fSpotCutoff;
87 double fCosSpotCutoff;
88 double fConstantAttenuation;
89 double fLinearAttenuation;
90 double fQuadraticAttenuation;
92 unsigned bIsFirstLight : 1;
93 unsigned bIsEnabled : 1;
94 unsigned bIsDirectionalSource : 1;
95 unsigned bIsSpot : 1;
96 unsigned bIsAmbient : 1;
97 unsigned bIsDiffuse : 1;
98 unsigned bIsSpecular : 1;
99 unsigned bLinearOrQuadratic : 1;
101 public:
102 B3dLight();
104 // Zugriffsfunktionen
105 void SetIntensity(const Color rNew,
106 Base3DMaterialValue=Base3DMaterialAmbient);
107 const Color GetIntensity(Base3DMaterialValue=Base3DMaterialAmbient);
108 void SetPositionEye(const Vector3D& rNew)
109 { aPositionEye=rNew; }
110 const Vector3D& GetPositionEye()
111 { return aPositionEye; }
112 void SetPosition(const Vector3D& rNew)
113 { aPosition=rNew; }
114 const Vector3D& GetPosition()
115 { return aPosition; }
116 const Vector3D& GetSpotDirection()
117 { return aSpotDirection; }
118 const Vector3D& GetSpotDirectionEye()
119 { return aSpotDirectionEye; }
120 void SetSpotExponent(UINT16 nNew)
121 { nSpotExponent=nNew; }
122 UINT16 GetSpotExponent()
123 { return nSpotExponent; }
124 double GetSpotCutoff()
125 { return fSpotCutoff; }
126 double GetCosSpotCutoff()
127 { return fCosSpotCutoff; }
128 void SetConstantAttenuation(double fNew)
129 { fConstantAttenuation=fNew; }
130 double GetConstantAttenuation()
131 { return fConstantAttenuation; }
132 double GetLinearAttenuation()
133 { return fLinearAttenuation; }
134 double GetQuadraticAttenuation()
135 { return fQuadraticAttenuation; }
137 void Enable(BOOL bNew=TRUE)
138 { bIsEnabled=bNew; }
139 BOOL IsEnabled()
140 { return bIsEnabled; }
141 void SetFirst(BOOL bNew=TRUE)
142 { bIsFirstLight=bNew; }
143 BOOL IsFirst()
144 { return bIsFirstLight; }
145 void SetDirectionalSource(BOOL bNew=TRUE)
146 { bIsDirectionalSource=bNew; }
147 BOOL IsDirectionalSource()
148 { return bIsDirectionalSource; }
149 BOOL IsSpot()
150 { return bIsSpot; }
151 BOOL IsAmbient()
152 { return bIsAmbient; }
153 BOOL IsDiffuse()
154 { return bIsDiffuse; }
155 BOOL IsSpecular()
156 { return bIsSpecular; }
157 BOOL IsLinearOrQuadratic()
158 { return bLinearOrQuadratic; }
160 void Init();
162 // Laden/Speichern in StarView
163 virtual void WriteData(SvStream& rOut) const;
164 virtual void ReadData(SvStream& rIn);
166 protected:
169 /*************************************************************************
171 |* Gruppe von Lichtquellen
173 \************************************************************************/
175 class B3dLightGroup
177 private:
178 // Lichtquellen
179 B3dLight aLight[BASE3D_MAX_NUMBER_LIGHTS];
181 // lokale Parameter des LightModels
182 Color aGlobalAmbientLight;
184 // Hauptschalter fuer die Beleuchtung
185 unsigned bLightingEnabled : 1;
186 unsigned bLocalViewer : 1;
187 unsigned bModelTwoSide : 1;
189 public:
190 // Konstruktor
191 B3dLightGroup();
193 // lokale Parameter des LightModels
194 virtual void SetGlobalAmbientLight(const Color rNew);
195 const Color GetGlobalAmbientLight();
196 virtual void SetLocalViewer(BOOL bNew=TRUE);
197 virtual void SetModelTwoSide(BOOL bNew=FALSE);
198 BOOL GetModelTwoSide();
200 // Hauptschalter fuer die Beleuchtung
201 virtual void EnableLighting(BOOL bNew=TRUE);
202 BOOL IsLightingEnabled();
204 // Lichtquellen Interface
205 void SetIntensity(const Color rNew,
206 Base3DMaterialValue=Base3DMaterialAmbient,
207 Base3DLightNumber=Base3DLight0);
208 const Color GetIntensity(Base3DMaterialValue=Base3DMaterialAmbient,
209 Base3DLightNumber=Base3DLight0);
210 void SetPosition(const Vector3D& rNew,
211 Base3DLightNumber=Base3DLight0);
212 void SetDirection(const Vector3D& rNew,
213 Base3DLightNumber=Base3DLight0);
214 const Vector3D& GetDirection(Base3DLightNumber=Base3DLight0);
215 void Enable(BOOL bNew=TRUE,
216 Base3DLightNumber=Base3DLight0);
217 BOOL IsEnabled(Base3DLightNumber=Base3DLight0);
219 // Direkter Zugriff auf B3dLight
220 B3dLight& GetLightObject(Base3DLightNumber=Base3DLight0);
222 // Laden/Speichern in StarView
223 virtual void WriteData(SvStream& rOut) const;
224 virtual void ReadData(SvStream& rIn);
226 protected:
229 }//end of namespace binfilter
231 #endif // _B3D_B3DLIGHT_HXX