21 #ifndef INSTANCED_SOLID_TORUS_H
22 #define INSTANCED_SOLID_TORUS_H
136 void draw(
float* rotationVector);
static const unsigned int patchVerticesCount
Total number of vertices in a patch.
static const unsigned int patchComponentsCount
Total number of components describing a patch (only U/V components are defined).
static const unsigned int patchDimension
Number of control points in one dimension for a patch.
static const unsigned int controlPointsIndicesCount
Number of indices needed to create a control mesh.
float torusRadius
Distance between the center of torus and the center of its tube.
static const unsigned int controlPointsInPatchCount
Total number of control points in a patch.
GLuint patchIndicesBufferID
Index of a buffer that we bind to GL_ELEMENT_ARRAY_BUFFER binding point. It containts indices of patc...
void draw(float *rotationVector)
Draws instanced solid torus.
Class derived form Torus abstract class. It manages drawing of a rotating solid torus, built from separate patches. Each patch is modelled as a Bezier surface approximating surface of a perfect torus. To satisfy the C1 continuity between neighbour patches, the number of circles creating the torus and also the number of points in each circle is restricted to 12. It allows us to divide both circles of torus ("big" and "small") into 4 quadrants and approximate each of it using bicubic Bezier curves. Control mesh vertices has to be distored, so the derivatives on the patch edges are equal and resulting image is round. That is why we cannot use the regular way to determine control points. The patches are in fact very dense square-shaped meshes, used as input attributes by vertex shader. The shader changes their shape on the basis of the distorted control mesh and places them next to each other, forming a round torus. The class, apart from inherited components, manages:
~InstancedSolidTorus(void)
Frees allocated memory.
GLuint controlIndicesBufferID
Index of a buffer that we bind to GL_UNIFORM_BUFFER binding point. It stores uniform control indices ...
static const unsigned int patchDensity
Number of vertices in one edge of a patch.
float circleRadius
Radius of circles that model the tube.
Abstract class that draws torus on the screen. It stores generic data describing the drawn torus: ...
GLuint patchVertexBufferID
Index of a buffer that we bind to GL_ARRAY_BUFFER binding point. It stores patch vertices passed as a...
static const unsigned int quadsInPatchCount
Number of quads in a patch.
static const unsigned int patchInstancesCount
Number of instances needed to draw the whole torus.
static const unsigned int torusVerticesCount
Total number of vertices in torus model.
bool initializeVertexAttribs(void)
Initialize vertex attribute arrays and buffer objects coresponding to them. Make sure that programID ...
InstancedSolidTorus(float torusRadius, float circleRadius)
Instantiates a representation of a solid torus, using user-provided radius and tube radius...
typedef GLuint(GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGKHRPROC)(GLuint count
bool initializeControlUniformBuffers(void)
Initializes control mesh data and stores it in appropriate uniform buffers.
void setLightParameters(void)
Sets directionl light parameters, such as light direction, its color and ambient intensity and passes...
static const unsigned int patchTriangleIndicesCount
Number of indices that need to be defined to draw quads consisting of triangles (6 points per quad ne...
GLuint controlVerticesBufferID
Index of a buffer that we bind to GL_UNIFORM_BUFFER binding point. It stores uniform control vertices...