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 spheres

Spheres tend to a be a popular choice for modeling programmatically, as they tend to appear in a lot of places in games where manually modeling them would be an exercise in tedium, such as particle effects and planetary bodies.

The method demonstrated here is a personal favorite as it generates a mesh similar in look to a geodesic dome, with its surface being built up from a collection of identical triangles woven together as opposed to other techniques, which can result in squashed and irregular triangles near the poles or equator.

Getting ready

This example was written with the GeometricBuffer classes in mind, presented in the Modeling triangles recipe, but should be equally applicable with any mesh building framework.

How to ...

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