Is it possible to change a MeshInstance's point of origin?

foumfofoumfo Posts: 7Member

The title says it all. It would be very useful if we could do that

Answers

  • TwistedTwiglegTwistedTwigleg Posts: 1,043Admin

    You can change the MeshInstance's position, which would achieve effect you are looking for. You just need to change global_transform.origin or transform.origin if you want to move the MeshInstance around in 3D space through code.

    But unfortunately, I do not think there is any interface to offset a mesh from the MeshInstance node it is attached to in Godot right now.

  • foumfofoumfo Posts: 7Member
    edited December 2018

    @TwistedTwigleg said:
    You can change the MeshInstance's position, which would achieve effect you are looking for. You just need to change global_transform.origin or transform.origin if you want to move the MeshInstance around in 3D space through code.

    But unfortunately, I do not think there is any interface to offset a mesh from the MeshInstance node it is attached to in Godot right now.

    So we can't actually change a mesh's transform origin. That's inconvenient because if a MeshInstance is used as a member of a mesh library to be used in a gridmap, the placement is not as intended most of the times, especially when it comes to the Y-axis.

  • MegalomaniakMegalomaniak Posts: 1,086Admin
    Answer ✓

    parent the mesh instance to a spatial and move the mesh instance as you would like, to an extent the spatial can be handled and considered as the new/moved origin point.

  • foumfofoumfo Posts: 7Member

    @Megalomaniak said:
    parent the mesh instance to a spatial and move the mesh instance as you would like, to an extent the spatial can be handled and considered as the new/moved origin point.

    I actually had to make the spatial the parent of the mesh node in order for it to work the way I wanted it. But there is one problem: It doesn't work when it's converted to a meshLibrary.

  • foumfofoumfo Posts: 7Member
    edited December 2018

    Is it possible for a mesh with a spatial as parent to work in a gridLibrary and gridmaps?

  • MegalomaniakMegalomaniak Posts: 1,086Admin

    I hean't used gridmaps nor mesh/gridLibrary so I'm honestly not sure. Maybe someone else can answer that.

  • TwistedTwiglegTwistedTwigleg Posts: 1,043Admin

    @foumfo said:
    Is it possible for a mesh with a spatial as parent to work in a gridLibrary and gridmaps?

    I did some testing using the default shapes included with MeshInstance nodes, and unfortunately it appears to ignore the parent Spatial node and any offsets. I also tried parenting a MeshInstance node to another MeshInstance node in a GridMap/MeshLibrary, but alas it also didn't work and instead just completely ignored both nodes.

    It appears that for a GridMap/MeshLibrary, there is no way to offset the MeshInstance node. I was surprised, as I thought it would respect the offset from the parent Spatial node so long as it was not the root spatial node, but it appears that is not the case.

    Maybe this should be a feature request on the GitHub repository?

  • foumfofoumfo Posts: 7Member
    edited December 2018

    @TwistedTwigleg said:

    @foumfo said:
    Is it possible for a mesh with a spatial as parent to work in a gridLibrary and gridmaps?

    I did some testing using the default shapes included with MeshInstance nodes, and unfortunately it appears to ignore the parent Spatial node and any offsets. I also tried parenting a MeshInstance node to another MeshInstance node in a GridMap/MeshLibrary, but alas it also didn't work and instead just completely ignored both nodes.

    It appears that for a GridMap/MeshLibrary, there is no way to offset the MeshInstance node. I was surprised, as I thought it would respect the offset from the parent Spatial node so long as it was not the root spatial node, but it appears that is not the case.

    Maybe this should be a feature request on the GitHub repository?

    I even tried it with a MultiMesh. Nothing.
    Has anyone ever done this request?

  • TwistedTwiglegTwistedTwigleg Posts: 1,043Admin

    @foumfo said:

    @TwistedTwigleg said:

    @foumfo said:
    Is it possible for a mesh with a spatial as parent to work in a gridLibrary and gridmaps?

    I did some testing using the default shapes included with MeshInstance nodes, and unfortunately it appears to ignore the parent Spatial node and any offsets. I also tried parenting a MeshInstance node to another MeshInstance node in a GridMap/MeshLibrary, but alas it also didn't work and instead just completely ignored both nodes.

    It appears that for a GridMap/MeshLibrary, there is no way to offset the MeshInstance node. I was surprised, as I thought it would respect the offset from the parent Spatial node so long as it was not the root spatial node, but it appears that is not the case.

    Maybe this should be a feature request on the GitHub repository?

    I even tried it with a MultiMesh. Nothing.
    Has anyone ever done this request?

    Good to know that both GridMap and MultiMesh nodes do not seem to take parent Spatial nodes into account when converted. My guess is that in the converting process, it does not process the offset(s) from Spatial nodes.

    It seems there is one issue sort of relating to the problem, but with children of the MeshInstance node instead of the MeshInstance node itself.

    I'm not sure if the conversion from scene to MeshLibrary should be a new issue, or is a duplicate of the issue above. The issue above is more about positioning children nodes rather than the MeshInstance node itself, but on the other hand, a fix for one may fix the other.

  • foumfofoumfo Posts: 7Member

    So, in essence, the only solution are imported objects?

  • TwistedTwiglegTwistedTwigleg Posts: 1,043Admin

    @foumfo said:
    So, in essence, the only solution are imported objects?

    Unfortunately, I think so.

    Hopefully it will change in the future, but right now it seems any offsets have to be done in the 3D modeling program by changing the object’s origin prior to importing.

Sign In or Register to comment.