Atoms Crowd  4.1.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 resetTime() { m_resetTime = true; };
36  void setFps(double fps);
37 
38  void setDoNotAdvanceClips(const bool value) { m_doNotAdvanceClips = value; };
39 
40  AgentBehaviourNetwork& network() { return m_network; };
41 
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, 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  unsigned int m_blendIn;
73  unsigned int m_blendOut;
74 
75  bool m_doNotAdvanceClips;
76  bool m_needLockDirectionForTurning;
77  bool m_oneShot;
78  bool m_resetTime;
79  bool m_first;
80 
81  };
82 }
Atoms::AnimationState
Animation State.
Definition: AnimationState.h:25
Atoms::StateMachineBaseNodeOperator
Definition: StateMachineBaseNodeOperator.h:27
AtomsGraph::PortTemplate
Generic node port class.
Definition: PortTemplate.h:24
Atoms
Atoms namespace.
Definition: Agent.h:28
Atoms::StateMachineBaseNodeOperator::reset
void reset()
Operator reset function.
Atoms::Operator
Operator node.
Definition: Operator.h:26