Qt Quick 3D物理形状和实体

Qt Quick 3D Physics Shapes and Bodies

Qt Quick 3D物理形状和实体

The objects in the simulation are represented by any of the following four types of bodies: StaticRigidBodyDynamicRigidBodyCharacterController and TriggerBody. The physical shape of a body is represented by subtypes of CollisionShape.

​模拟中的对象由以下四种类型的实体中的任何一种表示:StaticRigidBody、DynamicRigidBodys、CharacterController和TriggerBody。物体的物理形状由碰撞形状的子类型表示。

Shapes

形状

A collision shape is used to define the physical shape and extent of an object for the purposes of the physics simulation. The collision shape will typically be simpler than the object's visual appearance.

碰撞形状用于定义对象的物理形状和范围,以便进行物理模拟。碰撞形状通常比对象的视觉外观更简单。

There are some predefined shapes built into the engine: BoxShapeCapsuleShapeSphereShape, and PlaneShape. Handling of these shapes is optimized, so simulation using them will typically perform better.

​引擎中内置了一些预定义的形状:BoxShape、CapsuleShape、SphereShape和PlaneShape。对这些形状的处理是优化的,因此使用它们的模拟通常会表现得更好。

In addition, there are custom shapes that are defined by data: ConvexMeshShapeHeightFieldShape, and TriangleMeshShape. These allow more flexibility at the expense of performance.

​此外,还有由数据定义的自定义形状:凸网格形状、高场形状和三角形网格形状。这些允许以牺牲性能为代价实现更大的灵活性。

Bodies

实体

body represents a physical object in the simulation. These bodies interact and collide with each other. The two main types are static bodies (StaticRigidBody) and dynamic bodies (DynamicRigidBody). The physical shape of a body is specified by a list of shapes. The effective shape is the union of these shapes. The relative position of the shapes is fixed: the bodies are rigid.

​实体表示模拟中的物理对象。这些实体相互作用和碰撞。两种主要类型是静态刚体(StaticRigidBody)和动态刚体(DynamicRigidBodys)。实体的物理形状由形状列表指定。有效形状是这些形状的结合。形状的相对位置是固定的:实体是刚性的。

Dynamic body

动态实体

Dynamic bodies are able to move. The isKinematic property determines how it moves. When isKinematic is true, the body is positioned explicitly by modifying the kinematicPosition and kinematicRotation properties. When isKinematic is false, the object is controlled by the simulation: it will fall under gravity, and bounce off other objects.

​动态实体能够移动。isKinematic属性决定了它的移动方式。当isKinematic为true时,通过修改kinematicPosition和kinematicRotation属性来显式定位实体。当isKinematic为false时,对象将由模拟控制:它将在重力作用下坠落,并从其他对象上反弹。

When isKinematic is true, all shapes are allowed. However, non-kinematic bodies are more restricted: only convex shapes can be used. These are the pre-defined shapes BoxShapeCapsuleShape, and SphereShape; and the custom shape ConvexMeshShape. This does not mean that it is impossible to have a non-convex physical geometry: several convex shapes can be combined for a single body. The Compound Shapes Example shows how to form ring-shaped bodies based on convex shapes.

​当isKinematic为真时,允许使用所有形状。然而,非运动体受到更多限制:只能使用凸形。这些是预定义的形状BoxShape、CapsuleShape和SphereShape;以及自定义形状ConverxMeshShape。这并不意味着不可能有一个非凸的物理几何体:几个凸形可以组合成一个实体。复合形状示例展示了如何基于凸形形成环形体。

Static body

静态实体

Static bodies do not move. They represent the environment in which the other bodies move. Note that it is technically possible to move a static body, but the physical simulation will behave unexpectedly. In particular, a dynamic body that has entered a resting position on a static body will not be awoken if the static body moves. This means the dynamic body will remain in the same position even if the static body is moved.

静止的实体不会移动。它们代表了其他物体运动的环境。请注意,从技术上讲,移动静态物体是可能的,但物理模拟的行为会出乎意料。特别是,如果静态实体移动,则已经在静态实体上进入静止位置的动态物体将不会被唤醒。这意味着即使移动静态实体,动态体也将保持在相同的位置。

Character controller

角色控制器

The CharacterController type is a special case. It represents a character that moves through the environment. One typical use case is a first-person view where the camera is a child of the character controller, and its movement is controlled by keyboard/mouse or gamepad.

​CharacterController类型是一种特殊情况。它代表了一个在环境中移动的角色。一个典型的用例是第一人称视图,其中相机是角色控制器的子设备,其移动由键盘/鼠标或游戏手柄控制。

Trigger body

触发体

There is also the TriggerBody type which is another special case. As opposed to the other bodies it is not a physical body, meaning it does not interact in collision with other bodies. As the name suggests it is only used to trigger actions when another body enters or leaves its volume as defined by its collision shapes. If another body has sendTriggerReports set to true and its collision volume enters a TriggerBody the bodyEntered signal is emitted.

​还有另一个特例TriggerBody类型。与其他物体不同,它不是一个物理实体,这意味着它不会与其他物体发生碰撞。顾名思义,它只用于在另一个物体进入或离开其碰撞形状定义的体积时触发动作。如果另一个实体将sendTriggerReports设置为true,并且其碰撞体积进入TriggerBody,则会发出bodyEntered信号。

The following table shows a summary of the different types of bodies, how they interact and can be used:

下表显示了不同类型的身体、它们如何相互作用以及可以使用的总结:

Body

实体

Interaction

交互

Allowed shapes

允许的形状

StaticRigidBody

Does not move

不动

All shapes

所有形状

DynamicRigidBody with isKinematic true

Positioned programatically. Influences dynamic bodies. Stopped by nothing.

按程序定位。影响动态物体。什么都没阻止。

All shapes

所有形状

DynamicRigidBody with isKinematic false

Fully controlled by simulation

完全由模拟控制

Limited shapes

形状有限

CharacterController

Moved programatically. Influences dynamic bodies. Stopped by static bodies.

按程序移动。影响动态物体。被静止的物体阻挡。

Only a single CapsuleShape


只有一个CapsuleShape

TriggerBodyNone

All shapes

所有形状

Physics Materials

物理材质

The PhysicsMaterial type specifies how an object behaves when it collides with another. The dynamicFriction and staticFriction properties determine how slippery the object is, and restitution determines how bouncy it is.

​PhysicsMaterial类型指定了对象与另一个对象碰撞时的行为。动态摩擦和静态摩擦属性决定了物体有多滑,恢复力决定了物体的弹性。

Units

© 2024 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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值