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/collection.h" 00036 #include "iengine/light.h" 00037 #include "iutil/threadmanager.h" 00038 #include "ivideo/rendermesh.h" 00039 00040 class csBox3; 00041 class csColor; 00042 class csFrustum; 00043 00044 struct iCacheManager; 00045 struct iCamera; 00046 struct iCameraPosition; 00047 struct iCameraPositionList; 00048 struct iClipper2D; 00049 struct iCustomMatrixCamera; 00050 struct iDataBuffer; 00051 struct iLight; 00052 struct iLightFactory; 00053 struct iLightIterator; 00054 struct iLoaderContext; 00055 struct iMaterial; 00056 struct iMaterialList; 00057 struct iMaterialWrapper; 00058 struct iMeshFactoryList; 00059 struct iMeshFactoryWrapper; 00060 struct iMeshList; 00061 struct iMeshObject; 00062 struct iMeshObjectFactory; 00063 struct iMeshObjectType; 00064 struct iMeshWrapper; 00065 struct iMeshWrapperIterator; 00066 struct iObject; 00067 struct iObjectIterator; 00068 struct iObjectWatcher; 00069 struct iPerspectiveCamera; 00070 struct iPortal; 00071 struct iProgressMeter; 00072 struct iRenderLoop; 00073 struct iRenderLoopManager; 00074 struct iRenderManager; 00075 struct iRenderView; 00076 struct iSector; 00077 struct iSectorIterator; 00078 struct iSectorList; 00079 struct iSharedVariableList; 00080 struct iTextureHandle; 00081 struct iTextureList; 00082 struct iTextureWrapper; 00083 struct iThreadedLoader; 00084 00085 struct iEngine; 00086 00089 enum csRenderPrioritySorting 00090 { 00094 CS_RENDPRI_SORT_NONE = 0, 00095 00099 CS_RENDPRI_SORT_BACK2FRONT = 1, 00100 00104 CS_RENDPRI_SORT_FRONT2BACK = 2 00105 }; 00108 namespace CS 00109 { 00111 enum RenderPriorityGrouping 00112 { 00119 rpgByLayer = 0, 00126 rpgByMesh = 1 00127 }; 00128 } // namespace CS 00129 00137 struct iEngineFrameCallback : public virtual iBase 00138 { 00139 SCF_INTERFACE(iEngineFrameCallback,1,0,0); 00143 virtual void StartFrame (iEngine* engine, iRenderView* rview) = 0; 00144 }; 00145 00153 struct iEngineSectorCallback : public virtual iBase 00154 { 00155 SCF_INTERFACE(iEngineSectorCallback,2,0,0); 00159 virtual void NewSector (iEngine* engine, iSector* sector) = 0; 00160 00164 virtual void RemoveSector (iEngine* engine, iSector* sector) = 0; 00165 }; 00166 00167 00182 struct iEngine : public virtual iBase 00183 { 00184 SCF_INTERFACE(iEngine, 8, 0, 1); 00185 00187 virtual iObject *QueryObject() = 0; 00188 00209 virtual bool Prepare (iProgressMeter* meter = 0) = 0; 00210 00218 virtual void PrepareTextures () = 0; 00219 00225 virtual void PrepareMeshes () = 0; 00226 00239 virtual void SetCacheManager (iCacheManager* cache_mgr) = 0; 00240 00247 virtual void SetVFSCacheManager (const char* vfspath = 0) = 0; 00248 00252 virtual iCacheManager* GetCacheManager () = 0; 00253 00297 virtual void RegisterRenderPriority (const char* name, uint priority, 00298 csRenderPrioritySorting rendsort = CS_RENDPRI_SORT_NONE, 00299 CS::RenderPriorityGrouping grouping = CS::rpgByLayer) = 0; 00304 virtual void RegisterDefaultRenderPriorities () = 0; 00305 00312 virtual CS::Graphics::RenderPriority GetRenderPriority (const char* name) const = 0; 00314 virtual csRenderPrioritySorting GetRenderPrioritySorting ( 00315 const char* name) const = 0; 00317 virtual csRenderPrioritySorting GetRenderPrioritySorting ( 00318 CS::Graphics::RenderPriority priority) const = 0; 00320 00321 virtual CS::RenderPriorityGrouping GetRenderPriorityGrouping ( 00322 const char* name) const = 0; 00323 virtual CS::RenderPriorityGrouping GetRenderPriorityGrouping ( 00324 CS::Graphics::RenderPriority priority) const = 0; 00326 00327 virtual CS::Graphics::RenderPriority GetSkyRenderPriority () = 0; 00329 virtual CS::Graphics::RenderPriority GetPortalRenderPriority () = 0; 00331 virtual CS::Graphics::RenderPriority GetWallRenderPriority () = 0; 00333 virtual CS::Graphics::RenderPriority GetObjectRenderPriority () = 0; 00335 virtual CS::Graphics::RenderPriority GetAlphaRenderPriority () = 0; 00337 virtual void ClearRenderPriorities () = 0; 00339 virtual size_t GetRenderPriorityCount () const = 0; 00341 virtual const char* GetRenderPriorityName (CS::Graphics::RenderPriority priority) const = 0; 00342 00357 virtual csPtr<iMaterial> CreateBaseMaterial (iTextureWrapper* txt) = 0; 00358 00364 virtual iMaterialWrapper* CreateMaterial (const char *name, 00365 iTextureWrapper* texture) = 0; 00366 00368 virtual iMaterialList* GetMaterialList () const = 0; 00369 00383 virtual iMaterialWrapper* FindMaterial (const char* name, 00384 iCollection* collection = 0) = 0; 00385 00407 virtual iTextureWrapper* CreateTexture (const char *name, 00408 const char *fileName, csColor *transp, int flags) = 0; 00409 00420 virtual iTextureWrapper* CreateBlackTexture (const char *name, 00421 int w, int h, csColor *transp, int flags) = 0; 00422 00427 virtual int GetTextureFormat () const = 0; 00428 00430 virtual iTextureList* GetTextureList () const = 0; 00431 00444 virtual iTextureWrapper* FindTexture (const char* name, 00445 iCollection* collection = 0) = 0; 00446 00455 virtual iLightFactory* CreateLightFactory (const char* name) = 0; 00456 00460 virtual iLightFactory* FindLightFactory (const char* name, iCollection* col = 0) = 0; 00461 00465 virtual iLightFactoryList* GetLightFactories () = 0; 00466 00488 virtual csPtr<iLight> CreateLight (const char* name, const csVector3& pos, 00489 float radius, const csColor& color, 00490 csLightDynamicType dyntype = CS_LIGHT_DYNAMICTYPE_STATIC) = 0; 00491 00495 virtual csPtr<iLight> CreateLight (const char* name, const csVector3& pos, 00496 iLightFactory* factory) = 0; 00497 00502 virtual iLight* FindLight (const char *Name, bool RegionOnly = false) 00503 const = 0; 00504 00509 virtual iLight* FindLightID (const char* light_id) const = 0; 00510 00517 virtual csPtr<iLightIterator> GetLightIterator (iCollection* collection = 0) = 0; 00518 00529 virtual void RemoveLight (iLight* light) = 0; 00530 00535 virtual void SetAmbientLight (const csColor &) = 0; 00537 virtual void GetAmbientLight (csColor &) const = 0; 00539 virtual void GetDefaultAmbientLight (csColor &c) const = 0; 00540 00552 virtual int GetNearbyLights (iSector* sector, const csVector3& pos, 00553 iLight** lights, int max_num_lights) = 0; 00554 00566 virtual int GetNearbyLights (iSector* sector, const csBox3& box, 00567 iLight** lights, int max_num_lights) = 0; 00568 00578 virtual iSector *CreateSector (const char *name, bool addToList = true) = 0; 00579 00581 virtual iSectorList* GetSectors () = 0; 00582 00595 virtual iSector* FindSector (const char* name, 00596 iCollection* collection = 0) = 0; 00597 00606 virtual csPtr<iSectorIterator> GetNearbySectors (iSector* sector, 00607 const csVector3& pos, float radius) = 0; 00608 00617 virtual csPtr<iSectorIterator> GetNearbySectors (iSector* sector, 00618 const csBox3& box) = 0; 00619 00624 virtual void AddEngineFrameCallback (iEngineFrameCallback* cb) = 0; 00625 00629 virtual void RemoveEngineFrameCallback (iEngineFrameCallback* cb) = 0; 00630 00635 virtual void AddEngineSectorCallback (iEngineSectorCallback* cb) = 0; 00636 00640 virtual void RemoveEngineSectorCallback (iEngineSectorCallback* cb) = 0; 00641 00660 virtual csPtr<iMeshWrapper> CreateMeshWrapper (iMeshFactoryWrapper* factory, 00661 const char* name, iSector* sector = 0, const csVector3& pos = csVector3 (0, 0, 0), 00662 bool addToList = true) = 0; 00663 00676 virtual csPtr<iMeshWrapper> CreateMeshWrapper (iMeshObject* meshobj, 00677 const char* name, iSector* sector = 0, const csVector3& pos = csVector3 (0, 0, 0), 00678 bool addToList = true) = 0; 00679 00698 virtual csPtr<iMeshWrapper> CreateMeshWrapper (const char* classid, 00699 const char* name, iSector* sector = 0, const csVector3& pos = csVector3 (0, 0, 0), 00700 bool addToList = true) = 0; 00701 00706 virtual csPtr<iMeshWrapper> CreateMeshWrapper (const char* name, bool addToList = true) = 0; 00707 00722 virtual csPtr<iMeshWrapper> LoadMeshWrapper ( 00723 const char* name, const char* loaderClassId, 00724 iDataBuffer* input, iSector* sector, const csVector3& pos) = 0; 00725 00730 THREADED_INTERFACE1(AddMeshAndChildren, iMeshWrapper* mesh); 00731 00738 virtual csPtr<iMeshWrapperIterator> GetNearbyMeshes (iSector* sector, 00739 const csVector3& pos, float radius, bool crossPortals = true) = 0; 00740 00748 virtual csPtr<iMeshWrapperIterator> GetNearbyMeshes (iSector* sector, 00749 const csBox3& box, bool crossPortals = true) = 0; 00750 00758 virtual csPtr<iMeshWrapperIterator> GetNearbyMeshes (iSector* sector, 00759 const csVector3& start, const csVector3& end, 00760 bool crossPortals = true) = 0; 00761 00763 virtual iMeshList* GetMeshes () = 0; 00764 00777 virtual iMeshWrapper* FindMeshObject (const char* name, 00778 iCollection* collection = 0) = 0; 00779 00786 virtual void WantToDie (iMeshWrapper* mesh) = 0; 00787 00806 virtual csPtr<iMeshFactoryWrapper> CreateMeshFactory (const char* classId, 00807 const char* name, bool addToList = true) = 0; 00808 00816 virtual csPtr<iMeshFactoryWrapper> CreateMeshFactory ( 00817 iMeshObjectFactory * factory, const char* name, 00818 bool addToList = true) = 0; 00819 00825 virtual csPtr<iMeshFactoryWrapper> CreateMeshFactory (const char* name, 00826 bool addToList = true) = 0; 00827 00835 virtual csPtr<iMeshFactoryWrapper> LoadMeshFactory ( 00836 const char* name, const char* loaderClassId, 00837 iDataBuffer* input, bool addToList = true) = 0; 00838 00851 virtual iMeshFactoryWrapper* FindMeshFactory (const char* name, 00852 iCollection* collection = 0) = 0; 00853 00855 virtual iMeshFactoryList* GetMeshFactories () = 0; 00856 00865 virtual iCollection* CreateCollection (const char* name) = 0; 00866 00870 virtual iCollection* GetCollection (const char* name) const = 0; 00871 00875 virtual csPtr<iCollectionArray> GetCollections () = 0; 00876 00880 virtual void RemoveCollection (iCollection* collect) = 0; 00881 00885 virtual void RemoveCollection (const char* name) = 0; 00886 00890 virtual void RemoveAllCollections () = 0; 00891 00901 CS_DEPRECATED_METHOD_MSG("Use CreatePerspectiveCamera instead") 00902 virtual csPtr<iCamera> CreateCamera () = 0; 00903 00916 virtual iCameraPosition* FindCameraPosition (const char* name, 00917 iCollection* collection = 0) = 0; 00918 00920 virtual iCameraPositionList* GetCameraPositions () = 0; 00921 00946 virtual csPtr<iMeshWrapper> CreatePortal ( 00947 const char* name, 00948 iMeshWrapper* parentMesh, iSector* destSector, 00949 csVector3* vertices, int num_vertices, 00950 iPortal*& portal) = 0; 00951 00971 virtual csPtr<iMeshWrapper> CreatePortal ( 00972 const char* name, 00973 iSector* sourceSector, const csVector3& pos, 00974 iSector* destSector, 00975 csVector3* vertices, int num_vertices, 00976 iPortal*& portal) = 0; 00977 00991 virtual csPtr<iMeshWrapper> CreatePortalContainer (const char* name, 00992 iSector* sector = 0, const csVector3& pos = csVector3 (0, 0, 0)) = 0; 00993 01011 CS_DEPRECATED_METHOD_MSG("Z buffer clearing handled by the rendermanager.") 01012 virtual void SetClearZBuf (bool yesno) = 0; 01013 01017 CS_DEPRECATED_METHOD_MSG("Z buffer clearing handled by the rendermanager.") 01018 virtual bool GetClearZBuf () const = 0; 01019 01021 CS_DEPRECATED_METHOD_MSG("Z buffer clearing handled by the rendermanager.") 01022 virtual bool GetDefaultClearZBuf () const = 0; 01023 01036 CS_DEPRECATED_METHOD_MSG("Screen clearing handled by the rendermanager.") 01037 virtual void SetClearScreen (bool yesno) = 0; 01038 01042 CS_DEPRECATED_METHOD_MSG("Screen clearing handled by the rendermanager.") 01043 virtual bool GetClearScreen () const = 0; 01044 01046 CS_DEPRECATED_METHOD_MSG("Screen clearing handled by the rendermanager.") 01047 virtual bool GetDefaultClearScreen () const = 0; 01048 01055 CS_DEPRECATED_METHOD_MSG("Screen and Z buffer clearing handled by the rendermanager.") 01056 virtual int GetBeginDrawFlags () const = 0; 01057 01061 virtual iRenderView* GetTopLevelClipper () const = 0; 01062 01066 virtual void PrecacheMesh (iMeshWrapper* s) = 0; 01067 01076 virtual void PrecacheDraw (iCollection* collection = 0) = 0; 01077 01089 virtual void Draw (iCamera* c, iClipper2D* clipper, 01090 iMeshWrapper* mesh = 0) = 0; 01091 01097 virtual void SetContext (iTextureHandle* ctxt) = 0; 01099 virtual iTextureHandle *GetContext () const = 0; 01100 01104 virtual iRenderLoopManager* GetRenderLoopManager () = 0; 01105 01118 virtual iRenderLoop* GetCurrentDefaultRenderloop () = 0; 01119 01126 virtual bool SetCurrentDefaultRenderloop (iRenderLoop* loop) = 0; 01127 01131 virtual uint GetCurrentFrameNumber () const = 0; 01132 01136 virtual void UpdateNewFrame () = 0; 01145 virtual void EnableAdaptiveLODs(bool enable, float target_fps) = 0; 01146 01150 virtual void UpdateAdaptiveLODs() = 0; 01151 01155 virtual float GetAdaptiveLODsMultiplier() const = 0; 01170 virtual void SetSaveableFlag (bool enable) = 0; 01171 01175 virtual bool GetSaveableFlag () = 0; 01176 01185 virtual csPtr<iLoaderContext> CreateLoaderContext ( 01186 iCollection* collection = 0, bool searchCollectionOnly = true) = 0; 01187 01191 virtual void SetDefaultKeepImage (bool enable) = 0; 01192 01197 virtual bool GetDefaultKeepImage () = 0; 01198 01216 virtual csPtr<iObjectIterator> GetNearbyObjects (iSector* sector, 01217 const csVector3& pos, float radius, bool crossPortals = true ) = 0; 01218 01219 01220 01230 virtual csPtr<iObjectIterator> GetVisibleObjects (iSector* sector, 01231 const csVector3& pos) = 0; 01232 01239 virtual csPtr<iMeshWrapperIterator> GetVisibleMeshes (iSector* sector, 01240 const csVector3& pos) = 0; 01241 01251 virtual csPtr<iObjectIterator> GetVisibleObjects (iSector* sector, 01252 const csFrustum& frustum) = 0; 01253 01260 virtual csPtr<iMeshWrapperIterator> GetVisibleMeshes (iSector* sector, 01261 const csFrustum& frustum) = 0; 01262 01267 virtual csPtr<iObjectWatcher> CreateObjectWatcher () = 0; 01268 01270 virtual iSharedVariableList* GetVariableList () const = 0; 01271 01287 virtual bool RemoveObject (iBase* object) = 0; 01288 01297 virtual void DelayedRemoveObject (csTicks delay, iBase* object) = 0; 01298 01304 virtual void RemoveDelayedRemoves (bool remove = false) = 0; 01305 01307 THREADED_INTERFACE(DeleteAll); 01308 01316 virtual void ResetWorldSpecificSettings() = 0; 01317 01320 01321 virtual void FireStartFrame (iRenderView* rview) = 0; 01322 01329 virtual csPtr<iPerspectiveCamera> CreatePerspectiveCamera () = 0; 01330 01336 virtual csPtr<iCustomMatrixCamera> CreateCustomMatrixCamera ( 01337 iCamera* copyFrom = 0) = 0; 01342 01343 virtual iRenderManager* GetRenderManager () = 0; 01348 virtual void SetRenderManager (iRenderManager*) = 0; 01349 01354 virtual void ReloadRenderManager() = 0; 01357 // @{ 01361 THREADED_INTERFACE1(SyncEngineLists, csRef<iThreadedLoader> loader); 01362 virtual void SyncEngineListsNow(csRef<iThreadedLoader> loader) = 0; 01363 // @} 01364 01367 01368 virtual float GetDefaultNearClipDistance () const = 0; 01370 virtual void SetDefaultNearClipDistance (float dist) = 0; 01372 }; 01373 01376 #endif // __CS_IENGINE_ENGINE_H__
Generated for Crystal Space 2.1 by doxygen 1.6.1
