1 // ============================================================================= 2 // PROJECT CHRONO - http://projectchrono.org 3 // 4 // Copyright (c) 2014 projectchrono.org 5 // All rights reserved. 6 // 7 // Use of this source code is governed by a BSD-style license that can be found 8 // in the LICENSE file at the top level of the distribution and at 9 // http://projectchrono.org/license-chrono.txt. 10 // 11 // ============================================================================= 12 // Authors: Asher Elmquist 13 // ============================================================================= 14 // 15 // Visual assets that can be used for higher quality rendering such as that 16 // used by the sensing module. These materials follow, in part, from the 17 // wavefront obj mtl specification. 18 // 19 // ============================================================================= 20 21 #ifndef CHVISUALMATERIAL_H 22 #define CHVISUALMATERIAL_H 23 24 #include "chrono/assets/ChAsset.h" 25 26 namespace chrono { 27 28 /// Class for setting a color (used by ChVisualization) 29 class ChApi ChVisualMaterial : public ChAsset { 30 public: 31 /// Constructors 32 ChVisualMaterial(); 33 34 // Setting functions 35 void SetAmbientColor(ChVector<float> rgb); 36 void SetDiffuseColor(ChVector<float> rgb); 37 void SetSpecularColor(ChVector<float> rgb); 38 void SetSpecularExponent(float exponent); 39 void SetTransparency(float tr); SetKdTexture(std::string filename)40 void SetKdTexture(std::string filename) { kd_texture = filename; }; SetKsTexture(std::string filename)41 void SetKsTexture(std::string filename) { ks_texture = filename; }; SetNormalMapTexture(std::string filename)42 void SetNormalMapTexture(std::string filename) { normal_texture = filename; }; SetMetallicTexture(std::string filename)43 void SetMetallicTexture(std::string filename) { metallic_texture = filename; }; SetRoughnessTexture(std::string filename)44 void SetRoughnessTexture(std::string filename) { roughness_texture = filename; }; SetOpacityTexture(std::string filename)45 void SetOpacityTexture(std::string filename) { opacity_texture = filename; }; 46 void SetFresnelExp(float exp); 47 void SetFresnelMax(float max); 48 void SetFresnelMin(float min); 49 void SetRoughness(float r); 50 void SetMetallic(float m); SetUseSpecularWorkflow(bool s)51 void SetUseSpecularWorkflow(bool s) { use_specular_workflow = s; } SetClassID(unsigned short int id)52 void SetClassID(unsigned short int id) { class_id = id; } SetInstanceID(unsigned short int id)53 void SetInstanceID(unsigned short int id) { instance_id = id; } 54 55 // accessor functions GetAmbientColor()56 ChVector<float> GetAmbientColor() { return Ka; } GetDiffuseColor()57 ChVector<float> GetDiffuseColor() { return Kd; } GetSpecularColor()58 ChVector<float> GetSpecularColor() { return Ks; } GetSpecularExponent()59 float GetSpecularExponent() { return Ns; } GetTransparency()60 float GetTransparency() { return d; } GetKdTexture()61 std::string GetKdTexture() { return kd_texture; }; GetKsTexture()62 std::string GetKsTexture() { return ks_texture; }; GetNormalMapTexture()63 std::string GetNormalMapTexture() { return normal_texture; }; GetMetallicTexture()64 std::string GetMetallicTexture() { return metallic_texture; }; GetRoughnessTexture()65 std::string GetRoughnessTexture() { return roughness_texture; }; GetOpacityTexture()66 std::string GetOpacityTexture() { return opacity_texture; }; GetFresnelExp()67 float GetFresnelExp() { return fresnel_exp; } GetFresnelMax()68 float GetFresnelMax() { return fresnel_max; } GetFresnelMin()69 float GetFresnelMin() { return fresnel_min; } GetRoughness()70 float GetRoughness() { return roughness; } GetMetallic()71 float GetMetallic() { return metallic; } GetUseSpecularWorkflow()72 bool GetUseSpecularWorkflow() { return use_specular_workflow; } GetClassID()73 unsigned short int GetClassID() { return class_id; } GetInstanceID()74 unsigned short int GetInstanceID() { return instance_id; } 75 76 private: 77 ChVector<float> Ka; // ambient color 0-1 78 ChVector<float> Kd; // diffuse color 0-1 79 ChVector<float> Ks; // specular color 0-1 80 81 float fresnel_max; 82 float fresnel_min; 83 float fresnel_exp; 84 float Ns; // specular exponent 85 float d; // transparency 86 87 float roughness; 88 float metallic; 89 90 bool use_specular_workflow; 91 92 std::string kd_texture; 93 std::string ks_texture; 94 std::string normal_texture; 95 std::string metallic_texture; 96 std::string roughness_texture; 97 std::string opacity_texture; 98 99 unsigned short int class_id; 100 unsigned short int instance_id; 101 }; 102 103 } // end namespace chrono 104 105 #endif 106