This fragment graph Splits a line segment into five lines. The first line segment uses the first 1/3 of the original line segment, and the last line segment uses the last 1/3 of the original line segment. The three lines in the middle form an open square.
Core code:
static void FractalSquare(const Vector3& vStart, const Vector3& vEnd, Vector3* pVertices){ Vector3 vSub = vEnd - vStart; Yreal len = D3DXVec3Length(&vSub); pVertices[0] = vStart; pVertices[5] = vEnd; Vector3 vMiddle; vMiddle.x = (vStart.x + vStart.y + vEnd.x - vEnd.y) / 2; vMiddle.y = (vEnd.x + vEnd.y + vStart.y - vStart.x) / 2; vMiddle.z = 0.0f; pVertices[1] = vStart + vSub/3.0f; pVertices[4] = vStart + vSub/1.5f; pVertices[2] = (vStart + vMiddle*2.0f)/3.0f; pVertices[3] = (vEnd + vMiddle*2.0f)/3.0f;}
Software:
Software: http://files.cnblogs.com/WhyEngine/Fractal.7z
Square Line of Fragment