1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
#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 <[email protected]>
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_
|