BVB Source Codes

CRYENGINE Show FlowTrackEventNode.cpp Source code

Return Download CRYENGINE: download FlowTrackEventNode.cpp Source code - Download CRYENGINE Source code - Type:.cpp
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. /********************************************************************
  4.    ---------------------------------------------------------------------
  5.    File name:   FlowTrackEventNode.cpp
  6.    Description: Dynamic node for Track Event logic
  7.    ---------------------------------------------------------------------
  8.    History:
  9.    - 10:04:2008 : Created by Kevin Kirst
  10.  
  11.  *********************************************************************/
  12.  
  13. #include "StdAfx.h"
  14. #include "FlowTrackEventNode.h"
  15.  
  16. CFlowTrackEventNode::CFlowTrackEventNode(SActivationInfo* pActInfo) :
  17.         m_refs(0),
  18.         m_pSequence(NULL),
  19.         m_nOutputs(1)
  20. {
  21.         m_outputs = new SOutputPortConfig[1];
  22.         m_outputs[0] = SOutputPortConfig();
  23. }
  24.  
  25. CFlowTrackEventNode::~CFlowTrackEventNode()
  26. {
  27.         SAFE_DELETE_ARRAY(m_outputs);
  28.         if (NULL != m_pSequence && false == gEnv->IsEditor())
  29.         {
  30.                 m_pSequence->RemoveTrackEventListener(this);
  31.                 m_pSequence = NULL;
  32.         }
  33. }
  34.  
  35. CFlowTrackEventNode::CFlowTrackEventNode(CFlowTrackEventNode const& obj) :
  36.         m_refs(0),
  37.         m_pSequence(NULL),
  38.         m_outputs(NULL)
  39. {
  40.         *this = obj;
  41. }
  42.  
  43. CFlowTrackEventNode& CFlowTrackEventNode::operator=(CFlowTrackEventNode const& obj)
  44. {
  45.         if (this != &obj)
  46.         {
  47.                 m_refs = 0; // New reference count
  48.                 m_pSequence = obj.m_pSequence;
  49.  
  50.                 // Copy outputs
  51.                 m_nOutputs = obj.m_nOutputs;
  52.                 SAFE_DELETE_ARRAY(m_outputs);
  53.                 m_outputs = new SOutputPortConfig[m_nOutputs];
  54.                 for (int i = 0; i < m_nOutputs; ++i)
  55.                 {
  56.                         m_outputs[i] = obj.m_outputs[i];
  57.                 }
  58.  
  59.                 m_outputStrings = obj.m_outputStrings;
  60.         }
  61.         return *this;
  62. }
  63.  
  64. void CFlowTrackEventNode::AddRef()
  65. {
  66.         ++m_refs;
  67. }
  68.  
  69. void CFlowTrackEventNode::Release()
  70. {
  71.         if (0 == --m_refs)
  72.                 delete this;
  73. }
  74.  
  75. IFlowNodePtr CFlowTrackEventNode::Clone(SActivationInfo* pActInfo)
  76. {
  77.         CFlowTrackEventNode* pClone = new CFlowTrackEventNode(*this);
  78.         return pClone;
  79. }
  80.  
  81. void CFlowTrackEventNode::GetConfiguration(SFlowNodeConfig& config)
  82. {
  83.         static const SInputPortConfig inputs[] = {
  84.                 // Note: Must be first!
  85.                 InputPortConfig<string>("seq_Sequence",  "", _HELP("Working animation sequence"), _HELP("Sequence"),   0),
  86.                 InputPortConfig<int>("seqid_SequenceId", 0,  _HELP("Working animation sequence"), _HELP("SequenceId"), 0),
  87.                 { 0 }
  88.         };
  89.  
  90.         config.pInputPorts = inputs;
  91.         config.pOutputPorts = m_outputs;
  92.         config.SetCategory(EFLN_APPROVED);
  93.         config.nFlags |= EFLN_DYNAMIC_OUTPUT;
  94.         config.nFlags |= EFLN_HIDE_UI;
  95. }
  96.  
  97. void CFlowTrackEventNode::ProcessEvent(EFlowEvent event, SActivationInfo* pActInfo)
  98. {
  99.         if (event == eFE_Initialize && false == gEnv->IsEditor())
  100.         {
  101.                 AddListener(pActInfo);
  102.         }
  103. }
  104.  
  105. bool CFlowTrackEventNode::SerializeXML(SActivationInfo* pActInfo, const XmlNodeRef& root, bool reading)
  106. {
  107.         if (true == reading)
  108.         {
  109.                 int count = root->getChildCount();
  110.  
  111.                 // Resize
  112.                 if (m_outputs)
  113.                 {
  114.                         SAFE_DELETE_ARRAY(m_outputs);
  115.                 }
  116.                 m_outputs = new SOutputPortConfig[count + 1];
  117.                 m_nOutputs = count + 1;
  118.  
  119.                 for (int i = 0; i < count; ++i)
  120.                 {
  121.                         XmlNodeRef child = root->getChild(i);
  122.                         m_outputStrings.push_back(child->getAttr("Name"));
  123.                         m_outputs[i] = OutputPortConfig<string>(m_outputStrings[i]);
  124.                 }
  125.                 m_outputs[count] = SOutputPortConfig();
  126.         }
  127.         return true;
  128. }
  129.  
  130. void CFlowTrackEventNode::Serialize(SActivationInfo* pActInfo, TSerialize ser)
  131. {
  132.         if (ser.IsReading() && false == gEnv->IsEditor())
  133.         {
  134.                 AddListener(pActInfo);
  135.         }
  136. }
  137.  
  138. void CFlowTrackEventNode::AddListener(SActivationInfo* pActInfo)
  139. {
  140.         CRY_ASSERT(pActInfo);
  141.         m_actInfo = *pActInfo;
  142.  
  143.         // Remove from old
  144.         if (NULL != m_pSequence)
  145.         {
  146.                 m_pSequence->RemoveTrackEventListener(this);
  147.                 m_pSequence = NULL;
  148.         }
  149.  
  150.         // Look up sequence
  151.         const int kSequenceName = 0;
  152.         const int kSequenceId = 1;
  153.         m_pSequence = gEnv->pMovieSystem->FindSequenceById((uint32)GetPortInt(pActInfo, kSequenceId));
  154.         if (NULL == m_pSequence)
  155.         {
  156.                 string name = GetPortString(pActInfo, kSequenceName);
  157.                 m_pSequence = gEnv->pMovieSystem->FindSequence(name.c_str());
  158.         }
  159.         if (NULL != m_pSequence)
  160.                 m_pSequence->AddTrackEventListener(this);
  161. }
  162.  
  163. void CFlowTrackEventNode::OnTrackEvent(IAnimSequence* pSequence, int reason, const char* event, void* pUserData)
  164. {
  165.         if (reason != ITrackEventListener::eTrackEventReason_Triggered)
  166.                 return;
  167.  
  168.         // Find output port and call it
  169.         for (int i = 0; i < m_nOutputs; ++i)
  170.         {
  171.                 if (m_outputs[i].name && strcmp(m_outputs[i].name, event) == 0)
  172.                 {
  173.                         // Call it
  174.                         TFlowInputData value;
  175.                         const char* param = (const char*)pUserData;
  176.                         value.Set(string(param));
  177.                         ActivateOutput(&m_actInfo, i, value);
  178.                         return;
  179.                 }
  180.         }
  181. }
  182.  
downloadFlowTrackEventNode.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