To assist players, we need to display the 3D model’s appearance in 2D.
How can I unfold the faces of a 3D model into a 2D flat effect in Godot?
Is there an API that can help me quickly implement it?
Or could you provide some ideas?
Thank you.
Is this needed to happen in game, like some transition effect from the solid to the flattened version, or can you just model two versions of the asset, one as a solid and one flattened?
This can be done either by script, or by using 3D models specifically crafted for this.
If you go the script route, you need to find all triangles (assuming the mesh is triangulated) with the same normal, those are one “visual” face. Then you want to find the neighboring such faces, and rotate them around the connecting edge so that they are flat. This can be done iteratively for all faces. You may need some extra logic to decide into which direction the flat representation should grow to not intersect itself.
If you go the 3D model way, there’s several option:
shape keys
use additional data per vertex to store face adjacency information
use additional data per vertex to store the flattened position
use a skeleton with joints on the edges (this solution is really powerful and allows you to fine tune unfolding animations very nicely)
etc…
Displaying the Unfolding
This depends a bit on the approach picked to get to the flat representation, but there is basically three ways:
You’ll want to ask some more high-level questions like some I posed in a previous response, before you proceed into the solutions side as there will be many potential solutions and most not be easy to setup or implement.
What is the gameplay or demonstrative goal here?
Does it need to animate from one state to another, or just either show the solid version and/or the flattened and unfolded?
Are any parts of this interactive by the player, or just visual?
How varying are the shapes going to need to be? And how many unique shapes?
How varying are the cut patterns going to need to be? And how many unique cut patterns?
I would then ask ‘why’ after every answer given for the above or any other question, as there are many ways to do something this potentially complex, and often times the best solution is to modify the design and/or gameplay need.
Also what experience level of 3D artist, animator, programmer are you? How about experience with Godot?