Atoms Crowd  7.0.0
Locomotion.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 #include <Atoms/Globals.h>
11 #include <AtomsCore/AtomsMath.h>
12 #include <AtomsUtils/Triangle.h>
13 #include <Atoms/Locomotion/LocomotionHelper.h>
14 #include <vector>
15 #include <map>
16 
17 namespace Atoms
18 {
19 
20  class ATOMS_EXPORT LocomotionClip
21  {
22  public:
23  std::string clipName;
24  AtomsCore::Vector2 clipCoord;
25  int inBlend;
26  int outBlend;
27  bool disableDirectionBlending;
28  bool unsynced;
29  int waitFrames;
30  };
31 
33  class ATOMS_EXPORT Locomotion
34  {
35 
36  public:
37 
40 
43 
44  inline unsigned int numLocomotionClips() const { return m_clips.size(); };
45 
46  inline unsigned int numTriangles() const { return m_triangles.size(); } ;
47 
49  void addAnimationClip(const std::string& clipName, const AtomsCore::Vector2 coords, const int inBlend, const int outBlend, const bool disableDirectionBlending, const bool unsynced, const int waitFrames);
50 
52  void buildTriangles(const LocomotionSort xSort = LocomotionSort::kGreater, const LocomotionSort ySort = LocomotionSort::kLess, const float eps = 1e-4);
53 
55  const LocomotionClip& getClip(unsigned int index) const;
56 
58  const AtomsUtils::Triangle2& getTriangle(unsigned int index) const;
59 
61  void addTriangle(const unsigned int p0Id, const unsigned int p1Id, const unsigned int p2Id);
62 
65 
67  std::vector<AtomsUtils::Triangle2> getTriangles() const { return m_triangles; };
68 
70  std::vector<AtomsUtils::Triangle2> getTrianglesWithoutUnsync() const;
71 
72  private:
73 
74  std::vector<AtomsUtils::Triangle2> m_triangles;
75 
76  std::vector<LocomotionClip> m_clips;
77 
78  static const LocomotionClip m_emptyClip;
79 
80  static const AtomsUtils::Triangle2 m_emptyTriangle;
81 
82  };
83 
84  typedef AtomsPtr<Locomotion> LocomotionPtr;
85 
86  typedef AtomsPtr<const Locomotion> LocomotionCPtr;
87 }
88 
89 
Definition: Locomotion.h:21
Animation clip.
Definition: Locomotion.h:34
void clearTriangles()
clears all triangles
const AtomsUtils::Triangle2 & getTriangle(unsigned int index) const
Gets a locomotion triangle.
const LocomotionClip & getClip(unsigned int index) const
Gets a locomotion clip.
Locomotion()
Constructor.
~Locomotion()
Destructor.
Definition: Locomotion.h:42
std::vector< AtomsUtils::Triangle2 > getTrianglesWithoutUnsync() const
get all triangles without the sync clips
void addAnimationClip(const std::string &clipName, const AtomsCore::Vector2 coords, const int inBlend, const int outBlend, const bool disableDirectionBlending, const bool unsynced, const int waitFrames)
Add a new clip.
std::vector< AtomsUtils::Triangle2 > getTriangles() const
get a copy of all triangles
Definition: Locomotion.h:67
void buildTriangles(const LocomotionSort xSort=LocomotionSort::kGreater, const LocomotionSort ySort=LocomotionSort::kLess, const float eps=1e-4)
builds the triangles for this locomotion system
void addTriangle(const unsigned int p0Id, const unsigned int p1Id, const unsigned int p2Id)
adds a triangle
Triangle 2D class.
Definition: Triangle.h:87
AtomsMath::Vector2 Vector2
Vector2 class.
Definition: AtomsMath.h:54
Atoms namespace.
Definition: Agent.h:29
AtomsPtr< Locomotion > LocomotionPtr
locomotion pointer
Definition: Locomotion.h:84
AtomsPtr< const Locomotion > LocomotionCPtr
locomotion const pointer
Definition: Locomotion.h:86