00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __CS_IENGINE_SECTOR_H__
00022 #define __CS_IENGINE_SECTOR_H__
00023
00031 #include "ivideo/rendermesh.h"
00032
00033 #include "csutil/cscolor.h"
00034 #include "csutil/scf.h"
00035 #include "csutil/set.h"
00036 #include "csgeom/vector3.h"
00037 #include "csgeom/aabbtree.h"
00038
00039 #include "iutil/threadmanager.h"
00040
00041 struct iMeshWrapper;
00042 struct iMeshGenerator;
00043 struct iMeshList;
00044 struct iLightList;
00045 struct iLight;
00046 struct iPortal;
00047 struct iVisibilityCuller;
00048
00049 struct iObject;
00050
00051 struct iRenderView;
00052 struct iRenderLoop;
00053 struct iSector;
00054 struct iDocumentNode;
00055
00056 struct iShaderVariableContext;
00057
00058 class csBox3;
00059 class csRenderMeshList;
00060 class csReversibleTransform;
00061 class csVector3;
00062
00063
00064 enum csFogMode
00065 {
00066 CS_FOG_MODE_NONE = 0,
00067 CS_FOG_MODE_LINEAR,
00068 CS_FOG_MODE_CRYSTALSPACE,
00069 CS_FOG_MODE_EXP,
00070 CS_FOG_MODE_EXP2
00071 };
00072
00076 struct csFog
00077 {
00079 float density;
00081 csColor4 color;
00083 float start;
00085 float end;
00087 float limit;
00089 csFogMode mode;
00090
00091 csFog() : density (0), color (0, 0, 0, 1.0f), start (0), end (0), limit (0),
00092 mode (CS_FOG_MODE_NONE) {}
00093 };
00094
00103 struct iSectorCallback : public virtual iBase
00104 {
00105 SCF_INTERFACE (iSectorCallback, 0, 0, 1);
00106
00111 virtual void Traverse (iSector* sector, iBase* context) = 0;
00112 };
00113
00121 struct iSectorMeshCallback : public virtual iBase
00122 {
00123 SCF_INTERFACE (iSectorMeshCallback, 0, 0, 1);
00124
00129 virtual void NewMesh (iSector* sector, iMeshWrapper* mesh) = 0;
00130
00134 virtual void RemoveMesh (iSector* sector, iMeshWrapper* mesh) = 0;
00135 };
00136
00143 struct iLightVisibleCallback : public virtual iBase
00144 {
00145 SCF_INTERFACE (iLightVisibleCallback, 0, 0, 1);
00146
00148 virtual void LightVisible (iSector* sector, iLight* light) = 0;
00149 };
00150
00155 struct csSectorHitBeamResult
00156 {
00158 iMeshWrapper* mesh;
00159
00161 csVector3 isect;
00162
00164 int polygon_idx;
00165
00170 iSector* final_sector;
00171 };
00172
00176 struct csSectorVisibleRenderMeshes
00177 {
00179 iMeshWrapper* imesh;
00181 int num;
00183 csRenderMesh** rmeshes;
00184 };
00185
00209 struct iSector : public virtual iBase
00210 {
00211 SCF_INTERFACE(iSector,4,1,0);
00213 virtual iObject *QueryObject () = 0;
00214
00217
00218 virtual iMeshList* GetMeshes () = 0;
00219
00226 virtual csRenderMeshList* GetVisibleMeshes (iRenderView *) = 0;
00227
00234 virtual const csSet<csPtrKey<iMeshWrapper> >& GetPortalMeshes () const = 0;
00235
00242 virtual void UnlinkObjects () = 0;
00243
00248 virtual void AddSectorMeshCallback (iSectorMeshCallback* cb) = 0;
00249
00253 virtual void RemoveSectorMeshCallback (iSectorMeshCallback* cb) = 0;
00258
00259 virtual void Draw (iRenderView* rview) = 0;
00260
00265 virtual void PrepareDraw (iRenderView* rview) = 0;
00266
00270 virtual int GetRecLevel () const = 0;
00271
00275 virtual void IncRecLevel () = 0;
00276
00280 virtual void DecRecLevel () = 0;
00281
00286 THREADED_INTERFACE1(SetRenderLoop, iRenderLoop* rl);
00287
00293 virtual iRenderLoop* GetRenderLoop () = 0;
00301 virtual iMeshGenerator* CreateMeshGenerator (const char* name) = 0;
00302
00306 virtual size_t GetMeshGeneratorCount () const = 0;
00307
00311 virtual iMeshGenerator* GetMeshGenerator (size_t idx) = 0;
00312
00316 virtual iMeshGenerator* GetMeshGeneratorByName (const char* name) = 0;
00317
00321 virtual void RemoveMeshGenerator (size_t idx) = 0;
00322
00326 virtual void RemoveMeshGenerator (const char* name) = 0;
00327
00331 virtual void RemoveMeshGenerators () = 0;
00336
00337 virtual bool HasFog () const = 0;
00339 virtual const csFog& GetFog () const = 0;
00341 virtual void SetFog (float density, const csColor& color) = 0;
00343 virtual void SetFog (const csFog& fog) = 0;
00345 virtual void DisableFog () = 0;
00353 virtual iLightList* GetLights () = 0;
00354
00358 THREADED_INTERFACE1(AddLight, csRef<iLight> light);
00359
00364 virtual void SetDynamicAmbientLight (const csColor& color) = 0;
00365
00367 virtual csColor GetDynamicAmbientLight () const = 0;
00368
00373 virtual uint GetDynamicAmbientVersion () const = 0;
00383 virtual void CalculateSectorBBox (csBox3& bbox,
00384 bool do_meshes) const = 0;
00385
00395 virtual bool SetVisibilityCullerPlugin (const char* name,
00396 iDocumentNode* culler_params = 0) = 0;
00402 virtual iVisibilityCuller* GetVisibilityCuller () = 0;
00403
00414 virtual csSectorHitBeamResult HitBeamPortals (const csVector3& start,
00415 const csVector3& end) = 0;
00416
00426 virtual csSectorHitBeamResult HitBeam (const csVector3& start,
00427 const csVector3& end, bool accurate = false) = 0;
00428
00465 virtual iSector* FollowSegment (csReversibleTransform& t,
00466 csVector3& new_position, bool& mirror, bool only_portals = false,
00467 iPortal** crossed_portals = 0, iMeshWrapper** portal_meshes = 0,
00468 int firstIndex = 0, int* lastIndex = 0) = 0;
00477 THREADED_INTERFACE1(SetSectorCallback, csRef<iSectorCallback> cb);
00478
00482 THREADED_INTERFACE1(RemoveSectorCallback, csRef<iSectorCallback> cb);
00483
00485 virtual int GetSectorCallbackCount () const = 0;
00486
00488 virtual iSectorCallback* GetSectorCallback (int idx) const = 0;
00501 virtual void SetLightCulling (bool enable) = 0;
00503 virtual bool IsLightCullingEnabled () const = 0;
00508 virtual void AddLightVisibleCallback (iLightVisibleCallback* cb) = 0;
00512 virtual void RemoveLightVisibleCallback (iLightVisibleCallback* cb) = 0;
00515
00516 virtual iShaderVariableContext* GetSVContext() = 0;
00517
00522 virtual void PrecacheDraw () = 0;
00523
00527 virtual void CallSectorCallbacks (iRenderView* rview) = 0;
00528
00532 virtual csSectorVisibleRenderMeshes* GetVisibleRenderMeshes (int& num,
00533 iMeshWrapper* mesh, iRenderView *rview, uint32 frustum_mask) = 0;
00534 };
00535
00536
00547 struct iSectorList : public virtual iBase
00548 {
00549 SCF_INTERFACE(iSectorList, 2,0,0);
00551 virtual int GetCount () const = 0;
00552
00554 virtual iSector *Get (int n) const = 0;
00555
00560 virtual int Add (iSector *obj) = 0;
00561
00566 virtual bool Remove (iSector *obj) = 0;
00567
00572 virtual bool Remove (int n) = 0;
00573
00575 virtual void RemoveAll () = 0;
00576
00582 virtual int Find (iSector *obj) const = 0;
00583
00588 virtual iSector *FindByName (const char *Name) const = 0;
00589 };
00590
00591
00599 struct iSectorIterator : public virtual iBase
00600 {
00601 SCF_INTERFACE(iSectorIterator,2,0,0);
00603 virtual bool HasNext () const = 0;
00604
00609 virtual iSector* Next () = 0;
00610
00615 virtual const csVector3& GetLastPosition () const = 0;
00616
00618 virtual void Reset () = 0;
00619 };
00620
00623 #endif // __CS_IENGINE_SECTOR_H__