0 votes

I am using Godot to import a model from an .STL file in order to write a user interface for a robotic arm power washer. I have successfully displayed models with less than 1024 facets, but when they get larger, the facets with an index greater than 1024 show as transparent.

Below I show the function used to build the mesh from an array of facets. This is inside of a MeshInstance node. This node's parent is a RigidBody who's addShapes() function creates a trimesh shape and adds it to the RigidBody. I am then able to perform collisions, even with the facets that are transparent.

func setTriangles(newTriangles):
    surfTool = SurfaceTool.new()
    var mesh = Mesh.new()
    var dataTool = MeshDataTool.new()
    var material = FixedMaterial.new()
    var selectedTriangles = []
    material.set_fixed_flag(FixedMaterial.FLAG_USE_COLOR_ARRAY, true)

    for triangle in triangles:
        changeColor(triangle, selectedTriangles)

I also have an additional procedurally generated line (primitivelinestrip) using immediate geometry in an ImmediateGeometry node which shows the path of the arm. This is built after the part model, and also does not appear if the part model size is greater than 1024 facets.

I am not aware of any maximum number for immediate geometry shapes, but it looks like I am running into a wall somehow. Anyone have any ideas?

in Engine by (12 points)

1 Answer

0 votes

It looks like you're creating a new surface for every triangle. I guess a Meshcan only have 1024 surfaces? Try moving surfTool.begin(), surfTool.index() and surfTool.commit() outside the loop, so that you're only creating one surface from the set of triangles.

by (1,558 points)

That worked! Thank you!

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.