-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add OMI_collider #63
Add OMI_collider #63
Conversation
Co-authored-by: Chris Sinclair <56918851+chrissinclairhadean@users.noreply.github.com>
Co-authored-by: Chris Sinclair <56918851+chrissinclairhadean@users.noreply.github.com>
The `mesh` property of the extension must be used to link to an element in the `meshes` array. Note that the mesh MUST be a `trimesh` to work. | ||
|
||
Due to limitations of some game engines (e.g. Unity), authors SHOULD limit the polygon count to 255 vertexes. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hull meshes can be used to be used compound, multiples of 255 vertices compunded.
|
||
Compound colliders can be used to group several colliders together in order to give an entity a complex shape using several primitives without resorting to an entire mesh. | ||
|
||
A `Node` set to be a `compund` collider will use any direct child nodes with the `OMI_collider` extension as part of it's collision shape. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
compund
-> compound
BIG TODO:
|
|
||
#### Capsule | ||
|
||
This represents a "pill" shape which has a `radius` and `height` property. By default the `capsule`'s height is aligned with the vertical axis. If you wish to align it along a different axis, apply the appropriate transform to the `node`. The `radius` field must be set to `0.5` if omitted, and the `height` must be set to `1` if omitted. The final height of the capsule is `height + radius * 2`. TODO: Improve wording? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From our meeting: Is there any way to represent a cylinder with a capsule? Is that currently the right way to represent a cylinder in a physics engine that doesn't support cylinders?
TODO:
|
bump, whats our status on moving this forward to done @robertlong @RangerMauve :) ? |
Blocked on time needed to split these into two PRs and start working on an implementation of OMI_collider. We want to focus on the OMI_collider extension first and tackle physics bodies next. I probably will have time to start implementing something in Third Room in the next couple weeks and can add to this when I start on that. If anyone else is working on an implementation sooner, let us know. |
thanks for the bump @mrmetaverse ! I split the physics body out to its own PR and now this PRcan remove the physics body folder and continue on toward a final Collider extension :D |
If given access to your fork @RangerMauve I can make the update to remove the physics body from this PR. (I think its your repo I would need access to?) onward! :D |
Related GLTF proposal: KhronosGroup/glTF#1986 |
As commented on tuesday meeting, here is the proposal I used in collider, I know this also includes physics bodies, but we can focus on the collider section if needed :)
|
Comment by @lyuma was that center is duplicating the gltf translation property. When converting GameObjects from Unity the center can be emulated via adding a child node. |
@antpb mentioned that for a demo, we could implement this as blender extension as a button that can create a component creating the internal nodes. Has an hack to show a visible presentation of the node. |
## Contributors | ||
|
||
* Mauve Signweaver, Mauve Software Inc. | ||
* YOUR NAME HERE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add all contributors to the spec.
@antpb mentioned that a next step can be an example:
Create an example asset as a sample for implementation without editing the gltf. |
There was multiple attempt to draft a collider spec for gltf.
Task to contact and to reconcile differences. |
|
||
## Overview | ||
|
||
This extension allows for the addition of colliders to gLTF scenes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo, gLTF
should be either glTF
or GLTF
(I see both of these in the file).
| Shape | Unity | Godot | Unreal | Ammo | | ||
| -------- | ------------ | --------------------- | ------- | ---------- | | ||
| Box | Box | BoxShape | Box | Box | | ||
| Sphere | Sphere | SphereShape | Sphere | Sphere | | ||
| Capsule | Capsule | CapsuleShape | Capsule | Capsule | | ||
| Hull | Mesh(convex) | ConvexPolygonShape | Mesh? | ConvexHull | | ||
| Mesh | Mesh | ConcavePolygonShape | Mesh | Mesh | | ||
| Compound | Compound | Add mutiple colliders | ??? | ??? | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I highly recommend adding cylinders to this list. Cylinders are very useful, I would use them extensively. It's the perfect shape to use for barrels and circular platforms (which I'd like to store in GLTF files).
For engines that do not support cylinders, they can be approximated with capsules, and we can provide guidelines of what to do if this is needed. Maybe even allow providing extra data to hint at what the best way to approximate the shape is (like shrink/grow/average)? We could also discourage the use of cylinders in general, but I think it's very much worth having it in the standard since there are many use cases.
|
||
#### Box | ||
|
||
This represents a "box" shape which can either be a cube or an arbitrary rectangular prism. You can specify an `extents` property which is an array that contains the `[x, y, z]` sizes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should consider making this size
instead of extents
, and making this be an array representing the "diameter" of the box. I think it's noticeably more intuitive this way, so much so that Godot switched from extents
to size
in Godot 4.0.
Also, like Sphere with a default radius of 0.5, we should specify that a box has a default size of [1, 1, 1]
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I came up with these names from looking at existing properties in different engines. Are any engines using a generic extents
for everything?
In the example above:
|
### `isTrigger` | ||
|
||
Specifying `isTrigger: true` in the collider hints to engines that this collider should not be used for physics interactions and should exist as a "trigger volume" which emits events when an entity intersects with it. | ||
By default an engine may assume that the collider is a static (or rigid) physics body. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isTrigger
should be removed from OMI_collider
, it's out-of-scope to define usage for the collision shapes in this extension, and it's already a part of OMI_physics_body
.
EDIT: Hmm, good points below, see my latest comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think some engines combine whether a collider is a trigger or not with the physics body (I think it was unreal) so I'm not sure I agree with that. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm in my opinion I think "isTrigger" actually should be here in OMI_collider and not in OMI_physics, a collider may be a trigger without the need of having a rigidbody (physics), but a rigidbody -without- a collider, wont work with "isTrigger" flag.
Also, Im taking as reference from how its applied in Unity3D (https://docs.unity3d.com/ScriptReference/Collider.html) where isTrigger is applied from Collider component, and also im taking as reference how is applied in Rapier3D (https://rapier.rs/docs/user_guides/javascript/colliders) where sensor is set from Collider definition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@memelotsqui Good points! In Godot, a trigger needs an Area node as a parent of the colliders.
How does it work in Unity if you want multiple collider shapes to trigger the same thing?
If we have this API on both the colliders and physics bodies, we can still import this in Godot, but we should specify how these are imported. Perhaps if a trigger collider has a parent physics object of type trigger, then they use that parent physics object Area node (and possibly multiple shapes could use it, not sure how this would work in Unity). Otherwise if trigger colliders are on their own without a trigger physics object parent, we generate 2 nodes in Godot, an Area and a collider shape child, or 1 GameObject with a component in Unity, and then this trigger is on its own.
If we move this API to only be on the colliders and not on the physics bodies, then this basically means that we would always have to generate 2 nodes in Godot, and always 1 GameObject with a component in Unity, and it wouldn't be possible to make a trigger have multiple shapes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding for Godot is that you can add an Area node as a child of a physics body, and then put all of the "isTrigger" collision shapes as children of the area node, while adding the non-isTrigger shapes as direct children of the physics body itself.
I have seen multiple posts online that use this trick inside of Godot to detect collision events separate from the body itself, such as: https://godotengine.org/qa/92172/collision-detection-independent-of-a-kinematicbody
It would be good to make a demo project so we can show that this works, but I'm pretty sure it is possible.
found these ammo binding docs earlier while looking at mozilla hubs. check out the https://github.com/n5ro/aframe-physics-system/blob/master/AmmoDriver.md#shape-fit
|
I think this was brought up at a previous meeting, too. From what I remember "fit" is not a universal feature of runtimes in engines so it would make it a lot harder to incorporate such a feature everywhere. I think we also discussed how GLTF was likely going to get authored in an engine or editor somewhere ahead of time where colliders could be generated to |
note that in the referenced docs "fit" refers to a feature of the binding itself (not of the underlying ammo physics engine). considering how so perhaps: fit == (trimesh + author's blessing for the engine to radically simplify the resulting hull) |
Outstanding questions for this extension and the OMI_physics_body extension:
|
@robertlong I think this would make sense to have in its own dedicated |
These are my toughts on @robertlong questions: I personally think physics material should go in collider, instead of being in the physics body: It seems that even if colliders don't have a physics body, they can have a physics material, and any other object with physics material will behave accordingly as they're in contact with them. Also, as @aaronfranke mentioned I think it should have a separate extension and be connected in collider by an id: example:{physicsMaterial : id}. Having it connected by id instead of fully defining it inside the OMI_collider (besides looking clean and compact :) ) might also be useful for programming section to modify all materials connected to the shared physics material (for example, change all the ice material friction to 0.1) To assign different materials per mesh, maybe we could use an array instead of a single ID? ( example {physicsMaterials : [ids]} ), and Im not sure, but maybe this could also work in triangle definition if something like mesh groups are allowed/supported in mesh physics (https://threejs.org/docs/#api/en/core/BufferGeometry.groups), if its not supported we could separate the mesh into per material mesh, but this might create some compund mesh colliders and im not sure how good that would be. |
From the July 21st glTF Meeting:
|
Another outstanding question: How should a two different colliders under a single rigid body (compound collider) behave if the colliders have different physics materials? |
We should note the implementation detail that if using a mesh collision shape where the mesh has multiple primitives, all the primitives should be used in the resulting collider. |
During today's OMI glTF meeting @aaronfranke proposed renaming |
@aaronfranke also suggested adding the |
We should move from storing collider definitions on the node to storing them on a root level extension and storing an index to the collider on each node. Very similar to |
Let's close this PR and continue in #118 At the next meeting lets make sure all of the feedback captured here is applied to the new PR. |
As per the discussion at the last GLTF working group meeting, here's an initial draft of the READMEs for the OMI_collider and OMI_physics_body extensions.
Based on the initial draft from this hackmd
These proposals add:
Some TODOs: