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  · 

CapsuleMesh

The CapsuleMesh item represents a simple capsule in 3D space. More...

Inherits Mesh

CapsuleMesh instantiates the C++ class CapsuleMesh

This type was introduced in Qt 4.8.

Detailed Description

The CapsuleMesh element in QML provides a simple way to create a capsule object, usually for testing material effects. Capsule's center is its barycenter. For example, the following QML code displays a green capsule with a uniform diameter of 0.5, and a length of 3.0:

 Item3D {
     mesh: CapsuleMesh {
         radius: 0.5
         length: 3.0
     }
     effect: Effect {
         color: "#aaca00"
     }
 }

The CapsuleMesh element is part of the Qt3D.Shapes namespace, so the following must appear at the top of any QML file that references it:

 import Qt3D.Shapes 1.0

The capsule shape can have differing levels of detail, allowing for additional slices and layers to be drawn if more detailed meshes are required.

Note that the length of the capsule should always exceed its diameter to be considered valid.

To display the capsule mesh you can create your own Item3D as shown above, or use the convenience Capsule QML Component.

 Capsule {
     radius: 0.5
     length: 3.0
     effect: Effect {
         color: "#aaca00"
     }
 }

Performance Hints for Larger Scenes

The convenience Capsule QML component will create a new mesh each time is instantiated.

If you have a scene with a number of similar capsules use your own Item3D elements to all refer to the same mesh. See the Performance Hints section of the SphereMesh documentation for more details on this important technique.

Performance Hints for Animation

Because of the need to maintain the relative proportions of the cylinders components, the length and radius are implemented directly in the construction of the mesh. This differs from the approach used in the SphereMesh where a scale is used.

For this reason avoid animating the length and radius properties of a CapsuleMesh, as it will give poor results due to the mesh being recreated every frame.

Since the capules components are created with named sections in the mesh, one approach would be to individually apply scales to these sections using the meshNode property. This is an advanced topic, and future tutorials may cover it in more depth.

See also Item3D and SphereMesh.

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