Atoms Crowd  4.1.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  };
30 
32  class ATOMS_EXPORT Locomotion
33  {
34 
35  public:
36 
39 
42 
43  inline unsigned int numLocomotionClips() const { return m_clips.size(); };
44 
45  inline unsigned int numTriangles() const { return m_triangles.size(); } ;
46 
48  void addAnimationClip(const std::string& clipName, const AtomsCore::Vector2 coords, const int inBlend, const int outBlend, const bool disableDirectionBlending, const bool unsynced);
49 
51  void buildTriangles(const LocomotionSort xSort = LocomotionSort::kGreater, const LocomotionSort ySort = LocomotionSort::kLess, const float eps = 1e-4);
52 
54  const LocomotionClip& getClip(unsigned int index) const;
55 
57  const AtomsUtils::Triangle2& getTriangle(unsigned int index) const;
58 
60  void addTriangle(const unsigned int p0Id, const unsigned int p1Id, const unsigned int p2Id);
61 
64 
66  std::vector<AtomsUtils::Triangle2> getTriangles() const { return m_triangles; };
67 
68  private:
69 
70  std::vector<AtomsUtils::Triangle2> m_triangles;
71 
72  std::vector<LocomotionClip> m_clips;
73 
74  static const LocomotionClip m_emptyClip;
75 
76  static const AtomsUtils::Triangle2 m_emptyTriangle;
77 
78  };
79 
80  typedef AtomsPtr<Locomotion> LocomotionPtr;
81 
82  typedef AtomsPtr<const Locomotion> LocomotionCPtr;
83 }
84 
85 
Atoms::Locomotion::clearTriangles
void clearTriangles()
clears all triangles
AtomsUtils::Triangle2
Triangle 2D class.
Definition: Triangle.h:87
Atoms::Locomotion::Locomotion
Locomotion()
Constructor.
Atoms::Locomotion
Animation clip.
Definition: Locomotion.h:33
Atoms::Locomotion::getTriangles
std::vector< AtomsUtils::Triangle2 > getTriangles() const
get a copy of all triangles
Definition: Locomotion.h:66
AtomsCore::Vector2
AtomsMath::Vector2 Vector2
Vector2 class.
Definition: AtomsMath.h:54
Atoms::Locomotion::getClip
const LocomotionClip & getClip(unsigned int index) const
Gets a locomotion clip.
Atoms::Locomotion::~Locomotion
~Locomotion()
Destructor.
Definition: Locomotion.h:41
Atoms::LocomotionClip
Definition: Locomotion.h:21
Atoms::Locomotion::buildTriangles
void buildTriangles(const LocomotionSort xSort=LocomotionSort::kGreater, const LocomotionSort ySort=LocomotionSort::kLess, const float eps=1e-4)
builds the triangles for this locomotion system
Atoms::Locomotion::getTriangle
const AtomsUtils::Triangle2 & getTriangle(unsigned int index) const
Gets a locomotion triangle.
Atoms
Atoms namespace.
Definition: Agent.h:28
Atoms::LocomotionPtr
AtomsPtr< Locomotion > LocomotionPtr
locomotion pointer
Definition: Locomotion.h:80
Atoms::Locomotion::addAnimationClip
void addAnimationClip(const std::string &clipName, const AtomsCore::Vector2 coords, const int inBlend, const int outBlend, const bool disableDirectionBlending, const bool unsynced)
Add a new clip.
Atoms::Locomotion::addTriangle
void addTriangle(const unsigned int p0Id, const unsigned int p1Id, const unsigned int p2Id)
adds a triangle
Atoms::LocomotionCPtr
AtomsPtr< const Locomotion > LocomotionCPtr
locomotion const pointer
Definition: Locomotion.h:82