Discs don't represent a particularly difficult exercise in terms of modeling programmatically, but if you're anything like me, you'll find yourself using them as a basis for a whole lot of other, more complex modeling tasks such as cylinders, tori, and hemispheres. Therefore, having a reference implementation at hand can be useful.
This example was written with the
GeometricBuffer class, and related ones demonstrated in the Modeling triangles recipe covered earlier in this chapter, but is equally applicable for use with any mesh building framework.
To create a disc programmatically:
var discRadius = 0.5f; var segmentCount = 16; var segmentAngle ...