Qt Quick 3D Physics - 素材例
物理マテリアルを使用する方法を示します。
Materialの例では、物理ボディのマテリアルのプロパティを制御する方法を示します。シーンには、View3D 、PhysicsWorld 、PerspectiveCamera 、DirectionalLight の通常の定型文が含まれています。これに加えて、シーンには、わずかに傾いた平面とボックスの 2 つの物理ボディが含まれています。各物理ボディには、PhysicsMaterial ノードを含むphysicsMaterial プロパティがあります。PhysicsMaterial には、staticFriction 、dynamicFriction 、restitution の3つのマテリアル・プロパティがあり、これらは、ボディが他のボディと衝突したり、スライドしたりするときにどのように動作するかを定義するために使用されます。箱のマテリアルをインタラクティブに調整できるシンプルなユーザーインターフェイスがあり、マテリアルプロパティによって箱がどのように相互作用するかを見ることができます。
これはマテリアルのQMLコードです:
PhysicsMaterial { id: physicsMaterial staticFriction: staticFrictionSlider.value dynamicFriction: dynamicFrictionSlider.value restitution: restitutionSlider.value }
マテリアルは、ユーザーインターフェースのスライダーの値を参照しているだけです。この同じマテリアルが、ボックスと床の両方に使われています:
DynamicRigidBody { id: box physicsMaterial: physicsMaterial massMode: DynamicRigidBody.CustomDensity density: 10 property vector3d startPosition: Qt.vector3d(700, 300, 0) position: startPosition Model { source: "#Cube" materials: PrincipledMaterial { baseColor: "red" } } collisionShapes: BoxShape {} } StaticRigidBody { eulerRotation: Qt.vector3d(-79, -90, 0) scale: Qt.vector3d(20, 30, 100) physicsMaterial: physicsMaterial collisionShapes: PlaneShape {} Model { source: "#Rectangle" materials: DefaultMaterial { diffuseColor: "green" } castsShadows: false receivesShadows: true } }
ファイル
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.