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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
|
#ifndef _HAIR_VR_MOVING_VOXEL_PRIMITIVE_H_
#define _HAIR_VR_MOVING_VOXEL_PRIMITIVE_H_
// Shave and a Haircut
// (c) 2019 Epic Games
// US Patent 6720962
/**********************************************************************
*<
FILE: HairVrStaticVoxelPrim.h
DESCRIPTION: Motion blurred hair voxel primitive
CREATED BY: Vladimir Dubovoy <[email protected]>
HISTORY: created 04-09-2008 ( as part of 3ds Max + VRay hair shaders)
merged 30-03-2010
*>
**********************************************************************/
#include "shaveVrayVoxelPrim.h"
#include "hairprimitives.h"
class shaveVrayMovingVoxelPrim : public shaveVrayVoxelPrim,
public VR::MovingHairGenerator {
public:
shaveVrayMovingVoxelPrim(IHairVoxel* voxel, VR::VRayCore *vray,shaveVrayInstance* inst);
virtual ~shaveVrayMovingVoxelPrim();
/*
| from StaicPrimitive
*/
// Return the bounding box of this primitive.
void getBBox (VR::MovingBox &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::MovingBox &bLeft, VR::MovingBox &bRight);
//Return true here
int expandable();
//Expand the primitive into other sub-primitives.
int expand (VR::DynamicRaycaster< VR::MovingBox > *raycaster, int threadIndex);
//Collapse the primitive.
int collapse (VR::DynamicRaycaster< VR::MovingBox > *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, float time, 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);
//VR::Vector getNormal(VR::RSRayRef& rsrayref);
//void setIntersectionData(VR::RSRayRef& rsrayref, void *isData);
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);
void setCommonIntersectionData(VR::RSRay &rsray, void *isd, int strandIdx, int segmentIdx,
float wParam, const VR::Vector &gNormal, const VR::Vector &normal) ;
#elif defined(VRAY40)
void setCommonIntersectionData(VR::RSRay &rsray, void *isd, int strandIdx, int segmentIdx,
float wParam, const VR::ShadeVec &gNormal, const VR::ShadeVec &normal) ;
#endif
#if defined(VRAY30) || defined(VRAY40)
void getMovingIntersectionData(int strandIdx, int segmentIdx, float time, VR::Vector *p, VR::Vector *dirs);
// Returns the number of hair strands
int initHairData();
#endif
//const member access
inline const VR::MovingHairStrand& strand(int i) const {return m_strands[i];}
inline VR::MovingHairStrand* strands()const {return m_strands;}
inline const VR::Vector& pt(int i) const {return m_pts[i];}
inline const VR::Vector& dpt(int i)const {return m_dpts[i];}
inline const VR::Vector& un(int i) const {return m_uns[i];}
inline const VR::Vector& dun(int i)const {return m_duns[i];}
inline const VR::Vector& vn(int i) const {return m_vns[i];}
inline const VR::Vector& dvn(int i)const {return m_dvns[i];}
inline const VR::MovingBox& bbox() const {return m_bbox;}
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* dpts(int offset) const {return &m_dpts[offset];}
inline VR::Vector* duns(int offset) const {return &m_duns[offset];}
inline VR::Vector* dvns(int offset) const {return &m_dvns[offset];}
inline VR::Vector* pts() const {return m_pts;}
inline VR::Vector* dpts() const {return m_dpts;}
inline VR::Vector* uns() const {return m_uns;}
inline VR::Vector* duns() const {return m_duns;}
inline VR::Vector* vns() const {return m_vns;}
inline VR::Vector* dvns() const {return m_dvns;}
inline int firstid() const {return m_firstid;}
inline int numblur() const {return m_numblur;}
//member access
inline VR::MovingHairStrand& _strand(int i) {return m_strands[i];}
inline VR::MovingHairStrand*& _strands() {return m_strands;}
inline VR::MovingBox& _bbox() {return m_bbox;}
inline VR::Vector& _pt(int i) {return m_pts[i];}
inline VR::Vector& _dpt(int i){return m_dpts[i];}
inline VR::Vector& _un(int i) {return m_uns[i];}
inline VR::Vector& _dun(int i){return m_duns[i];}
inline VR::Vector& _vn(int i) {return m_vns[i];}
inline VR::Vector& _dvn(int i){return m_dvns[i];}
inline VR::Vector*& _pts() {return m_pts;}
inline VR::Vector*& _dpts() {return m_dpts;}
inline VR::Vector*& _uns() {return m_uns;}
inline VR::Vector*& _duns() {return m_duns;}
inline VR::Vector*& _vns() {return m_vns;}
inline VR::Vector*& _dvns() {return m_dvns;}
inline int& _firstid() {return m_firstid;}
inline int& _numblur() {return m_numblur;}
private:
int m_firstid;
int m_numblur;
VR::Vector* m_pts;
VR::Vector* m_dpts;
VR::Vector* m_uns;
VR::Vector* m_duns;
VR::Vector* m_vns;
VR::Vector* m_dvns;
VR::MovingHairStrand* m_strands;
VR::MovingBox m_bbox;
#if defined(VRAY30) || defined(VRAY40)
VR::HairData hairData[2];
VR::HairData tessHairData[2];
VR::TransformedHairData tmHairData[2];
VR::MovingHairTreePrimitive *movingHairTree;
int maxDepth;
float minLeaf;
float leafCoeff;
VUtils::TessHairParams tessParams;
VR::ThreadManager *threadman;
VR::ProgressCallback *prog;
#endif
};
#endif //endof_HAIR_VR_MOVING_VOXEL_PRIMITIVE_H_
|