#ifndef _HAIR_VR_STATIC_VOXEL_PRIMITIVE_H_ #define _HAIR_VR_STATIC_VOXEL_PRIMITIVE_H_ // Shave and a Haircut // (c) 2019 Epic Games // US Patent 6720962 /********************************************************************** *< FILE: shaveVrayStaticVoxelPrim.h DESCRIPTION: Staic (non motion blurred) hair voxel primitive CREATED BY: Vladimir Dubovoy HISTORY: created 20-08-2008 ( as part of 3ds Max + VRay hair shaders) merged 31-03-2010 *> **********************************************************************/ #include "shaveVrayVoxelPrim.h" #include "hairprimitives.h" class shaveVrayStaticVoxelPrim : public shaveVrayVoxelPrim, public VR::StaticHairGenerator { public: shaveVrayStaticVoxelPrim(IHairVoxel* voxel, VR::VRayCore *vray, shaveVrayInstance* inst); virtual ~shaveVrayStaticVoxelPrim(); /* | from StaicPrimitive */ // Return the bounding box of this primitive. void getBBox (VR::StaticBox &bbox); //Return true if the primitive is splittable. bool splittable (); //Return the bounding boxes of the primitive with respect to a given plane. void split (int dim, VR::real middle, VR::StaticBox &bLeft, VR::StaticBox &bRight); //Return true here int expandable(); //Expand the primitive into other sub-primitives. int expand (VR::DynamicRaycaster< VR::StaticBox > *raycaster, int threadIndex); //Collapse the primitive. int collapse (VR::DynamicRaycaster< VR::StaticBox > *raycaster, int threadIndex); /* | from StaicHairGenerator */ // always returns 4 int getNumSides(void) const; // number of segments in the strand int getNumKnots(void); // returns two arrays, of getNumSides() length each, // with the cosine and sine along the circle at regular intervals void getSidesUV(float *&uc, float *&vc); // vlad|8Apr2010 - uc,vc are const now void getSidesUV(const float *&uc, const float *&vc) const; //return true to use a simplified normal calculation inside the //StaticHairSegmentLine::getNormal() and getGNormal(), and false to use a more correct model int getFlatNormal(void) const; //not sure about these float getRadius(); float getLength(); float getTaper(); //hair engine hanles gravity and other forces VR::Vector getGravity(); //we return 0.0f for all of these float getLengthRand(); float getRadiusRand(); float getGravityRand(); float getDirRand(); float getBend(); int generateStrand(int faceIndex, int strandIndex, const VR::Vector *pv, const VR::Vector *nv, VR::Vector *pts, VR::Vector *un, VR::Vector *vn); VR::Vector getStrandBaryCoords(int faceIndex, int strandIndex) const; VR::Vector* newVectors(int threadIndex); void deleteVectors(VR::Vector *x, int threadIndex); /* | from GeometryGenerator */ #if defined(VRAY30) VR::Vector getGNormal(VR::RSRay &rsray); VR::Vector getNormal(VR::RSRay &rsray); #elif defined(VRAY40) VR::ShadeVec getGNormal(VR::RSRay &rsray); VR::ShadeVec getNormal(VR::RSRay &rsray); #endif void setIntersectionData(VR::RSRay &rsray, void *isData); #if defined(VRAY30) void setIntersectionData(const VR::RayBunchParams& params, VR::PrimitiveIntersections& result, const RAY_IDX* idxs, size_t count); #endif VR::Shadeable* getShadeable() { return ownbsdf() ? shade() : shdata(); } VR::VRayShadeInstance* getExtShadeData() { return shinst(); } VR::VRayShadeData* getExtTexMapping() { return shdata(); } VR::VRayVolume* getVolumeShader() { return NULL; } VR::VRaySurfaceProperties* getExtSurfaceProperties() { return NULL; } #if defined(VRAY30) void storeInGlobalTree(VR::RayServerInterface2 *rayserver); #elif defined(VRAY40) void storeInGlobalTree(VR::RayServerInterface *rayserver); #endif #if defined(VRAY30) || defined(VRAY40) // no need to implement, that is used by our automatic hair generation primitives int generateStrand(int faceIndex, int strandIndex, int threadIndex, const VR::Vector *pv, const VR::Vector *nv, VR::Vector *pts, VR::Vector *un, VR::Vector *vn) { return 0; } VR::ShadeVec getHairDir(const VR::VRayContext &rc) const; #endif //VR::Vector getGNormal(VR::RSRayRef& rsrayref); //3ds Max specific //VR::Vector getNormal(VR::RSRayRef& rsrayref); //3ds Max specific //void setIntersectionData(VR::RSRayRef& rsrayref, void *isData); //3ds Max specific protected: #if defined(VRAY30) void setCommonIntersectionData(const VR::RayBunchParams& params, VR::PrimitiveIntersections& result, const RAY_IDX idx, int strandIdx, int segmentIdx, float wParam, const VUtils::Vector &gNormal, const VUtils::Vector &normal) ; #endif #if defined(VRAY30) || defined(VRAY40) void getStaticIntersectionData(int strandIdx, int segmentIdx, const VR::Vector* &p, const VR::Vector* &dirs); void setCommonIntersectionData(VR::RSRay &rsray, void *isd, int strandIdx, int segmentIdx, float wParam, const VR::ShadeVec &gNormal, const VR::ShadeVec &normal) ; // Returns the number of hair strands int initHairData(); #endif //const member access inline const VR::StaticHairStrand& strand(int i) const {return m_strands[i];} inline VR::StaticHairStrand* strands() const {return m_strands;} inline const VR::Vector& pt(int i) const {return m_pts[i];} inline const VR::Vector& un(int i) const {return m_uns[i];} inline const VR::Vector& vn(int i) const {return m_vns[i];} inline VR::Vector* pts(int offset) const {return &m_pts[offset];} inline VR::Vector* uns(int offset) const {return &m_uns[offset];} inline VR::Vector* vns(int offset) const {return &m_vns[offset];} inline VR::Vector* pts() const {return m_pts;} inline VR::Vector* uns() const {return m_uns;} inline VR::Vector* vns() const {return m_vns;} inline int firstid() const {return m_firstid;} //member access inline VR::StaticHairStrand& _strand(int i) {return m_strands[i];} inline VR::StaticHairStrand*& _strands() {return m_strands;} inline VR::Vector& _pt(int i) {return m_pts[i];} inline VR::Vector& _un(int i) {return m_uns[i];} inline VR::Vector& _vn(int i) {return m_vns[i];} inline VR::Vector*& _pts() {return m_pts;} inline VR::Vector*& _uns() {return m_uns;} inline VR::Vector*& _vns() {return m_vns;} inline int& _firstid() {return m_firstid;} private: int m_firstid; VR::Vector* m_pts; VR::Vector* m_uns; VR::Vector* m_vns; VR::StaticHairStrand* m_strands; #if defined(VRAY30) || defined(VRAY40) VR::HairData hairData; VR::HairData tessHairData; VR::TransformedHairData tmHairData; VR::StaticHairTreePrimitive *staticHairTree; int maxDepth; float minLeaf; float leafCoeff; VUtils::TessHairParams tessParams; VR::ThreadManager *threadman; VR::ProgressCallback *prog; #endif }; #endif //end of_HAIR_VR_STATIC_VOXEL_PRIMITIVE_H_