1
//----------------------------------------------
2
// Bilinear/bicubic patches & patch meshes
3
//----------------------------------------------
8
#include "Parametric.h"
15
//------------------------------------------------------------------------------
18
class BilinearPatch : public Parametric
22
BilinearPatch(RtInt n, RtToken tokens[], RtPointer parms[]);
23
// only used for polygon & patchmesh splitting
24
BilinearPatch(const Primitive& p, const RtPoint p0, const RtPoint p1,
25
const RtPoint p2, const RtPoint p3);
26
virtual ~BilinearPatch();
28
virtual void post_init();
30
virtual Bound bound();
31
virtual Parametric* duplicateSelf() { return new BilinearPatch(*this); }
33
virtual bool in_camspace() const { return true; }
36
virtual void eval(float u, float v, RtPoint P, RtVector dPdu=NULL, RtVector dPdv=NULL) const;
41
//------------------------------------------------------------------------------
43
// only splits the patchmesh into its individual patches, dice() never called
45
class BilinearPatchMesh : public Primitive
48
BilinearPatchMesh(RtInt nu, bool uperiodic, RtInt nv, bool vperiodic,
49
RtInt n, RtToken tokens[], RtPointer parms[]);
50
virtual ~BilinearPatchMesh();
51
virtual void post_init() {}
52
virtual bool boundable() { return true; }
53
virtual Bound bound();
54
virtual bool splitable() { return true; }
55
virtual void split(const Framework &f, bool usplit, bool vsplit, splitbprims_t* spb=NULL);
56
virtual bool diceable(MicroPolygonGrid &g, Hider &h, bool &usplit, bool &vsplit) { return false; }
57
virtual void dice(MicroPolygonGrid &g, bool Pclose=false);
60
RtFloat* pts; // RtFloat here, since besides 'P', data could also be 'Pz' or 'Pw'
61
bool uperiodic, vperiodic;
63
int nu, nv, nupatches, nvpatches, nuvarying, nvvarying;
64
int mtype, num_verts; // mtype will be one of (0, 1, 2) for P/Pz/Pw respectivly
67
// helper function, split data for new patch, also called by Polygons.cpp
68
void splitPrimVars(const Primitive* parent, Primitive* newp,
69
int uni_idx, int vary_idx[4], int* vert_idx, bool cubic=false);
71
//------------------------------------------------------------------------------
74
class BicubicPatch : public Primitive
77
friend class JS_SDPatch;
80
// only used for splitting patchmesh
81
BicubicPatch(const Primitive& p, const Point3 _hull[16]);
82
BicubicPatch(RtInt n, RtToken tokens[], RtPointer parms[]);
83
virtual ~BicubicPatch();
84
virtual void post_init();
86
virtual bool boundable() { return true; }
87
virtual Bound bound();
89
virtual bool splitable() { return true; }
90
virtual void split(const Framework &f, bool usplit, bool vsplit, splitbprims_t* spb=NULL);
91
virtual bool diceable(MicroPolygonGrid &g, Hider &h, bool &usplit, bool &vsplit);
92
virtual void dice(MicroPolygonGrid &g, bool Pclose=false);
94
Primitive* duplicateSelf();
96
virtual bool in_camspace() const { return true; }
98
virtual void get_uvlim(float uvl[4]) const { uvl[0] = umin, uvl[1] = umax, uvl[2] = vmin, uvl[3] = vmax; }
102
float umin, umax, vmin, vmax;
106
//------------------------------------------------------------------------------
108
// only splits the patchmesh into its individual patches, dice() is never called
110
class BicubicPatchMesh : public Primitive
113
BicubicPatchMesh(RtInt nu, bool uperiodic, RtInt nv, bool vperiodic,
114
RtInt n, RtToken tokens[], RtPointer parms[]);
115
virtual ~BicubicPatchMesh();
116
virtual void post_init() {}
117
virtual bool boundable() { return true; }
118
virtual Bound bound();
119
virtual bool splitable() { return true; }
120
virtual void split(const Framework &f, bool usplit, bool vsplit, splitbprims_t* spb=NULL);
121
virtual bool diceable(MicroPolygonGrid &g, Hider &h, bool &usplit, bool &vsplit) { return false; }
122
virtual void dice(MicroPolygonGrid &g, bool Pclose=false);
124
RtFloat* pts; // RtFloat here, since besides 'P', data could also be 'Pz' or 'Pw'
125
bool uperiodic, vperiodic;
127
int nu, nv, ustep, vstep, nupatches, nvpatches, nuvarying, nvvarying;
128
int mtype, num_verts; // mtype will be one of (0, 1, 2) for P/Pz/Pw respectivly