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 iLightIterator; 00053 struct iLoaderContext; 00054 struct iMaterial; 00055 struct iMaterialList; 00056 struct iMaterialWrapper; 00057 struct iMeshFactoryList; 00058 struct iMeshFactoryWrapper; 00059 struct iMeshList; 00060 struct iMeshObject; 00061 struct iMeshObjectFactory; 00062 struct iMeshObjectType; 00063 struct iMeshWrapper; 00064 struct iMeshWrapperIterator; 00065 struct iObject; 00066 struct iObjectIterator; 00067 struct iObjectWatcher; 00068 struct iPerspectiveCamera; 00069 struct iPortal; 00070 struct iProgressMeter; 00071 struct iRenderLoop; 00072 struct iRenderLoopManager; 00073 struct iRenderManager; 00074 struct iRenderView; 00075 struct iSector; 00076 struct iSectorIterator; 00077 struct iSectorList; 00078 struct iSharedVariableList; 00079 struct iTextureHandle; 00080 struct iTextureList; 00081 struct iTextureWrapper; 00082 struct iThreadedLoader; 00083 00084 struct iEngine; 00085 00088 enum csRenderPrioritySorting 00089 { 00093 CS_RENDPRI_SORT_NONE = 0, 00094 00098 CS_RENDPRI_SORT_BACK2FRONT = 1, 00099 00103 CS_RENDPRI_SORT_FRONT2BACK = 2 00104 }; 00107 namespace CS 00108 { 00110 enum RenderPriorityGrouping 00111 { 00118 rpgByLayer = 0, 00125 rpgByMesh = 1 00126 }; 00127 } // namespace CS 00128 00136 struct iEngineFrameCallback : public virtual iBase 00137 { 00138 SCF_INTERFACE(iEngineFrameCallback,1,0,0); 00142 virtual void StartFrame (iEngine* engine, iRenderView* rview) = 0; 00143 }; 00144 00152 struct iEngineSectorCallback : public virtual iBase 00153 { 00154 SCF_INTERFACE(iEngineSectorCallback,2,0,0); 00158 virtual void NewSector (iEngine* engine, iSector* sector) = 0; 00159 00163 virtual void RemoveSector (iEngine* engine, iSector* sector) = 0; 00164 }; 00165 00166 00181 struct iEngine : public virtual iBase 00182 { 00183 SCF_INTERFACE(iEngine, 8, 0, 1); 00184 00186 virtual iObject *QueryObject() = 0; 00187 00208 virtual bool Prepare (iProgressMeter* meter = 0) = 0; 00209 00217 virtual void PrepareTextures () = 0; 00218 00224 virtual void PrepareMeshes () = 0; 00225 00238 virtual void SetCacheManager (iCacheManager* cache_mgr) = 0; 00239 00246 virtual void SetVFSCacheManager (const char* vfspath = 0) = 0; 00247 00251 virtual iCacheManager* GetCacheManager () = 0; 00252 00296 virtual void RegisterRenderPriority (const char* name, uint priority, 00297 csRenderPrioritySorting rendsort = CS_RENDPRI_SORT_NONE, 00298 CS::RenderPriorityGrouping grouping = CS::rpgByLayer) = 0; 00303 virtual void RegisterDefaultRenderPriorities () = 0; 00304 00311 virtual CS::Graphics::RenderPriority GetRenderPriority (const char* name) const = 0; 00313 virtual csRenderPrioritySorting GetRenderPrioritySorting ( 00314 const char* name) const = 0; 00316 virtual csRenderPrioritySorting GetRenderPrioritySorting ( 00317 CS::Graphics::RenderPriority priority) const = 0; 00319 00320 virtual CS::RenderPriorityGrouping GetRenderPriorityGrouping ( 00321 const char* name) const = 0; 00322 virtual CS::RenderPriorityGrouping GetRenderPriorityGrouping ( 00323 CS::Graphics::RenderPriority priority) const = 0; 00325 00326 virtual CS::Graphics::RenderPriority GetSkyRenderPriority () = 0; 00328 virtual CS::Graphics::RenderPriority GetPortalRenderPriority () = 0; 00330 virtual CS::Graphics::RenderPriority GetWallRenderPriority () = 0; 00332 virtual CS::Graphics::RenderPriority GetObjectRenderPriority () = 0; 00334 virtual CS::Graphics::RenderPriority GetAlphaRenderPriority () = 0; 00336 virtual void ClearRenderPriorities () = 0; 00338 virtual size_t GetRenderPriorityCount () const = 0; 00340 virtual const char* GetRenderPriorityName (CS::Graphics::RenderPriority priority) const = 0; 00341 00356 virtual csPtr<iMaterial> CreateBaseMaterial (iTextureWrapper* txt) = 0; 00357 00363 virtual iMaterialWrapper* CreateMaterial (const char *name, 00364 iTextureWrapper* texture) = 0; 00365 00367 virtual iMaterialList* GetMaterialList () const = 0; 00368 00382 virtual iMaterialWrapper* FindMaterial (const char* name, 00383 iCollection* collection = 0) = 0; 00384 00406 virtual iTextureWrapper* CreateTexture (const char *name, 00407 const char *fileName, csColor *transp, int flags) = 0; 00408 00419 virtual iTextureWrapper* CreateBlackTexture (const char *name, 00420 int w, int h, csColor *transp, int flags) = 0; 00421 00426 virtual int GetTextureFormat () const = 0; 00427 00429 virtual iTextureList* GetTextureList () const = 0; 00430 00443 virtual iTextureWrapper* FindTexture (const char* name, 00444 iCollection* collection = 0) = 0; 00445 00472 virtual csPtr<iLight> CreateLight (const char* name, const csVector3& pos, 00473 float radius, const csColor& color, 00474 csLightDynamicType dyntype = CS_LIGHT_DYNAMICTYPE_STATIC) = 0; 00475 00480 virtual iLight* FindLight (const char *Name, bool RegionOnly = false) 00481 const = 0; 00482 00487 virtual iLight* FindLightID (const char* light_id) const = 0; 00488 00495 virtual csPtr<iLightIterator> GetLightIterator (iCollection* collection = 0) = 0; 00496 00507 virtual void RemoveLight (iLight* light) = 0; 00508 00513 virtual void SetAmbientLight (const csColor &) = 0; 00515 virtual void GetAmbientLight (csColor &) const = 0; 00517 virtual void GetDefaultAmbientLight (csColor &c) const = 0; 00518 00530 virtual int GetNearbyLights (iSector* sector, const csVector3& pos, 00531 iLight** lights, int max_num_lights) = 0; 00532 00544 virtual int GetNearbyLights (iSector* sector, const csBox3& box, 00545 iLight** lights, int max_num_lights) = 0; 00546 00556 virtual iSector *CreateSector (const char *name, bool addToList = true) = 0; 00557 00559 virtual iSectorList* GetSectors () = 0; 00560 00573 virtual iSector* FindSector (const char* name, 00574 iCollection* collection = 0) = 0; 00575 00584 virtual csPtr<iSectorIterator> GetNearbySectors (iSector* sector, 00585 const csVector3& pos, float radius) = 0; 00586 00595 virtual csPtr<iSectorIterator> GetNearbySectors (iSector* sector, 00596 const csBox3& box) = 0; 00597 00602 virtual void AddEngineFrameCallback (iEngineFrameCallback* cb) = 0; 00603 00607 virtual void RemoveEngineFrameCallback (iEngineFrameCallback* cb) = 0; 00608 00613 virtual void AddEngineSectorCallback (iEngineSectorCallback* cb) = 0; 00614 00618 virtual void RemoveEngineSectorCallback (iEngineSectorCallback* cb) = 0; 00619 00638 virtual csPtr<iMeshWrapper> CreateMeshWrapper (iMeshFactoryWrapper* factory, 00639 const char* name, iSector* sector = 0, const csVector3& pos = csVector3 (0, 0, 0), 00640 bool addToList = true) = 0; 00641 00654 virtual csPtr<iMeshWrapper> CreateMeshWrapper (iMeshObject* meshobj, 00655 const char* name, iSector* sector = 0, const csVector3& pos = csVector3 (0, 0, 0), 00656 bool addToList = true) = 0; 00657 00676 virtual csPtr<iMeshWrapper> CreateMeshWrapper (const char* classid, 00677 const char* name, iSector* sector = 0, const csVector3& pos = csVector3 (0, 0, 0), 00678 bool addToList = true) = 0; 00679 00684 virtual csPtr<iMeshWrapper> CreateMeshWrapper (const char* name, bool addToList = true) = 0; 00685 00700 virtual csPtr<iMeshWrapper> LoadMeshWrapper ( 00701 const char* name, const char* loaderClassId, 00702 iDataBuffer* input, iSector* sector, const csVector3& pos) = 0; 00703 00708 THREADED_INTERFACE1(AddMeshAndChildren, iMeshWrapper* mesh); 00709 00716 virtual csPtr<iMeshWrapperIterator> GetNearbyMeshes (iSector* sector, 00717 const csVector3& pos, float radius, bool crossPortals = true) = 0; 00718 00726 virtual csPtr<iMeshWrapperIterator> GetNearbyMeshes (iSector* sector, 00727 const csBox3& box, bool crossPortals = true) = 0; 00728 00736 virtual csPtr<iMeshWrapperIterator> GetNearbyMeshes (iSector* sector, 00737 const csVector3& start, const csVector3& end, 00738 bool crossPortals = true) = 0; 00739 00741 virtual iMeshList* GetMeshes () = 0; 00742 00755 virtual iMeshWrapper* FindMeshObject (const char* name, 00756 iCollection* collection = 0) = 0; 00757 00764 virtual void WantToDie (iMeshWrapper* mesh) = 0; 00765 00784 virtual csPtr<iMeshFactoryWrapper> CreateMeshFactory (const char* classId, 00785 const char* name, bool addToList = true) = 0; 00786 00794 virtual csPtr<iMeshFactoryWrapper> CreateMeshFactory ( 00795 iMeshObjectFactory * factory, const char* name, 00796 bool addToList = true) = 0; 00797 00803 virtual csPtr<iMeshFactoryWrapper> CreateMeshFactory (const char* name, 00804 bool addToList = true) = 0; 00805 00813 virtual csPtr<iMeshFactoryWrapper> LoadMeshFactory ( 00814 const char* name, const char* loaderClassId, 00815 iDataBuffer* input, bool addToList = true) = 0; 00816 00829 virtual iMeshFactoryWrapper* FindMeshFactory (const char* name, 00830 iCollection* collection = 0) = 0; 00831 00833 virtual iMeshFactoryList* GetMeshFactories () = 0; 00834 00843 virtual iCollection* CreateCollection (const char* name) = 0; 00844 00848 virtual iCollection* GetCollection (const char* name) const = 0; 00849 00853 virtual csPtr<iCollectionArray> GetCollections () = 0; 00854 00858 virtual void RemoveCollection (iCollection* collect) = 0; 00859 00863 virtual void RemoveCollection (const char* name) = 0; 00864 00868 virtual void RemoveAllCollections () = 0; 00869 00879 CS_DEPRECATED_METHOD_MSG("Use CreatePerspectiveCamera instead") 00880 virtual csPtr<iCamera> CreateCamera () = 0; 00881 00894 virtual iCameraPosition* FindCameraPosition (const char* name, 00895 iCollection* collection = 0) = 0; 00896 00898 virtual iCameraPositionList* GetCameraPositions () = 0; 00899 00924 virtual csPtr<iMeshWrapper> CreatePortal ( 00925 const char* name, 00926 iMeshWrapper* parentMesh, iSector* destSector, 00927 csVector3* vertices, int num_vertices, 00928 iPortal*& portal) = 0; 00929 00949 virtual csPtr<iMeshWrapper> CreatePortal ( 00950 const char* name, 00951 iSector* sourceSector, const csVector3& pos, 00952 iSector* destSector, 00953 csVector3* vertices, int num_vertices, 00954 iPortal*& portal) = 0; 00955 00969 virtual csPtr<iMeshWrapper> CreatePortalContainer (const char* name, 00970 iSector* sector = 0, const csVector3& pos = csVector3 (0, 0, 0)) = 0; 00971 00989 CS_DEPRECATED_METHOD_MSG("Z buffer clearing handled by the rendermanager.") 00990 virtual void SetClearZBuf (bool yesno) = 0; 00991 00995 CS_DEPRECATED_METHOD_MSG("Z buffer clearing handled by the rendermanager.") 00996 virtual bool GetClearZBuf () const = 0; 00997 00999 CS_DEPRECATED_METHOD_MSG("Z buffer clearing handled by the rendermanager.") 01000 virtual bool GetDefaultClearZBuf () const = 0; 01001 01014 CS_DEPRECATED_METHOD_MSG("Screen clearing handled by the rendermanager.") 01015 virtual void SetClearScreen (bool yesno) = 0; 01016 01020 CS_DEPRECATED_METHOD_MSG("Screen clearing handled by the rendermanager.") 01021 virtual bool GetClearScreen () const = 0; 01022 01024 CS_DEPRECATED_METHOD_MSG("Screen clearing handled by the rendermanager.") 01025 virtual bool GetDefaultClearScreen () const = 0; 01026 01033 CS_DEPRECATED_METHOD_MSG("Screen and Z buffer clearing handled by the rendermanager.") 01034 virtual int GetBeginDrawFlags () const = 0; 01035 01039 virtual iRenderView* GetTopLevelClipper () const = 0; 01040 01044 virtual void PrecacheMesh (iMeshWrapper* s) = 0; 01045 01054 virtual void PrecacheDraw (iCollection* collection = 0) = 0; 01055 01067 virtual void Draw (iCamera* c, iClipper2D* clipper, 01068 iMeshWrapper* mesh = 0) = 0; 01069 01075 virtual void SetContext (iTextureHandle* ctxt) = 0; 01077 virtual iTextureHandle *GetContext () const = 0; 01078 01082 virtual iRenderLoopManager* GetRenderLoopManager () = 0; 01083 01096 virtual iRenderLoop* GetCurrentDefaultRenderloop () = 0; 01097 01104 virtual bool SetCurrentDefaultRenderloop (iRenderLoop* loop) = 0; 01105 01109 virtual uint GetCurrentFrameNumber () const = 0; 01110 01114 virtual void UpdateNewFrame () = 0; 01123 virtual void EnableAdaptiveLODs(bool enable, float target_fps) = 0; 01124 01128 virtual void UpdateAdaptiveLODs() = 0; 01129 01133 virtual float GetAdaptiveLODsMultiplier() const = 0; 01148 virtual void SetSaveableFlag (bool enable) = 0; 01149 01153 virtual bool GetSaveableFlag () = 0; 01154 01163 virtual csPtr<iLoaderContext> CreateLoaderContext ( 01164 iCollection* collection = 0, bool searchCollectionOnly = true) = 0; 01165 01169 virtual void SetDefaultKeepImage (bool enable) = 0; 01170 01175 virtual bool GetDefaultKeepImage () = 0; 01176 01194 virtual csPtr<iObjectIterator> GetNearbyObjects (iSector* sector, 01195 const csVector3& pos, float radius, bool crossPortals = true ) = 0; 01196 01197 01198 01208 virtual csPtr<iObjectIterator> GetVisibleObjects (iSector* sector, 01209 const csVector3& pos) = 0; 01210 01217 virtual csPtr<iMeshWrapperIterator> GetVisibleMeshes (iSector* sector, 01218 const csVector3& pos) = 0; 01219 01229 virtual csPtr<iObjectIterator> GetVisibleObjects (iSector* sector, 01230 const csFrustum& frustum) = 0; 01231 01238 virtual csPtr<iMeshWrapperIterator> GetVisibleMeshes (iSector* sector, 01239 const csFrustum& frustum) = 0; 01240 01245 virtual csPtr<iObjectWatcher> CreateObjectWatcher () = 0; 01246 01248 virtual iSharedVariableList* GetVariableList () const = 0; 01249 01265 virtual bool RemoveObject (iBase* object) = 0; 01266 01275 virtual void DelayedRemoveObject (csTicks delay, iBase* object) = 0; 01276 01282 virtual void RemoveDelayedRemoves (bool remove = false) = 0; 01283 01285 THREADED_INTERFACE(DeleteAll); 01286 01294 virtual void ResetWorldSpecificSettings() = 0; 01295 01298 01299 virtual void FireStartFrame (iRenderView* rview) = 0; 01300 01307 virtual csPtr<iPerspectiveCamera> CreatePerspectiveCamera () = 0; 01308 01314 virtual csPtr<iCustomMatrixCamera> CreateCustomMatrixCamera ( 01315 iCamera* copyFrom = 0) = 0; 01320 01321 virtual iRenderManager* GetRenderManager () = 0; 01326 virtual void SetRenderManager (iRenderManager*) = 0; 01327 01332 virtual void ReloadRenderManager() = 0; 01335 // @{ 01339 THREADED_INTERFACE1(SyncEngineLists, csRef<iThreadedLoader> loader); 01340 virtual void SyncEngineListsNow(csRef<iThreadedLoader> loader) = 0; 01341 // @} 01342 01345 01346 virtual float GetDefaultNearClipDistance () const = 0; 01348 virtual void SetDefaultNearClipDistance (float dist) = 0; 01350 }; 01351 01354 #endif // __CS_IENGINE_ENGINE_H__
Generated for Crystal Space 2.0 by doxygen 1.6.1