10 #include <AtomsCore/AtomsMath.h>
11 #include <Atoms/Globals.h>
12 #include <Atoms/AgentGroup.h>
13 #include <AtomsCore/Metadata/Vector3Metadata.h>
59 enum GlobalRotationMode
61 kRotationPositionAndDirection = 0,
73 kScalePositionAndAgent = 0,
79 kAverageOrientation = 0,
126 inline void setMode(
unsigned short mode) { m_mode = mode; m_falloffDirty =
true;}
127 inline unsigned short mode() {
return m_mode; }
129 inline void setRotationAxis(
unsigned short mode) { m_rotationAxis = mode; }
130 inline unsigned short rotationAxis() {
return m_rotationAxis; }
132 inline void setAgentMode(
unsigned short mode) { m_agentMode = mode; }
133 inline unsigned short agentMode() {
return m_agentMode; }
135 inline void setLayout(
unsigned short layout) { m_layout = layout; generateSamples(); }
136 inline unsigned short layout() {
return m_layout; }
138 inline void setUseHeightFields(
bool val) { m_useHeightFields = val; }
139 inline short useHeightFields() {
return m_useHeightFields; }
141 inline void setMoveSpace(
bool val) { m_moveSpace = val; }
142 inline short moveSpace() {
return m_moveSpace; }
144 inline void setRotationSpace(
bool val) { m_rotationSpace = val; }
145 inline short rotationSpace() {
return m_rotationSpace; }
147 inline void setGlobalRotationMode(
unsigned short val) { m_globalRotationMode = val; }
148 inline short globalRotationMode() {
return m_globalRotationMode; }
150 inline void setScaleSpace(
bool val) { m_scaleSpace = val; }
151 inline short scaleSpace() {
return m_scaleSpace; }
153 inline void setGlobalScaleMode(
unsigned short val) { m_globalScaleMode = val; }
154 inline short globalScaleMode() {
return m_globalScaleMode; }
156 inline void setRandomSelected(
bool val) { m_randomSelected = val; }
157 inline bool randomSelected() {
return m_randomSelected; }
159 inline void setUpVector(
short val) { m_upVector = val; }
160 inline short upVector() {
return m_upVector; }
162 inline void setSelectedObjects(std::vector<std::string>& obList) { m_selectedObjects = obList; }
163 inline std::vector<std::string>& selectedObjects() {
return m_selectedObjects; }
165 inline void setTargetObjects(std::vector<std::string>& obList) { m_targetObjects = obList; }
166 inline std::vector<std::string>& targetObjects() {
return m_targetObjects; }
168 inline void setAgentTypes(std::vector<std::string>& agentTypes) { m_agentTypes = agentTypes; }
169 inline std::vector<std::string>& agentTypes() {
return m_agentTypes; }
171 inline void setAgentTypeWeights(std::vector<int>& weights) { m_agentTypeWeights = weights; }
172 inline std::vector<int>& agentTypeWeights() {
return m_agentTypeWeights; }
174 std::string agentType();
176 inline bool translateLockX() {
return m_translateLockX; }
177 inline bool translateLockY() {
return m_translateLockY; }
178 inline bool translateLockZ() {
return m_translateLockZ; }
180 inline void setTranslateLockX(
bool val) { m_translateLockX = val; }
181 inline void setTranslateLockY(
bool val) { m_translateLockY = val; }
182 inline void setTranslateLockZ(
bool val) { m_translateLockZ = val; }
184 inline bool rotateLockX() {
return m_rotateLockX; }
185 inline bool rotateLockY() {
return m_rotateLockY; }
186 inline bool rotateLockZ() {
return m_rotateLockZ; }
188 inline void setRotateLockX(
bool val) { m_rotateLockX = val; }
189 inline void setRotateLockY(
bool val) { m_rotateLockY = val; }
190 inline void setRotateLockZ(
bool val) { m_rotateLockZ = val; }
192 inline bool scaleLockX() {
return m_scaleLockX; }
193 inline bool scaleLockY() {
return m_scaleLockY; }
194 inline bool scaleLockZ() {
return m_scaleLockZ; }
196 inline void setScaleLockX(
bool val) { m_scaleLockX = val; }
197 inline void setScaleLockY(
bool val) { m_scaleLockY = val; }
198 inline void setScaleLockZ(
bool val) { m_scaleLockZ = val; }
203 inline void setDirectionRandom(
const AtomsCore::Vector3& val) { m_directionRandom = val; }
206 inline void setGridSize(
const AtomsCore::Vector3i& val) { m_gridSize = val; generateSamples();}
209 inline void setGridSpace(
const AtomsCore::Vector3& val) { m_gridSpace = val; generateSamples();}
212 inline void setGridSpaceRandom(
const AtomsCore::Vector3& val) { m_gridSpaceRandom = val; generateSamples();}
221 inline void setPoissonRadius(
double val) { m_poissonRadius = val; generateSamples();}
222 inline double poissonRadius() {
return m_poissonRadius; }
224 inline void setPoissonMinDistance(
double val) { m_poissonMinDistance = val; generateSamples();}
225 inline double poissonMinDistance() {
return m_poissonMinDistance; }
227 inline void setPoissonNumPoints(
int val) { m_poissonPoints = val; generateSamples(); }
228 inline int poissonNumPoints() {
return m_poissonPoints; }
230 inline void setPoissonSeed(
int val) { m_poissonSeed = val; generateSamples(); }
231 inline int poissonSeed() {
return m_poissonSeed; }
233 inline void setPoissonShape(
short val) { m_poissonShape = val; generateSamples(); }
234 inline short poissonShape() {
return m_poissonShape; }
236 inline void setDrawScale(
double value) { m_drawScale = value; }
237 inline double drawScale() {
return m_drawScale; }
239 inline bool timeOffsetGroupAgents() {
return m_timeOffsetGroupAgents; }
240 inline void setTimeOffsetGroupAgents(
const bool value) { m_timeOffsetGroupAgents = value; }
242 inline const std::string &copiedVariationName(
const std::string &agentType) {
return m_copiedVariationName[agentType]; }
243 inline void setCopiedVariationName(
const std::string &agentType,
const std::string &name) { m_copiedVariationName[agentType] = name; }
245 inline const bool falloffEnabled() {
return m_falloffEnabled; }
246 inline void setFalloffEnabled(
const bool value) { m_falloffEnabled = value; m_falloffDirty =
true; }
248 inline const double falloffRadius() {
return m_falloffRadius; }
249 inline void setFalloffRadius(
const double value) { m_falloffRadius = value; m_falloffDirty =
true; }
251 inline void setFalloffMode(
const unsigned int mode) { m_falloffMode = mode; }
252 inline const unsigned int falloffMode() {
return m_falloffMode; }
254 inline void clearFalloffDirty() { m_falloffDirty =
false; }
255 inline bool falloffDirty() {
return m_falloffDirty; }
256 inline void markFalloffDirty() { m_falloffDirty =
true; }
258 virtual void generateSamples();
260 inline std::vector<AtomsCore::Vector3> cachedSamples() {
return m_cachedSamples; }
261 inline void setCachedSamples(std::vector<AtomsCore::Vector3>& samples) { m_cachedSamples = samples; }
263 void agentSelectionChanged();
265 virtual void reset();
267 inline void setJointModeAgentGroupId(
size_t mode) { m_jointModeAgentId = mode; }
268 inline size_t jointModeAgentGroupId() {
return m_jointModeAgentId; }
270 inline void setJointModeJointId(
int mode) { m_jointModeJointId = mode; }
271 inline int jointModeJointId() {
return m_jointModeJointId; }
273 inline void setJointModeGroupIndex(
int index) { m_jointModeGroupIndex = index; }
274 inline int jointModeGroupIndex() {
return m_jointModeGroupIndex; }
276 inline double polyMinRadius() {
return m_polyMinRadius; };
277 inline double polyMaxRadius() {
return m_polyMaxRadius; };
278 inline int polyNumAgents() {
return m_polyNumAgents; };
279 inline int polyIterations() {
return m_polyIterations; };
280 inline int polySeed() {
return m_polySeed; };
281 inline bool polyRandom() {
return m_polyRandom; };
283 inline void setPolyMinRadius(
double value) { m_polyMinRadius = value; m_polyHash++; };
284 inline void setPolyMaxRadius(
double value) { m_polyMaxRadius = value; m_polyHash++; };
285 inline void setPolyNumAgents(
int value) { m_polyNumAgents = value; m_polyHash++; };
286 inline void setPolyIterations(
int value) { m_polyIterations = value; m_polyHash++;};
287 inline void setPolySeed(
int value) { m_polySeed = value; m_polyHash++;};
288 inline void setPolyRandom(
bool value) { m_polyRandom = value; m_polyHash++;};
289 inline long polyHash() {
return m_polyHash; }
291 inline void setDuplicateAgentGroupIds(
const std::string groupName,
const int id1,
const int id2) { m_agentDuplicateIds[groupName][id1] = id2; };
292 inline void resetDuplicateAgentGroupIds() { m_agentDuplicateIds.clear(); };
293 int getDuplicateAgentGroupIds(
const std::string &groupName,
const int id);
295 inline SocialLayoutMode socialLayoutMode() {
return m_socialLayoutMode; };
296 inline void setSocialLayoutMode(SocialLayoutMode mode) { m_socialLayoutMode = mode; };
297 inline std::vector<int> &getSocialAgentIds() {
return m_socialAgentIds; }
298 inline std::vector<AtomsCore::Vector3> &socialAgentPositions() {
return m_socialAgentPositions; }
299 inline std::vector<AtomsCore::Vector3> &socialAgentDirections() {
return m_socialAgentDirections; }
300 inline std::vector<AtomsCore::Quaternion> &socialAgentRotations() {
return m_socialAgentRotations; }
301 inline AtomsCore::Vector3 &socialAveragePosition() {
return m_socialAgentsAveragePosition; }
302 inline AtomsCore::Vector3 &socialAverageDirection() {
return m_socialAgentsAverageDirection; }
303 inline AtomsCore::Vector3 &socialReferencePosition() {
return m_socialReferencePosition; }
304 inline void setSocialReferencePosition(
const AtomsCore::Vector3 &pos) { m_socialReferencePosition = pos; }
305 inline std::vector<int> &socialGroupSizes() {
return m_socialGroupSizes; }
307 inline void setDisplayTimeOffsetBarOnScreenBottom(
const bool value) { m_displayTimeOffsetBarOnScreenBottom = value; }
308 inline bool displayTimeOffsetBarOnScreenBottom() {
return m_displayTimeOffsetBarOnScreenBottom; }
310 inline void setSocialSeparationForce(
double value) { m_socialSeparationForce = value; };
311 inline void setSocialSeparationRadius(
double value) { m_socialSeparationRadius = value; };
312 inline void setSocialDistanceNoise(
const AtomsCore::Vector3 &value) { m_socialDistanceNoise = value; };
313 inline void setSocialOrientationNoise(
const AtomsCore::Vector3 &value) { m_socialOrientationNoise = value; };
314 inline double socialSeparationRadius() {
return m_socialSeparationRadius; };
315 inline double socialSeparationForce() {
return m_socialSeparationForce; };
316 inline const AtomsCore::Vector3& socialDistanceNoise() {
return m_socialDistanceNoise; };
317 inline const AtomsCore::Vector3& socialOrientationNoise() {
return m_socialOrientationNoise; };
318 inline const std::vector<AtomsCore::Vector3> &socialFinalDirections() {
return m_socialFinalDirections; };
319 inline const std::vector<AtomsCore::Vector3> &socialFinalPositions() {
return m_socialFinalPositions; };
320 inline void setSocialFinalDirections(
const std::vector<AtomsCore::Vector3> &value) { m_socialFinalDirections = value; };
321 inline void setSocialFinalPositions(
const std::vector<AtomsCore::Vector3> &value) { m_socialFinalPositions = value; };
323 inline void setMeshScatterIterations(
const int value) { m_meshScatterIterations = value; }
324 inline void setMeshScatterDefaultRadius(
const double value) { m_meshScatterDefaultRadius = value; }
325 inline void setMeshScatterMaxRadius(
const double value) { m_meshScatterMaxRadius = value; }
326 inline void setMeshScatterSeed(
const int value) { m_meshScatterSeed = value; }
327 inline void setMeshScatterMode(
const int value) { m_meshScatterMode = value; }
328 inline void setRandRadius(
const bool value) { m_meshScatterRandRadius = value; }
329 inline void setMeshScatterMesh(
const AtomsUtils::Mesh &mesh) { m_meshScatterMesh = mesh; }
330 inline int meshScatterIterations() {
return m_meshScatterIterations; }
331 inline double meshScatterDefaultRadius() {
return m_meshScatterDefaultRadius; }
332 inline double meshScatterMaxRadius() {
return m_meshScatterMaxRadius; }
333 inline int meshScatterSeed() {
return m_meshScatterSeed; }
334 inline int meshScatterMode() {
return m_meshScatterMode; }
335 inline bool meshRandRadius() {
return m_meshScatterRandRadius; }
337 int getSocialIndex(
const int id)
const;
339 void initSocialLayoutData(
const std::vector<Atoms::AgentGroup *> &agentGroups);
340 void editAgentsWithSocialValue(
double value);
342 static void searchAgents(
const std::vector<Atoms::AgentGroup * > &agentGroups,
const bool useSearchRadius,
const double searchRadius,
const bool usePercentage,
const int percentage,
const bool useAgentType,
const std::vector<std::string> &agentTypeNames,
const bool useMetadata,
const std::string &metadataName,
const double metadataMin,
const double metadataMax, std::vector<std::vector<int>> &selection);
345 inline void setApplyPelvisHeightOffset(
bool val) { m_applyPelvisHeightOffset = val; }
346 inline bool applyPelvisHeightOffset() {
return m_applyPelvisHeightOffset; }
350 void cachePelvisTransformation(
const std::vector<Atoms::AgentGroup *> &agentGroups);
352 bool computeHeightField(
Atoms::Agent *agent,
AtomsCore::Poser &poser,
Atoms::HeightField *hf,
Atoms::HeightField *gf,
AtomsCore::Vector3 &jointRootWorldTranlsate,
AtomsCore::Quaternion &jointRootWorldRotation,
AtomsCore::Vector3 &jointRootWorldScale,
AtomsCore::Vector3f &currPose,
AtomsCore::Vector3 &agentUp, AtomsPtr<AtomsCore::Vector3Metadata> &upVec,
double &pelvisHeight,
bool useHeightFields);
353 void findModules(
const AtomsPtr<Atoms::AgentGroup> &agentGroup,
bool &isPointLayout,
bool &isCacheReader, std::string ¤tModuleName);
355 unsigned short m_mode;
357 unsigned short m_layout;
359 unsigned short m_agentMode;
361 unsigned short m_globalRotationMode;
362 unsigned short m_globalScaleMode;
364 unsigned short m_rotationAxis;
366 bool m_useHeightFields;
368 bool m_randomSelected;
370 bool m_timeOffsetGroupAgents;
375 bool m_translateLockX;
376 bool m_translateLockY;
377 bool m_translateLockZ;
388 short m_rotationSpace;
391 bool m_displayTimeOffsetBarOnScreenBottom;
403 std::map<std::string, std::map<int, int>> m_agentDuplicateIds;
405 double m_poissonRadius;
406 double m_poissonMinDistance;
407 double m_poissonPoints;
408 short m_poissonShape;
409 unsigned int m_poissonSeed;
410 std::string m_poissonMask;
412 std::map<std::string, std::string> m_copiedVariationName;
416 std::vector<std::string> m_agentTypes;
417 std::vector<int> m_agentTypeWeights;
419 std::vector<std::string> m_selectedObjects;
421 std::vector<std::string> m_targetObjects;
423 std::vector<AtomsCore::Vector3> m_cachedSamples;
425 size_t m_jointModeAgentId;
427 int m_jointModeJointId;
428 int m_jointModeGroupIndex;
430 bool m_falloffEnabled;
431 double m_falloffRadius;
433 unsigned short m_falloffMode;
435 double m_polyMinRadius;
436 double m_polyMaxRadius;
438 int m_polyIterations;
444 std::vector<int> m_socialAgentIds;
445 std::vector<int> m_socialGroupSizes;
446 std::vector<AtomsCore::Vector3> m_socialAgentPositions;
447 std::vector<AtomsCore::Vector3> m_socialAgentDirections;
448 std::vector<AtomsCore::Quaternion> m_socialAgentRotations;
449 std::vector<AtomsCore::Vector3> m_agentRandomOffsetDistances;
450 std::vector<AtomsCore::Vector3> m_agentRandomOffsetDirections;
451 std::vector<std::string> m_socialAgentGroupNames;
455 std::vector<AtomsCore::Vector3> m_socialFinalPositions;
456 std::vector<AtomsCore::Vector3> m_socialFinalDirections;
457 SocialLayoutMode m_socialLayoutMode;
461 double m_socialSeparationForce;
462 double m_socialSeparationRadius;
466 int m_meshScatterIterations;
467 double m_meshScatterDefaultRadius;
468 double m_meshScatterMaxRadius;
469 int m_meshScatterSeed;
470 int m_meshScatterMode;
471 bool m_meshScatterRandRadius;
476 bool m_applyPelvisHeightOffset;