0 votes

Hi. Silly question... Using the MeshDataTool I can get a vertex's position (formerly: translation) via get_vertex().
How do I convert that position into a global transform??

Godot version 4.0 alfa 1
in Engine by (506 points)

1 Answer

0 votes
Best answer

Global according to what?
When you get a vertex from a mesh with MeshDataTool, you get the vertex relative to the model. There is no other "coordinate space" to reason with because a model alone has no parent or anything, it's just a model.

You can, however, transform it if you want the global position the vertex would have, if it was set on a MeshInstance3D for example (I assume this is what you meant?).
In which case, you can do mesh_instance_node.global_transform * vertex_position and it gives you the global position.

I'm having to assume because your question lacks details, but if you meant the global transform including the basis (orientation based on normals and tangents, not just the global position), then you'd have to obtain the normal and tangent too. In which case it would be mesh_instance.global_transform * Transform3D(Basis(tangent, normal, bitangent), vertex_position).

by (29,034 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.