#ifndef _HAIR_VR_VOXEL_PRIMITIVE_H_ #define _HAIR_VR_VOXEL_PRIMITIVE_H_ // Shave and a Haircut // (c) 2019 Epic Games // US Patent 6720962 /********************************************************************** *< FILE: shaveVrayVoxelPrim.h (was shaveVrayVoxelPrim.h) DESCRIPTION: Generic hair voxel primitive CREATED BY: Vladimir Dubovoy HISTORY: created 02-09-2008 ( as part of 3ds Max + VRay hair shaders) merged 30-03-2010 *> **********************************************************************/ ////#include //VRayInterface needs it - ShadeContext //#include ////#include //#include //#include //#include //#include #include "utils.h" #include "box.h" #include "rayserver.h" #include "vrayplugins.h" #include "rayserver.h" #include "geometryclasses.h" #ifdef VRAY20 #include "pool.h" #endif #include "hairAPIvrayutil.h" #include "shaveVrayShadeData.h" #include "shaveVrayVoxelPrimBase.h" class shaveVrayInstance; class shaveVrayVoxelPrim : public shaveVrayVoxelPrimBase { public: shaveVrayVoxelPrim(IHairVoxel* vox, VR::VRayCore* vray, shaveVrayInstance* inst); virtual ~shaveVrayVoxelPrim(); enum consts { eNumSides = 4, //always 4 eDefNumKnots = 5 //actual value from HairType should be used }; void SetTipFade(bool set){ _tipfade() = set;} bool GetTipFade() const {return tipfade();} void SetUseOwnBSDF(bool set){ _ownbsdf() = set;} bool GetUseOwnBSDF() const {return ownbsdf();} void SetAmbient(const VR::Color& c) {_ambient() = c;} const VR::Color& GetAmbient() const {return ambient();} const VR::Color& GetSpecTint() const {return spectint();} void SetSpecTint(const VR::Color& c) {_spectint() = c;} const VR::Color& GetSpecTint2() const {return spectint2();} void SetSpecTint2(const VR::Color& c) {_spectint2() = c;} bool IsColorConst(int strandidx) const; void GetRootColor(int strandidx,VR::Color& c) const; void GetInterpColor(int segmentIdx, int strandidx, float segmentOffset, VR::Color& res) const; float GetInterpOpacity(int segmentIdx, int strandidx, float segmentOffset) const; float GetOpacity (int strandidx) const; float GetAmbDiff (int strandidx) const; float GetGlossiness(int strandidx) const; float GetSpecLevel (int strandidx) const; VR::ShadeVec GetHairDir(const VR::ShadeVec& hit, int segmentIdx, int strandidx, float segmentOffset) const; VR::ShadeVec GetUVW(int segmentIdx, int strandIdx, float segmentOffset, int channel) const; inline shaveVrayInstance* GetInstance() const {return hinst();} #if defined(VRAY30) || defined(VRAY40) virtual VR::ShadeVec getHairDir(const VR::VRayContext &rc) const=0; #endif protected: //const member access inline VR::Shadeable* shade() const {return m_shade;} inline VR::VRayShadeInstance* shinst() const {return m_shinst;} //inline VR::VRayShadeData* shdata() const {return m_shdata;} //inline VR::BaseMeshShadeData/**/* shdata() const {return m_shdata;} inline shaveVrayShadeData* shdata() const {return m_shdata;} inline shaveVrayInstance* hinst() const {return m_hinst;} //inline VR::SurfaceProperties* sfprops() const {return m_sfprops;} #if defined(VRAY20) || defined(VRAY30) || defined(VRAY40) inline const VR::FixedPool& pool_Vector() const {return m_pool_Vector;} #else inline const VR::FixedPool& pool_Vector() const {return m_pool_Vector;} #endif inline const VR::Color& ambient() const {return m_ambient;} inline const VR::Color& spectint() const {return m_spectint;} inline const VR::Color& spectint2() const {return m_spectint2;} inline int numknots()const {return m_numknots;} inline float uc(int i) const {return m_uc[i];} inline float vc(int i) const {return m_vc[i];} inline bool tipfade() const {return m_tipfade;} inline bool ownbsdf() const {return m_ownbsdf;} //ptr access inline const float* puc() const {return m_uc;} inline const float* pvc() const {return m_vc;} inline float* _puc() {return m_uc;} inline float* _pvc() {return m_vc;} //member access inline VR::Shadeable*& _shade() {return m_shade;} inline VR::VRayShadeInstance*& _shinst() {return m_shinst;} //inline VR::VRayShadeData*& _shdata() {return m_shdata;} inline shaveVrayShadeData*& _shdata() {return m_shdata;} inline shaveVrayInstance*& _hinst() {return m_hinst;} //inline VR::BaseMeshShadeData/**/*& _shdata() {return m_shdata;} //inline VR::SurfaceProperties*& _sfprops() {return m_sfprops;} #if defined(VRAY20) || defined(VRAY30) || defined(VRAY40) inline VR::FixedPool& _pool_Vector() {return m_pool_Vector;} #else inline VR::FixedPool& _pool_Vector() {return m_pool_Vector;} #endif inline VR::Color& _ambient() {return m_ambient;} inline VR::Color& _spectint() {return m_spectint;} inline VR::Color& _spectint2() {return m_spectint2;} inline int& _numknots() {return m_numknots;} inline float& _uc(int i) {return m_uc[i];} inline float& _vc(int i) {return m_vc[i];} inline bool& _tipfade() {return m_tipfade;} inline bool& _ownbsdf() {return m_ownbsdf;} private: int m_numknots; bool m_tipfade; bool m_ownbsdf; float m_uc[eNumSides]; float m_vc[eNumSides]; VR::Color m_ambient; VR::Color m_spectint; VR::Color m_spectint2; #if defined(VRAY20) || defined(VRAY30) || defined(VRAY40) VR::FixedPool m_pool_Vector; #else VR::FixedPool m_pool_Vector; #endif VR::Shadeable* m_shade; VR::VRayShadeInstance* m_shinst; //3ds Max related //VR::VRayShadeData* m_shdata; //3ds Max related //VR::BaseMeshShadeData/**/* m_shdata; shaveVrayShadeData* m_shdata; shaveVrayInstance* m_hinst; //VR::SurfaceProperties* m_sfprops; //3ds Max related }; #endif //end of_HAIR_VR_VOXEL_PRIMITIVE_H_