drwhut / tabletop-club

An open-source platform for playing tabletop games in a physics-based 3D environment for Windows, macOS, and Linux! Made with the Godot Engine.
https://tabletopclub.net
MIT License
1.29k stars 57 forks source link

Allow custom 3D tables to be imported. #44

Closed drwhut closed 3 years ago

drwhut commented 3 years ago

Is your feature request related to a problem? Please describe. Right now the only in-game table that can be used is the one that comes with the game (which is defined in the Room scene).

Describe the solution you'd like Add a folder to the asset pack (e.g. assets/[PACK]/tables/), which contains exported 3D models that are imported as tables. There can then be an option to change which table the room is using in the room dialog.

Plus, the config.cfg file for the new tables should contain information about the positions of player hands (like they are defined currently), for example:

[MyTable.gltf]

hands = [
    {
        ; The position and forward direction of the first player's hand.
        "position": Vector3(0, 0, -5),
        "direction": Vector3(0, 0, 1)
    },
    {
        ; The position and forward direction of the second player's hand.
        "position": Vector3(0, 0, 5),
        "direction": Vector3(0, 0, -1)
    }
    ; ...
]

Describe alternatives you've considered I've considered only allowing the texture of the current table to be modified, but this feature inherently has more flexibility and creative potential.

Additional context Side note: This would probably mean having to change the name and extension of save files (.table -> .ot?) to avoid confusion.

The problem, and the reason I have been putting off this feature for so long, is due to the collision of the table - when I first added the current table to the game, I found that having the engine automatically create a convex collision shape for the table meant that very thin objects like cards just fall through the table until the collision shapes are changed to basic cube shapes. I'm assuming what's happening here is that the Bullet physics engine cannot handle a complex (convex) collision shape colliding with a very thin cube shape.

This is problematic for custom tables since we can only really make collision shapes of a convex type out of them (since there is an in-built function for it). With the current understanding of the physics engine, the custom table needs to have basic collision shapes (i.e. cubes, cylinders).

So, there are two options for approaching this feature:

  1. Somehow fix thin collision shapes not colliding correctly with convex collision shapes.
  2. Have the creator of the custom table define their own collision shapes in the config.cfg file.

Ideally, I would like to implement this feature using the first method, but I need help figuring this one out - If there are no apparent fixes, I will implement it with the second (less creator-friendly) method.

drwhut commented 3 years ago

I've done some more testing, and I think I got convex and concave collision shapes mixed up - thin objects like cards fall through concave collision shapes, but they don't seem to fall through convex ones! So we're good to go!