Qt Quick 3D Physics - 재료 예시
물리적 머티리얼을 사용한 데모입니다.
머티리얼 예제는 물리적 몸체의 머티리얼 속성을 제어하는 방법을 보여줍니다. 이 씬에는 View3D, PhysicsWorld, PerspectiveCamera, DirectionalLight 의 일반적인 상용구가 포함되어 있으며, 이 외에도 약간 기울어진 평면과 상자라는 두 개의 물리적 바디가 포함되어 있습니다. 모든 피지컬 바디에는 PhysicsMaterial 노드가 포함된 physicsMaterial 프로퍼티가 있습니다. PhysicsMaterial 에는 staticFriction, dynamicFriction 및 restitution 의 세 가지 머티리얼 프로퍼티가 있으며, 이는 바디가 다른 바디와 충돌하고 미끄러질 때 어떻게 작동할지 정의하는 데 사용됩니다. 상자의 머티리얼을 대화식으로 조정할 수 있는 간단한 사용자 인터페이스가 있어 머티리얼 속성에 따라 어떻게 상호작용하는지 확인할 수 있습니다.
이것이 머티리얼의 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.