Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Eden |
Hi, Community!
I am writing a mesh by SurfaceTool object in Godot 3.2.2. I try to set the colour of the mesh vertices and surfaces by adding a material with a colour, or by using MeshDataTool to access the vertices to change the colour. But the colour stays "Black".
The following is my simple code:
# mesh
var tmpMesh = Mesh.new()
var vertices = PoolVector3Array()
var mat = SpatialMaterial.new()
var color = Color(225,0,0,1)
var st = SurfaceTool.new()
# add color to the surface
mat.albedo_color = color
st.set_material(mat)
# draw mesh
st.begin(Mesh.PRIMITIVE_TRIANGLE_STRIP)
for v in vertices.size():
st.add_color(color)
st.add_vertex(vertices[v])
st.commit(tmpMesh)
mesh = tmpMesh
How could I fix it up?
Thank you in advance!
-Eden
var color = Color(225,0,0,1)
Note, 225 is crazy HDR bright. If you just want red, Color(1,0,0,1)
should be enough
Zylann | 2020-09-17 12:39
Thanks for the advice on coding!
Eden | 2020-09-18 08:21