尝试生成由线条组成的递归树。我当前的绘图功能没有按计划工作。在我在这里展示问题之前是绘制代码:
void _generateTreeBranches(const Point3f& startPoint,
const Point3f& endPoint,
float rotation,
const int depth)
{
if(depth > MAX_DEPTH) return;
cout << "at depth = " << depth << endl;
if(depth == 0)glColor3f(0.0f,1.0f,0.0f);
else glColor3f(1.0f,1.0f,1.0f);
float distanceOfPoint = pointDistance(startPoint, endPoint);
glRotatef(rotation, 0.0f, 0.0f, 1.0f);
glTranslatef(-startPoint.x, 0.0f, 0.0f);
drawLine(startPoint, endPoint);
glTranslatef(startPoint.x, 0.0f, 0.0f);
glRotatef(-rotation, 0.0f, 0.0f, 1.0f);
const float nextLength = distanceOfPoint;
Point3f nextBranchStart = endPoint;
Point3f nextBranchEnd = {endPoint.x + nextLength,endPoint.y,endPoint.z};
_generateTreeBranches(nextBranchStart, nextBranchEnd,45.0f,depth+1);
画出这样的东西
/__
而我试图让它画出这样的东西
__/
对实现上述目标有任何帮助吗?