O'Reilly logo

Microsoft XNA 4.0 Game Development Cookbook by Luke Drumm

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Modeling discs

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.

Getting ready

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.

How to do it...

To create a disc programmatically:

  1. Create some variables to hold the specifications of the disc:
    var discRadius = 0.5f; var segmentCount = 16; var segmentAngle ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required