2
\$\begingroup\$

From what I can tell Godot uses Projection for 4x4 matrixes, but I see no way to generate a localtoworldmatrix from a given transform in Godot, how do I do this?

\$\endgroup\$
2

1 Answer 1

4
\$\begingroup\$

In Godot a Transform3D has no concept of local or world. They are transformations between spaces, and what those spaces are depend on how you use them.

For a concept of local or world space, we would have a Node3D. They expose two Transform3D:

  • Transform: converts from local space to parent space (i.e. local space of the parent Node3D).
  • GlobalTransform: converts from local space to world space.

Thus, if you want to convert a Vector3 from local space of a Node3D to global space (world coordinates), you can multiply like this: node.GlobalTransform * vector.

For the opposite operation (global space to local space) you can get the inverse of the transform: node.GlobalTransform.AffineInverse() * vector.

However, we rarely do it like that, because Node3D has short hands for those operations: to_global and to_local.

So, if you have a Camera3D and you want to convert a Vector3 from its local space to world space, you do this: cam.to_global(vector).

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .