10 #include <Atoms/Globals.h>
11 #include <AtomsCore/Hash.h>
12 #include <AtomsUtils/Logger.h>
22 class AgentTypeVariation;
23 class VariationGeometry;
24 class VariationMaterial;
26 class VariationOverride;
27 class VariationGroupLod;
28 class VariationMaterialColor;
30 class VariationTreeGeo;
31 class MaterialConstraint;
32 class ExcludeGeometry;
55 typedef std::map<std::string, VariationTreeGeo> VariationTreeGeoMap;
56 typedef std::map<std::string, MaterialConstraint> MaterialConstraintMap;
57 typedef std::map<std::string, ExcludeGeometry> ExcludeGeometryMap;
68 m_geometryFilter(
"*") {}
77 void setGeometryFile(
const std::string& geometryFile) { m_geometryFile = geometryFile; };
91 std::string m_geometryFile;
94 std::string m_geometryFilter;
110 void setRed(
const int red) { m_red = red > 255 ? 255 : red < 0 ? 0 : red; }
112 void setGreen(
const int green) { m_green = green > 255 ? 255 : green < 0 ? 0 : green; }
114 void setBlue(
const int blue) { m_blue = blue > 255 ? 255 : blue < 0 ? 0 : blue; }
116 unsigned int getRed()
const {
return m_red; }
117 unsigned int getGreen()
const {
return m_green; }
118 unsigned int getBlue()
const {
return m_blue; }
125 unsigned int m_green;
140 m_diffuseWeight(1.0f),
141 m_specularWeight(0.0f),
142 m_specularRollOff(0.7f),
143 m_specularEccentricity(0.3f)
145 m_diffuseFiles.resize(1);
146 m_diffuseRGBs.resize(1);
156 void setMaterialFile(
const std::string& materialFile) { m_materialFile = materialFile; };
265 std::string m_materialFile;
268 std::vector<std::string> m_diffuseFiles;
271 std::string m_specularFile;
274 std::string m_normalMapFile;
277 float m_diffuseWeight;
280 float m_specularWeight;
283 float m_specularRollOff;
286 float m_specularEccentricity;
289 std::string m_diffuseHueMetadataName;
292 std::string m_diffuseSlotMetadataName;
298 std::vector<VariationMaterialColor> m_diffuseRGBs;
315 inline void clear() { m_combinations.clear(); }
318 inline unsigned int numCombinations()
const {
return static_cast<unsigned int>(m_combinations.size()); }
321 inline bool hasCombination(
const std::string& geometryName,
const std::string& materialName);
324 void addCombination(
const std::string& geometryName,
const std::string& materialName);
327 inline const std::pair<std::string, std::string>& getCombinationAtIndex(
unsigned int index)
const;
330 inline bool removeCombinationAtIndex(
unsigned int index);
336 const std::vector<std::pair<std::string, std::string>>&
getCombinations()
const {
return m_combinations; };
375 inline std::vector<std::string> getLodNames()
const;
378 inline bool hasLod(
const std::string& name)
const {
return m_lods.find(name) != m_lods.end(); }
387 inline bool removeLod(
const std::string &name);
398 std::map<std::string, VariationGroupLod> m_lods;
408 ExcludeGeometry(
const std::string& sourceGeometry,
const std::string& destinationGeometry) : m_sourceGeometry(sourceGeometry), m_destinationGeometry(destinationGeometry) {}
411 void setSourceGeometry(
const std::string& sourceGeometry) { m_sourceGeometry = sourceGeometry; }
412 const std::string& getSourceGeometry()
const {
return m_sourceGeometry; }
414 void setDestinationGeometry(
const std::string& destinationGeometry) { m_destinationGeometry = destinationGeometry; }
415 const std::string& getDestinationGeometry()
const {
return m_destinationGeometry; }
418 std::string m_sourceGeometry;
419 std::string m_destinationGeometry;
435 unsigned int numGeometryFilter()
const {
return static_cast<unsigned int>(m_geometryFilter.size()); }
438 inline bool hasGeometryFilter(
const std::string& geometryName)
const;
444 inline const std::string& getGeometryFilterAtIndex(
unsigned int index)
const;
447 inline bool removeGeometryFilterAtIndex(
unsigned int index);
458 std::vector<std::string> m_geometryFilter;
460 static std::string m_emptyString;
471 unsigned int numMaterials()
const {
return static_cast<unsigned int>(m_materialNames.size()); }
474 inline bool hasMaterial(
const std::string& materialName)
const;
477 inline void addMaterial(
const std::string& materialName,
const double weight=1.0);
480 inline const std::string& getMaterialNameAtIndex(
unsigned int index)
const;
483 inline const double getMaterialWeightAtIndex(
unsigned int index)
const;
486 inline bool removeMaterialAtIndex(
unsigned int index);
489 std::vector<std::string> m_materialNames;
490 std::vector<double> m_materialWeights;
493 static std::string m_emptyString;
510 VariationTreeGeo(
AgentTypeVariationCPtr vt,
const std::string &name) : m_atVariation(vt), m_name(name), m_weight(1), m_locked(
false), m_type(GeoType::kVariationType), m_materialOverride(vt) {}
511 VariationTreeGeo(
AgentTypeVariationCPtr vt,
const std::string& name,
const double weight,
const bool locked,
const GeoType geoType): m_atVariation(vt), m_name(name), m_weight(weight), m_locked(locked), m_type(geoType), m_materialOverride(vt) { }
516 const VariationTreeGeoMap& getChildren()
const {
return m_children; }
517 void clearChildren() { m_children.clear(); }
519 void setLocked(
const bool locked) { m_locked = locked; }
520 const bool getLocked()
const {
return m_locked; }
522 void setWeight(
const double weight) { m_weight = weight; }
523 const double getWeight()
const {
return m_weight; }
525 void setGeoType(
const GeoType geoType) { m_type = geoType; }
526 const GeoType getGeoType()
const {
return m_type; }
528 const MaterialOverride& getMaterialOverride()
const {
return m_materialOverride; };
531 void addExcludeGeometry(
const std::string& name,
const ExcludeGeometry& eg);
532 const ExcludeGeometryMap& getExcludeGeometries()
const {
return m_excludeGeometries; };
533 ExcludeGeometryMap& getExcludeGeometries() {
return m_excludeGeometries; };
535 const std::string& getName()
const {
return m_name; }
547 ExcludeGeometryMap m_excludeGeometries;
548 VariationTreeGeoMap m_children;
558 MaterialConstraint(
const std::string &material,
const std::string& geometryName,
const std::string& destinationMaterialName ) : m_material(material), m_geometryName(geometryName), m_destinationMaterialName(destinationMaterialName) {}
561 void setMaterial(
const std::string& material) { m_material = material; }
562 const std::string& getMaterial()
const {
return m_material; }
564 void setGeometryName(
const std::string& geometryName) { m_geometryName = geometryName; }
565 const std::string& getGeometryName()
const {
return m_geometryName; }
567 void setDestinationMaterialName(
const std::string& destinationMaterialName) { m_destinationMaterialName = destinationMaterialName; }
568 const std::string& getDestinationMaterialName()
const {
return m_destinationMaterialName; }
571 std::string m_material;
572 std::string m_geometryName;
573 std::string m_destinationMaterialName;
599 bool hasVariationType(
const std::string& name)
const {
return m_variationTypes.find(name) != m_variationTypes.end(); };
602 const VariationTreeGeoMap&
getExtraGeos()
const {
return m_extraGeos; };
611 inline void addVariationType(
const std::string& name,
const VariationTreeGeo& vg);
614 inline void addExtraGeo(
const std::string& name,
const VariationTreeGeo& vg);
617 inline void addMaterialConstraint(
const std::string& name,
const MaterialConstraint& mc);
620 inline void addExcludeGeometry(
const std::string& name,
const ExcludeGeometry& mc);
623 inline void setGeoMatSuffixReplacement(
const std::string& geo,
const std::string& mat) { m_geoMatSuffixRepl.first = geo; m_geoMatSuffixRepl.second = mat;}
632 inline const std::vector<std::pair<std::string, std::string>>&
getGeoMatAliases()
const {
return m_geoMatAlias; }
635 inline void setMaterialPrefix(
const std::string& materialPrefix) { m_materialPrefix = materialPrefix; }
644 std::vector<std::pair<std::string, std::string>>
build(
const std::string &variationType,
unsigned agentSeed,
unsigned int seed, std::vector<std::string>& debugMessages,
const bool storeDebugMessages =
false)
const;
656 VariationTreeGeoMap m_variationTypes;
659 VariationTreeGeoMap m_extraGeos;
662 MaterialConstraintMap m_materialConstraints;
665 ExcludeGeometryMap m_excludeGeometries;
668 std::vector<std::pair<std::string, std::string>> m_geoMatAlias;
671 std::pair<std::string, std::string> m_geoMatSuffixRepl;
674 std::string m_materialPrefix;
676 std::vector<std::string> m_debugMessages;
700 inline std::vector<std::string> getGeometryNames()
const;
703 inline std::vector<std::string> getMaterialNames()
const;
706 inline std::vector<std::string> getGroupNames()
const;
709 inline std::vector<std::string> getOverrideNames()
const;
739 inline void setLookFile(
const std::string &path) { m_lookFile = path; }
763 inline const std::string &
getLookFile()
const {
return m_lookFile; }
766 inline bool hasGeometry(
const std::string &name)
const {
return m_geos.find(name) != m_geos.end(); }
769 inline bool hasMaterial(
const std::string &name)
const {
return m_mats.find(name) != m_mats.end(); }
772 inline bool hasGroup(
const std::string &name)
const {
return m_groups.find(name) != m_groups.end(); }
775 inline bool hasOverride(
const std::string& name)
const {
return m_overrides.find(name) != m_overrides.end(); }
778 inline bool removeGeometry(
const std::string &name);
781 inline bool removeMaterial(
const std::string &name);
784 inline bool removeGroup(
const std::string &name);
787 inline bool removeOverride(
const std::string& name);
790 inline bool removeAllGroups();
793 inline bool removeAllOverrides();
800 const std::string& lodName,
801 const int variationSeed,
803 const std::vector<std::string>& variationOverrides,
804 const std::vector<std::string>& geoMatOverrides,
805 const std::vector<std::string>& geometryFilters,
806 std::vector<std::string>& debugMessages,
807 std::vector<std::pair<std::string,
808 std::string>>& combinations,
809 const bool storeDebugMessages =
false)
const;
814 std::map<std::string, VariationGeometry> m_geos;
817 std::map<std::string, VariationMaterial> m_mats;
820 std::map<std::string, VariationGroup> m_groups;
823 std::map<std::string, VariationOverride> m_overrides;
829 std::string m_clothSetup;
832 std::string m_lookFile;
849 void clear() { m_agentTypeVariations.clear(); };
852 inline std::vector<std::string> getAgentTypeNames()
const;
864 inline bool hasAgentTypeVariation(
const std::string &agentTypeName) {
return m_agentTypeVariations.find(agentTypeName) != m_agentTypeVariations.end(); }
867 inline bool removeAgentTypeVariation(
const std::string &agentTypeName);
873 std::string
toString(
const bool prettyprint =
false);
878 inline size_t size()
const;
883 std::map<std::string, AgentTypeVariation> m_agentTypeVariations;
887 #include <Atoms/Variations.impl.h>
Agent type variation class.
Definition: Variations.h:685
AgentTypeVariation()
Constructor.
Definition: Variations.h:688
const VariationTree & getVariationTree() const
Gets Variation Tree.
Definition: Variations.h:727
~AgentTypeVariation()
Destructor.
Definition: Variations.h:691
bool hasMaterial(const std::string &name) const
Checks if this object contains a material.
Definition: Variations.h:769
void buildCombinations(const std::string &variationName, const std::string &lodName, const int variationSeed, const int agentSeed, const std::vector< std::string > &variationOverrides, const std::vector< std::string > &geoMatOverrides, const std::vector< std::string > &geometryFilters, std::vector< std::string > &debugMessages, std::vector< std::pair< std::string, std::string >> &combinations, const bool storeDebugMessages=false) const
retrieve combinations
VariationGeometry & getGeometry(const std::string &name)
Gets a geometry.
Definition: Variations.h:712
VariationOverride & getOverride(const std::string &name)
Gets a override.
bool hasGroup(const std::string &name) const
Checks if this object contains a group.
Definition: Variations.h:772
bool hasGeometry(const std::string &name) const
Checks if this object contains a geometry.
Definition: Variations.h:766
VariationGroup & getGroup(const std::string &name)
Gets a group.
void setLookFile(const std::string &path)
Sets look file.
Definition: Variations.h:739
bool hasOverride(const std::string &name) const
Checks if this object contains an override.
Definition: Variations.h:775
VariationMaterial & getMaterial(const std::string &name)
Gets a material.
Definition: Variations.h:715
void setGeometry(const std::string &name, const VariationGeometry &v)
Sets a geometry.
Definition: Variations.h:730
void setGroup(const std::string &name, const VariationGroup &v)
Sets a group.
Definition: Variations.h:742
void setOverride(const std::string &name, const VariationOverride &v)
Sets an override.
Definition: Variations.h:745
const std::string & getClothSetup() const
Gets cloth setup file.
Definition: Variations.h:760
VariationTree & getVariationTree()
Gets Variation Tree.
Definition: Variations.h:724
void setClothSetup(const std::string &path)
Sets cloth setup file.
Definition: Variations.h:736
void hash(AtomsCore::MurmurHash3 &hasher) const
Hash.
const std::string & getLookFile() const
Gets look file.
Definition: Variations.h:763
void setMaterial(const std::string &name, const VariationMaterial &v)
Sets a material.
Definition: Variations.h:733
AgentTypeVariation(const AgentTypeVariation &atv)
Copy constructor.
Definition: Variations.h:303
AgentTypeVariationCPtr m_atVariation
Agent type variation.
Definition: Variations.h:336
BaseVariationGroup(AgentTypeVariationCPtr agentTypeVariation)
Constructor.
Definition: Variations.h:306
void hash(AtomsCore::MurmurHash3 &hasher) const
Hash.
const std::vector< std::pair< std::string, std::string > > & getCombinations() const
Gets a reference to the combinations vector.
Definition: Variations.h:336
BaseVariationGroup(AgentTypeVariationCPtr agentTypeVariation, const BaseVariationGroup &vg)
Constructor.
std::pair< std::string, std::string > m_emptyPair
Empty combination.
Definition: Variations.h:349
void addCombination(const std::string &geometryName, const std::string &materialName)
Adds a combination.
~BaseVariationGroup()
Destructor.
Definition: Variations.h:312
unsigned int numCombinations() const
Gets the number of combinations.
Definition: Variations.h:318
std::vector< std::pair< std::string, std::string > > m_combinations
Map of combinations.
Definition: Variations.h:346
void clear()
Clear all combinations.
Definition: Variations.h:315
Exclude Geometry.
Definition: Variations.h:405
Material Constraint class.
Definition: Variations.h:555
Definition: Variations.h:464
unsigned int numMaterials() const
Gets the number of materials.
Definition: Variations.h:471
VariationGeometry class.
Definition: Variations.h:64
const std::string & getGeometryFilter() const
Gets the geometry filter.
Definition: Variations.h:80
const std::string & getGeometryFile() const
Gets the geometry file path.
Definition: Variations.h:74
void setGeometryFilter(const std::string &filter)
Sets the geometry file path.
Definition: Variations.h:83
void setGeometryFile(const std::string &geometryFile)
Sets the geometry file path.
Definition: Variations.h:77
void hash(AtomsCore::MurmurHash3 &hasher) const
Hash.
VariationGeometry()
Constructor.
Definition: Variations.h:67
~VariationGeometry()
Destructor.
Definition: Variations.h:71
Variation group class.
Definition: Variations.h:367
void hash(AtomsCore::MurmurHash3 &hasher) const
Hash.
bool hasLod(const std::string &name) const
Checks if a lod exists.
Definition: Variations.h:378
VariationGroup(AgentTypeVariationCPtr agentTypeVariation, const VariationGroup &vg)
Constructor.
VariationGroupLod & getLod(const std::string &name)
Gets a lod variation group.
void setLod(const std::string &name, const VariationGroupLod &v)
Sets a lod.
Definition: Variations.h:390
Variation group lod class.
Definition: Variations.h:357
Variation Material Color.
Definition: Variations.h:101
void setRed(const int red)
Sets the diffuse red value.
Definition: Variations.h:110
void setBlue(const int blue)
Sets the diffuse blue value.
Definition: Variations.h:114
void hash(AtomsCore::MurmurHash3 &hasher) const
Hash.
void setGreen(const int green)
Sets the diffuse green value.
Definition: Variations.h:112
Variation Material.
Definition: Variations.h:135
unsigned int getSpecularColorBlue() const
Gets the specular blue value.
void setSpecularColorBlue(const int blue)
Sets the specular blue value.
unsigned int getDiffuseSlotSize() const
Set diffuse slot size.
float getDiffuseWeight() const
Gets the diffuse weight.
unsigned int getDiffuseColorGreen() const
Gets the diffuse green value.
void setDiffuseWeight(float value)
Sets the diffuse weight.
void setDiffuseSlotSize(unsigned int size)
Set diffuse slot size.
const std::string & getDiffuseFile(unsigned int index=0) const
Gets the diffuse texture path.
const std::string & getNormalMapFile() const
Gets the normal file path.
void setDiffuseHueMetadataName(const std::string &value)
Sets the diffuse hue metadata name.
const std::string & getSpecularFile() const
Gets the specural file path.
void setDiffuseColorBlue(const int blue)
Sets the diffuse blue value.
~VariationMaterial()
Destructor.
Definition: Variations.h:150
float getSpecularRollOff() const
Gets the specular rolloff.
VariationMaterialColor & getSpecularColor()
Gets the specular color.
void setMaterialFile(const std::string &materialFile)
Sets the material file path.
Definition: Variations.h:156
const std::string & getDiffuseSlotMetadataName() const
Gets the diffuse slot metadata name.
unsigned int getDiffuseColorRed() const
Gets the diffuse red value.
void hash(AtomsCore::MurmurHash3 &hasher) const
Hash.
const VariationMaterialColor & getDiffuseColor(unsigned int index=0) const
Gets the diffuse color.
float getSpecularEccentricity() const
Gets the specular eccentricity.
unsigned int getSpecularColorGreen() const
Gets the specular green value.
void setSpecularColorGreen(const int green)
Sets the specular green value.
void setDiffuseSlotMetadataName(const std::string &value)
Sets the diffuse slot metadata name.
void setNormalMapFile(const std::string &normalMapFile)
Sets the normal file path.
void setSpecularRollOff(float value)
Sets the specular rolloff.
float getSpecularWeight() const
Gets the specular weight.
const std::string & getMaterialFile() const
Gets the material file path.
Definition: Variations.h:153
unsigned int getDiffuseColorBlue() const
Gets the diffuse blue value.
void setDiffuseColorRed(const int red)
Sets the diffuse red value.
void setDiffuseColorGreen(const int green)
Sets the diffuse green value.
void setSpecularFile(const std::string &specularFile)
Sets the specural file path.
void setDiffuseFile(const std::string &diffuseFile, unsigned int index=0)
Sets the diffuse texture path.
VariationMaterial()
Constructor.
Definition: Variations.h:139
unsigned int getSpecularColorRed() const
Gets the specular red value.
const std::string & getDiffuseHueMetadataName() const
Gets the diffuse hue metadata name.
void setSpecularEccentricity(float value)
Sets the specular eccentricity.
void setSpecularColorRed(const int red)
Sets the specular red value.
void setSpecularWeight(float value)
Sets the specular weight.
Variation override class.
Definition: Variations.h:427
VariationOverride(AgentTypeVariationCPtr agentTypeVariation, const VariationOverride &vg)
Constructor.
const std::vector< std::string > & getGeometryFilters() const
Get all geometry filters.
Definition: Variations.h:453
unsigned int numGeometryFilter() const
Gets the number of geometry filters.
Definition: Variations.h:435
void addGeometryFilter(const std::string &geometryName)
Adds a geometry filter.
void hash(AtomsCore::MurmurHash3 &hasher) const
Hash.
Variation Tree Geo class.
Definition: Variations.h:500
Variation Tree class.
Definition: Variations.h:580
const VariationTreeGeoMap & getVariationTypes() const
get the variation types
Definition: Variations.h:596
void addGeoMatAliases(const std::string &geo, const std::string &mat)
add geo mat aliases
const std::vector< std::pair< std::string, std::string > > & getGeoMatAliases() const
get geo mat aliases
Definition: Variations.h:632
const MaterialConstraintMap & getMaterialConstraints() const
get the material constraints
Definition: Variations.h:605
VariationTree(AgentTypeVariationCPtr agentTypeVariation, const VariationTree &variationTree)
Constructor.
VariationTree(AgentTypeVariationCPtr agentTypeVariation)
Constructor.
Definition: Variations.h:584
const std::pair< std::string, std::string > & getGeoMatSuffixReplacement() const
get geo mat suffix replacement
Definition: Variations.h:626
const VariationTreeGeoMap & getExtraGeos() const
get the extra geos
Definition: Variations.h:602
void setGeoMatSuffixReplacement(const std::string &geo, const std::string &mat)
set geo mat suffix replacement
Definition: Variations.h:623
const ExcludeGeometryMap & getExcludeGeometries() const
get the exclude geometries
Definition: Variations.h:608
void setMaterialPrefix(const std::string &materialPrefix)
add geo mat aliases
Definition: Variations.h:635
bool hasVariationType(const std::string &name) const
has variation type
Definition: Variations.h:599
void hash(AtomsCore::MurmurHash3 &hasher) const
Hash.
std::vector< std::pair< std::string, std::string > > build(const std::string &variationType, unsigned agentSeed, unsigned int seed, std::vector< std::string > &debugMessages, const bool storeDebugMessages=false) const
build variation method
const std::string & getMaterialPrefix() const
get material prefix
Definition: Variations.h:638
~VariationTree()
Destructor.
Definition: Variations.h:590
Variations class.
Definition: Variations.h:839
void hash(AtomsCore::MurmurHash3 &hasher) const
Hash.
bool hasAgentTypeVariation(const std::string &agentTypeName)
Checks if an agent type variation exists.
Definition: Variations.h:864
AgentTypeVariation & getAgentTypeVariation(const std::string &agentTypeName)
Gets an agent type variation.
Definition: Variations.h:855
bool writeToFile(const std::string &filePath)
Write the agent variations map to a file.
~Variations()
Destructor.
Definition: Variations.h:846
std::string toString(const bool prettyprint=false)
Converts the agent variations map to a string.
Variations()
Constructor.
Definition: Variations.h:843
void setAgentTypeVariation(const std::string &agentTypeName, const AgentTypeVariation &atv)
Sets an agent type variation.
Definition: Variations.h:858
void clear()
Removes the agents variations.
Definition: Variations.h:849
Atoms namespace.
Definition: Agent.h:29
AgentTypeVariation * AgentTypeVariationPtr
agent type variation pointer
Definition: Variations.h:35
const VariationTreeGeo * VariationTreeGeoCPtr
variation tree geo pointer
Definition: Variations.h:53
const VariationOverride * VariationOverrideCPtr
variation override const pointer
Definition: Variations.h:49
const VariationTree * VariationTreeCPtr
variation tree pointer
Definition: Variations.h:52
VariationGeometry * VariationGeometryPtr
variation geometry pointer
Definition: Variations.h:36
VariationMaterialColor * VariationMaterialColorPtr
variation material color pointer
Definition: Variations.h:41
const VariationMaterialColor * VariationMaterialColorCPtr
variation material color const pointer
Definition: Variations.h:51
const Variations * VariationsCPtr
variations const pointer
Definition: Variations.h:44
VariationMaterial * VariationMaterialPtr
variation material pointer
Definition: Variations.h:37
Variations * VariationsPtr
variations pointer
Definition: Variations.h:32
VariationOverride * VariationOverridePtr
variation override pointer
Definition: Variations.h:39
const VariationMaterial * VariationMaterialCPtr
variation material const pointer
Definition: Variations.h:47
const VariationGroupLod * VariationGroupLodCPtr
variation group lod const pointer
Definition: Variations.h:50
VariationGroupLod * VariationGroupLodPtr
variation group lod pointer
Definition: Variations.h:40
VariationGroup * VariationGroupPtr
variation group pointer
Definition: Variations.h:38
const AgentTypeVariation * AgentTypeVariationCPtr
agent type const pointer
Definition: Variations.h:45
const VariationGroup * VariationGroupCPtr
variation group const pointer
Definition: Variations.h:48
const VariationGeometry * VariationGeometryCPtr
variation geometry const pointer
Definition: Variations.h:46
VariationTree * VariationTreePtr
variation tree pointer
Definition: Variations.h:42