Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

119 lines
4.7 KiB

  1. //===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //===========================================================================//
  8. #ifndef IWORLDRENDERER_H
  9. #define IWORLDRENDERER_H
  10. #ifdef _WIN32
  11. #pragma once
  12. #endif
  13. #include "tier1/interface.h"
  14. #include "appframework/IAppSystem.h"
  15. #include "bitmap/imageformat.h"
  16. #include "tier1/utlbuffer.h"
  17. #include "mathlib/vector4d.h"
  18. #include "ibvhnode.h"
  19. #include "iresourcedictionary.h"
  20. #include "raytrace.h"
  21. #include "bitvec.h"
  22. //-----------------------------------------------------------------------------
  23. enum RenderAction_t
  24. {
  25. ACTION_NONE = 0,
  26. ACTION_RENDER_PARENT = 1
  27. };
  28. //-----------------------------------------------------------------------------
  29. // Methods related to a traversal through the world
  30. //-----------------------------------------------------------------------------
  31. abstract_class IWorldTraversal
  32. {
  33. public:
  34. virtual Vector GetOrigin() = 0;
  35. virtual int GetStartNode() = 0;
  36. virtual void SetOrigin( Vector &vOrigin ) = 0;
  37. virtual void SetStartNode( int nNode ) = 0;
  38. };
  39. //-----------------------------------------------------------------------------
  40. // Methods related to rendering the world
  41. //-----------------------------------------------------------------------------
  42. abstract_class IWorldRenderer
  43. {
  44. public:
  45. // Loading
  46. virtual bool Unserialize( const char *pszFileName, bool bToolMode = false ) = 0;
  47. virtual bool Initialize( IRenderDevice *pDevice, uint64 nMaxGPUMemoryBytes, uint64 nMaxSysMemoryBytes ) = 0;
  48. virtual void CreateAndDispatchLoadRequests( IRenderDevice *pDevice, const Vector &vEye ) = 0;
  49. virtual void DestroyResources( IRenderDevice *pDevice ) = 0;
  50. // Reflection
  51. virtual IResourceDictionary *GetResourceDictionary() = 0;
  52. virtual const WorldFileHeader_t *GetHeader() = 0;
  53. virtual IBVHNode *GetNode( int i ) = 0;
  54. virtual bool IsAncestor( int nNodeInQuestion, int nPotentialAncestor ) = 0;
  55. virtual int GetNumNodes() = 0;
  56. virtual int GetNumChunks() = 0;
  57. virtual BVHChunkDescriptor_t &GetChunkDesc( int i ) = 0;
  58. virtual uint64 GetMaxNodeSizeBytes() = 0;
  59. virtual uint64 GetAvgNodeSizeBytes() = 0;
  60. // Resource updates
  61. virtual void ClearOutstandingLoadRequests() = 0;
  62. virtual bool UpdateResources( IRenderDevice *pDevice, IRenderContext *pContext, int nMaxResourcesToUpdate ) = 0;
  63. // Raycasting
  64. virtual float CastRay( Vector *pNormalOut, Vector vOrigin, Vector vDir ) = 0;
  65. virtual Vector CalculateCurrentOrigin( Vector &vPosition ) = 0;
  66. // Visibility
  67. virtual int GetLeafNodeForPoint( Vector &vPosition ) = 0;
  68. /*
  69. virtual CVarBitVec *GetVisibilityVectorForPoint( Vector &vPosition ) = 0;
  70. virtual CVarBitVec *GetAllVisibleVector( ) = 0;
  71. */
  72. virtual float GetMaxVisibleDistance( Vector &vPosition ) = 0;
  73. // Rendering
  74. virtual RenderAction_t BuildRenderList( CUtlVector<IBVHNode*> *pRenderListOut,
  75. BVHNodeFlags_t nSkipFlags,
  76. const Vector &vEyePoint,
  77. float flLODScale,
  78. float flFarPlane,
  79. float flElapsedTime,
  80. int nCurrentFrameNumber ) = 0;
  81. virtual void SortRenderList( CUtlVector<IBVHNode*> *pRenderList, Vector &vEyePoint ) = 0;
  82. virtual void RenderNode( IBVHNode* pNode, IRenderContext *pContext, CFrustum &frustum, Vector &vOriginShift, uint nCurrentFrameNumber, ShaderComboVariation_t nVariation = VARIATION_DEFAULT, ConstantBufferHandle_t hObjectCB = 0 ) = 0;
  83. // Entities
  84. virtual void GetEntities( char *pEntityName, CUtlVector<KeyValues*> &entityList, CUtlVector<Vector> *pOriginList = NULL ) = 0;
  85. virtual void GetEntities( char *pEntityName, CUtlVector<KeyValues*> &entityList, IWorldTraversal *pTraversal ) = 0;
  86. // Traversals
  87. virtual CUtlVector<IWorldTraversal*> *GetTraversals() = 0;
  88. virtual RayTracingEnvironment *GetKDTreeForTraversal( IWorldTraversal *pTraversal ) = 0;
  89. // Tools only (TODO: pull these into their own interface)
  90. virtual void ShiftOrigins( Vector vOriginShift ) = 0;
  91. virtual void ShiftNodes( int nIDOffset, int *pResourceRemap ) = 0;
  92. virtual void WriteNodes( FileHandle_t fp ) = 0;
  93. virtual void WriteNodesSwapped( CUtlBuffer *pOutBuffer ) = 0;
  94. virtual uint64 GetChunkSize( BVHChunkType_t nChunkType ) = 0;
  95. virtual uint64 GetChunkOffset( BVHChunkType_t nChunkType ) = 0;
  96. virtual void WriteHeaderData( int32 nChunks, FileHandle_t fp ) = 0;
  97. virtual void WriteChunkDesc( BVHChunkDescriptor_t &chunkDesc, FileHandle_t fp ) = 0;
  98. virtual void WriteNonTerminatedEntityChunk( FileHandle_t fp ) = 0;
  99. virtual bool ReorderResourceFile( IBVHNode **ppOrderedNodes, int nNodes ) = 0;
  100. virtual bool WriteHierarchyFile( char *pWHFName ) = 0;
  101. virtual bool WriteByteSwappedWorld( char *pWHFName, char *pWRFName ) = 0;
  102. };
  103. #endif