0 votes

Hello, I need to know the size of a 3d object, so I was looking for some way to get the AABB. ArrayMesh unfortunately does not have.

I tried to do the following:

func get_bounds(nd):
    var mdt = MeshDataTool.new()
    var m = nd.get_mesh()
    #get surface 0 into mesh data tool
    mdt.create_from_surface(m, 0)

    var bounds = AABB()
    for vtx in range(mdt.get_vertex_count()):
        var vert=mdt.get_vertex(vtx)

        bounds = bounds.expand(nd.global_transform.xform(vert))

    return bounds

But with some simple tests I realized it doesn't work, can anyone help me?

asked Sep 25, 2019 in Engine by Ícaro Dantas de Araú (26 points)

1 Answer

+1 vote
Best answer

Omg, i solved!

Solution:

var bounds = myMeshInstance.get_aabb()
answered Sep 26, 2019 by Ícaro Dantas de Araú (26 points)
selected Sep 26, 2019 by Ícaro Dantas de Araú
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 How to use this Q&A? before posting your first questions.