In file include/csengine/world.h:

## class csWorld : public csObject

> The world! This class basicly represents the 3D engine

## Inheritance:

### Public Fields

  csCleanup | cleanup This is a vector which holds objects of type 'csCleanable'
  csObjVector | collections List of collections
  csObjVector | libraries List of libraries
  csObjVector | planes List of planes
  csObjVector | sectors List of sectors in the world
  csObjVector | sprite_templates List of sprite templates
  csObjVector | sprites List of all sprites in the world
  char* | start_sector The starting sector for the camera as specified in the world file
  csVector3 | start_vec The starting vector for the camera as specified in the world file
  csObjVector | thing_templates List of thing templates

### Public Methods

  void | AddDynLight (csDynLight* dyn) Add a dynamic light to the world
  void | AddHalo (csHaloInformation* pinfo) Add a halo to the world
  void | AdvanceSpriteFrames (long current_time) Advance the frames of all sprites given an elapsed time
  void | Clear () Clear everything in the world
  void | CloseWorldFile () Close the world file
  | csWorld () Initialize an empty world
  void | Draw (IGraphics3D* g3d, csCamera* c, csClipper* clipper) Draw the world given a camera and a clipper
  void | DrawFunc (IGraphics3D* g3d, csCamera* c, csClipper* clipper, csDrawFunc* callback, void* callback_data = NULL) This function is similar to Draw
  void | EnableCBuffer (bool en) Enable/disable c-buffer
  void | EnableLightingCache (bool en) Cache lighting
  csStatLight* | FindLight (float x, float y, float z, float dist) Locate the first static light which is closer than 'dist' to the given position
  csCBuffer* | GetCBuffer () Return c-buffer (or NULL if not used)
  csEngineConfig* | GetEngineConfig () Get the configurator class for this engine
  IConfig* | GetEngineConfigCOM () Get the configurator interface for this engine
  csDynLight* | GetFirstDynLight () Return the first dynamic light in this world
  IHaloRasterizer* | GetHaloRastizer () Get the Halo Rasterizer COM interface if supported (NULL if not)
  int | GetNearbyLights (csSector* sector, const csVector3& pos, ULong flags, csLight** lights, int max_num_lights) This routine returns all lights which might affect an object at some position according to the following flags: CS_NLIGHT_SHADOWS: detect shadows and don't return lights for which the object is shadowed (not implemented yet)
  csSpriteTemplate* | GetSpriteTemplate (const char* name, bool use_libs = false) Find a named sprite template in the loaded world and optionally in all loaded libraries
  csTextureList* | GetTextures () Return the object managing all loaded textures
  csThing* | GetThing (const char* name) Find a thing with a given name
  csThingTemplate* | GetThingTemplate (const char* name, bool use_libs = false) Find a named thing template in the loaded world and optionally in all loaded libraries
  Archive* | GetWorldFile () Get the default world archive
  bool | HasHalo (csLight* pLight) Check if a light has a halo attached
  bool | Initialize (ISystem* sys, IGraphics3D* g3d, csIniFile* config) Initialize the world
  bool | IsLightingCacheEnabled () Return true if lighting cache is enabled.
  csSector* | NewSector () Create a new sector and add it to the world
  Archive* | OpenWorldFile (const char* filename) Open a file as the world file
  bool | Prepare (IGraphics3D* g3d) Prepare the world
  void | PrepareSectors () Prepare all the loaded sectors
  void | PrepareTextures (IGraphics3D* g3d) Prepare the textures
  void | ReadConfig (csIniFile* config) Read configuration file for all engine specific values
  void | RemoveDynLight (csDynLight* dyn) Remove a dynamic light from the world
  void | RemoveSprite (csSprite3D* sprite) Unlink and delete a sprite from the world
  void | StartWorld () Prepare for creation of a world
  void | UnlinkSprite (csSprite3D* sprite) Unlink a sprite from the world (but do not delete it)
  virtual | ~csWorld () Delete the world and all entities in the world

### Private Fields

  csCBuffer* | c_buffer Optional c-buffer used for rendering.
  csEngineConfig* | cfg_engine The engine configurator object.
  bool | do_lighting_cache If true then the lighting cache is enabled.
  csDynLight* | first_dyn_lights Linked list of dynamic lights.
  csVector | halos List of halos (csHaloInformation).
  IHaloRasterizer* | piHR The Halo rasterizer. If NULL halo's are not supported by the rasterizer.
  csTextureList* | textures Texture and color information object.
  Archive* | world_file If world file was loaded from a ZIP archive

### Private Methods

  void | CreateLightMaps (IGraphics3D* g3d)
  void | ShineLights ()

### 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)

## Documentation

> The world! This class basicly represents the 3D engine. It is the main anchor class for working with Crystal Space.

`csCleanup cleanup`
  This is a vector which holds objects of type 'csCleanable'. They will be destroyed when the world is destroyed. That's the only special thing. This is useful for holding memory which you allocate locally in a function but you want to reuse accross function invocations. There is no general way to make sure that the memory will be freed it only exists as a static pointer in your function code. Adding a class encapsulating that memory to this array will ensure that the memory is removed once the world is destroyed.

`csObjVector sectors`
  List of sectors in the world. This vector contains objects of type csSector*. Use NewSector() to add sectors to the world.

`csObjVector libraries`
  List of libraries. This vector contains objects of type csLibrary*. You can use CSLoader::LoadLibrary() to add a new library or manipulate this vector yourselves.

`csObjVector planes`
  List of planes. This vector contains objects of type csPolyPlane*. Note that this vector only contains named planes. Default planes which are created for polygons are not in this list.

`csObjVector collections`
  List of collections. This vector contains objects of type csCollection*.

`csObjVector sprite_templates`
  List of sprite templates. This vector contains objects of type csSpriteTemplate*. You can use GetSpriteTemplate() to locate a template for a sprite. This function can optionally look in all loaded libraries as well.

`csObjVector thing_templates`
  List of thing templates. This vector contains objects of type csThingTemplate*. You can use GetThingTemplate() to locate a template for a thing. This function can optionally look in all loaded libraries as well.

`csObjVector sprites`
  List of all sprites in the world. This vector contains objects of type csSprite3D*. Use UnlinkSprite() and RemoveSprite() to unlink and/or remove sprites from this list. These functions take care of correctly removing the sprites from all sectors as well. Note that after you add a sprite to the list you still need to add it to all sectors that you want it to be visible in.

`csTextureList* textures`
  Texture and color information object.

`csDynLight* first_dyn_lights`
  Linked list of dynamic lights.

`Archive* world_file`
  If world file was loaded from a ZIP archive. If not this points to the 'precalc.zip' archive.

`csVector halos`
  List of halos (csHaloInformation).

`IHaloRasterizer* piHR`
  The Halo rasterizer. If NULL halo's are not supported by the rasterizer.

`csEngineConfig* cfg_engine`
  The engine configurator object.

`bool do_lighting_cache`
  If true then the lighting cache is enabled.

`csCBuffer* c_buffer`
  Optional c-buffer used for rendering.

`void ShineLights()`

`void CreateLightMaps(IGraphics3D* g3d)`

`char* start_sector`
  The starting sector for the camera as specified in the world file. This is optional. If the world file does not have a starting sector then this field will be NULL.

`csVector3 start_vec`
  The starting vector for the camera as specified in the world file. This is optional. If the world file does not have a starting vector then this field will be equal to the 0-vector (i.e. (0,0,0)).

`csWorld()`
  Initialize an empty world. The only thing that is valid just after creating the world is the configurator object which you can use to configure the world before continuing (see GetEngineConfig()).

`virtual ~csWorld()`
  Delete the world and all entities in the world. All objects added to this world by the user (like Things, Sectors, ...) will be deleted as well. If you don't want this then you should unlink them manually before destroying the world.

`bool Initialize(ISystem* sys, IGraphics3D* g3d, csIniFile* config)`
  Initialize the world. This function must be called before you do anything else with this world. It will read the configuration file (ReadConfig()) and start a new empty world (StartWorld()).

`void PrepareTextures(IGraphics3D* g3d)`
  Prepare the textures. It will initialise all loaded textures for the texture manager. (Normally you shouldn't call this function directly, because it will be called by Prepare() for you.

`void PrepareSectors()`
  Prepare all the loaded sectors. (Normally you shouldn't call this function directly, because it will be called by Prepare() for you.

`bool Prepare(IGraphics3D* g3d)`
  Prepare the world. This function must be called after you loaded/created the world. It will prepare all lightmaps for use and also free all images that were loaded for the texture manager (the texture manager should have them locally now).

`void EnableCBuffer(bool en)`
  Enable/disable c-buffer

`csCBuffer* GetCBuffer()`
  Return c-buffer (or NULL if not used)

`void EnableLightingCache(bool en)`
  Cache lighting. If true (default) then lighting will be cached in either the world file or else 'precalc.zip'. If false then this will not happen and lighting will be calculated at startup. If set to 'false' recalculating of lightmaps will be forced. If set to 'true' recalculating of lightmaps will depend on wether or not the lightmap was cached.

`bool IsLightingCacheEnabled()`
  Return true if lighting cache is enabled.

`void ReadConfig(csIniFile* config)`
  Read configuration file for all engine specific values. This function is called by Initialize() so you normally do not need to call it yourselves.

`void StartWorld()`
  Prepare for creation of a world. This function is called by Initialize() so you normally do not need to call it yourselves.

`IHaloRasterizer* GetHaloRastizer()`
  Get the Halo Rasterizer COM interface if supported (NULL if not)

`csEngineConfig* GetEngineConfig()`
  Get the configurator class for this engine. This class can be used to query/set engine specific settings.

`IConfig* GetEngineConfigCOM()`
  Get the configurator interface for this engine. This interface can be used to query/set engine specific settings. This is the COM version.

`Archive* GetWorldFile()`
  Get the default world archive. If there is none this function will open precalc.zip and use that.

`Archive* OpenWorldFile(const char* filename)`
  Open a file as the world file

`void CloseWorldFile()`
  Close the world file

`void Clear()`
  Clear everything in the world

`csSector* NewSector()`
  Create a new sector and add it to the world

`csSpriteTemplate* GetSpriteTemplate(const char* name, bool use_libs = false)`
  Find a named sprite template in the loaded world and optionally in all loaded libraries. This template can then be used to create sprites.

`csThingTemplate* GetThingTemplate(const char* name, bool use_libs = false)`
  Find a named thing template in the loaded world and optionally in all loaded libraries. This template can then be used to create things.

`csThing* GetThing(const char* name)`
  Find a thing with a given name. This function will scan all sectors of the current world and return the first thing that it can find with the given name.

`csTextureList* GetTextures()`
  Return the object managing all loaded textures

`void AddDynLight(csDynLight* dyn)`
  Add a dynamic light to the world

`void RemoveDynLight(csDynLight* dyn)`
  Remove a dynamic light from the world

`csDynLight* GetFirstDynLight()`
  Return the first dynamic light in this world

`int GetNearbyLights(csSector* sector, const csVector3& pos, ULong flags, csLight** lights, int max_num_lights)`
  This routine returns all lights which might affect an object at some position according to the following flags:
  - CS_NLIGHT_SHADOWS: detect shadows and don't return lights for which the object is shadowed (not implemented yet).
  - CS_NLIGHT_STATIC: return static lights.
  - CS_NLIGHT_DYNAMIC: return dynamic lights.
  - CS_NLIGHT_NEARBYSECTORS: Also check lights in nearby sectors (not implemented yet).
  It will only return as many lights as the size that you specified for the light array. The returned lights are not guaranteed to be sorted but they are guaranteed to be the specified number of lights closest to the given position.
  This function returns the actual number of lights added to the 'lights' array.

`void AddHalo(csHaloInformation* pinfo)`
  Add a halo to the world

`bool HasHalo(csLight* pLight)`
  Check if a light has a halo attached

`void Draw(IGraphics3D* g3d, csCamera* c, csClipper* clipper)`
  Draw the world given a camera and a clipper. Note that in order to be able to draw using the given 3D driver all textures must have been registered to that driver (using Prepare()). Note that you need to call Prepare() again if you switch to another 3D driver.

`void DrawFunc(IGraphics3D* g3d, csCamera* c, csClipper* clipper, csDrawFunc* callback, void* callback_data = NULL)`
  This function is similar to Draw. It will do all the stuff that Draw would do except for one important thing: it will not draw anything. Instead it will call a callback function for every entity that it was planning to draw. This allows you to show or draw debugging information (2D egdes for example).

`csStatLight* FindLight(float x, float y, float z, float dist)`
  Locate the first static light which is closer than 'dist' to the given position. This function scans all sectors and locates the first one which statisfies that criterium.

`void AdvanceSpriteFrames(long current_time)`
  Advance the frames of all sprites given an elapsed time

`void UnlinkSprite(csSprite3D* sprite)`
  Unlink a sprite from the world (but do not delete it). It is also removed from all sectors.

`void RemoveSprite(csSprite3D* sprite)`
  Unlink and delete a sprite from the world. It is also removed from all sectors.

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