In file include/csengine/sector.h:

## class csSector : public csPolygonSet

> A sector is a convex hull of polygons

## Inheritance:

### Public Fields

int beam_busy
  How many times are we shining a specific light through this sector.
static int cfg_reflections
  Configuration variable: number of allowed reflections for static lighting
static bool do_portals
  Option variable: render portals? If this variable is false portals are rendered as a solid polygon
static bool do_radiosity
  Option variable: do pseudo-radiosity? When pseudo-radiosity is enabled every polygon behaves as if it is a mirroring portal when lighting calculations are concerned
static bool do_things
  Option variable: render things? If this variable is false sprites and things are not rendered
csObjVector lights
  All static and pseudo-dynamic lights in this sector
csObjVector sprites
  List of sprites in this sector

### Public Methods

void AddLight(csStatLight* light)
  Add a static or pseudo-dynamic light to this sector
void AddThing(csThing* thing)
  Add a thing to this sector
void CacheLightMaps()
  Cache the lightmaps for all polygons in this sector
void CalculateLighting(csLightView& lview)
  Update all lighting for all things and polygons in this sector and possibly traverse through portals to other sectors
void CreateLightMaps(IGraphics3D* g3d)
  Given the first lightmap as calculated by the lighting routines create the lightmaps for the other mipmap levels and also convert the lightmaps so that they are suitable for the 3D rasterizer
csSector()
  Construct a sector
void Draw(csRenderView& rview)
  Draw the sector in the given view and with the given transformation
csStatLight* FindLight(float x, float y, float z, float dist)
  Find a light with the given position and radius
csSector* FollowSegment(csReversibleTransform& t, csVector3& new_position, bool& mirror)
  Follow a segment starting at this sector
void GetAmbientColor(int& r, int& g, int& b)
  Get ambient color valid in this sector
csThing* GetFirstThing()
  Get the first thing in this sector
csThing* GetStaticThing()
  Get the thing representing all non-moving things (all things which are moved into this thing will return IsMerged()==true)
csThing* GetThing(const char* name)
  Find a thing with the given name
csThing** GetVisibleThings(csLightView& lview, int& num_things)
  Get a list of all things which are visible in the given frustrum
csPolygon3D* HitBeam(csVector3& start, csVector3& end)
  Follow a beam from start to end and return the first polygon that is hit
void InitLightMaps(bool do_cache = true)
  Init the lightmaps for all polygons in this sector
virtual csPolygon3D* IntersectSegment(const csVector3& start, const csVector3& end, csVector3& isect, float* pr = NULL)
  Intersect world-space segment with polygons of this sector
csPolygon3D* IntersectSphere(csVector3& center, float radius, float* pr = NULL)
  Intersects world-space sphere with polygons of this set
virtual void Prepare()
  Prepare all polygons for use
void SetAmbientColor(int r, int g, int b)
  Set the ambient color for this sector
void ShineLights(csProgressPulse* = 0)
  The whole setup starts with csWorld::shine_lights calling csSector::shine_lights for every sector in the world
void ShineLights(csThing*, csProgressPulse* = 0)
  Version of shine_lights() which only affects one thing.
void UseStaticBSP(int mode = BSP_MINIMIZE_SPLITS)
  Call this function to generate a BSP tree for all csThings in this sector
virtual ~csSector()
  Destroy this sector

### Private Fields

csThing* first_thing
  First thing in this sector.
int level_b
  Ambient light level for blue in this sector.
int level_g
  Ambient light level for green in this sector.
int level_r
  Ambient light level for red in this sector.
csBspTree* static_bsp
  If this variable is not NULL then it is a BSP tree in this sector which includes all static (non-moving) csThings
csThing* static_thing
  If static_bsp is not NULL then this is a pointer to the csThing which holds all polygons of the non-moving csThings
int visited

### Private Methods

static void* CalculateLightingPolygons(csPolygonParentInt*, csPolygonInt** polygon, int num, void* data)
  This function is called by the BSP tree traversal routine to update the lighting for a number of polygons
static void* DrawPolygons(csPolygonParentInt*, csPolygonInt** polygon, int num, void* data)
  This function is called by the BSP tree traversal routine to draw a number of polygons
void DrawPolygonsFromQueue(csPolygon2DQueue* queue, csRenderView* rview)
  Draw a number of polygons from a queue (used with C buffer processing)
static void* TestQueuePolygons(csPolygonParentInt*, csPolygonInt** polygon, int num, void* data)
  This function is called by the BSP tree traversal routine to test polygons against the C buffer and add them to a queue if needed

### Inherited from csPolygonSet:

### Public Fields

static long current_light_frame_number
csVector2* curve_texels
csVector3* curve_vertices
csVector3 curves_center
float curves_scale
int draw_busy
int max_curve_vertices
int num_curve_vertices

### Public Methods

void AddCurve(csCurve* curve)
void AddCurveVertex(csVector3& v, csVector2& t)
void AddPolygon(csPolygonInt* spoly)
int AddVertex(const csVector3& v)
int AddVertex(float x, float y, float z)
int AddVertexSmart(const csVector3& v)
int AddVertexSmart(float x, float y, float z)
void CamUpdate()
void CreateBoundingBox()
csVector2& CurveTexel(int i)
csVector3& CurveVertex(int i)
csPolygonSetBBox* GetBoundingBox()
void GetCameraMinMaxZ(float& minz, float& mazx)
csCurve* GetCurve(char* name)
csCurve* GetCurve(int idx)
csFog& GetFog()
csPolygonSet* GetNext()
int GetNumCurves()
int GetNumCurveVertices()
int GetNumPolygons()
int GetNumVertices()
csPolygon3D* GetPolygon(char* name)
csPolygonInt* GetPolygon(int idx)
csSector* GetSector()
csFrustrumList* GetShadows(csVector3& origin)
bool HasFog()
csVector2* IntersectCameraZPlane(float z, csVector2* clipper, int num_clip, int& num_pts)
bool IsBSP()
csPolygon3D* NewPolygon(csTextureHandle* texture)
void SetNext(csPolygonSet* next)
void SetSector(csSector* sector)
void UpdateTransformation(const csCamera& c)
void UpdateTransformation(const csVector3& trans)
void UseBSP()
csVector3& Vcam(int idx)
csVector3& Vobj(int idx)
csVector3& Vwor(int idx)

### Protected Fields

csPolygonSetBBox* bbox
csBspTree* bsp
csVector3* cam_verts
csTransformedSet cam_verts_set
csCurve** curves
long light_frame_number
int max_curves
int max_polygon
csPolygonSet* next
int num_curves
int num_polygon
csVector3* obj_verts
csPolygonInt** polygons
csSector* sector
csVector3* wor_verts

### Protected Methods

void DrawOnePolygon(csPolygon3D* p, csPolygon2D* poly, csRenderView* d, bool use_z_buf)
void DrawPolygonArray(csPolygonInt** polygon, int num, csRenderView* rview, bool use_z_buf)
void* TestQueuePolygonArray(csPolygonInt** polygon, int num, csRenderView* d, csPolygon2DQueue* poly_queue)

### Private Fields

csFog fog

### Inherited from csObject:

### Public Methods

CS_ID GetID()
csObject* GetObj(const csIdType& objtype)
virtual csObject* GetObjectParent()
void ObjAdd(csObject* obj)
csObjIterator ObjGet(const csIdType& objtype)
void ObjRelease(csObject* obj)
void ObjRemove(csObject* obj)

### Private Fields

CS_ID csid_value
csObjTree* objtree

### Private Methods

virtual void SetObjectParent(csObject* parent)

### Inherited from csBase:

### Inherited from csPolygonParentInt:

## Documentation

> A sector is a convex hull of polygons. It is one of the base classes for the portal engine.

`csObjVector sprites`
  List of sprites in this sector. Note that sprites also need to be in the world list. This vector contains objects of type csSprite3D*.

`csObjVector lights`
  All static and pseudo-dynamic lights in this sector. This vector contains objects of type csStatLight*.

`csThing* first_thing`
  First thing in this sector.

`int level_r`
  Ambient light level for red in this sector.

`int level_g`
  Ambient light level for green in this sector.

`int level_b`
  Ambient light level for blue in this sector.

`int visited`

`csBspTree* static_bsp`
  If this variable is not NULL then it is a BSP tree in this sector which includes all static (non-moving) csThings

`csThing* static_thing`
  If static_bsp is not NULL then this is a pointer to the csThing which holds all polygons of the non-moving csThings

`static void* DrawPolygons(csPolygonParentInt*, csPolygonInt** polygon, int num, void* data)`
  This function is called by the BSP tree traversal routine to draw a number of polygons

`static void* TestQueuePolygons(csPolygonParentInt*, csPolygonInt** polygon, int num, void* data)`
  This function is called by the BSP tree traversal routine to test polygons against the C buffer and add them to a queue if needed

`static void* CalculateLightingPolygons(csPolygonParentInt*, csPolygonInt** polygon, int num, void* data)`
  This function is called by the BSP tree traversal routine to update the lighting for a number of polygons

`void DrawPolygonsFromQueue(csPolygon2DQueue* queue, csRenderView* rview)`
  Draw a number of polygons from a queue (used with C buffer processing)

`static bool do_portals`
  Option variable: render portals? If this variable is false portals are rendered as a solid polygon

`static bool do_things`
  Option variable: render things? If this variable is false sprites and things are not rendered

`static int cfg_reflections`
  Configuration variable: number of allowed reflections for static lighting. This option controls how many time a given sector may be visited by the same beam of light. When this value is 1 it means that light is not reflected.

`static bool do_radiosity`
  Option variable: do pseudo-radiosity? When pseudo-radiosity is enabled every polygon behaves as if it is a mirroring portal when lighting calculations are concerned. This simulates radiosity because light reflects from every surface. The number of reflections allowed is controlled by cfg_reflections.

`int beam_busy`
  How many times are we shining a specific light through this sector.

`csSector()`
  Construct a sector. This sector will be completely empty.

`virtual ~csSector()`
  Destroy this sector. All things in this sector are also destroyed. Sprites are unlinked from the sector but not removed because they could be in other sectors.

`virtual void Prepare()`
  Prepare all polygons for use. This function MUST be called AFTER the texture manager has been prepared. This function is normally called by csWorld::Prepare() so you only need to worry about this function when you add sectors later.

`void AddThing(csThing* thing)`
  Add a thing to this sector

`void AddLight(csStatLight* light)`
  Add a static or pseudo-dynamic light to this sector

`csStatLight* FindLight(float x, float y, float z, float dist)`
  Find a light with the given position and radius

`csThing* GetThing(const char* name)`
  Find a thing with the given name

`csThing* GetFirstThing()`
  Get the first thing in this sector

`csThing* GetStaticThing()`
  Get the thing representing all non-moving things (all things which are moved into this thing will return IsMerged()==true)

`void UseStaticBSP(int mode = BSP_MINIMIZE_SPLITS)`
  Call this function to generate a BSP tree for all csThings in this sector. This might make drawing more efficient because those things can then be drawn using Z-fill instead of Z-buffer. This function will only generate BSP trees for the csThings which cannot move. Note that you can no longer remove a csThing from the sector if it has been added to the static BSP tree. The mode is given to the BSP building routines and can be one of the BSP_... flags.

`void GetAmbientColor(int& r, int& g, int& b)`
  Get ambient color valid in this sector

`void SetAmbientColor(int r, int g, int b)`
  Set the ambient color for this sector. This is only useful before lighting is calculated.

`csPolygon3D* HitBeam(csVector3& start, csVector3& end)`
  Follow a beam from start to end and return the first polygon that is hit. This function correctly traverse portals but not space warping portals.

`void CreateLightMaps(IGraphics3D* g3d)`
  Given the first lightmap as calculated by the lighting routines create the lightmaps for the other mipmap levels and also convert the lightmaps so that they are suitable for the 3D rasterizer

`void Draw(csRenderView& rview)`
  Draw the sector in the given view and with the given transformation

`void InitLightMaps(bool do_cache = true)`
  Init the lightmaps for all polygons in this sector. If this routine can find them in the cache it will load them, otherwise it will prepare the lightmap for the lighting routines. If do_cache == false this function will not try to read from the cache.

`void CalculateLighting(csLightView& lview)`
  Update all lighting for all things and polygons in this sector and possibly traverse through portals to other sectors

`csThing** GetVisibleThings(csLightView& lview, int& num_things)`
  Get a list of all things which are visible in the given frustrum. Return an array to pointers to visible things. You must delete this array after you are ready using it.

`void CacheLightMaps()`
  Cache the lightmaps for all polygons in this sector. The lightmaps will be cached to the current level file (if it is an archive) or else to 'precalc.zip'.

`csPolygon3D* IntersectSphere(csVector3& center, float radius, float* pr = NULL)`
  Intersects world-space sphere with polygons of this set. Return polygon it hits with (or NULL) and the intersection point in world coordinates. It will also return the polygon with the closest hit (the most nearby polygon). If 'pr' != NULL it will also return the distance where the intersection happened. Note. This function correctly accounts for portal polygons and could thus return a polygon not belonging to this sector.

`csSector* FollowSegment(csReversibleTransform& t, csVector3& new_position, bool& mirror)`
  Follow a segment starting at this sector. If the segment intersects with a polygon it will stop there unless the polygon is a portal in which case it will recursively go to that sector (possibly applying warping transformations) and continue there.

  This routine will modify all the given parameters to reflect space warping. These should be used as the new camera transformation when you decide to really go to the new position.

  This function returns the resulting sector and new_position will be set to the last position that you can go to before hitting a wall.

`virtual csPolygon3D* IntersectSegment(const csVector3& start, const csVector3& end, csVector3& isect, float* pr = NULL)`
  Intersect world-space segment with polygons of this sector. Return polygon it intersects with (or NULL) and the intersection point in world coordinates.

  If 'pr' != NULL it will also return a value between 0 and 1 indicating where on the 'start'-'end' vector the intersection happened.

  This function is an extension of csPolygonSet::intersect_segment in that it will also test for hits against things.

`void ShineLights(csProgressPulse* = 0)`
  The whole setup starts with csWorld::shine_lights calling csSector::shine_lights for every sector in the world. This function will call csStatLight::shine_lightmaps for every light in the sector. csStatLight::shine_light will generate a view frustrum from the center of the light and use that to light all polygons that are hit by the frustrum.

`void ShineLights(csThing*, csProgressPulse* = 0)`
  Version of shine_lights() which only affects one thing.

This class has no child classes.

alphabetic index hierarchy of classes

this page has been generated automatically by doc++

(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de