Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

QGLCylinder Class

The 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

QGLCylinder(qreal diameterTop = 1.0f, qreal diameterBase = 1.0f, qreal height = 1.0f, int slices = 6, int layers = 3, bool top = true, bool base = true)
bool baseEnabled() const
qreal diameterBottom() const
qreal diameterTop() const
qreal height() const
int layers() const
void setBaseEnabled(bool base)
void setDiameterBottom(qreal diameter)
void setDiameterTop(qreal diameter)
void setHeight(qreal height)
void setLayers(int layers)
void setSlices(int slices)
void setTopEnabled(bool top)
int slices() const
bool topEnabled() const

Detailed Description

The 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

QGLCylinder::QGLCylinder(qreal diameterTop = 1.0f, qreal diameterBase = 1.0f, qreal height = 1.0f, int slices = 6, int layers = 3, bool top = true, bool base = true)

Constructs the geometry for a cylinder with top of diameter diameterTop, a base of diameter diameterBase, and a height of height.

The resultant mesh will be divided around the vertical axis of the cylinder into slices individual wedges, and shall be formed of layers stacked to form the cylinder.

If the values for top or base are true, then the cylinder will be created with solid endcaps. Otherwise, it shall form a hollow pipe.

units on a side.

bool QGLCylinder::baseEnabled() const

Returns true if the base of the cyclinder will be created when building the mesh.

The default is true.

See also setBaseEnabled().

qreal QGLCylinder::diameterBottom() const

Returns the diameter of the bottom of the cylinder.

The default value is 1.

See also setDiameterBottom().

qreal QGLCylinder::diameterTop() const

Returns the diameter of the top of the cylinder.

The default value is 1.

See also setDiameterTop().

qreal QGLCylinder::height() const

Returns the height of the cylinder.

The default value is 1.0

See also setHeight() and setDiameterBottom().

int QGLCylinder::layers() const

Returns the number of cylindrical layers the cylinder is divided into along its height.

The default is 3.

See also setLayers().

void QGLCylinder::setBaseEnabled(bool base)

Set whether the base end-cap of the cylinder will be created when building the mesh. If base is true, the end-cap will be created.

See also baseEnabled().

void QGLCylinder::setDiameterBottom(qreal diameter)

Sets the diameter of the bottom of this cylinder to diameter.

See also diameterBottom().

void QGLCylinder::setDiameterTop(qreal diameter)

Sets the diameter of the top of this cylinder to diameter.

See also diameterTop().

void QGLCylinder::setHeight(qreal height)

Sets the height of this cylinder to height.

See also height() and diameterBottom().

void QGLCylinder::setLayers(int layers)

Sets the number of stacked layers the cylinder is divided into along its height.

See also layers().

void QGLCylinder::setSlices(int slices)

Sets the number of triangular slices the cylinder is divided into around its polar axis.

See also slices().

void QGLCylinder::setTopEnabled(bool top)

Set whether the top end-cap of the cylinder will be created when building the mesh. If top is true, the end-cap will be created.

See also topEnabled().

int QGLCylinder::slices() const

Returns the number of triangular slices the cylinder is divided into around its polar axis.

The default is 6.

See also setSlices().

bool QGLCylinder::topEnabled() const

Returns true if the top of the cyclinder will be created when building the mesh.

The default is true.

See also setTopEnabled().

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 5.0-snapshot
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web