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: PrincipledMaterial {
baseColor: "green"
}
castsShadows: false
receivesShadows: true
}
}파일:
© 2026 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.