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  · 

LookAtTransform

The LookAtTransform item implements a transformation that causes objects to face the camera. More...

Inherits QtObject

LookAtTransform instantiates the C++ class QGraphicsLookAtTransform

This type was introduced in Qt 4.8.

Detailed Description

Sometimes it can be useful to make an object face towards another object, wherever it might be located. This is useful for objects like cameras, lights, arrows, faces etc.

Another common use is called "billboarding", where a quad is always oriented to face the camera. In QML, this can be achieved as follows:

 Camera3D camera
 Item3D {
     mesh: Mesh { source: "pane.obj" }
     position: Qt.vector3d(2, 0, -20)
     transform: LookAtTransform { worldPosition - camera.worldPosition }
     effect: Effect { texture: "picture.jpg" }
 }

Because the lookAt transformation will override many other transformations ont the matrix, it will usually be the last element in the transform list (transformations are applied to the matrix in reverse order of their appearance in transform):

 Item3D {
     mesh: Mesh { source: "pane.obj" }
     position: Qt.vector3d(2, 0, -20)
     transform: [
         Scale3D { scale: 0.5 },
         Rotation3D { angle: 30 },
         LookAtTransform { worldPosition - camera.worldPosition }
     ]
     effect: Effect { texture: "picture.jpg" }
 }

Typically, orientation as well as facing is important. For example, a face that does not remain basically upright will look very odd indeed as it tracks a subject. The lookAt transform will always rotate first around the local y axis, and secondarily around the local x axis, around an origin of (0,0,0).

If rotation around a different axis or origin is desired, place the Item3D to be rotated inside a new parent Item3D. Apply rotations the and translations to the original Item3D such that the desired "front" matches the new parent Item3d's positive z direction and the left to right matches the parent's x-axis, and then apply the LookAt transform to the new parent item.

 Item3D {
     position: Qt.vector3d(0,0,4)
     transform: LookAt { subject: subjectPenguin }

     Item3D {
         id: lookAwayMonkey
         mesh: Mesh { source: "meshes/monkey.3ds" }
         transform: Rotation3D { axis: Qt.vector3d(0,1,0); angle: 180 }
     }
 }

By default the LookAt transform will cause the object to face directly at the subject no matter how the world co-ordinate system is rotated. Sometimes it is useful to limit the lookAt to only one axis of rotation - for example, a tank with a turret and barrel that each have only one degree of freedom. This is achieved by using the preserveUpVector property:

 Pane {
     position: Qt.vector3d(2, 0, -20)
     transform: LookAtTransform { preserveUpVector: true }
     effect: Effect { texture: "picture.jpg" }
 }
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