Google

Main Page   Class Hierarchy   Compound List   File List   Compound Members  

iEngine Struct Reference

This interface is the main interface to the 3D engine. More...

#include <engine.h>

Inheritance diagram for iEngine:

iBase csEngine List of all members.

Public Methods

virtual csEngineGetCsEngine ()=0
 @@KLUDGE: This will no longer be needed once the iEngine interface is complete.

virtual iObjectQueryObject ()=0
 Get the iObject for the engine.

virtual bool Prepare (iProgressMeter *meter=NULL)=0
 Prepare the engine. More...

virtual void PrepareTextures ()=0
 Prepare the textures. More...

virtual void PrepareMeshes ()=0
 Calls UpdateMove for all meshes to initialise bsp bounding boxes. More...

virtual void ShineLights (iRegion *region=NULL, iProgressMeter *meter=NULL)=0
 Calculate all lighting information. More...

virtual int GetTextureFormat () const=0
 Query the format to load textures (usually this depends on texture manager).

virtual bool IsPVS () const=0
 Return true if engine want to use PVS.

virtual void SelectRegion (const char *name)=0
 Create or select a new region (name can be NULL for the default main region). More...

virtual void SelectRegion (iRegion *region)=0
 Create or select a new region (region can be NULL for the default main region). More...

virtual iRegionGetCurrentRegion () const=0
 Get a reference to the current region (or NULL if the default main region is selected).

virtual void DeleteAll ()=0
 Delete everything in the engine.

virtual void RegisterRenderPriority (const char *name, long priority, int rendsort=CS_RENDPRI_NONE)=0
 Register a new render priority. More...

virtual long GetRenderPriority (const char *name) const=0
 Get a render priority by name.

virtual int GetRenderPrioritySorting (const char *name) const=0
 Get the render priority sorting flag.

virtual int GetRenderPrioritySorting (long priority) const=0
 Get the render priority sorting flag.

virtual long GetSkyRenderPriority () const=0
 Get the render priority for sky objects (attached to 'sky' name).

virtual long GetWallRenderPriority () const=0
 Get the render priority for wall objects (attached to 'wall' name).

virtual long GetObjectRenderPriority () const=0
 Get the render priority for general objects (attached to 'object' name).

virtual long GetAlphaRenderPriority () const=0
 Get the render priority for alpha objects (attached to 'alpha' name).

virtual void ClearRenderPriorities ()=0
 Clear all render priorities.

virtual iMaterialCreateBaseMaterial (iTextureWrapper *txt)=0
 Create a base material that can be used to give to the texture manager.

virtual iMaterialCreateBaseMaterial (iTextureWrapper *txt, int num_layers, iTextureWrapper **wrappers, csTextureLayer *layers)=0
 Create a base material that can be used to give to the texture manager. More...

virtual iTextureWrapperCreateTexture (const char *name, const char *fileName, csColor *transp, int flags)=0
 Register a texture to be loaded during Prepare().

virtual iMaterialWrapperCreateMaterial (const char *name, iTextureWrapper *texture)=0
 Register a material to be loaded during Prepare().

virtual iSectorCreateSector (const char *name)=0
 Create a empty sector with given name.

virtual iMeshWrapperCreateSectorWallsMesh (iSector *sector, const char *name)=0
 Conveniance function to create the thing containing the convex outline of a sector. More...

virtual iSectorListGetSectors ()=0
 Get the list of sectors.

virtual iMeshFactoryListGetMeshFactories ()=0
 Get the list of mesh factories.

virtual iMeshListGetMeshes ()=0
 Get the list of meshes.

virtual iCollectionList* GetCollections ()=0
 Get the list of collections.

virtual iCameraPositionListGetCameraPositions ()=0
 Get the list of camera positions.

virtual iTextureListGetTextureList () const=0
 Get the list of all textures.

virtual iMaterialListGetMaterialList () const=0
 Get the list of all materials.

virtual iRegionListGetRegions ()=0
 Get the list of all regions.

virtual iMaterialWrapperFindMaterial (const char *name, iRegion *region=NULL)=0
 Find the given material. More...

virtual iTextureWrapperFindTexture (const char *name, iRegion *region=NULL)=0
 Find the given texture. More...

virtual iSectorFindSector (const char *name, iRegion *region=NULL)=0
 Find the given sector. More...

virtual iMeshWrapperFindMeshObject (const char *name, iRegion *region=NULL)=0
 Find the given mesh object. More...

virtual iMeshFactoryWrapperFindMeshFactory (const char *name, iRegion *region=NULL)=0
 Find the given mesh factory. More...

virtual iCameraPositionFindCameraPosition (const char *name, iRegion *region=NULL)=0
 Find the given camera position. More...

virtual iCollectionFindCollection (const char *name, iRegion *region=NULL)=0
 Find the given collection. More...

virtual void SetLightingCacheMode (int mode)=0
 Set the mode for the lighting cache (combination of CS_ENGINE_CACHE_???). More...

virtual int GetLightingCacheMode ()=0
 Get the mode for the lighting cache.

virtual int GetLightmapCellSize () const=0
 Return the current lightmap cell size.

virtual void SetLightmapCellSize (int Size)=0
 Set lightmap cell size.

virtual iCameraCreateCamera ()=0
 Create a new camera.

virtual iStatLightCreateLight (const char *name, const csVector3 &pos, float radius, const csColor &color, bool pseudoDyn)=0
 Create a static/pseudo-dynamic light. name can be NULL.

virtual iStatLightFindLight (const char *Name, bool RegionOnly=false) const=0
 Find a static/pseudo-dynamic light by name.

virtual iDynLightCreateDynLight (const csVector3 &pos, float radius, const csColor &color)=0
 Create a dynamic light.

virtual void RemoveDynLight (iDynLight *)=0
 Remove a dynamic light.

virtual void SetClearZBuf (bool yesno)=0
 Require that the Z-buffer is cleared every frame. More...

virtual bool GetClearZBuf () const=0
 Get the value of the clear Z-buffer flag set with SetClearZBuf().

virtual int GetBeginDrawFlags () const=0
 Get the required flags for 3D->BeginDraw() which should be called from the application. More...

virtual void SetEngineMode (int mode)=0
 Set the desired engine mode. More...

virtual int GetEngineMode () const=0
 Get the current engine mode. More...

virtual iClipper2DGetTopLevelClipper () const=0
 Get the top-level clipper.

virtual iMeshFactoryWrapperCreateMeshFactory (const char *classId, const char *name)=0
 Conveniance function to create a mesh factory from a given type. More...

virtual iMeshFactoryWrapperCreateMeshFactory (iMeshObjectFactory *, const char *name)=0
 Create a mesh factory wrapper for an existing mesh factory.

virtual iMeshFactoryWrapperCreateMeshFactory (const char *name)=0
 Create an uninitialized mesh factory wrapper.

virtual iLoaderContextCreateLoaderContext (iRegion *region=NULL)=0
 Create a loader context that you can give to loader plugins. More...

virtual iMeshFactoryWrapperLoadMeshFactory (const char *name, const char *loaderClassId, iDataBuffer *input)=0
 Conveniance function to load a mesh factory from a given loader plugin.

virtual iMeshWrapperCreateMeshWrapper (iMeshFactoryWrapper *factory, const char *name, iSector *sector=NULL, const csVector3 &pos=csVector3(0, 0, 0))=0
 Conveniance function to create a mesh object for a given factory. More...

virtual iMeshWrapperCreateMeshWrapper (iMeshObject *, const char *name, iSector *sector=NULL, const csVector3 &pos=csVector3(0, 0, 0))=0
 Create a mesh wrapper for an existing mesh object.

virtual iMeshWrapperCreateMeshWrapper (const char *name)=0
 Create an uninitialized mesh wrapper.

virtual iMeshWrapperLoadMeshWrapper (const char *name, const char *loaderClassId, iDataBuffer *input, iSector *sector, const csVector3 &pos)=0
 Conveniance function to load a mesh object from a given loader plugin. More...

virtual iMeshObjectTypeGetThingType () const=0
 @@ This function is deprecated! Please don't use it! Only the engine and thing mesh objects should use this now.

virtual void Draw (iCamera *c, iClipper2D *clipper)=0
 Draw the 3D world given a camera and a clipper. More...

virtual void DrawFunc (iCamera *c, iClipper2D *clipper, iDrawFuncCallback *callback)=0
 This function is similar to Draw. More...

virtual void SetContext (iGraphics3D *)=0
 Set the drawing context.

virtual iGraphics3DGetContext () const=0
 Return the current drawing context.

virtual void SetAmbientLight (const csColor &)=0
 Set the amount of ambient light. More...

virtual void GetAmbientLight (csColor &) const=0
 Return the amount of ambient light.

virtual int GetNearbyLights (iSector *sector, const csVector3 &pos, uint32 flags, iLight **lights, int max_num_lights)=0
 This routine returns all lights which might affect an object at some position according to the following flags:
.
More...


virtual iSectorIteratorGetNearbySectors (iSector *sector, const csVector3 &pos, float radius)=0
 This routine returns an iterator to iterate over all nearby sectors. More...

virtual iObjectIteratorGetNearbyObjects (iSector *sector, const csVector3 &pos, float radius)=0
 This routine returns an iterator to iterate over all objects of a given type that are within a radius of a given position. More...

virtual bool RemoveObject (iBase *object)=0
 Conveniance function to 'remove' a CS object from the engine. More...

virtual void SetCacheManager (iCacheManager *cache_mgr)=0
 Set the cache manager that the engine will use. More...

virtual iCacheManagerGetCacheManager ()=0
 Get the cache manager that the engine is currently using.


Detailed Description

This interface is the main interface to the 3D engine.

The engine is responsible for creating new engine-specific objects such as sectors, things, sprites and so on.


Member Function Documentation

iMaterial * iEngine::CreateBaseMaterial ( iTextureWrapper * txt,
int num_layers,
iTextureWrapper ** wrappers,
csTextureLayer * layers ) [pure virtual]
 

Create a base material that can be used to give to the texture manager.

This version also supports texture layers.

Reimplemented in csEngine.

iLoaderContext * iEngine::CreateLoaderContext ( iRegion * region = NULL ) [pure virtual]
 

Create a loader context that you can give to loader plugins.

It will basically allow loader plugins to find materials, ... If region != NULL then only that region will be searched. Destroy this object with DecRef(). The engine itself does not keep track of it.

Reimplemented in csEngine.

iMeshFactoryWrapper * iEngine::CreateMeshFactory ( const char * classId,
const char * name ) [pure virtual]
 

Conveniance function to create a mesh factory from a given type.

The type plugin will only be loaded if needed. 'classId' is the SCF name of the plugin (like 'crystalspace.mesh.object.cube'). Returns NULL on failure. The factory will be registered with the engine under the given name. If there is already a factory with that name no new factory will be created but the found one is returned instead. If the name is NULL then no name will be set and no check will happen if the factory already exists.

Reimplemented in csEngine.

iMeshWrapper * iEngine::CreateMeshWrapper ( iMeshFactoryWrapper * factory,
const char * name,
iSector * sector = NULL,
const csVector3 & pos = csVector3(0, 0, 0) ) [pure virtual]
 

Conveniance function to create a mesh object for a given factory.

If 'sector' is NULL then the mesh object will not be set to a position. Returns NULL on failure. The object will be given the specified name. 'name' can be NULL if no name is wanted. Different mesh objects can have the same name (in contrast with factory objects).

Reimplemented in csEngine.

iMeshWrapper * iEngine::CreateSectorWallsMesh ( iSector * sector,
const char * name ) [pure virtual]
 

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 (so that the Z-buffer will be filled by the polygons of this object) and have 'wall' as render priority. This version creates a mesh wrapper.

Reimplemented in csEngine.

void iEngine::Draw ( iCamera * c,
iClipper2D * clipper ) [pure virtual]
 

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 in csEngine.

void iEngine::DrawFunc ( iCamera * c,
iClipper2D * clipper,
iDrawFuncCallback * callback ) [pure virtual]
 

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 edges for example).

Reimplemented in csEngine.

iCameraPosition * iEngine::FindCameraPosition ( const char * name,
iRegion * region = NULL ) [pure virtual]
 

Find the given camera position.

The name can be a normal name. In that case this function will look in all regions except if region is not NULL in which case it will only look in that region. If the name is specified as 'regionname/objectname' then this function will only look in the specified region and return NULL if that region doesn't contain the object or the region doesn't exist. In this case the region parameter is ignored.

Reimplemented in csEngine.

iCollection * iEngine::FindCollection ( const char * name,
iRegion * region = NULL ) [pure virtual]
 

Find the given collection.

The name can be a normal name. In that case this function will look in all regions except if region is not NULL in which case it will only look in that region. If the name is specified as 'regionname/objectname' then this function will only look in the specified region and return NULL if that region doesn't contain the object or the region doesn't exist. In this case the region parameter is ignored.

Reimplemented in csEngine.

iMaterialWrapper * iEngine::FindMaterial ( const char * name,
iRegion * region = NULL ) [pure virtual]
 

Find the given material.

The name can be a normal name. In that case this function will look in all regions except if region is not NULL in which case it will only look in that region. If the name is specified as 'regionname/objectname' then this function will only look in the specified region and return NULL if that region doesn't contain the object or the region doesn't exist. In this case the region parameter is ignored.

Reimplemented in csEngine.

iMeshFactoryWrapper * iEngine::FindMeshFactory ( const char * name,
iRegion * region = NULL ) [pure virtual]
 

Find the given mesh factory.

The name can be a normal name. In that case this function will look in all regions except if region is not NULL in which case it will only look in that region. If the name is specified as 'regionname/objectname' then this function will only look in the specified region and return NULL if that region doesn't contain the object or the region doesn't exist. In this case the region parameter is ignored.

Reimplemented in csEngine.

iMeshWrapper * iEngine::FindMeshObject ( const char * name,
iRegion * region = NULL ) [pure virtual]
 

Find the given mesh object.

The name can be a normal name. In that case this function will look in all regions except if region is not NULL in which case it will only look in that region. If the name is specified as 'regionname/objectname' then this function will only look in the specified region and return NULL if that region doesn't contain the object or the region doesn't exist. In this case the region parameter is ignored.

Reimplemented in csEngine.

iSector * iEngine::FindSector ( const char * name,
iRegion * region = NULL ) [pure virtual]
 

Find the given sector.

The name can be a normal name. In that case this function will look in all regions except if region is not NULL in which case it will only look in that region. If the name is specified as 'regionname/objectname' then this function will only look in the specified region and return NULL if that region doesn't contain the object or the region doesn't exist. In this case the region parameter is ignored.

Reimplemented in csEngine.

iTextureWrapper * iEngine::FindTexture ( const char * name,
iRegion * region = NULL ) [pure virtual]
 

Find the given texture.

The name can be a normal name. In that case this function will look in all regions except if region is not NULL in which case it will only look in that region. If the name is specified as 'regionname/objectname' then this function will only look in the specified region and return NULL if that region doesn't contain the object or the region doesn't exist. In this case the region parameter is ignored.

Reimplemented in csEngine.

int iEngine::GetBeginDrawFlags ( ) const [pure virtual]
 

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. Use SetClearZBuf() to let this function return that the Z-buffer must be cleared.

Reimplemented in csEngine.

int iEngine::GetEngineMode ( ) const [pure virtual]
 

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 in csEngine.

int iEngine::GetNearbyLights ( iSector * sector,
const csVector3 & pos,
uint32 flags,
iLight ** lights,
int max_num_lights ) [pure virtual]
 

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.

Reimplemented in csEngine.

iObjectIterator * iEngine::GetNearbyObjects ( iSector * sector,
const csVector3 & pos,
float radius ) [pure virtual]
 

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 'DecRef()' when ready.

Reimplemented in csEngine.

iSectorIterator * iEngine::GetNearbySectors ( iSector * sector,
const csVector3 & pos,
float radius ) [pure virtual]
 

This routine returns an iterator to iterate over all nearby sectors.

Delete the iterator with 'DecRef()' when ready.

Reimplemented in csEngine.

iMeshWrapper * iEngine::LoadMeshWrapper ( const char * name,
const char * loaderClassId,
iDataBuffer * input,
iSector * sector,
const csVector3 & pos ) [pure virtual]
 

Conveniance function to load a mesh object from a given loader plugin.

If sector == NULL the object will not be placed in a sector.

Reimplemented in csEngine.

bool iEngine::Prepare ( iProgressMeter * meter = NULL ) [pure virtual]
 

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 in csEngine.

void iEngine::PrepareMeshes ( ) [pure virtual]
 

Calls UpdateMove for all meshes to initialise bsp bounding boxes.

Call this after creating a BSP tree. Prepare() will call this function automatically so you normally don't have to call it.

Reimplemented in csEngine.

void iEngine::PrepareTextures ( ) [pure virtual]
 

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.

Reimplemented in csEngine.

void iEngine::RegisterRenderPriority ( const char * name,
long priority,
int rendsort = CS_RENDPRI_NONE ) [pure virtual]
 

Register a new render priority.

The parameter rendsort is one of the CS_RENDPRI_... flags. By default this is CS_RENDPRI_NONE. The following values are possible:

  • CS_RENDPRI_NONE: objects in this render priority are not sorted.
  • CS_RENDPRI_FRONT2BACK: sort objects front to back (as seen from camera viewpoint).
  • CS_RENDPRI_BACK2FRONT: sort objects back to front.

Reimplemented in csEngine.

bool iEngine::RemoveObject ( iBase * object ) [pure virtual]
 

Conveniance function to 'remove' a CS object from the engine.

This will not clear the object but it will remove all references to that object that the engine itself keeps. This function works for: iSector, iCollection, iMeshWrapper, iMeshFactoryWrapper, iCameraPosition, iDynLight, iMaterialWrapper, and iTextureWrapper. In addition this function also knows about iCurveTemplate and iPolyTxtPlane from the thing environment and will be able to clean those up too. Note that the object is only removed if the resulting ref count will become zero. So basically this function only releases the references that the engine holds.

This function returns true if the engine recognized the object as one on which it can operate.

This function will also remove the object from the region it may be in.

Reimplemented in csEngine.

void iEngine::SelectRegion ( iRegion * region ) [pure virtual]
 

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 in csEngine.

void iEngine::SelectRegion ( const char * iName ) [pure virtual]
 

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 in csEngine.

void iEngine::SetAmbientLight ( const csColor & c ) [pure virtual]
 

Set the amount of ambient light.

This has no effect until you recalculate the lightmaps.

Reimplemented in csEngine.

void iEngine::SetCacheManager ( iCacheManager * cache_mgr ) [pure virtual]
 

Set the cache manager that the engine will use.

If this is not done then the engine will use its own cache manager based on VFS. This will do an incref on the given cache manager and a decref on the old one. The engine will release the cache manager at destruction time.

Reimplemented in csEngine.

void iEngine::SetClearZBuf ( bool yesno ) [pure virtual]
 

Require that the Z-buffer is cleared every frame.

The engine itself will not use this setting but will only return the correct flag in GetBeginDrawFlags() so that the Z-buffer is actually cleared. Note that this requires that the application actually uses GetBeginDrawFlags() in the call to g3d->BeginDraw() (which it should). By default this flag is false. It is useful to set this flag to true if you have a level that doesn't itself have another way to initialize the Z-buffer.

Reimplemented in csEngine.

void iEngine::SetEngineMode ( int mode ) [pure virtual]
 

Set the desired engine mode.

One of the CS_ENGINE_... flags. Default is CS_ENGINE_AUTODETECT.

  • CS_ENGINE_AUTODETECT: try to auto-detect the best mode to use for rendering this level (also depends on hardware capabilities). This is calculated the first time iEngine->Draw() is called.
  • CS_ENGINE_BACK2FRONT: Render polygons back to front (optionally using octree/bsp for this).
  • CS_ENGINE_FRONT2BACK: Use the c-buffer for culling polygons and render front to back (only if octree/bsp tree is available).
  • CS_ENGINE_ZBUFFER: Use the Z-buffer for rendering.

Reimplemented in csEngine.

void iEngine::SetLightingCacheMode ( int mode ) [pure virtual]
 

Set the mode for the lighting cache (combination of CS_ENGINE_CACHE_???).

Default is CS_ENGINE_CACHE_READ.

  • CS_ENGINE_CACHE_READ: Read the cache.
  • CS_ENGINE_CACHE_WRITE: Write the cache.

Reimplemented in csEngine.

void iEngine::ShineLights ( iRegion * region = NULL,
iProgressMeter * meter = NULL ) [pure virtual]
 

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 in csEngine.


The documentation for this struct was generated from the following file:
Generated for Crystal Space by doxygen 1.2.5 written by Dimitri van Heesch, ©1997-2000