72 if ( ((x-1)/3)*3+1 != x || ((y-1)/3)*3+1 != y )
74 vl::Log::error(
"BezierPatch::resize(): illegal patch dimensions.\n");
90 for(
unsigned ipatch=0; ipatch<patches().size(); ++ipatch)
91 patch_count += ((patches()[ipatch]->
x()-1)/3)*((patches()[ipatch]->
y()-1)/3);
97 setVertexArray(vert_array.
get());
99 vert_array->
resize(detail()*detail()*patch_count);
103 if ( gen_tex_coords )
108 setTexCoordArray(0,texc_array.
get());
110 texc_array->
resize(detail()*detail()*patch_count);
119 drawCalls().push_back(de.
get());
126 for(
unsigned ipatch=0, patch_num=0; ipatch<patches().size(); ++ipatch)
129 for(
int ix=0; ix<p->
x()-3; ix+=3)
130 for(
int iy=0; iy<p->
y()-3; iy+=3)
132 for(
unsigned y=0;
y<detail(); ++
y)
143 real v = (real)
y/(detail()-1);
145 real ty1 = 1.0f - ty;
147 real k1 = 3*ty*ty*ty1;
148 real k2 = 3*ty*ty1*ty1;
149 real k3 = ty1*ty1*ty1;
150 vec3 A = p->
at(ix+0,iy+0)*k0 + p->
at(ix+0,iy+1)*k1 + p->
at(ix+0,iy+2)*k2 + p->
at(ix+0,iy+3)*k3;
151 vec3 B = p->
at(ix+1,iy+0)*k0 + p->
at(ix+1,iy+1)*k1 + p->
at(ix+1,iy+2)*k2 + p->
at(ix+1,iy+3)*k3;
152 vec3 C = p->
at(ix+2,iy+0)*k0 + p->
at(ix+2,iy+1)*k1 + p->
at(ix+2,iy+2)*k2 + p->
at(ix+2,iy+3)*k3;
153 vec3 D = p->
at(ix+3,iy+0)*k0 + p->
at(ix+3,iy+1)*k1 + p->
at(ix+3,iy+2)*k2 + p->
at(ix+3,iy+3)*k3;
154 for(
unsigned x=0;
x<detail(); ++
x, ++ivert)
156 real u = (real)
x/(detail()-1);
158 real tx1 = 1.0f - tx;
159 vert_array->
at(ivert) = (
fvec3)(A*tx*tx*tx + B*3*tx*tx*tx1 + C*3*tx*tx1*tx1 + D*tx1*tx1*tx1);
162 texc_array->
at(ivert).
x() = (float)u;
163 texc_array->
at(ivert).
y() = (float)v;
168 int istart = detail()*detail()*patch_num;
169 for(
unsigned y=0;
y<detail()-1; ++
y)
171 for(
unsigned x=0;
x<detail()-1; ++
x)
183 #if defined(VL_OPENGL_ES1) || defined(VL_OPENGL_ES2) 184 this->makeGLESFriendly();
Vector3< float > fvec3
A 3 components vector with float precision.
int x() const
Returns the x dimension of the patch as specified by resize().
static void error(const String &message)
Use this function to provide information about run-time errors: file not found, out of memory...
vec3 & at(int i, int j)
Returns the i/j control point.
Visualization Library main namespace.
int y() const
Returns the y dimension of the patch as specified by resize().
void setBufferObjectDirty(bool dirty=true)
Wether the BufferObject should be updated or not using the local storage.
Defines one or more concatenated bicubic Bézier patches to be used with the BezierSurface class...
void resize(int x, int y)
Defines the x and y dimensions of the control point grid defining the patch.
arr_type * indexBuffer()
The BufferObject containing the indices used to render.
void updateBezierSurface(bool gen_tex_coords=true)
Generates the Bézier surface geometry based on the current patches and detail.
T_VectorType & at(size_t i)
The ref<> class is used to reference-count an Object.
const T_Scalar & x() const
const T_Scalar & y() const