BVB Source Codes

CRYENGINE Show VehiclePartWaterRipplesGenerator.cpp Source code

Return Download CRYENGINE: download VehiclePartWaterRipplesGenerator.cpp Source code - Download CRYENGINE Source code - Type:.cpp
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. #include "StdAfx.h"
  4.  
  5. #include "IVehicleSystem.h"
  6.  
  7. #include "VehiclePartWaterRipplesGenerator.h"
  8. #include "Vehicle.h"
  9.  
  10. //#pragma optimize("", off)
  11. //#pragma inline_depth(0)
  12.  
  13. CVehiclePartWaterRipplesGenerator::CVehiclePartWaterRipplesGenerator()
  14.         : m_localOffset(ZERO)
  15.         , m_waterRipplesScale(1.0f)
  16.         , m_waterRipplesStrength(1.0f)
  17.         , m_minMovementSpeed(1.0f)
  18.         , m_onlyMovingForward(false)
  19. {
  20.  
  21. }
  22.  
  23. CVehiclePartWaterRipplesGenerator::~CVehiclePartWaterRipplesGenerator()
  24. {
  25. }
  26.  
  27. bool CVehiclePartWaterRipplesGenerator::Init(IVehicle* pVehicle, const CVehicleParams& table, IVehiclePart* parent, CVehicle::SPartInitInfo& initInfo, int partType)
  28. {
  29.         if (!CVehiclePartBase::Init(pVehicle, table, parent, initInfo, eVPT_Massbox))
  30.                 return false;
  31.  
  32.         const CVehicleParams waterRipplesTable = table.findChild("WaterRipplesGen");
  33.         if (waterRipplesTable)
  34.         {
  35.                 waterRipplesTable.getAttr("scale", m_waterRipplesScale);
  36.                 waterRipplesTable.getAttr("strength", m_waterRipplesStrength);
  37.                 waterRipplesTable.getAttr("minMovementSpeed", m_minMovementSpeed);
  38.                 waterRipplesTable.getAttr("moveForwardOnly", m_onlyMovingForward);
  39.  
  40.                 m_minMovementSpeed = max(m_minMovementSpeed, 0.01f);
  41.         }
  42.  
  43.         m_pVehicle->SetObjectUpdate(this, IVehicle::eVOU_AlwaysUpdate);
  44.  
  45.         return true;
  46. }
  47.  
  48. void CVehiclePartWaterRipplesGenerator::PostInit()
  49. {
  50.         IVehicleHelper* pHelper = m_pVehicle->GetHelper(m_pSharedParameters->m_helperPosName.c_str());
  51.         if (pHelper)
  52.         {
  53.                 m_localOffset = pHelper->GetLocalTM().GetTranslation();
  54.         }
  55. }
  56.  
  57. void CVehiclePartWaterRipplesGenerator::Update(const float frameTime)
  58. {
  59.         //IVehicleMovement* pMovement = m_pVehicle->GetMovement();
  60.         const SVehicleStatus& status = m_pVehicle->GetStatus();
  61.  
  62.         const bool movingFastEnough = (status.speed > m_minMovementSpeed);
  63.         if (movingFastEnough)
  64.         {
  65.                 const Matrix34 vehicleWorldTM = m_pVehicle->GetEntity()->GetWorldTM();
  66.  
  67.                 // Check if moving backwards...
  68.                 if (m_onlyMovingForward)
  69.                 {
  70.                         const float dotProduct = vehicleWorldTM.GetColumn1().Dot((status.vel / status.speed));
  71.                         if (dotProduct < 0.0f)
  72.                                 return;
  73.                 }
  74.  
  75.                 gEnv->p3DEngine->AddWaterRipple(vehicleWorldTM.TransformPoint(m_localOffset), m_waterRipplesScale, m_waterRipplesStrength);
  76.         }
  77. }
  78.  
  79. DEFINE_VEHICLEOBJECT(CVehiclePartWaterRipplesGenerator);
  80.  
downloadVehiclePartWaterRipplesGenerator.cpp 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