#include <engine.h>
Inheritance diagram for csEngine:
Public Methods | |
csEngine (iBase *iParent) | |
Initialize an empty engine. More... | |
virtual | ~csEngine () |
Delete the engine and all entities it contains. More... | |
void | Report (const char *description,...) |
Report a notification message. | |
void | Warn (const char *description,...) |
Report a warning. | |
void | ReportBug (const char *description,...) |
Report a bug. | |
bool | CheckConsistency () |
Check consistency of the loaded elements which comprise the world. More... | |
void | PrepareTextures () |
Prepare the textures. More... | |
void | PrepareMeshes () |
Calls UpdateMove for all meshes to initialise bsp bounding boxes. More... | |
virtual void | ShineLights (iRegion *region=NULL, iProgressMeter *meter=NULL) |
Calculate all lighting information. More... | |
virtual iObject* | QueryObject () |
Query the iObject for the engine. | |
csObject* | QueryCsObject () |
Query the csObject for the engine. | |
virtual bool | Prepare (iProgressMeter *meter=NULL) |
Prepare the engine. More... | |
csRadiosity* | GetRadiosity () const |
Get the pointer to the radiosity object (used with step-by-step debugging). | |
void | InvalidateLightmaps () |
Invalidate all lightmaps. More... | |
virtual void | SetEngineMode (int mode) |
Set the desired engine mode. More... | |
virtual int | GetEngineMode () const |
Get the current engine mode. More... | |
virtual int | GetBeginDrawFlags () const |
Get the required flags for 3D->BeginDraw() which should be called from the application. More... | |
csTicks | GetLastAnimationTime () const |
Get the last animation time. | |
void | InitCuller () |
Initialize the culler. | |
csCBuffer* | GetCBuffer () const |
Return c-buffer (or NULL if not used). | |
csCBufferCube* | GetCBufCube () const |
Return cbuffer cube. | |
void | EnablePVS () |
Enable PVS. | |
void | DisablePVS () |
Disable PVS. | |
virtual bool | IsPVS () const |
Is PVS enabled? | |
void | EnablePVSOnly () |
Use only PVS for culling. More... | |
void | DisablePVSOnly () |
Don't use only PVS for culling. | |
bool | IsPVSOnly () |
Is PVS only enabled? | |
void | FreezePVS (const csVector3 &pos) |
Freeze the PVS for some position. | |
void | UnfreezePVS () |
Unfreeze the PVS. | |
bool | IsPVSFrozen () |
Is the PVS frozen? | |
const csVector3& | GetFrozenPosition () const |
Return the frozen position for the PVS. | |
virtual void | SetLightingCacheMode (int mode) |
Set the mode for the lighting cache (combination of CS_ENGINE_CACHE_???). More... | |
virtual int | GetLightingCacheMode () |
Get the mode for the lighting cache. | |
virtual int | GetLightmapCellSize () const |
Return current lightmap cell size. | |
virtual void | SetLightmapCellSize (int Size) |
Set lightmap cell size. | |
void | ReadConfig (iConfigFile *) |
Read configuration file (using the system driver) for all engine specific values. More... | |
void | StartEngine () |
Prepare for creation of a world. More... | |
csTextureList* | GetTextures () const |
Return the object managing all loaded textures. | |
csMaterialList* | GetMaterials () const |
Return the object managing all loaded materials. | |
virtual iMaterial* | CreateBaseMaterial (iTextureWrapper *txt) |
Create a base material. | |
virtual iMaterial* | CreateBaseMaterial (iTextureWrapper *txt, int num_layers, iTextureWrapper **wrappers, csTextureLayer *layers) |
Create a base material that can be used to give to the texture manager. More... | |
virtual iMaterialList* | GetMaterialList () const |
Get the list of all materials. | |
virtual iTextureList* | GetTextureList () const |
Get the list of all textures. | |
iMeshWrapper* | CreateSectorWallsMesh (csSector *sector, const char *name) |
Conveniance function to create the thing containing the convex outline of a sector. More... | |
virtual iMeshWrapper* | CreateSectorWallsMesh (iSector *sector, const char *name) |
Conveniance function to create the thing containing the convex outline of a sector. More... | |
void | AddDynLight (csDynLight *dyn) |
Add a dynamic light to the engine. | |
void | RemoveDynLight (csDynLight *dyn) |
Remove a dynamic light from the engine. | |
csDynLight* | GetFirstDynLight () const |
Return the first dynamic light in this engine. | |
int | GetNearbyLights (csSector *sector, const csVector3 &pos, ULong flags, iLight **lights, int max_num_lights) |
This routine returns all lights which might affect an object at some position according to the following flags: . More... | |
csSectorIt* | GetNearbySectors (csSector *sector, const csVector3 &pos, float radius) |
This routine returns an iterator to iterate over all nearby sectors. More... | |
csObjectIt* | GetNearbyObjects (csSector *sector, const csVector3 &pos, float radius) |
This routine returns an iterator to iterate over all objects of a given type that are within a radius of a given position. More... | |
void | AddHalo (csLight *Light) |
Add a halo attached to given light to the engine. | |
void | RemoveHalo (csLight *Light) |
Remove halo attached to given light from the engine. | |
virtual void | Draw (iCamera *c, iClipper2D *clipper) |
Draw the 3D world given a camera and a clipper. More... | |
virtual void | DrawFunc (iCamera *c, iClipper2D *clipper, iDrawFuncCallback *callback) |
This function is similar to Draw. More... | |
csStatLight* | FindCsLight (float x, float y, float z, float dist) const |
Locate the first static light which is closer than 'dist' to the given position. More... | |
csStatLight* | FindCsLight (unsigned long id) const |
Find the light with the given light id. | |
csStatLight* | FindCsLight (const char *name, bool regionOnly=false) const |
Find the light with the given name. | |
csLightIt* | NewLightIterator (iRegion *region=NULL) |
Create an iterator to iterate over all static lights of the engine. | |
void | AddToCurrentRegion (csObject *obj) |
Add an object to the current region. | |
virtual void | RegisterRenderPriority (const char *name, long priority) |
Register a new render priority. | |
virtual long | GetRenderPriority (const char *name) const |
Get a render priority by name. | |
virtual long | GetSkyRenderPriority () const |
Get the render priority for sky objects (attached to 'sky' name). | |
virtual long | GetWallRenderPriority () const |
Get the render priority for wall objects (attached to 'wall' name). | |
virtual long | GetObjectRenderPriority () const |
Get the render priority for general objects (attached to 'object' name). | |
virtual long | GetAlphaRenderPriority () const |
Get the render priority for alpha objects (attached to 'alpha' name). | |
virtual void | ClearRenderPriorities () |
Clear all render priorities. | |
virtual iMeshObjectType* | GetThingType () const |
@ Temporary function until things are moved to a plugin. More... | |
virtual bool | Initialize (iObjectRegistry *object_reg) |
Initialize the engine. More... | |
virtual bool | HandleEvent (iEvent &Event) |
We need to handle some events. | |
virtual csEngine* | GetCsEngine () |
@@KLUDGE: This will no longer be needed once the iEngine interface is complete. | |
virtual int | GetTextureFormat () const |
Query the format to load textures (usually this depends on texture manager). | |
virtual void | SelectRegion (const char *iName) |
Create or select a new region (name can be NULL for the default main region). More... | |
virtual void | SelectRegion (iRegion *region) |
Create or select a new region (region can be NULL for the default main region). More... | |
virtual iRegion* | GetCurrentRegion () const |
Get a reference to the current region (or NULL if the default main region is selected). | |
virtual iRegion* | FindRegion (const char *name) const |
find a region by name. | |
virtual void | DeleteAll () |
Clear the entire engine. | |
virtual iTextureWrapper* | CreateTexture (const char *iName, const char *iFileName, csColor *iTransp, int iFlags) |
Register a texture to be loaded during Prepare(). | |
virtual iMaterialWrapper* | CreateMaterial (const char *iName, iTextureWrapper *texture) |
Register a material to be loaded during Prepare(). | |
virtual iSector* | CreateSector (const char *iName, bool link=true) |
Create a empty sector with given name. | |
virtual iSectorList* | GetSectors () |
Return the list of sectors. | |
virtual iMeshFactoryList* | GetMeshFactories () |
Return the list of mesh factories. | |
virtual iMeshList* | GetMeshes () |
Return the list of meshes. | |
virtual iCollectionList* | GetCollections () |
Return the list of collections. | |
virtual iCameraPositionList* | GetCameraPositions () |
Return the list of camera positions. | |
virtual iCamera* | CreateCamera () |
Create a new camera. | |
virtual iStatLight* | CreateLight (const char *name, const csVector3 &pos, float radius, const csColor &color, bool pseudoDyn) |
Create a static/pseudo-dynamic light. | |
virtual iStatLight* | FindLight (const char *Name, bool RegionOnly=false) const |
Find a static/pseudo-dynamic light by name. | |
virtual iDynLight* | CreateDynLight (const csVector3 &pos, float radius, const csColor &color) |
Create a dynamic light. | |
virtual void | RemoveDynLight (iDynLight *) |
Remove a dynamic light. | |
virtual iMeshFactoryWrapper* | CreateMeshFactory (const char *classId, const char *name) |
Create a mesh factory wrapper from a mesh plugin. | |
virtual iMeshFactoryWrapper* | CreateMeshFactory (iMeshObjectFactory *, const char *name) |
Create a mesh factory wrapper for an existing mesh factory. | |
virtual iMeshFactoryWrapper* | CreateMeshFactory (const char *name) |
Create an uninitialized mesh factory wrapper. | |
virtual iMeshFactoryWrapper* | LoadMeshFactory (const char *classId, const char *name, const char *loaderClassId, iDataBuffer *input) |
Load mesh factory. | |
virtual iMeshWrapper* | CreateMeshWrapper (iMeshFactoryWrapper *factory, const char *name, iSector *sector=NULL, const csVector3 &pos=csVector3(0, 0, 0)) |
Create a mesh wrapper from a mesh factory wrapper. | |
virtual iMeshWrapper* | CreateMeshWrapper (iMeshObject *, const char *name, iSector *sector=NULL, const csVector3 &pos=csVector3(0, 0, 0)) |
Create a mesh wrapper for an existing mesh object. | |
virtual iMeshWrapper* | CreateMeshWrapper (const char *name) |
Create an uninitialized mesh wrapper. | |
virtual iMeshWrapper* | LoadMeshWrapper (const char *classId, const char *name, const char *loaderClassId, iDataBuffer *input, iSector *sector, const csVector3 &pos) |
Load mesh object. | |
virtual iClipper2D* | GetTopLevelClipper () const |
Get the top-level clipper. | |
virtual void | SetAmbientLight (const csColor &c) |
Set the amount of ambient light. | |
virtual void | GetAmbientLight (csColor &c) const |
Return the amount of ambient light. | |
virtual void | SetContext (iGraphics3D *g3d) |
Point engine to rendering context. | |
virtual iGraphics3D* | GetContext () const |
Return the current drawing context. | |
Public Attributes | |
iVFS* | VFS |
This is the Virtual File System object where all the files used by the engine live. More... | |
iReporter* | Reporter |
Pointer to an optional reporter that will be used for notification and warning messages. | |
csObjVector | cleanup |
This is a vector which holds objects of type 'csCleanable'. More... | |
csSectorList | sectors |
List of sectors in the engine. More... | |
csCollectionList | collections |
List of all collections in the engine. More... | |
csMeshFactoryList | mesh_factories |
List of mesh object factories. More... | |
csEngineMeshList | meshes |
List of all meshes in the engine. More... | |
csCameraPositionList | camera_positions |
The list of all camera position objects. | |
csPoly2DPool* | render_pol2d_pool |
An object pool for 2D polygons used by the rendering process. | |
csLightPatchPool* | lightpatch_pool |
An object pool for lightpatches. | |
iGraphics3D* | G3D |
The 3D driver. | |
iGraphics2D* | G2D |
The 2D driver. | |
iImageIO* | ImageLoader |
The graphics loader. | |
G3D_FOGMETHOD | fogmethod |
The fog mode this G3D implements. | |
bool | NeedPO2Maps |
Does the 3D driver require power-of-two lightmaps? | |
int | MaxAspectRatio |
Maximum texture aspect ratio. | |
iRegion* | region |
A pointer to the current region. | |
csNamedObjVector | regions |
The list of all regions currently loaded. | |
csVector | render_priorities |
The list of all named render priorities. | |
long | render_priority_sky |
The engine knows about the following render priorities and keeps them here:. More... | |
long | render_priority_wall |
long | render_priority_object |
long | render_priority_alpha |
iCamera* | current_camera |
The current camera for drawing the world. | |
iClipper2D* | top_clipper |
The top-level clipper we are currently using for drawing. | |
csThingObjectType* | thing_type |
@ Temporary until things move to their own mesh plugin system. More... | |
SCF_DECLARE_IBASE | |
csEngine::eiComponent | scfiComponent |
csEngine::eiEventHandler | scfiEventHandler |
csEngineConfig | scfiConfig |
Static Public Methods | |
void | SetMaxProcessPolygons (int m) |
Set the maximum number of polygons to process in one frame. More... | |
int | GetMaxProcessPolygons () |
Get the maximum number of polygons to process in one frame. | |
bool | ProcessPolygon () |
Indicate that we will process another polygon. More... | |
bool | ProcessLastPolygon () |
Return true if we are processing the last polygon. | |
Static Public Attributes | |
int | frame_width |
Remember dimensions of display. | |
int | frame_height |
Remember dimensions of display. | |
iObjectRegistry* | object_reg |
Remember iObjectRegistry. | |
iPluginManager* | plugin_mgr |
Remember iPluginManager. | |
csEngine* | current_engine |
The shared engine instance. | |
iEngine* | current_iengine |
The shared engine instance. | |
bool | use_new_radiosity |
Need to render using newradiosity? | |
int | lightcache_mode |
Option variable: force lightmap recalculation? | |
int | lightmap_quality |
Option variable: quality for lightmap calculation. | |
bool | do_force_revis |
Option variable: force visibility recalculation? | |
bool | do_rad_debug |
Option variable: radiosity debugging (step by step)? | |
Friends | |
class | csEngineState |
This class manages all components which comprise a 3D world including sectors, polygons, curves, mesh objects, etc.
|
Initialize an empty engine. The only thing that is valid just after creating the engine is the configurator object which you can use to configure the engine before continuing (see GetEngineConfig()). |
|
Delete the engine and all entities it contains. All objects added to this engine 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 engine. |
|
Check consistency of the loaded elements which comprise the world. Currently this function only checks if polygons have three or more vertices and if the vertices are coplanar (if more than three). This function prints out warnings for all found errors. Returns true if everything is in order. |
|
Create a base material that can be used to give to the texture manager. This version also supports texture layers. Reimplemented from iEngine. |
|
Conveniance function to create the thing containing the convex outline of a sector. The thing will be empty but it will have CS_ZBUF_FILL set. This version creates a mesh wrapper. Reimplemented from iEngine. |
|
Conveniance function to create the thing containing the convex outline of a sector. The thing will be empty but it will have CS_ZBUF_FILL set. This version creates a mesh wrapper. |
|
Draw the 3D 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. Reimplemented from iEngine. |
|
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). Reimplemented from iEngine. |
|
Use only PVS for culling. This flag only makes sense when PVS is enabled. |
|
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. |
|
Get the required flags for 3D->BeginDraw() which should be called from the application. These flags must be or-ed with optional other flags that the application might be interested in. Reimplemented from iEngine. |
|
Get the current engine mode. If called between SetEngineMode() and the first Draw() it is possible that this mode will still be CS_ENGINE_AUTODETECT. Reimplemented from iEngine. |
|
This routine returns all lights which might affect an object at some position according to the following flags:
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. |
|
This routine returns an iterator to iterate over all objects of a given type that are within a radius of a given position. You can use SCF_QUERY_INTERFACE to get any interface from the returned objects. Delete the iterator with 'delete' when ready. |
|
This routine returns an iterator to iterate over all nearby sectors. Delete the iterator with 'delete' when ready. |
|
@ Temporary function until things are moved to a plugin. @ Reimplemented from iEngine. |
|
Initialize the engine. This is automatically called by system driver at startup so that plugin can do basic initialization stuff, register with the system driver and so on. |
|
Invalidate all lightmaps. This can be called after doing a significant change on the static lightmaps (i.e. after doing a radiosity debug function). |
|
Prepare the engine. 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). The optional progress meter will be used to report progress. Reimplemented from iEngine. |
|
Calls UpdateMove for all meshes to initialise bsp bounding boxes. Call this after creating a BSP tree. csEngine::Prepare() will call this function automatically so you normally don't have to call it. |
|
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. This function will also prepare all loaded materials after preparing the textures. |
|
Indicate that we will process another polygon. Returns false if we need to stop. |
|
Read configuration file (using the system driver) for all engine specific values. This function is called by Initialize() so you normally do not need to call it yourselves. |
|
Create or select a new region (region can be NULL for the default main region). All new objects will be marked as belonging to this region. Reimplemented from iEngine. |
|
Create or select a new region (name can be NULL for the default main region). All new objects will be marked as belonging to this region. Reimplemented from iEngine. |
|
Set the desired engine mode. One of the CS_ENGINE_... flags. Default is CS_ENGINE_AUTODETECT. If you select CS_ENGINE_AUTODETECT then the mode will be auto-detected (depending on level and/or hardware capabilities) the first time csEngine::Draw() is called. Reimplemented from iEngine. |
|
Set the mode for the lighting cache (combination of CS_ENGINE_CACHE_???). Default is CS_ENGINE_CACHE_READ. Reimplemented from iEngine. |
|
Set the maximum number of polygons to process in one frame. This is mainly useful for debugging. |
|
Calculate all lighting information. Normally you shouldn't call this function directly, because it will be called by Prepare(). If the optional 'region' parameter is given then only lights will be recalculated for the given region. Reimplemented from iEngine. |
|
Prepare for creation of a world. This function is called by Initialize() so you normally do not need to call it yourselves. |
|
This is the Virtual File System object where all the files used by the engine live. Textures, models, data, everything - reside on this virtual disk volume. You should avoid using the standard file functions (such as fopen(), fread() and so on) since they are highly system-dependent (for example, DOS uses '\' as path separator, Mac uses ':' and Unix uses '/'). |
|
This is a vector which holds objects of type 'csCleanable'. They will be destroyed when the engine 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 engine is destroyed. |
|
List of all collections in the engine. This vector contains objects of type iCollection*. |
|
List of mesh object factories. This vector contains objects of type csMeshFactoryWrapper*. |
|
List of all meshes in the engine. This vector contains objects of type csMeshWrapper*. Use RemoveMesh() to remove meshes from this list. This function will take care of correctly removing the meshes from all sectors as well. Note that after you add a mesh to the list you still need to add it to all sectors that you want it to be visible in. |
|
The engine knows about the following render priorities and keeps them here:.
|
|
List of sectors in the engine. This vector contains objects of type iSector*. Use CreateSector() to add sectors to the engine. |
|
@ Temporary until things move to their own mesh plugin system. @ |