diff options
| author | Ben Marsh <[email protected]> | 2019-10-22 09:07:59 -0400 |
|---|---|---|
| committer | Ben Marsh <[email protected]> | 2019-10-22 09:07:59 -0400 |
| commit | bd0027e737c6512397f841c22786274ed74b927f (patch) | |
| tree | f7ffbdb8f3741bb7f24635616cc189cba5cb865c /vrayPlug/plugin/shaveVrayShadeData.h | |
| download | shave-and-a-haircut-bd0027e737c6512397f841c22786274ed74b927f.tar.xz shave-and-a-haircut-bd0027e737c6512397f841c22786274ed74b927f.zip | |
Adding Shave-and-a-Haircut 9.6
Diffstat (limited to 'vrayPlug/plugin/shaveVrayShadeData.h')
| -rw-r--r-- | vrayPlug/plugin/shaveVrayShadeData.h | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/vrayPlug/plugin/shaveVrayShadeData.h b/vrayPlug/plugin/shaveVrayShadeData.h new file mode 100644 index 0000000..b85c8aa --- /dev/null +++ b/vrayPlug/plugin/shaveVrayShadeData.h @@ -0,0 +1,124 @@ +#ifndef _HAIR_VRAY_SHADE_DATA_H_ +#define _HAIR_VRAY_SHADE_DATA_H_ + +// Shave and a Haircut +// (c) 2019 Epic Games +// US Patent 6720962 + +// V-Ray headers +#include "vraybase.h" +#include "vraymayageom.h" +#include "vrayplugins.h" +#include "geometryclasses.h" +#include "hairprimitives.h" +#include "rayprimitives.h" + +class shaveVrayInstance; +class shaveVrayVoxelPrim; + +class shaveVrayShadeData : public VR::BaseShadeData, +#if VRAY_DLL_VERSION < 0x31000 + public VR::VRayMayaHairDataInterface, + public VR::VRayFurSamplingInterface, +#else + public VR::VRayHairCommonShadeData, +#endif + public VR::MappedSurface +{ +#if defined(VRAY30) || defined(VRAY40) + VR::HairData *hairData; +#endif + shaveVrayVoxelPrim* getIntersectedPrimitive(const VR::VRayContext &rc); +public: + + shaveVrayShadeData(shaveVrayInstance *instance /*, MayaHairPrimitiveType *hairPrimitive*/); + + PluginBase* getPlugin(void) VRAY_OVERRIDE + { + return NULL; + } + PluginInterface* newInterface(InterfaceID id) VRAY_OVERRIDE + { +#if VRAY_DLL_VERSION < 0x31000 + if (id==EXT_MAYA_HAIR_DATA) + return static_cast<VR::VRayMayaHairDataInterface*>(this); + if (id==EXT_VRAY_FUR_SAMPLING) + return static_cast<VR::VRayFurSamplingInterface*>(this); +#else + if (id==EXT_VRAY_COMMON_HAIR_SHADE_DATA) + return static_cast<VR::VRayHairCommonShadeData*>(this); +#endif + if (id==EXT_MAPPED_SURFACE) + return static_cast<VR::MappedSurface*>(this); + + return BaseShadeData::newInterface(id); + } + + // From VRayMayaHairDataInterface + // From VRayHairCommonShadeData (3.0) + VR::Color getColor(const VR::VRayContext &rc) VRAY_OVERRIDE; + VR::Color getIncandescence(const VR::VRayContext &rc) VRAY_OVERRIDE; + VR::Color getTransparency(const VR::VRayContext &rc) VRAY_OVERRIDE; + void getShadeData(const VR::VRayContext &rc, VR::VRayMayaHairShadeData &result) VRAY_OVERRIDE; +#if defined(VRAY30) || defined(VRAY40) + float getRandByStrand(const VR::VRayContext &rc, int seedOffset) VRAY_OVERRIDE; + + int getStrandIndex(const VR::VRayContext &rc) VRAY_OVERRIDE; + + int getSegmentIndexInStrand(const VR::VRayContext &rc) VRAY_OVERRIDE; + + void getIndexAndBlend(const VR::VRayContext &rc, int &out_index, float &out_blend) VRAY_OVERRIDE; +# if VRAY_DLL_VERSION >= 0x36000 + float getStrandLength(const VR::VRayContext &rc) VRAY_OVERRIDE; +# endif + +#endif + + // From VRayFurSamplingInterface + float getDistanceAlongStrand(const VR::VRayContext &rc) VRAY_OVERRIDE; + + // From MappedSurface +#if defined(VRAY30) + VR::Transform getLocalUVWTransform(const VR::VRayContext &rc, int channel) VRAY_OVERRIDE; +#elif defined(VRAY40) + void getLocalUVWTransform(const VR::VRayContext &rc, int channel, VR::ShadeTransform &result) override; + void getLocalUVWCoordinates(const VR::VRayContext &rc, int channel, VR::ShadeVec &result) override; + int getLocalUVWTransformByName(const VR::VRayContext &rc, const VR::StringID &channelName, VR::ShadeTransform &result) override; + int getUVWCoordinatesByName(const VR::VRayContext &rc, const VR::StringID &channelName, VR::ShadeVec &result) override; + VR::ShadeVec getMapChannelVertexVector(int mapChannelIdx, int vertexIdx) override; + VR::ShadeVec getUVWcoords(const VR::VRayContext &vri, int channel) override; + void getUVWderivs(const VR::VRayContext &vri, int channel, VR::ShadeVec derivs[2]) override; + void getUVWbases(const VR::VRayContext &vri, int channel, VR::ShadeVec bases[3]) override; + VR::ShadeVec getUVWnormal(const VR::VRayContext &vri, int channel) override; +#endif +}; + +/* + * Get strand, segment index and offset within segment from ray context. + */ +static inline void shaveVrayGetHairParams(const VR::VRayContext &rc, int &out_strand, int &out_segment, float &out_offset) { +#if defined(VRAY30) || defined(VRAY40) + out_strand = rc.rayresult.extra_int[1]; + out_segment = rc.rayresult.faceIndex; + out_offset = rc.rayresult.bary[0]; +#else + out_strand = rc.rayresult.faceIndex; + out_segment = (int)rc.rayresult.extraf; + out_offset = rc.rayresult.bary[2]; +#endif +} + +/* + * Get strand and segment index from ray context. + */ +static inline void shaveVrayGetHairParams(const VR::VRayContext &rc, int &out_strand, int &out_segment) { +#if defined(VRAY30) || defined(VRAY40) + out_strand = rc.rayresult.extra_int[1]; + out_segment = rc.rayresult.faceIndex; +#else + out_strand = rc.rayresult.faceIndex; + out_segment = (int)rc.rayresult.extraf; +#endif +} + +#endif |