Atoms Crowd  7.0.0
MeshScatterLayoutGenerator.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 <vector>
11 #include <Atoms/LayoutGenerators/DynamicLayoutGenerator.h>
12 #include <AtomsUtils/Mesh.h>
13 #include <AtomsUtils/Image.h>
14 
15 namespace Atoms
16 {
18  {
19  public:
20 
21  enum ScatterMode
22  {
23  kRandom = 0,
24  kVertices,
25  kFaceCenter,
26  kVerticesIteration,
27  kFaceCenterIteration
28  };
29 
31 
32  virtual ~MeshScatterLayoutGenerator();
33 
34  virtual std::vector<Atoms::AgentInitData> generate(double time)
35  #ifdef __APPLE__
36  override
37  #endif
38  ;
39 
40  void setMesh(const AtomsUtils::Mesh &mesh, short mode = 0);
41  inline void setDefaultRadius(double radius){m_defaultRadius = radius;}
42  inline void setDensityMap(AtomsUtils::Image* densityMap){m_densityMap = densityMap;}
43  inline void setMaxRadius(double radius){m_maxRadius = radius;}
44  inline void setUseDensityMap(bool state){m_useDensityMap = state;}
45  inline void setRandomizeRadius(bool state){m_randomizeRadius = state;}
46  inline void setIterations(int iterations){m_iterations = iterations;}
47  inline void setRandomDirection(const AtomsMath::Vector3f &randomDirection) { m_randomDirection = randomDirection; }
48  inline void setMeshMatrix(const AtomsMath::Matrix &matrix){m_meshMatrix = matrix;}
49  inline void setRandomSeed(unsigned int seed){m_randomSeed = seed;}
50  inline void setEraseMap(AtomsUtils::Image* densityMap) { m_eraseMap = densityMap; }
51  inline void setEraseThreshold(double radius) { m_eraseThreshold = radius; }
52  inline void setUseEraseMap(bool state) { m_useEraseMap = state; }
53  inline void useNormalAsUpVector(bool value) { m_useNormalAsUp = value; }
54  inline void setUseNavMesh(bool value) { m_useNavMesh = value; }
55  inline void setNavMeshName(const std::string & value) { m_navMeshName = value; };
56  inline void setClamp(const bool useClampVector, const AtomsCore::Vector3 &clampVector, const double clampAngle) { m_useClampVector = useClampVector; m_clampVector = clampVector; m_clampAngle = clampAngle;}
57  inline void setOtherSamples(const std::vector<AtomsCore::Vector3> &otherSamples) { m_otherSamples = otherSamples; }
58  inline void setAgentMaxNum(const int agentMaxNum) { m_agentMaxNum = agentMaxNum; }
59 
60  inline const std::map<int, AtomsCore::Vector3> scaleOverride() const { AtomsUtils::Logger::warning() << "LayoutGenerator.scaleOverride method is deprecated."; return std::map<int, AtomsCore::Vector3>(); };
61 
62  inline void setScaleOverride(const std::map<int, AtomsCore::Vector3>& value) { AtomsUtils::Logger::warning() << "LayoutGenerator.setScaleOverride method is deprecated, please use setScaleAttributeCache instead."; }
63 
64  inline void setScaleAttributeCache(const BehaviourModuleAttributeCache<AtomsCore::Vector3>& scaleAttributeCache) { m_scaleAttributeCache = scaleAttributeCache; }
65 
66  inline const char* typeName() override { return "meshScatter"; };
67 
68  private:
69  // scale attribute cache
71 
72  int m_iterations;
73  int m_agentMaxNum;
74  double m_defaultRadius;
75  double m_maxRadius;
76  double m_eraseThreshold;
77  AtomsUtils::Mesh m_mesh;
78  AtomsUtils::Image* m_densityMap;
79  AtomsUtils::Image* m_eraseMap;
80  AtomsMath::Vector3 m_randomDirection;
81  AtomsMath::Vector3 m_clampVector;
82  AtomsMath::Matrix m_meshMatrix;
83  double m_clampAngle;
84  unsigned int m_randomSeed;
85  short m_scatterMode;
86  bool m_randomizeRadius;
87  bool m_useDensityMap;
88  bool m_useEraseMap;
89  bool m_useNormalAsUp;
90  bool m_useNavMesh;
91  bool m_useClampVector;
92  std::string m_navMeshName;
93 
94  AtomsCore::Rand48 m_random;
95 
96  std::vector<AtomsCore::Vector3> m_otherSamples;
97  };
98 }
Definition: DynamicLayoutGenerator.h:15
Definition: MeshScatterLayoutGenerator.h:18
virtual std::vector< Atoms::AgentInitData > generate(double time)
Generate a vector of agent init data.
const char * typeName() override
Get the type name for this generator.
Definition: MeshScatterLayoutGenerator.h:66
Image class.
Definition: Image.h:22
static LogProxy warning()
Get logger proxy warning.
Mesh class.
Definition: Mesh.h:30
AtomsMath::Vector3 Vector3
Vector3 class.
Definition: AtomsMath.h:57
Atoms namespace.
Definition: Agent.h:29