Home | Features | Roadmap | Learn | Documentation | ||
Latest version: Tramway SDK 0.0.9 Github Quick links Home Get Started |
PhysicsThe physics system provides rigidbody physics simulation services. Currently a single backed is implemented, which is the Bullet physics library backed, but more will be added in the future. If you want to add rigidbodies to your entities, consider using the PhysicsComponent. For triggers, the TriggerComponent is available. Key conceptsRigidbodyAn object in the physics simlation. Rigidbodies have some kind of a shape or volume. This is determined by their CollisionModel or CollisionShape. TriggerTriggers are special shapes or volumes that can detect if a rigidbody enters its volume. Collision GroupCollision groups are groups that the rigidbody, trigger or other physics construct is a part of. The object can be a part of several groups. They are represented by bits in a bitmask. It is more efficient for an object to belong to only a single group, or very few groups. Collision MaskCollision masks are groups with which the rigidbody, trigger or other physics construct can collide with. The object can be set to collide with several groups. Allowed collision groups are represented by bits in a bitmask. To determine if an object should collide with another object, each objects group bitmask and the other object's mask bitmask are logically ANDed together. If the resulting value is not zero, the objects are allowed to collide. RaycastUseful for poking things, selecting objects. A raycast constructs a ray between two points and check whether it intersects any rigidbody between these points. If an intersection is found, it is returned. ShapecastSimilar to raycast, but instead of a checking an intersection with an infinitely thin line, a shape is used. Collisions: how do they work?Like this. This is how the bitmask ANDing works. Programming in C++
Physics::Init();
Here's how we do raycasts. Let's do one from the render view.
auto pos = Render::GetViewPositon();
This is how interactable object highlighting is usually done for a first-person view. We check if there is an object withing 5 meters right in front of the view, and if there is an object, we send the it a Selected message. Shapecasts work the same way, except that you also need to pass in the shape, which will be used for the collision. |
|
|