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.

146 lines
6.9 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef C_PORTALGHOSTRENDERABLE_H
  8. #define C_PORTALGHOSTRENDERABLE_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. //#include "iclientrenderable.h"
  13. #include "c_baseanimating.h"
  14. #define DEBUG_GHOSTRENDERABLES 0
  15. class C_PortalGhostRenderable : public C_BaseAnimating//IClientRenderable, public IClientUnknown
  16. {
  17. public:
  18. DECLARE_CLASS( C_PortalGhostRenderable, C_BaseAnimating );
  19. CHandle<C_BaseEntity> m_hGhostedRenderable; //the renderable we're transforming and re-rendering
  20. VMatrix m_matGhostTransform;
  21. float *m_pSharedRenderClipPlane; //shared by all portal ghost renderables within the same portal
  22. float *m_pPortalExitRenderClipPlane; //special clip plane to use if the current view entrance is our owner portal (we're on the exit side)
  23. CHandle< C_BasePlayer > m_hHoldingPlayer; //special draw rules for the local player
  24. bool m_bPlayerHeldClone;
  25. bool m_bSourceIsBaseAnimating;
  26. bool m_bCombatWeapon;
  27. bool m_bCombatWeaponWorldClone; //not actually derived from C_BaseCombatWeapon, but shares some of the same hacks
  28. C_Portal_Base2D *m_pOwningPortal;
  29. float m_fRenderableRange[2];
  30. float m_fNoTransformBeforeTime;
  31. float m_fDisablePositionChecksUntilTime;
  32. #if( DEBUG_GHOSTRENDERABLES == 1 )
  33. int m_iDebugColor[4];
  34. #endif
  35. static bool ShouldCloneEntity( C_BaseEntity *pEntity, C_Portal_Base2D *pPortal, bool bUsePositionChecks );
  36. static C_PortalGhostRenderable *CreateGhostRenderable( C_BaseEntity *pEntity, C_Portal_Base2D *pPortal );
  37. static C_PortalGhostRenderable *CreateInversion( C_PortalGhostRenderable *pSrc, C_Portal_Base2D *pSourcePortal, float fTime );
  38. struct
  39. {
  40. Vector vRenderOrigin;
  41. QAngle qRenderAngle;
  42. matrix3x4_t matRenderableToWorldTransform;
  43. } m_ReferencedReturns; //when returning a reference, it has to actually exist somewhere
  44. C_PortalGhostRenderable( C_Portal_Base2D *pOwningPortal, C_BaseEntity *pGhostSource, const VMatrix &matGhostTransform, float *pSharedRenderClipPlane, C_BasePlayer *pPlayer );
  45. virtual ~C_PortalGhostRenderable( void );
  46. virtual void UpdateOnRemove( void );
  47. void PerFrameUpdate( void ); //called once per frame for misc updating
  48. // Data accessors
  49. virtual Vector const& GetRenderOrigin( void );
  50. virtual QAngle const& GetRenderAngles( void );
  51. virtual bool ShouldDraw( void ) { return !IsEffectActive( EF_NODRAW ); }
  52. bool ShouldDrawForThisView( void );
  53. // Call this to get the current bone transforms for the model.
  54. // currentTime parameter will affect interpolation
  55. // nMaxBones specifies how many matrices pBoneToWorldOut can hold. (Should be greater than or
  56. // equal to studiohdr_t::numbones. Use MAXSTUDIOBONES to be safe.)
  57. virtual bool SetupBones( matrix3x4a_t *pBoneToWorldOut, int nMaxBones, int boneMask, float currentTime );
  58. virtual C_BaseAnimating *GetBoneSetupDependancy( void );
  59. // Returns the bounds relative to the origin (render bounds)
  60. virtual void GetRenderBounds( Vector& mins, Vector& maxs );
  61. // returns the bounds as an AABB in worldspace
  62. virtual void GetRenderBoundsWorldspace( Vector& mins, Vector& maxs );
  63. // These normally call through to GetRenderAngles/GetRenderBounds, but some entities custom implement them.
  64. virtual void GetShadowRenderBounds( Vector &mins, Vector &maxs, ShadowType_t shadowType );
  65. // These methods return true if we want a per-renderable shadow cast direction + distance
  66. //virtual bool GetShadowCastDistance( float *pDist, ShadowType_t shadowType ) const;
  67. //virtual bool GetShadowCastDirection( Vector *pDirection, ShadowType_t shadowType ) const;
  68. // Returns the transform from RenderOrigin/RenderAngles to world
  69. virtual const matrix3x4_t &RenderableToWorldTransform();
  70. // Attachments
  71. virtual bool GetAttachment( int number, Vector &origin, QAngle &angles );
  72. virtual bool GetAttachment( int number, matrix3x4_t &matrix );
  73. virtual bool GetAttachment( int number, Vector &origin );
  74. virtual bool GetAttachmentVelocity( int number, Vector &originVel, Quaternion &angleVel );
  75. // Rendering clip plane, should be 4 floats, return value of NULL indicates a disabled render clip plane
  76. virtual float *GetRenderClipPlane( void );
  77. virtual IClientModelRenderable* GetClientModelRenderable() { return NULL; }
  78. virtual int DrawModel( int flags, const RenderableInstance_t &instance );
  79. // Get the model instance of the ghosted model so that decals will properly draw across portals
  80. virtual ModelInstanceHandle_t GetModelInstance();
  81. virtual void GetToolRecordingState( KeyValues *msg );
  82. //------------------------------------------
  83. //IClientRenderable - Trivial or redirection
  84. //------------------------------------------
  85. virtual IClientUnknown* GetIClientUnknown() { return this; };
  86. virtual RenderableTranslucencyType_t ComputeTranslucencyType( void );
  87. virtual int GetRenderFlags();
  88. //virtual ClientShadowHandle_t GetShadowHandle() const { return m_hShadowHandle; };
  89. //virtual ClientRenderHandle_t& RenderHandle() { return m_hRenderHandle; };
  90. //virtual const model_t* GetModel( ) const;
  91. //virtual int GetBody();
  92. //virtual void ComputeFxBlend( ) { return m_pGhostedRenderable->ComputeFxBlend(); };
  93. //virtual int GetFxBlend( void ) { return m_pGhostedRenderable->GetFxBlend(); };
  94. virtual void GetColorModulation( float* color );
  95. //virtual bool LODTest() { return true; };
  96. //virtual void SetupWeights( void ) { NULL; };
  97. //virtual void DoAnimationEvents( void ) { NULL; }; //TODO: find out if there's something we should be doing with this
  98. //virtual IPVSNotify* GetPVSNotifyInterface() { return NULL; };
  99. virtual bool ShouldReceiveProjectedTextures( int flags );// { return false; };//{ return m_pGhostedRenderable->ShouldReceiveProjectedTextures( flags ); };
  100. //virtual bool IsShadowDirty( ) { return m_bDirtyShadow; };
  101. //virtual void MarkShadowDirty( bool bDirty ) { m_bDirtyShadow = bDirty; };
  102. //virtual IClientRenderable * GetShadowParent() { return NULL; };
  103. //virtual IClientRenderable * FirstShadowChild() { return NULL; };
  104. //virtual IClientRenderable * NextShadowPeer() { return NULL; };
  105. //virtual ShadowType_t ShadowCastType();
  106. //virtual void CreateModelInstance() { NULL; };
  107. //virtual ModelInstanceHandle_t GetModelInstance() { return m_pGhostedRenderable->GetModelInstance(); }; //TODO: find out if sharing an instance causes bugs
  108. virtual int LookupAttachment( const char *pAttachmentName );
  109. //virtual int GetSkin();
  110. //virtual bool IsTwoPass( void );
  111. //virtual void OnThreadedDrawSetup() { NULL; };
  112. //IHandleEntity
  113. //virtual void SetRefEHandle( const CBaseHandle &handle ) { m_RefEHandle = handle; };
  114. //virtual const CBaseHandle& GetRefEHandle() const { return m_RefEHandle; };
  115. };
  116. #endif //#ifndef C_PORTALGHOSTRENDERABLE_H