BVB Source Codes

CRYENGINE Show WaterWaveRenderNode.h Source code

Return Download CRYENGINE: download WaterWaveRenderNode.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. // -------------------------------------------------------------------------
  4. //  File name:   WaterWavesRenderNode.h
  5. //  Version:     v1.00
  6. //  Created:     20/09/2005 by Tiago Sousa.
  7. //  Compilers:   Visual Studio.NET 2003
  8. //  Description:
  9. // -------------------------------------------------------------------------
  10. //  History:
  11. //
  12. ////////////////////////////////////////////////////////////////////////////
  13.  
  14. #ifndef _WATERWAVES_RENDERNODE_
  15. #define _WATERWAVES_RENDERNODE_
  16.  
  17. #include <CryRenderer/VertexFormats.h>
  18.  
  19. struct SWaterWaveSerialize
  20. {
  21.         uint64            m_nID;
  22.         IMaterial*        m_pMaterial;
  23.  
  24.         Matrix34          m_pWorldTM;
  25.  
  26.         uint32            m_nVertexCount;
  27.         std::vector<Vec3> m_pVertices;
  28.  
  29.         f32               m_fUScale;
  30.         f32               m_fVScale;
  31.  
  32.         SWaterWaveParams  m_pParams;
  33.  
  34.         size_t            GetMemoryUsage() const
  35.         {
  36.                 size_t dynSize(sizeof(*this));
  37.                 dynSize += m_pVertices.capacity() * sizeof(std::vector<Vec3>::value_type);
  38.                 return dynSize;
  39.         }
  40. };
  41.  
  42. class CWaterWaveRenderNode : public IWaterWaveRenderNode, public Cry3DEngineBase
  43. {
  44.  
  45. public:
  46.         CWaterWaveRenderNode();
  47.         virtual void                    Create(uint64 nID, const Vec3* pVertices, uint32 nVertexCount, const Vec2& pUVScale, const Matrix34& pWorldTM);
  48.         void                            Update(float fDistanceToCamera);
  49.  
  50.         virtual void                    SetParams(const SWaterWaveParams& pParams);
  51.         virtual const SWaterWaveParams& GetParams() const;
  52.  
  53.         void                            SetRenderMesh(IRenderMesh* pRenderMesh);
  54.  
  55.         const SWaterWaveSerialize*      GetSerializationParams() const
  56.         {
  57.                 return m_pSerializeParams;
  58.         }
  59.  
  60.         uint64 GetID() const
  61.         {
  62.                 return m_nID;
  63.         }
  64.  
  65.         f32 GetWaveKey() const
  66.         {
  67.                 return m_fWaveKey;
  68.         }
  69.  
  70. public:
  71.  
  72.         ///////////////////////////////////////////////////////////////////////////////////////////////////
  73.         // IRenderNode implementation
  74.  
  75.         virtual EERType          GetRenderNodeType();
  76.         virtual const char*      GetEntityClassName() const;
  77.         virtual const char*      GetName() const;
  78.         virtual Vec3             GetPos(bool bWorldOnly = true) const;
  79.         virtual void             Render(const SRendParams& rParam, const SRenderingPassInfo& passInfo);
  80.         virtual IPhysicalEntity* GetPhysics() const;
  81.         virtual void             SetPhysics(IPhysicalEntity*);
  82.         virtual void             SetMaterial(IMaterial* pMat);
  83.         virtual IMaterial*       GetMaterial(Vec3* pHitPos) const;
  84.         virtual IMaterial*       GetMaterialOverride() { return m_pMaterial; }
  85.         virtual float            GetMaxViewDist();
  86.         virtual void             GetMemoryUsage(ICrySizer* pSizer) const;
  87.         virtual void             Precache();
  88.         virtual const AABB       GetBBox() const             { return m_WSBBox; }
  89.         virtual void             SetBBox(const AABB& WSBBox) { m_WSBBox = WSBBox; }
  90.         virtual void             FillBBox(AABB& aabb);
  91.         virtual void             OffsetPosition(const Vec3& delta);
  92.  
  93. private:
  94.  
  95.         ~CWaterWaveRenderNode();
  96.  
  97.         // Get wave boundings
  98.         void ComputeMinMax(const Vec3* pVertices, unsigned int nVertexCount);
  99.  
  100.         // Update bounding box
  101.         void UpdateBoundingBox();
  102.  
  103.         // Copy serialization parameters
  104.         void CopySerializationParams(uint64 nID, const Vec3* pVertices, unsigned int nVertexCount, const Vec2& pUVScale, const Matrix34& pWorldTM);
  105.  
  106.         // Spawn again
  107.         void Spawn();
  108.  
  109. private:
  110.  
  111.         uint64 m_nID;
  112.         f32    m_fWaveKey;
  113.  
  114.         // Render node serialization data
  115.         SWaterWaveSerialize* m_pSerializeParams;
  116.  
  117.         ///////////////////////////////////////////////////////////////////////////////////////////////////
  118.         // Renderer data
  119.  
  120.         _smart_ptr<IMaterial> m_pMaterial;
  121.  
  122.         IRenderMesh*          m_pRenderMesh;
  123.  
  124.         float                 m_fRECustomData[16]; // used for passing data to renderer
  125.  
  126.         ///////////////////////////////////////////////////////////////////////////////////////////////////
  127.         // Animation data
  128.  
  129.         SWaterWaveParams m_pParams;
  130.  
  131.         float            m_fCurrTerrainDepth;
  132.  
  133.         Vec3             m_pOrigPos;
  134.         Matrix34         m_pWorldTM;
  135.         Vec3             m_pMin, m_pMax; // Wave volume bounding
  136.  
  137.         AABB             m_WSBBox;
  138. };
  139.  
  140. ///////////////////////////////////////////////////////////////////////////////////////////////////
  141. // Wave manager
  142.  
  143. class CWaterWaveManager : public Cry3DEngineBase
  144. {
  145. public:
  146.         CWaterWaveManager();
  147.         ~CWaterWaveManager();
  148.  
  149.         // Updates all nearby and visible waves
  150.         void Update(const SRenderingPassInfo& passInfo);
  151.  
  152.         // Free all resources
  153.         void Release();
  154.  
  155.         // Adds wave to manager list, also creates/instances it's render mesh
  156.         void Register(CWaterWaveRenderNode* pWave);
  157.  
  158.         // Removes from manager and if no more instances sharing render mesh, removes it
  159.         void Unregister(CWaterWaveRenderNode* pWave);
  160.  
  161. private:
  162.  
  163.         // Make wave render mesh instance
  164.         IRenderMesh* CreateRenderMeshInstance(CWaterWaveRenderNode* pWave);
  165.  
  166.         typedef std::map<uint64, CWaterWaveRenderNode*> GlobalWavesMap;
  167.         typedef GlobalWavesMap::iterator                GlobalWavesMapIt;
  168.  
  169.         GlobalWavesMap m_pWaves;
  170.  
  171.         typedef std::map<f32, IRenderMesh*> InstancedWavesMap;
  172.         typedef InstancedWavesMap::iterator InstancedWavesMapIt;
  173.  
  174.         InstancedWavesMap m_pInstancedWaves;
  175.  
  176. };
  177.  
  178. #endif
  179.  
downloadWaterWaveRenderNode.h Source code - Download CRYENGINE Source code
Related Source Codes/Software:
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top