Advertisement
Guest User

Door

a guest
Nov 21st, 2011
693
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import QtQuick 1.0
  2. import Qt3D 1.0
  3.  
  4. Rectangle {
  5.     color: "black"
  6.     width: 400
  7.     height: 600
  8.  
  9.     Viewport {
  10.         anchors.fill: parent
  11.         MouseArea {
  12.             anchors.fill: parent
  13.             onClicked: {
  14.                 fullScene.openDoor();
  15.             }
  16.         }
  17.         camera: Camera {
  18.             id: viewCamera
  19.             eye: Qt.vector3d(15,10,40)
  20.             center: Qt.vector3d(-2,10,0)
  21.         }
  22.         Item3D {
  23.             id: fullScene
  24.  
  25.             function openDoor()
  26.             {
  27.                 doorOpenAndClose.loops = 1;
  28.                 doorOpenAndClose.start();
  29.             }
  30.  
  31.             Mesh { id: refrigirator; source: "refr.3ds" }
  32.             Mesh { id: ufo; source: "ufo.3ds" }
  33.             Mesh { id: bottom_door; source: "door.3ds" }
  34.  
  35.             Item3D { mesh: refrigirator }
  36.             Item3D { mesh: ufo;}
  37.             Item3D { mesh: bottom_door; transform: [doorOpen] }
  38.  
  39.             // ------------------ Transform + Animations ------------------
  40.             Rotation3D {
  41.                 id: doorOpen
  42.                 angle: 0
  43.                 axis: Qt.vector3d(0, 1, 0)
  44.                 origin: Qt.vector3d(-3, 0,  0)
  45.             }
  46.             SequentialAnimation { id: doorOpenAndClose;
  47.                 NumberAnimation { target: doorOpen; property: "angle"; from: 0; to : -80.0; duration: 800; easing.type: Easing.OutBounce}
  48.                 NumberAnimation { target: doorOpen; property: "angle"; from: -80; to : 0.0; duration: 1200; easing.type: Easing.OutCubic}
  49.             }
  50.         }
  51.     }
  52. }
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement