CrystalSpace

Public API Reference

iengine/engine.h

Go to the documentation of this file.
00001 /*
00002     Crystal Space 3D Engine
00003     Copyright (C) 1998-2002 by Jorrit Tyberghein
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public
00016     License along with this library; if not, write to the Free
00017     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 */
00019 
00020 #ifndef __CS_IENGINE_ENGINE_H__
00021 #define __CS_IENGINE_ENGINE_H__
00022 
00031 #include "csutil/scf_interface.h"
00032 
00033 #include "csgeom/vector3.h"
00034 
00035 #include "iengine/light.h"
00036 
00037 class csBox3;
00038 class csColor;
00039 class csFrustum;
00040 
00041 struct iCacheManager;
00042 struct iCamera;
00043 struct iCameraPosition;
00044 struct iCameraPositionList;
00045 struct iClipper2D;
00046 struct iCollection;
00047 struct iCollectionList;
00048 struct iDataBuffer;
00049 struct iFrustumView;
00050 struct iLight;
00051 struct iLightIterator;
00052 struct iLoaderContext;
00053 struct iMaterial;
00054 struct iMaterialList;
00055 struct iMaterialWrapper;
00056 struct iMeshFactoryList;
00057 struct iMeshFactoryWrapper;
00058 struct iMeshList;
00059 struct iMeshObject;
00060 struct iMeshObjectFactory;
00061 struct iMeshObjectType;
00062 struct iMeshWrapper;
00063 struct iMeshWrapperIterator;
00064 struct iObject;
00065 struct iObjectIterator;
00066 struct iObjectWatcher;
00067 struct iPortal;
00068 struct iProgressMeter;
00069 struct iRegion;
00070 struct iRegionList;
00071 struct iRenderLoop;
00072 struct iRenderLoopManager;
00073 struct iRenderView;
00074 struct iSector;
00075 struct iSectorIterator;
00076 struct iSectorList;
00077 struct iSharedVariableList;
00078 struct iTextureHandle;
00079 struct iTextureList;
00080 struct iTextureWrapper;
00081 
00082 struct iEngine;
00083 
00089 #define CS_ENGINE_CACHE_READ 1
00090 
00094 #define CS_ENGINE_CACHE_WRITE 2
00095 
00099 #define CS_ENGINE_CACHE_NOUPDATE 4
00100 
00104 enum csRenderPrioritySorting
00105 {
00109   CS_RENDPRI_SORT_NONE = 0,
00110 
00114   CS_RENDPRI_SORT_BACK2FRONT = 1,
00115 
00119   CS_RENDPRI_SORT_FRONT2BACK = 2
00120 };
00131 struct iEngineFrameCallback : public virtual iBase
00132 {
00133   SCF_INTERFACE(iEngineFrameCallback,1,0,0);
00137   virtual void StartFrame (iEngine* engine, iRenderView* rview) = 0;
00138 };
00139 
00147 struct iEngineSectorCallback : public virtual iBase
00148 {
00149   SCF_INTERFACE(iEngineSectorCallback,2,0,0);
00153   virtual void NewSector (iEngine* engine, iSector* sector) = 0;
00154 
00158   virtual void RemoveSector (iEngine* engine, iSector* sector) = 0;
00159 };
00160 
00161 
00176 struct iEngine : public virtual iBase
00177 {
00178   SCF_INTERFACE(iEngine,2,0,0);
00179   
00181   virtual iObject *QueryObject() = 0;
00182 
00201   virtual bool Prepare (iProgressMeter* meter = 0) = 0;
00202 
00210   virtual void PrepareTextures () = 0;
00211 
00217   virtual void PrepareMeshes () = 0;
00218 
00234   virtual void ForceRelight (iRegion* region = 0,
00235         iProgressMeter* meter = 0) = 0;
00236 
00249   virtual void ForceRelight (iLight* light, iRegion* region = 0) = 0;
00250 
00261   virtual void ShineLights (iRegion* region = 0,
00262         iProgressMeter* meter = 0) = 0;
00263 
00276   virtual void SetLightingCacheMode (int mode) = 0;
00277 
00279   virtual int GetLightingCacheMode () = 0;
00280 
00293   virtual void SetCacheManager (iCacheManager* cache_mgr) = 0;
00294 
00301   virtual void SetVFSCacheManager (const char* vfspath = 0) = 0;
00302 
00306   virtual iCacheManager* GetCacheManager () = 0;
00307 
00314   virtual void SetMaxLightmapSize (int w, int h) = 0;
00315 
00320   virtual void GetMaxLightmapSize (int& w, int& h) = 0;
00321 
00326   virtual void GetDefaultMaxLightmapSize (int& w, int& h) = 0;
00327 
00329   virtual int GetMaxLightmapAspectRatio () const = 0;
00330   
00357   virtual void RegisterRenderPriority (const char* name, long priority,
00358         csRenderPrioritySorting rendsort = CS_RENDPRI_SORT_NONE) = 0;
00359 
00367   virtual long GetRenderPriority (const char* name) const = 0;
00369   virtual csRenderPrioritySorting GetRenderPrioritySorting (
00370         const char* name) const = 0;
00372   virtual csRenderPrioritySorting GetRenderPrioritySorting (
00373         long priority) const = 0;
00375   virtual long GetSkyRenderPriority () = 0;
00377   virtual long GetPortalRenderPriority () = 0;
00379   virtual long GetWallRenderPriority () = 0;
00381   virtual long GetObjectRenderPriority () = 0;
00383   virtual long GetAlphaRenderPriority () = 0;
00385   virtual void ClearRenderPriorities () = 0;
00387   virtual int GetRenderPriorityCount () const = 0;
00389   virtual const char* GetRenderPriorityName (long priority) const = 0;
00390 
00405   virtual csPtr<iMaterial> CreateBaseMaterial (iTextureWrapper* txt) = 0;
00406 
00412   virtual iMaterialWrapper* CreateMaterial (const char *name,
00413         iTextureWrapper* texture) = 0;
00414 
00416   virtual iMaterialList* GetMaterialList () const = 0;
00417 
00430   virtual iMaterialWrapper* FindMaterial (const char* name,
00431         iRegion* region = 0) = 0;
00432 
00454   virtual iTextureWrapper* CreateTexture (const char *name,
00455         const char *fileName, csColor *transp, int flags) = 0;
00456 
00467   virtual iTextureWrapper* CreateBlackTexture (const char *name,
00468         int w, int h, csColor *transp, int flags) = 0;
00469 
00474   virtual int GetTextureFormat () const = 0;
00475 
00477   virtual iTextureList* GetTextureList () const = 0;
00478 
00491   virtual iTextureWrapper* FindTexture (const char* name,
00492         iRegion* region = 0) = 0;
00493 
00520   virtual csPtr<iLight> CreateLight (const char* name, const csVector3& pos,
00521         float radius, const csColor& color,
00522         csLightDynamicType dyntype = CS_LIGHT_DYNAMICTYPE_STATIC) = 0;
00523 
00528   virtual iLight* FindLight (const char *Name, bool RegionOnly = false)
00529     const = 0;
00530 
00535   virtual iLight* FindLightID (const char* light_id) const = 0;
00536 
00543   virtual csPtr<iLightIterator> GetLightIterator (iRegion* region = 0) = 0;
00544 
00555   virtual void RemoveLight (iLight* light) = 0;
00556 
00561   virtual void SetAmbientLight (const csColor &) = 0;
00563   virtual void GetAmbientLight (csColor &) const = 0;
00565   virtual void GetDefaultAmbientLight (csColor &c) const = 0;
00566 
00578   virtual int GetNearbyLights (iSector* sector, const csVector3& pos,
00579         iLight** lights, int max_num_lights) = 0;
00580 
00592   virtual int GetNearbyLights (iSector* sector, const csBox3& box,
00593         iLight** lights, int max_num_lights) = 0;
00594 
00604   virtual iSector *CreateSector (const char *name) = 0;
00605 
00607   virtual iSectorList* GetSectors () = 0;
00608 
00621   virtual iSector* FindSector (const char* name,
00622         iRegion* region = 0) = 0;
00623 
00632   virtual csPtr<iSectorIterator> GetNearbySectors (iSector* sector,
00633         const csVector3& pos, float radius) = 0;
00634 
00643   virtual csPtr<iSectorIterator> GetNearbySectors (iSector* sector,
00644         const csBox3& box) = 0;
00645 
00650   virtual void AddEngineFrameCallback (iEngineFrameCallback* cb) = 0;
00651 
00655   virtual void RemoveEngineFrameCallback (iEngineFrameCallback* cb) = 0;
00656 
00661   virtual void AddEngineSectorCallback (iEngineSectorCallback* cb) = 0;
00662 
00666   virtual void RemoveEngineSectorCallback (iEngineSectorCallback* cb) = 0;
00667 
00686   virtual csPtr<iMeshWrapper> CreateMeshWrapper (iMeshFactoryWrapper* factory,
00687         const char* name, iSector* sector = 0,
00688         const csVector3& pos = csVector3 (0, 0, 0)) = 0;
00689 
00702   virtual csPtr<iMeshWrapper> CreateMeshWrapper (iMeshObject* meshobj,
00703         const char* name, iSector* sector = 0,
00704         const csVector3& pos = csVector3 (0, 0, 0)) = 0;
00705 
00725   virtual csPtr<iMeshWrapper> CreateMeshWrapper (const char* classid,
00726         const char* name, iSector* sector = 0,
00727         const csVector3& pos = csVector3 (0, 0, 0)) = 0;
00728 
00733   virtual csPtr<iMeshWrapper> CreateMeshWrapper (const char* name) = 0;
00734 
00745   virtual csPtr<iMeshWrapper> CreateSectorWallsMesh (iSector* sector,
00746       const char* name) = 0;
00747 
00757   virtual csPtr<iMeshWrapper> CreateThingMesh (iSector* sector,
00758         const char* name) = 0;
00759 
00774   virtual csPtr<iMeshWrapper> LoadMeshWrapper (
00775         const char* name, const char* loaderClassId,
00776         iDataBuffer* input, iSector* sector, const csVector3& pos) = 0;
00777 
00782   virtual void AddMeshAndChildren (iMeshWrapper* mesh) = 0;
00783 
00790   virtual csPtr<iMeshWrapperIterator> GetNearbyMeshes (iSector* sector,
00791     const csVector3& pos, float radius, bool crossPortals = true) = 0;
00792 
00800   virtual csPtr<iMeshWrapperIterator> GetNearbyMeshes (iSector* sector,
00801     const csBox3& box, bool crossPortals = true) = 0;
00802 
00810   virtual csPtr<iMeshWrapperIterator> GetNearbyMeshes (iSector* sector,
00811     const csVector3& start, const csVector3& end,
00812     bool crossPortals = true) = 0;
00813 
00815   virtual iMeshList* GetMeshes () = 0;
00816 
00829   virtual iMeshWrapper* FindMeshObject (const char* name,
00830         iRegion* region = 0) = 0;
00831 
00838   virtual void WantToDie (iMeshWrapper* mesh) = 0;
00839 
00858   virtual csPtr<iMeshFactoryWrapper> CreateMeshFactory (const char* classId,
00859         const char* name) = 0;
00860 
00868   virtual csPtr<iMeshFactoryWrapper> CreateMeshFactory (
00869         iMeshObjectFactory * factory, const char* name) = 0;
00870 
00876   virtual csPtr<iMeshFactoryWrapper> CreateMeshFactory (const char* name) = 0;
00877 
00885   virtual csPtr<iMeshFactoryWrapper> LoadMeshFactory (
00886         const char* name, const char* loaderClassId,
00887         iDataBuffer* input) = 0;
00888 
00901   virtual iMeshFactoryWrapper* FindMeshFactory (const char* name,
00902         iRegion* region = 0) = 0;
00903 
00905   virtual iMeshFactoryList* GetMeshFactories () = 0;
00906 
00919   virtual iRegion* CreateRegion (const char* name) = 0;
00921   virtual iRegionList* GetRegions () = 0;
00922 
00932   virtual csPtr<iCamera> CreateCamera () = 0;
00933 
00946   virtual iCameraPosition* FindCameraPosition (const char* name,
00947         iRegion* region = 0) = 0;
00948 
00950   virtual iCameraPositionList* GetCameraPositions () = 0;
00951 
00976   virtual csPtr<iMeshWrapper> CreatePortal (
00977         const char* name,
00978         iMeshWrapper* parentMesh, iSector* destSector,
00979         csVector3* vertices, int num_vertices,
00980         iPortal*& portal) = 0;
00981 
01001   virtual csPtr<iMeshWrapper> CreatePortal (
01002         const char* name,
01003         iSector* sourceSector, const csVector3& pos,
01004         iSector* destSector,
01005         csVector3* vertices, int num_vertices,
01006         iPortal*& portal) = 0;
01007 
01021   virtual csPtr<iMeshWrapper> CreatePortalContainer (const char* name,
01022         iSector* sector = 0, const csVector3& pos = csVector3 (0, 0, 0)) = 0;
01023 
01041   virtual void SetClearZBuf (bool yesno) = 0;
01042 
01046   virtual bool GetClearZBuf () const = 0;
01047 
01049   virtual bool GetDefaultClearZBuf () const = 0;
01050 
01063   virtual void SetClearScreen (bool yesno) = 0;
01064 
01068   virtual bool GetClearScreen () const = 0;
01069 
01071   virtual bool GetDefaultClearScreen () const = 0;
01072 
01079   virtual int GetBeginDrawFlags () const = 0;
01080 
01084   virtual iRenderView* GetTopLevelClipper () const = 0;
01085 
01094   virtual void PrecacheDraw (iRegion* region = 0) = 0;
01095 
01107   virtual void Draw (iCamera* c, iClipper2D* clipper,
01108       iMeshWrapper* mesh = 0) = 0;
01109 
01115   virtual void SetContext (iTextureHandle* ctxt) = 0;
01117   virtual iTextureHandle *GetContext () const = 0;
01118 
01122   virtual iRenderLoopManager* GetRenderLoopManager () = 0;
01123   
01136   virtual iRenderLoop* GetCurrentDefaultRenderloop () = 0;
01137 
01144   virtual bool SetCurrentDefaultRenderloop (iRenderLoop* loop) = 0;
01145 
01149   virtual uint GetCurrentFrameNumber () const = 0;
01150 
01165   virtual void SetSaveableFlag (bool enable) = 0;
01166 
01170   virtual bool GetSaveableFlag () = 0;
01171 
01180   virtual csPtr<iLoaderContext> CreateLoaderContext (
01181         iRegion* region = 0, bool curRegOnly = true) = 0;
01182 
01200   virtual csPtr<iObjectIterator> GetNearbyObjects (iSector* sector,
01201     const csVector3& pos, float radius, bool crossPortals = true ) = 0;
01202 
01203   
01204 
01214   virtual csPtr<iObjectIterator> GetVisibleObjects (iSector* sector,
01215     const csVector3& pos) = 0;
01216 
01223   virtual csPtr<iMeshWrapperIterator> GetVisibleMeshes (iSector* sector,
01224     const csVector3& pos) = 0;
01225 
01235   virtual csPtr<iObjectIterator> GetVisibleObjects (iSector* sector,
01236     const csFrustum& frustum) = 0;
01237 
01244   virtual csPtr<iMeshWrapperIterator> GetVisibleMeshes (iSector* sector,
01245     const csFrustum& frustum) = 0;
01246 
01253   virtual csPtr<iFrustumView> CreateFrustumView () = 0;
01254 
01259   virtual csPtr<iObjectWatcher> CreateObjectWatcher () = 0;
01260 
01262   virtual iSharedVariableList* GetVariableList () const = 0;
01263 
01264 #include "csutil/win32/msvc_deprecated_warn_off.h"
01269   CS_DEPRECATED_METHOD_MSG("Collections are obsolete")
01270   virtual iCollectionList* GetCollections () = 0;
01271   
01285   CS_DEPRECATED_METHOD_MSG("Collections are obsolete")
01286   virtual iCollection* FindCollection (const char* name,
01287         iRegion* region = 0) = 0;
01288 #include "csutil/win32/msvc_deprecated_warn_on.h"
01289 
01305   virtual bool RemoveObject (iBase* object) = 0;
01306 
01315   virtual void DelayedRemoveObject (csTicks delay, iBase* object) = 0;
01316 
01322   virtual void RemoveDelayedRemoves (bool remove = false) = 0;
01323  
01325   virtual void DeleteAll () = 0;
01326 
01334   virtual void ResetWorldSpecificSettings() = 0;  
01335   
01337 };
01338 
01341 #endif // __CS_IENGINE_ENGINE_H__

Generated for Crystal Space 1.0.2 by doxygen 1.4.7