Atoms Crowd  7.0.0
StateMachineBaseNodeOperator.h
1 #pragma once
2 // ===========================================================================
3 // Copyright (c) 2015 Toolchefs Ltd. All rights reserved.
4 //
5 // Use of this software is subject to the terms of the Toolchefs license
6 // agreement provided at the time of installation or download, or which
7 // otherwise accompanies this software in either electronic or hard copy form.
8 // ===========================================================================
9 
10 
11 #include <AtomsGraph/Ports.h>
12 #include <Atoms/Globals.h>
13 #include <Atoms/Graph/Operator.h>
14 #include <Atoms/AnimationClip.h>
15 #include <Atoms/AnimationState.h>
16 #include <Atoms/StateMachine.h>
17 #include <Atoms/Graph/AgentBehaviourNetwork.h>
18 #include <unordered_map>
19 #include <list>
20 #include <Atoms/Graph/AgentBehaviourNetwork.h>
21 #include <mutex>
22 
23 namespace Atoms
24 {
25 
26  class ATOMS_EXPORT StateMachineBaseNodeOperator : public Operator
27  {
28  public:
29 
31 
33 
34  void reset();
35  void setFps(double fps);
36 
37  void setDoNotAdvanceClips(const bool value) { m_doNotAdvanceClips = value; };
38 
39  AgentBehaviourNetwork& network() { return m_network; };
40 
41  virtual void resetTime() { m_resetTime = true; };
42  virtual bool isReadyToTransition(double frameRate = 1.0, bool checkTransitionFrames = true, bool checkForceTransition = true) = 0;
43  virtual void advanceSingleClip(double timeStep, double frameStep, bool randomClip = false) = 0;
44  virtual double computeBlendInOffset(double frameRate, bool checkTransitionFrames = true) = 0;
45  virtual void computeBlendInOffsetInPlace(double frameRate, bool checkTransitionFrames = true) = 0;
46  virtual double getBlendInOffset() = 0;
47  virtual void prepareForBlendIn(double offset, double timeStep) = 0;
48  virtual bool isBlendInStage(double offset, unsigned int blend) = 0;
49  virtual bool isBlendOutStage(double& frameDifference, unsigned int blend) = 0;
50  virtual double computeBlendInWeight(double offset, unsigned int blend) = 0;
51  virtual double computeBlendOutWeight(unsigned int blend) = 0;
52  virtual void setUpBlendOutFrame(double offset, double timeStep) = 0;
53  virtual bool isBlendOutFinished(unsigned int blend) = 0;
54  virtual void initSubState(double frame) = 0;
55  virtual bool hasClips() = 0;
56 
57  virtual void buildNetwork(const AtomsPtr<Atoms::StateMachine>& stateMachine, const Atoms::AnimationState& state, std::map<std::string, std::string>& clipToAgentTypeNames, std::mutex& mutex, const double timeOffset, AtomsCore::Rand32* idRandom) = 0;
58 
59  unsigned int blendIn() { return m_blendIn; };
60  unsigned int blendOut() { return m_blendOut; };
61  bool isOneShot() { return m_oneShot; };
62  bool needLockDirectionForTurning() { return m_needLockDirectionForTurning; };
63 
64  protected:
65 
66  AgentBehaviourNetwork m_network;
67 
68  AtomsGraph::DoublePort* m_timePort;
69 
70  AtomsGraph::DoublePort* m_fpsPort;
71 
72  AtomsGraph::LongPort* m_frameOffset;
73 
74  unsigned int m_blendIn;
75  unsigned int m_blendOut;
76 
77  bool m_doNotAdvanceClips;
78  bool m_needLockDirectionForTurning;
79  bool m_oneShot;
80  bool m_resetTime;
81  bool m_first;
82 
83  };
84 }
Agent behaviour network.
Definition: AgentBehaviourNetwork.h:29
Animation State.
Definition: AnimationState.h:25
Operator node.
Definition: Operator.h:26
Definition: StateMachineBaseNodeOperator.h:27
void reset()
Operator reset function.
Generic node port class.
Definition: PortTemplate.h:24
Atoms namespace.
Definition: Agent.h:29