[SOLVED] No material when using PRIMITIVE_TRIANGLE_STRIP

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By NullPointer

Hi try to generate procetual mesh and start with a simple cube implementation.
But i run into basic problems like coloring and texturing. It not works

here my simple code

extends MeshInstance

#export(SpatialMaterial)  var material = null

func _ready():
	var size = 5
	var vertexList = [
		Vector3(size,	size,	size),
		Vector3(-size,	size,	size),
		Vector3(size,	size,	-size),
		Vector3(-size,	size,	-size),
		Vector3(size,	-size,	size),
		Vector3(-size,	-size,	size),
		Vector3(-size,	-size,	-size),
		Vector3(size,	-size,	-size)]
	var strip  = [ 3, 2, 6, 7, 4, 2, 0, 3, 1, 6, 5, 4, 1, 0 ]
	
	var surfaceTool = SurfaceTool.new()
	surfaceTool.begin(Mesh.PRIMITIVE_TRIANGLE_STRIP)
	for surface in range(0, strip.size()):
		var vertex = vertexList[strip[surface]]
		
		surfaceTool.add_vertex( vertex)
		surfaceTool.add_color(Color(0,0,1,1))
		#surfaceTool.add_uv( Vector2(1/vertex.x, 1/vertex.y))
		#surfaceTool.add_uv2( Vector2(1/vertex.x, 1/vertex.y))	
	
	
	var material = SpatialMaterial.new()
	#material.albedo_color = Color(0,0,1,1)
	
	surfaceTool.generate_normals()
	surfaceTool.set_material(material)
	surfaceTool.index()
	
	var mesh = Mesh.new()
	surfaceTool.commit(mesh)
	set_mesh(mesh)

the loop to set the color not works, only when i set globaly the material color it works.
same for textures, what i doing wrong?

I guess is a problem of normals, after reading offical docu

void generate_normals( bool flip=false )
Generates normals from Vertices so you do not have to do it manually.

Setting "flip" true inverts resulting normals.

Requires primitive type to be set to PRIMITIVE_TRIANGLES.

Is realy only type PRIMITIVE_TRIANGLES supported?

Thanks for help

:bust_in_silhouette: Reply From: NullPointer

I find the answer by my self.

The function generate_normals of SurfaceTool works only with PRIMITIVE_TRIANGLES

void SurfaceTool::generate_normals(bool p_flip) {

	ERR_FAIL_COND(primitive != Mesh::PRIMITIVE_TRIANGLES);

So i have to create the normals by my self