15 for (
int i = 0; i <= Slices; i++)
17 float theta = (float)i / Slices *
math::PI;
18 for (
int j = 0; j <= Slices; j++)
20 float phi = (float)j / Slices * 2 *
math::PI;
21 float x = sin(phi) * sin(theta);
23 float z = sin(phi) * cos(theta);
24 float x_tbn = sin(phi) * cos(theta);
25 float y_tbn = cos(phi) * cos(theta);
26 vec3 position { x, y, z };
27 vec3 tangent = position.
Cross({ x_tbn, 0, y_tbn }).Normalized();
29 vec2 texture_coordinates { (float)i / Slices, (
float)j / Slices };
32 position * Radius + Center, position,
vec3 Cross(const vec3 &Other) const
std::vector< vertex > Vertices
sphere(const vec3 &Center, float Radius, int Slices)
Sculpto library prehompiled header. Defines common definitions, includes commonly used modules.
Topology sphere object class implementation module.