0 votes

I am having trouble generating a mesh onscreen using the SurfaceTool, would someone take a look at my code and let me know what I am doing wrong?

public override void _Ready()
    material.AlbedoColor = new Color(0.8f, 0.0f, 0.0f);
    SurfaceTool tool = new SurfaceTool();


    tool.AddUv(new Vector2(0, 0));
    tool.AddVertex(new Vector3(5, 0, 0));

    tool.AddUv(new Vector2(0.5f, 1));
    tool.AddVertex(new Vector3(0, 5, 0));

    tool.AddUv(new Vector2(1, 0));
    tool.AddVertex(new Vector3(5, 5, 0));


    mesh = tool.Commit();

    AddChild(Instance, true);
in Engine by (12 points)

Where do you create the Material? I just see that you're assigning the albedo color to some unknown variable "material".

Also try to turn culling off in the material (for testing) to avoid the tri being invisible because you look at it from the wrong side (normal-wise).

Also make sure that you've a light set up (or an environment with ambient lighting) and have the camera set up to look at the right place.

Apart from that the code looks OK.
I assume that "Instance" ist a MeshInstance that is created somewhere.

Please log in or register to answer this question.

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.
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 webmaster@godotengine.org with your username.