godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.34k stars 21.06k forks source link

GridMap - Include transforms of tile object's children when generating .meshlib file #11722

Closed Scott3730 closed 5 years ago

Scott3730 commented 7 years ago

(currently using Godot 3.0, build from the 27th of September)

When creating a meshlib for use with a GridMap, the engine currently forces all components of each tile to be centred. This makes sense for neatly rotatable tiles of uniform size. But in some use cases, you want objects that are off-centre, and you still want them to have collision details.

image

This effect is exaggerated if you imagine the bookshelf is a painting, or something thin that you would typically mount on a wall, not in the centre of a grid space.

You can also imagine a half-tile object in a grid space would be affected by this issue.

BastiaanOlij commented 7 years ago

What i did to move things off center is make sure the mesh itself has its center point changed.

Ie, in blender move the mesh in edit mode instead of object mode. The advantage here is also that if you make changes to your blender file and export to dea, you don’t have to do all your changes again in godot, i found this workflow incredibly effective

On Sat, 30 Sep 2017 at 11:44 pm, Scott notifications@github.com wrote:

When creating a meshlib for use with a GridMap, the engine currently forces all components of each tile to be centred. This makes sense for neatly rotatable tiles of uniform size. But in some use cases, you want objects that are off-centre, and you still want them to have collision details.

[image: image] https://user-images.githubusercontent.com/1318345/31046141-f064dd3e-a636-11e7-9453-9f3854774f0d.png

  • My bookshelf model is deliberately off-centre so that it can be placed against a wall (it only takes up half a grid-space along one axis)
  • If I want to add a StaticBody with a BoxCollisionShape, I can't offset them to cover just the geometry (because they don't export their transforms, they are locked to the centre of the tile, or grid space)
  • I can centre its pivot in my modelling program, then I can apply the StaticBody and BoxCollisionShape. This will give me correct collision geometry, but my object is then forced to be in the centre of the tile/grid-space (which is undesired). [image: image] https://user-images.githubusercontent.com/1318345/31046153-20d1a8f8-a637-11e7-9efb-709edb698490.png
  • Ideally, the children of the MeshInstance nodes should retain their transforms when a .meshlib is created from a scene.

This effect is exaggerated if you imagine the bookshelf is a painting, or something thin that you would typically mount on a wall, not in the centre of a grid space.

You can also Image a half-tile object in a grid space would be affected by this issue.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/godotengine/godot/issues/11722, or mute the thread https://github.com/notifications/unsubscribe-auth/AB2vaRzMvGnMlF6X5HxGUQXbqAhgrR3Rks5snkW0gaJpZM4PpkCs .

-- Kindest regards,

Bastiaan Olij

https://www.facebook.com/bastiaan.olij https://www.youtube.com/channel/UCrbLJYzJjDf2p-vJC011lYw https://github.com/BastiaanOlij

Scott3730 commented 7 years ago

That is actually one of the cases that I outlined above. Offsetting the meshes isn't a problem at all, because you can just offset them in your modelling software of choice.

The issue is that you can't use collision information for meshes that are off centre, because the transforms of child nodes aren't stored when creating the .meshlib file. This means that CollisionShapes and StaticBodies are forced to be centred, even when the source model is not.

Specifically in the screenshot above, the StaticBody would need to be offset to match the offset of the model - which is currently impossible.

Scott3730 commented 7 years ago

Having this functionality would also allow you to composite tiles from multiple meshes, although I'm not sure how useful that would be to have.

reduz commented 6 years ago

kicking to 3.1, out of time

ghost commented 6 years ago

You can edit the center in Blender or you can go in edit mode and offset the vertices . This will create an offset mesh. Then you can use this offset mesh to generate a convex collision sibling that will also be offset. Of course if you use a complex 3D model you must simplify it re-import it and use only the generated collision image

reduz commented 5 years ago

This is more like a wishlist enhacement more than a bug, if someone wants to do it in MeshLibraryEditorPlugin, feel free.

TrueSgtMonkey commented 4 years ago

If the 2D tileset editor has this, then why wouldn't the 3D GridMap have this offset feature?