godotengine / godot

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

Ability to map meshes across curves #16322

Closed MirceaKitsune closed 4 years ago

MirceaKitsune commented 6 years ago

I'm aware that for a game engine and map editor, this isn't a highly conventional feature. As a Blender artist and animator, I find myself making use of it often to efficiently achieve some environmental details. As worlds are often built into the editor rather than exported as a single 3D mesh, I believe this is a legitimate suggestion to consider.

I would very much appreciate the ability to loop and deform static meshes across curves, and / or to solidify curves into mesh cylinders. I'm suggesting a Godot equivalent for Blender's curve modifier, which can be used to map a model across a line in 2D / 3D space.

The main use for this feature would be world details such as pipes and wires: Using curves skinned with mesh segments, you can more easily add wiring and plumbing to a room! The ability would also be useful for mapping roads to terrain, once Godot also implements builtin support for heightmaps (issues #16299 #3616 #9046 etc)... this would additionally require the ability to project curves across mesh surfaces though. Lastly it would be a convenient way to create places such tunnels and sewers, by using an interior segment on a curve which steers the given tunnel.

Zireael07 commented 6 years ago

There are more uses for a spline/curve mesh than pipes and wires. Railings/barriers... it all depends on the static mesh you use.

pgruenbacher commented 6 years ago

checkout the CSG module. it allows for extruding meshes along a path. It's pretty much exaclyt what you want I think. This is an example for raod and railings: https://www.youtube.com/watch?v=Yvy8vQ-5O_w&t=308s

@akien-mga close?

BastiaanOlij commented 6 years ago

I second @pgruenbacher remark, the CSG module recently added to 3.1 is pretty much what you're looking for.

You can also create much of the rest of the logic you're after. My video referenced above shows how to extrude the road from a curve, but you can easily add logic to the script to sample the heightmap at the coordinates of the points of the curve and adjust the height of each point.

MirceaKitsune commented 6 years ago

Will everything shown in that video be included with Godot 3.1 by default? That's fantastic news if so! It didn't explain whether a 3D mesh object can also be looped and bent across a curve, but it's by far good enough for most use cases.

My remaining curiosity is whether the curve will be possible to project onto other models in a given direction. Namely over terrain once the terrain module is also in. Mapping roads is going to be very tricky if you're going to have to adjust each point on the curve to try and estimate the terrain manually, especially if the ground has more roughness than the curve can normally handle.

BastiaanOlij commented 6 years ago

Yes, everything I used in that video is now part of the 3.1 release.

There isn't a mesh distortion option yet. You can do boolean operations with any mesh but no fancy bend a mesh along a curve thing. I am working on some code that may end up supporting something like that but that is still a long way off.

Adjusting the curve to follow the height of the terrain is something that you would do in code, so you would draw out the curve to get the shape of the road right, then have code run over that curve to adjust the height of each point and add additional points where needed to follow the terrain. I might attempt to build something as part of my demo when I have some time. It's all theory at this point :)

Calinou commented 4 years ago

This feature can now be achieved using the CSG module, closing.

YBPN commented 4 years ago

I wonder if this could be opened again? I don’t think the CSG module is the full answer to this proposal/feature request (“ability to map meshes across curves”). It would be still be very useful to have a curve modifier that can be applied to any mesh.

This is not the same as extrusion. As @Zireael07 says, you can take any non-curved mesh (a snake, railings, a flight of stairs, a wall...) and produce curved versions of them. Dynamically changeable curve deformations would be so useful! I was looking for something like this for an abstract-3D project I had in mind.

I found this https://github.com/TheFamousRat/MeshCurver but I haven’t tried it yet.

Calinou commented 4 years ago

@YBPN Please open a proposal on the Godot proposals repository, as this issue tracker is now meant to be used for bug reports only. Make sure to explain why CSG doesn't suit your needs in the proposal. (If you think performance might be an issue, try it in a real-world project first.)