## Public API Reference

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# 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 struct iShaderVariableContext;
    00045
    00046 struct iBaseHalo;
    00047 struct iCrossHalo;
    00048 struct iNovaHalo;
    00049 struct iFlareHalo;
    00050
    00058 #define CS_LIGHT_ACTIVEHALO     0x80000000
    00059
    00064 enum csLightDynamicType
    00065 {
    00071   CS_LIGHT_DYNAMICTYPE_STATIC = 1,
    00072
    00078   CS_LIGHT_DYNAMICTYPE_PSEUDO = 2,
    00079
    00085   CS_LIGHT_DYNAMICTYPE_DYNAMIC = 3
    00086 };
    00089
    00090 #define CS_DEFAULT_LIGHT_LEVEL 20
    00092 #define CS_NORMAL_LIGHT_LEVEL 128
    00093
    00107 enum csLightAttenuationMode
    00108 {
    00110   CS_ATTN_NONE = 0,
    00112   CS_ATTN_LINEAR = 1,
    00114   CS_ATTN_INVERSE = 2,
    00116   CS_ATTN_REALISTIC = 3,
    00121   CS_ATTN_CLQ = 4
    00122 };
    00137 enum csLightType
    00138 {
    00140   CS_LIGHT_POINTLIGHT,
    00142   CS_LIGHT_DIRECTIONAL,
    00144   CS_LIGHT_SPOTLIGHT
    00145 };
    00146
    00155 struct iLightCallback : public virtual iBase
    00156 {
    00157   SCF_INTERFACE(iLightCallback,2,0,0);
    00162   virtual void OnColorChange (iLight* light, const csColor& newcolor) = 0;
    00163
    00168   virtual void OnPositionChange (iLight* light, const csVector3& newpos) = 0;
    00169
    00174   virtual void OnSectorChange (iLight* light, iSector* newsector) = 0;
    00175
    00180   virtual void OnRadiusChange (iLight* light, float newradius) = 0;
    00181
    00186   virtual void OnDestroy (iLight* light) = 0;
    00187
    00192   virtual void OnAttenuationChange (iLight* light, int newatt) = 0;
    00193 };
    00194
    00195
    00231 struct iLight : public virtual iBase
    00232 {
    00233   SCF_INTERFACE(iLight,2,0,0);
    00235   virtual const char* GetLightID () = 0;
    00236
    00238   virtual iObject *QueryObject() = 0;
    00239
    00247   virtual csLightDynamicType GetDynamicType () const = 0;
    00248
    00253   virtual const csVector3& GetCenter () const = 0;
    00258   virtual const csVector3 GetFullCenter () const = 0;
    00260   virtual void SetCenter (const csVector3& pos) = 0;
    00261
    00263   virtual iSector *GetSector () = 0;
    00264
    00266   virtual iMovable *GetMovable () = 0;
    00267
    00271   virtual iSceneNode* QuerySceneNode () = 0;
    00272
    00274   virtual const csColor& GetColor () const = 0;
    00276   virtual void SetColor (const csColor& col) = 0;
    00277
    00279   virtual const csColor& GetSpecularColor () const = 0;
    00281   virtual void SetSpecularColor (const csColor& col) = 0;
    00282
    00284   virtual csLightType GetType () const = 0;
    00286   virtual void SetType (csLightType type) = 0;
    00287
    00292   virtual csLightAttenuationMode GetAttenuationMode () const = 0;
    00297   virtual void SetAttenuationMode (csLightAttenuationMode a) = 0;
    00298
    00303   virtual void SetAttenuationConstants (const csVector3& constants) = 0;
    00308   virtual const csVector3 &GetAttenuationConstants () const = 0;
    00309
    00316   virtual float GetCutoffDistance () const = 0;
    00317
    00324   virtual void SetCutoffDistance (float distance) = 0;
    00325
    00331   virtual float GetDirectionalCutoffRadius () const = 0;
    00332
    00338   virtual void SetDirectionalCutoffRadius (float radius) = 0;
    00339
    00343   virtual void SetSpotLightFalloff (float inner, float outer) = 0;
    00344
    00348   virtual void GetSpotLightFalloff (float& inner, float& outer) const = 0;
    00349
    00351   virtual iCrossHalo* CreateCrossHalo (float intensity, float cross) = 0;
    00353   virtual iNovaHalo* CreateNovaHalo (int seed, int num_spokes,
    00354         float roundness) = 0;
    00356   virtual iFlareHalo* CreateFlareHalo () = 0;
    00357
    00359   virtual iBaseHalo* GetHalo () const = 0;
    00360
    00362   virtual float GetBrightnessAtDistance (float d) const = 0;
    00363
    00369   virtual csFlags& GetFlags () = 0;
    00370
    00375   virtual void SetLightCallback (iLightCallback* cb) = 0;
    00376
    00380   virtual void RemoveLightCallback (iLightCallback* cb) = 0;
    00381
    00383   virtual int GetLightCallbackCount () const = 0;
    00384
    00386   virtual iLightCallback* GetLightCallback (int idx) const = 0;
    00387
    00392   virtual uint32 GetLightNumber () const = 0;
    00393
    00399   virtual void AddAffectedLightingInfo (iLightingInfo* li) = 0;
    00400
    00404   virtual void RemoveAffectedLightingInfo (iLightingInfo* li) = 0;
    00405
    00410   virtual void Setup () = 0;
    00411
    00415   virtual iShaderVariableContext* GetSVContext() = 0;
    00416 };
    00417
    00427 struct iLightList : public virtual iBase
    00428 {
    00429   SCF_INTERFACE(iLightList,2,0,0);
    00431   virtual int GetCount () const = 0;
    00432
    00434   virtual iLight *Get (int n) const = 0;
    00435
    00437   virtual int Add (iLight *obj) = 0;
    00438
    00440   virtual bool Remove (iLight *obj) = 0;
    00441
    00443   virtual bool Remove (int n) = 0;
    00444
    00446   virtual void RemoveAll () = 0;
    00447
    00449   virtual int Find (iLight *obj) const = 0;
    00450
    00452   virtual iLight *FindByName (const char *Name) const = 0;
    00453
    00455   virtual iLight *FindByID (const char* id) const = 0;
    00456 };
    00457
    00463 struct iLightingProcessData : public virtual iBase
    00464 {
    00465   SCF_INTERFACE (iLightingProcessData, 1, 0, 0);
    00466
    00471   virtual void FinalizeLighting () = 0;
    00472 };
    00473
    00480 struct iLightingProcessInfo : public iFrustumViewUserdata
    00481 {
    00482   SCF_INTERFACE(iLightingProcessInfo,2,0,0);
    00484   virtual iLight* GetLight () const = 0;
    00485
    00487   virtual bool IsDynamic () const = 0;
    00488
    00490   virtual void SetColor (const csColor& col) = 0;
    00491
    00493   virtual const csColor& GetColor () const = 0;
    00494
    00500   virtual void AttachUserdata (iLightingProcessData* userdata) = 0;
    00501
    00505   virtual csPtr<iLightingProcessData> QueryUserdata (scfInterfaceID id,
    00506         int version) = 0;
    00507
    00513   virtual void FinalizeLighting () = 0;
    00514 };
    00515
    00516 SCF_VERSION (iLightIterator, 0, 1, 0);
    00517
    00530 struct iLightIterator : public virtual iBase
    00531 {
    00533   virtual bool HasNext () = 0;
    00534
    00536   virtual iLight* Next () = 0;
    00537
    00539   virtual iSector* GetLastSector () = 0;
    00540
    00542   virtual void Reset () = 0;
    00543
    00544 };
    00545
    00548 #endif // __CS_IENGINE_LIGHT_H__
    00549