QGLCylinder ClassThe QGLCylinder class represents the geometry of a simple cylinder/cone in 3D space. More... #include <QGLCylinder> This class was introduced in Qt 4.8. Public Functions
Detailed DescriptionThe QGLCylinder class represents the geometry of a simple cylinder/cone in 3D space. The following example creates a cone with a top diameter of 1 unit, a bottom diameter of of 2 units in diameter and height of 3 units. It then draws it at (10, 25, 0) in a QGLPainter: QGLBuilder builder; builder << QGLCylinder(1.0,2.0,3.0); QGLSceneNode *node = builder.finalizedSceneNode(); painter.translate(10, 25, 0); node->draw(&painter); Note that the bottom circle of the cylinder will always be centred at (0,0,0) unless otherwise transformed after cylinder creation. The QGLCylinder class specifies positions, normals and 2D texture co-ordinates for all of the vertices that make up the cylinder. The texture co-ordinates are fixed at construction time. This is because constructing the cylinder can involve generating additional vertices which need to interpolate the texture co-ordinates of their neighboring vertices. The QGLCylinder is divided into slices and layers. The slices value indicate number of triangular sections into which the top and bottom circles of the cylinder are broken into. Consequently it also sets the number of facets which run the length of the cylinder. More slices results in a smoother circumference. The layers value indicates the number of longitudinal sections the cylinder is broken into. Fewer layers means that the side facets of the cylinder will be made up of fewer, very long, triangles, while a higher number of layers will produce many and smaller triangles. Often it is desirable to avoid large triangles as they may cause inefficiencies in texturing/lighting on certain platforms. The end-caps and sides of the cylinder are independent sections of the scene-graph, and so may be textured separately. Textures are wrapped around the sides of thecylinder in such a way that the texture may distort across the x axis if the top and bottom diameters of the cylinder differ (ie. the cylinder forms a truncated cone). Textures begin and end at the centre points of the top and bottom end-caps of the cylinder. This wrapping means that textures on either end-cap may be distorted. Texture coordinates are assigned as shown below. It is worth noting that the cylinder class can, in fact, be used to generate any regular solid polygonal prism. A rectangular prism can be created, for example, by creating a 4 sided cylinder. Likewise a hexagonal prism is simply a 6 sided cylinder. With this knowledge, and an understanding of the texture coordinate mapping, it is possible to make custom textures which will be usable with these three dimensional objects. See also QGLBuilder. Member Function Documentation
|