1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtQuick3D
import QtQuick3D.Physics
import QtQuick3D.Physics.Helpers
Window {
width: 640
height: 480
visible: true
title: qsTr("Qt Quick 3D Physics - Simple")
//! [world]
PhysicsWorld {
scene: viewport.scene
}
//! [world]
//! [scene]
View3D {
id: viewport
anchors.fill: parent
environment: SceneEnvironment {
clearColor: "#d6dbdf"
backgroundMode: SceneEnvironment.Color
}
PerspectiveCamera {
position: Qt.vector3d(-200, 100, 500)
eulerRotation: Qt.vector3d(-20, -20, 0)
clipFar: 5000
clipNear: 1
}
DirectionalLight {
eulerRotation.x: -45
eulerRotation.y: 45
castsShadow: true
brightness: 1
shadowFactor: 50
}
//! [plane]
StaticRigidBody {
position: Qt.vector3d(0, -100, 0)
eulerRotation: Qt.vector3d(-90, 0, 0)
collisionShapes: PlaneShape {}
Model {
source: "#Rectangle"
scale: Qt.vector3d(10, 10, 1)
materials: DefaultMaterial {
diffuseColor: "green"
}
castsShadows: false
receivesShadows: true
}
}
//! [plane]
//! [box]
DynamicRigidBody {
position: Qt.vector3d(-100, 100, 0)
collisionShapes: BoxShape {
id: boxShape
}
Model {
source: "#Cube"
materials: PrincipledMaterial {
baseColor: "yellow"
}
}
}
//! [box]
//! [sphere]
DynamicRigidBody {
position: Qt.vector3d(0, 100, 0)
collisionShapes: SphereShape {
id: sphereShape
}
Model {
source: "#Sphere"
materials: PrincipledMaterial {
baseColor: "blue"
}
}
}
//! [sphere]
//! [capsule]
DynamicRigidBody {
position: Qt.vector3d(75, 200, 0)
collisionShapes: CapsuleShape {
id: capsuleShape
}
Model {
geometry: CapsuleGeometry {}
materials: PrincipledMaterial {
baseColor: "red"
}
}
}
//! [capsule]
}
//! [scene]
}
|