void makeClosedBspline(int blineSplitNum, int bezierStep, int degreeSplitNum, float* blinesPoints_coralGroup, float* texcoord_coral,float** lines)
{
float blinesPointsGather[6000];
float f1, f2, f3, f4;
float deltaT = 1.0 / float(blineSplitNum);
float T;
for (int i = 0; i < blineSplitNum; i++)
{
T = float(i)*deltaT;
f1 = (-T*T*T + 3 * T*T - 3 * T + 1) / 6.0;
f2 = (3 * T*T*T - 6 * T*T + 4) / 6.0;
f3 = (-3 * T*T*T + 3 * T*T + 3 * T + 1) / 6.0;
f4 = (T*T*T) / 6.0;
//每条贝塞尔线段上拥有的点数 贝塞尔线段上的第m个点
for (int m = 0; m < bezierStep; m++)
{
//每个闭环包含的段数 * 每个曲线段包含的点个数 * 3 * 第m个闭合圈 每个闭合圈所包含的数值个数 +3是加的3条线段
int loopIndex = (degreeSplitNum + 3) * blineSplitNum * 3 * m;
//贝塞尔线段上的第 m 个点的索引
int mIndex1 = m * 3;
int mIndex2 = mIndex1 + 1;
int mIndex3 = mIndex2 + 1;
for (int j = 0; j < degreeSplitNum; j++) {
//j * steps * 3 横截面的第j个点
float x = f1 * lines[j][mIndex1] +
f2 * lines[j + 1][mIndex1] +
f3 * lines[j + 2][mIndex1] +
f4 * lines[j + 3][mIndex1];
float y = f1 * lines[j][mIndex2] +
f2 * lines[j + 1][mIndex2] +
f3 * lines[j + 2][mIndex2] +
f4 * lines[j + 3][mIndex2];
float z = f1 * lines[j][mIndex3] +
f2 * lines[j + 1][mIndex3] +
f3 * lines[j + 2][mIndex3] +
f4 * lines[j + 3][mIndex3];
//到第 j 个点时,当下的索引值
int secNum = blineSplitNum * 3 * j;
int blindex = secNum + i * 3 + loopIndex;
blinesPointsGather[blindex] = x;
blinesPointsGather[blindex + 1] = y;
blinesPointsGather[blindex + 2] = z;
}
//横截面的最后三个点
float x4 = f1
生成三次均匀B样条闭合曲线并合成NURBS
最新推荐文章于 2023-10-21 18:56:48 发布