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>
20 #include <Atoms/Graph/Operators/StateMachineBaseNodeOperator.h>
38 std::vector<unsigned int> clips;
39 int currentRandomClip;
46 SubState() : offset(0.0), hash(-1), isTurning(
false), transitionStarted(
false), bypass(
false) {}
47 std::vector<unsigned> ids;
51 bool transitionStarted;
93 framesBlendInOffset(0),
104 useClipDirection(
false),
118 double framesBlendInOffset;
120 unsigned int mergeType;
121 unsigned int motionType;
125 double previousAngle;
126 unsigned int numBlendFrames;
129 bool useClipDirection;
136 NODE_STANDARD_MEMBERS
146 void updateTurningData(
154 void initializeFirstFrame(
159 void advanceSingleClip(
double timeStep,
double frameStep,
bool randomClip =
false);
165 double updateTurnWeights(
MotionType& motionType,
double turnAngled,
double& straight_weight,
double maxWeight);
167 void computeTurnWeights(
double maxWeight);
169 std::pair<int, int> getUnsyncedClipId();
171 int getUnsyncedClip(
MotionType& motionData,
double turnAngled);
173 void buildNetwork(
const AtomsPtr<Atoms::StateMachine>& stateMachine,
const Atoms::AnimationState &state, std::map<std::string, std::string>& clipToAgentTypeNames, std::mutex& mutex, AtomsCore::Rand32* idRandom);
175 bool isReadyToTransition(
double frameRate = 1.0,
bool checkTransitionFrames =
true,
bool checkForceTransition =
true);
176 double computeBlendInOffset(
double frameRate,
bool checkTransitionFrames =
true);
177 void computeBlendInOffsetInPlace(
double frameRate,
bool checkTransitionFrames =
true);
178 double getBlendInOffset();
179 double getBlendInOffset(
int clipId);
180 void prepareForBlendIn(
double offset,
double timeStep);
181 void prepareClipForBlendIn(
int clipId,
double offset);
182 int getActiveClipId();
183 bool isBlendInStage(
double offset,
unsigned int blend);
184 bool isBlendInStage(
int clipId,
double offset,
unsigned int blend);
185 bool isBlendOutStage(
double& frameDifference,
unsigned int blend);
186 double computeBlendInWeight(
double offset,
unsigned int blend);
187 double computeBlendInWeight(
int clipId,
double offset,
unsigned int blend);
188 double computeBlendOutWeight(
unsigned int blend);
189 double computeBlendOutWeight(
int clipId,
unsigned int blend);
190 void setUpBlendOutFrame(
double offset,
double timeStep);
191 bool isBlendOutFinished(
unsigned int blend);
192 void setClipFrameAndWeights();
193 void initSubState(
double frame);
195 bool hasClips() {
return m_clips.size() > 0; };
199 std::vector<double> m_frames;
201 std::vector<MotionType> m_motionInfo;
203 std::vector<ClipData> m_clips;
205 std::vector<AdditiveClipData> m_additiveClips;
207 std::vector<std::string> m_clipNames;
209 std::list<SubState> m_subStateQueue;
211 AtomsCore::Rand32* m_idRandom;
221 double m_previousTime;
225 unsigned int m_postRandClipId;
229 bool m_transitionStarted;
232 bool m_needLockDirectionForTurning;