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?

in Engine by (26 points)

1 Answer

+1 vote
Best answer

Omg, i solved!


var bounds = myMeshInstance.get_aabb()
by (26 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.