BVB Source Codes

CRYENGINE Show TreeVisualizer.h Source code

Return Download CRYENGINE: download TreeVisualizer.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. #ifndef TreeVisualizer_h
  4. #define TreeVisualizer_h
  5.  
  6. #pragma once
  7.  
  8. #include <CryAISystem/BehaviorTree/IBehaviorTree.h>
  9.  
  10. #ifdef USING_BEHAVIOR_TREE_VISUALIZER
  11. namespace BehaviorTree
  12. {
  13. class TreeVisualizer
  14. {
  15. public:
  16.         TreeVisualizer(const UpdateContext& updateContext);
  17.  
  18.         void Draw(
  19.           const DebugTree& tree
  20.           , const char* behaviorTreeName
  21.           , const char* agentName
  22.         #ifdef USING_BEHAVIOR_TREE_LOG
  23.           , const MessageQueue& behaviorLog
  24.         #endif // USING_BEHAVIOR_TREE_LOG
  25.           , const TimestampCollection& timestampCollection
  26.           , const Blackboard& blackboard
  27.         #ifdef USING_BEHAVIOR_TREE_EVENT_DEBUGGING
  28.           , const MessageQueue& eventsLog
  29.         #endif // USING_BEHAVIOR_TREE_EVENT_DEBUGGING
  30.           );
  31.  
  32. private:
  33.         void SetLinePosition(float x, float y);
  34.         void DrawLine(const char* label, const ColorB& color);
  35.  
  36.         void DrawNode(const DebugNode& node, const uint32 depth);
  37.  
  38.         #ifdef USING_BEHAVIOR_TREE_LOG
  39.         void DrawBehaviorLog(const MessageQueue& behaviorLog);
  40.         #endif // USING_BEHAVIOR_TREE_LOG
  41.  
  42.         #ifdef USING_BEHAVIOR_TREE_TIMESTAMP_DEBUGGING
  43.         void DrawTimestampCollection(const TimestampCollection& timestampCollection);
  44.         #endif // USING_BEHAVIOR_TREE_TIMESTAMP_DEBUGGING
  45.  
  46.         void DrawBlackboard(const Blackboard& blackboard);
  47.  
  48.         #ifdef USING_BEHAVIOR_TREE_EVENT_DEBUGGING
  49.         void DrawEventLog(const MessageQueue& eventsLog);
  50.         #endif // USING_BEHAVIOR_TREE_EVENT_DEBUGGING
  51.  
  52.         const UpdateContext& m_updateContext;
  53.         float                m_currentLinePositionX;
  54.         float                m_currentLinePositionY;
  55. };
  56.  
  57. class DebugTreeSerializer
  58. {
  59. private:
  60.         struct TreeNode
  61.         {
  62.                 void Serialize(Serialization::IArchive& archive);
  63.  
  64.                 int                   xmlLine;
  65.                 string                node;
  66.                 std::vector<TreeNode> children;
  67.         };
  68.  
  69.         struct MBTree
  70.         {
  71.                 void Serialize(Serialization::IArchive& archive);
  72.  
  73.                 string   name;
  74.                 TreeNode rootNode;
  75.         };
  76.  
  77.         struct Variable
  78.         {
  79.                 void Serialize(Serialization::IArchive& archive);
  80.  
  81.                 string name;
  82.                 bool   value;
  83.         };
  84.         typedef std::vector<Variable> Variables;
  85.  
  86.         struct TimeStamp
  87.         {
  88.                 void Serialize(Serialization::IArchive& archive);
  89.  
  90.                 string name;
  91.                 float  value;
  92.                 bool   bIsValid;
  93.         };
  94.         typedef std::vector<TimeStamp> TimeStamps;
  95.  
  96.         typedef std::vector<string>    EventsLog;
  97.         typedef std::vector<string>    ErrorLog;
  98.  
  99.         struct Data
  100.         {
  101.                 void Serialize(Serialization::IArchive& archive);
  102.  
  103.                 MBTree     tree;
  104.                 Variables  variables;
  105.                 TimeStamps timeStamps;
  106.                 EventsLog  eventLog;
  107.                 ErrorLog   errorLog;
  108.         };
  109.  
  110. public:
  111.         DebugTreeSerializer() {};
  112.         DebugTreeSerializer(const BehaviorTreeInstance& treeInstance, const DebugTree& debugTree, const UpdateContext& updateContext, const bool bExecutionError);
  113.  
  114.         void Serialize(Serialization::IArchive& archive);
  115.  
  116. private:
  117.         void CollectTreeNodeInfo(const DebugNode& debugNode, const UpdateContext& updateContext, TreeNode& outNode);
  118.         void CollectVariablesInfo(const BehaviorTreeInstance& instance);
  119.         void CollectTimeStamps(const BehaviorTreeInstance& instance);
  120.         void CollectEventsLog(const BehaviorTreeInstance& instance);
  121.         void CollectExecutionErrorInfo(const DebugTree& debugTree);
  122.  
  123. private:
  124.         Data m_data;
  125. };
  126. }
  127. #endif // USING_BEHAVIOR_TREE_VISUALIZER
  128.  
  129. #endif // TreeVisualizer_h
  130.  
downloadTreeVisualizer.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