CrystalSpace

Public API Reference

iengine/light.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2000-2001 by Jorrit Tyberghein
00003     Copyright (C) 1999 by Andrew Zabolotny <bit@eltech.ru>
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public
00016     License along with this library; if not, write to the Free
00017     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 */
00019 
00020 #ifndef __CS_IENGINE_LIGHT_H__
00021 #define __CS_IENGINE_LIGHT_H__
00022 
00030 #include "csutil/scf.h"
00031 
00032 #include "iengine/fview.h"
00033 
00034 class csColor;
00035 class csFlags;
00036 class csVector3;
00037 
00038 struct iLight;
00039 struct iLightingInfo;
00040 struct iMovable;
00041 struct iObject;
00042 struct iSector;
00043 struct iSceneNode;
00044 
00045 struct iBaseHalo;
00046 struct iCrossHalo;
00047 struct iNovaHalo;
00048 struct iFlareHalo;
00049 
00057 #define CS_LIGHT_ACTIVEHALO     0x80000000
00058 
00063 enum csLightDynamicType
00064 {
00070   CS_LIGHT_DYNAMICTYPE_STATIC = 1, 
00071  
00077   CS_LIGHT_DYNAMICTYPE_PSEUDO = 2,
00078 
00084   CS_LIGHT_DYNAMICTYPE_DYNAMIC = 3
00085 };
00088 
00089 #define CS_DEFAULT_LIGHT_LEVEL 20
00090 
00091 #define CS_NORMAL_LIGHT_LEVEL 128
00092 
00106 enum csLightAttenuationMode
00107 {
00109   CS_ATTN_NONE = 0,
00111   CS_ATTN_LINEAR = 1,
00113   CS_ATTN_INVERSE = 2,
00115   CS_ATTN_REALISTIC = 3,
00120   CS_ATTN_CLQ = 4
00121 };
00136 enum csLightType
00137 {
00139   CS_LIGHT_POINTLIGHT,
00141   CS_LIGHT_DIRECTIONAL,
00143   CS_LIGHT_SPOTLIGHT
00144 };
00145 
00157 struct iLightCallback : public virtual iBase
00158 {
00159   SCF_INTERFACE(iLightCallback,2,0,0);
00164   virtual void OnColorChange (iLight* light, const csColor& newcolor) = 0;
00165 
00170   virtual void OnPositionChange (iLight* light, const csVector3& newpos) = 0;
00171 
00176   virtual void OnSectorChange (iLight* light, iSector* newsector) = 0;
00177 
00182   virtual void OnRadiusChange (iLight* light, float newradius) = 0;
00183 
00188   virtual void OnDestroy (iLight* light) = 0;
00189 
00194   virtual void OnAttenuationChange (iLight* light, int newatt) = 0;
00195 };
00196 
00197 
00233 struct iLight : public virtual iBase
00234 {
00235   SCF_INTERFACE(iLight,2,0,0);
00237   virtual const char* GetLightID () = 0;
00238 
00240   virtual iObject *QueryObject() = 0;
00241 
00249   virtual csLightDynamicType GetDynamicType () const = 0;
00250 
00255   virtual const csVector3& GetCenter () const = 0;
00260   virtual const csVector3 GetFullCenter () const = 0;
00262   virtual void SetCenter (const csVector3& pos) = 0;
00263 
00265   virtual iSector *GetSector () = 0;
00266 
00268   virtual iMovable *GetMovable () = 0;
00269 
00273   virtual iSceneNode* QuerySceneNode () = 0;
00274 
00276   virtual const csColor& GetColor () const = 0;
00278   virtual void SetColor (const csColor& col) = 0;
00279 
00281   virtual const csColor& GetSpecularColor () const = 0;
00283   virtual void SetSpecularColor (const csColor& col) = 0;
00284   
00286   virtual csLightType GetType () const = 0;
00288   virtual void SetType (csLightType type) = 0;
00289 
00294   virtual csLightAttenuationMode GetAttenuationMode () const = 0;
00299   virtual void SetAttenuationMode (csLightAttenuationMode a) = 0;
00300 
00305   virtual void SetAttenuationConstants (const csVector3& constants) = 0;
00310   virtual const csVector3 &GetAttenuationConstants () const = 0;
00311 
00318   virtual float GetCutoffDistance () const = 0;
00319 
00326   virtual void SetCutoffDistance (float distance) = 0;
00327 
00333   virtual float GetDirectionalCutoffRadius () const = 0;
00334 
00340   virtual void SetDirectionalCutoffRadius (float radius) = 0;
00341 
00345   virtual void SetSpotLightFalloff (float inner, float outer) = 0;
00346 
00350   virtual void GetSpotLightFalloff (float& inner, float& outer) const = 0;
00351 
00353   virtual iCrossHalo* CreateCrossHalo (float intensity, float cross) = 0;
00355   virtual iNovaHalo* CreateNovaHalo (int seed, int num_spokes,
00356         float roundness) = 0;
00358   virtual iFlareHalo* CreateFlareHalo () = 0;
00359 
00361   virtual iBaseHalo* GetHalo () const = 0;
00362 
00364   virtual float GetBrightnessAtDistance (float d) const = 0;
00365 
00371   virtual csFlags& GetFlags () = 0;
00372 
00377   virtual void SetLightCallback (iLightCallback* cb) = 0;
00378 
00382   virtual void RemoveLightCallback (iLightCallback* cb) = 0;
00383 
00385   virtual int GetLightCallbackCount () const = 0;
00386   
00388   virtual iLightCallback* GetLightCallback (int idx) const = 0;
00389 
00394   virtual uint32 GetLightNumber () const = 0;
00395 
00401   virtual void AddAffectedLightingInfo (iLightingInfo* li) = 0; 
00402 
00406   virtual void RemoveAffectedLightingInfo (iLightingInfo* li) = 0; 
00407 
00412   virtual void Setup () = 0;
00413 };
00414 
00424 struct iLightList : public virtual iBase
00425 {
00426   SCF_INTERFACE(iLightList,2,0,0);
00428   virtual int GetCount () const = 0;
00429 
00431   virtual iLight *Get (int n) const = 0;
00432 
00434   virtual int Add (iLight *obj) = 0;
00435 
00437   virtual bool Remove (iLight *obj) = 0;
00438 
00440   virtual bool Remove (int n) = 0;
00441 
00443   virtual void RemoveAll () = 0;
00444 
00446   virtual int Find (iLight *obj) const = 0;
00447 
00449   virtual iLight *FindByName (const char *Name) const = 0;
00450 
00452   virtual iLight *FindByID (const char* id) const = 0;
00453 };
00454 
00460 struct iLightingProcessData : public virtual iBase
00461 {
00462   SCF_INTERFACE (iLightingProcessData, 1, 0, 0);
00463 
00468   virtual void FinalizeLighting () = 0;
00469 };
00470 
00477 struct iLightingProcessInfo : public iFrustumViewUserdata
00478 {
00479   SCF_INTERFACE(iLightingProcessInfo,2,0,0);
00481   virtual iLight* GetLight () const = 0;
00482 
00484   virtual bool IsDynamic () const = 0;
00485 
00487   virtual void SetColor (const csColor& col) = 0;
00488 
00490   virtual const csColor& GetColor () const = 0;
00491 
00497   virtual void AttachUserdata (iLightingProcessData* userdata) = 0;
00498 
00502   virtual csPtr<iLightingProcessData> QueryUserdata (scfInterfaceID id,
00503         int version) = 0;
00504 
00510   virtual void FinalizeLighting () = 0;
00511 };
00512 
00513 SCF_VERSION (iLightIterator, 0, 1, 0);
00514 
00527 struct iLightIterator : public virtual iBase
00528 {
00530   virtual bool HasNext () = 0;
00531 
00533   virtual iLight* Next () = 0;
00534 
00536   virtual iSector* GetLastSector () = 0;
00537 
00539   virtual void Reset () = 0;
00540 
00541 };
00542 
00545 #endif // __CS_IENGINE_LIGHT_H__
00546 

Generated for Crystal Space by doxygen 1.4.6