Game Development Reference
In-Depth Information
The user can control the smoothness of the sphere by providing the number of latitudinal
segments, and we will set twice as many longitudinal segments as there are latitudinal.
We will begin by generating the vertex data for the sphere, this involves iterating over the
latitude where we calculate the polar coordinates for the latitudinal ring. Then we will iter-
ate over the longitudinal segments generating all the vertices along the ring.
Given the number of latitudinal segments n the latitude ϕ of each segment i will be given
by:
We then calculate the polar coordinates for the latitude,
The Δϕ y coordinate will give us the coordinate in the y axis for all the vertices in the cur-
rent ring, the Δϕ xz represents the distance from the center of the sphere to the current ring,
a ratio of the radius for the current ring.
Thenwewill iterate overthelongitude segments m creating thevertices, thelongitude λof
each segment j is given by:
Search WWH ::




Custom Search