double o = 0;
for (i = 0;i < dimensions + 1;i++)
o += param[i] * factorial(dimensions)/(factorial(i)*factorial(dimensions-i)) * pow(t, i) * pow(1 - t, dimensions - i);
+ return o;
}
*/
void Q3PatchTesselateFloat(int numcomponents, int outputstride, float *outputvertices, int patchwidth, int patchheight, int inputstride, float *patchvertices, int tesselationwidth, int tesselationheight)
{
int k, l, x, y, component, outputwidth = (patchwidth-1)*tesselationwidth+1;
- float px, py, *v0, *v1, a, b, c, *cp[3][3], temp[3][64];
+ float px, py, *v, a, b, c, *cp[3][3], temp[3][64];
// iterate over the individual 3x3 quadratic spline surfaces one at a time
// expanding them to fill the output array (with some overlap to ensure
// the edges are filled)
// (such as those produced by Q3PatchTesselate)
// (note: width and height are the actual vertex size, this produces
// (width-1)*(height-1)*2 triangles, 3 elements each)
-void Q3PatchTriangleElements(int *elements, int width, int height)
+void Q3PatchTriangleElements(int *elements, int width, int height, int firstvertex)
{
int x, y, row0, row1;
for (y = 0;y < height - 1;y++)
{
- row0 = (y + 0) * width;
- row1 = (y + 1) * width;
+ row0 = firstvertex + (y + 0) * width;
+ row1 = firstvertex + (y + 1) * width;
for (x = 0;x < width - 1;x++)
{
*elements++ = row0;