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  · 

SphereMesh

The SphereMesh item represents a simple UV-sphere in 3D space. More...

Inherits Item3D

SphereMesh instantiates the C++ class SphereMesh

This type was introduced in Qt 4.8.

Detailed Description

The SphereMesh element in QML provides a simple way to create a sphere object, usually for testing material effects. For example, the following QML code displays a green sphere mesh of radius 1.5, centered on the origin:

 Item3D {
     mesh: SphereMesh { radius: 1.5 }
     effect: Effect { color: "#aaca00" }
 }

As shown, the mesh is only displayed when it is set as the target of a mesh property on an Item3D.

The SphereMesh 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

By default, the sphere is aligned to lie along the Z axis. The axis property can change this to either the X or the Y axis, as shown in the following example:

 SphereMesh {
     radius: 1.5
     axis: Qt.YAxis
 }

To display the sphere mesh you can create your own Item3D as shown above, or use the convenience Sphere QML component:

 Sphere {
     radius: 1.5
     levelOfDetail: 6
     axis: Qt.YAxis
     effect: Effect { texture: "moon-texture.jpg" }
 }

Performance Hints for Larger Scenes

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

If you have a scene with a number of similar spheres use your own Item3D elements to all refer to the same mesh - this will save on graphics memory and improve the performance of your application since there is no need to recreate many copies of the same geometry. This is true even if you want to apply different materials, effects or transformations to each sphere.

To do this, first declare the SphereMesh object, outside of any Item3D so that it won't get drawn, and give it an id so you can refer to it.


Then set the various effects and so on you need for each instance of the sphere. If you need different sized spheres you can use a scale, and of course you can specify materials and effects.


In this case since only one copy of the triangle data for the mesh is sent to the GPU performance will generally be better.

Performance Hints for Animation

Some support for animation of the SphereMesh properties is provided by utilizing a QGraphicsScale3D to implement the radius property, and by caching levels of detail.

So within limits animation of these items should provide reasonable results. Be aware that on constrained devices animation of the level of detail for many spheres could cause problems with memory usage due to the caching.

The other shapes primitives are implemented differently with respect to radius, length and so on, so read the performance notes there, as they will differ from the sphere case.

See also Item3D.

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