-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMeshGen.gd
33 lines (24 loc) · 858 Bytes
/
MeshGen.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
tool
extends MeshInstance
export(Material) var mat
export(float) var scaleFactor = 0.10
# Due to the "tool" keyword at the top of this file
# this function already executes in the editor
func _ready():
var surfTool = SurfaceTool.new()
var mesh = Mesh.new()
surfTool.begin(Mesh.PRIMITIVE_TRIANGLES)
for z in 100:
for x in 100:
surfTool.add_vertex(Vector3(x,0,z) * scaleFactor)
surfTool.add_vertex(Vector3(x + 1,0,z) * scaleFactor)
surfTool.add_vertex(Vector3(x + 1, 0,z + 1) * scaleFactor)
surfTool.add_vertex(Vector3(x + 1, 0,z + 1) * scaleFactor)
surfTool.add_vertex(Vector3(x,0,z + 1) * scaleFactor)
surfTool.add_vertex(Vector3(x,0,z) * scaleFactor)
surfTool.generate_normals()
surfTool.index()
surfTool.commit(mesh)
surfTool.set_material(mat)
self.set_mesh(mesh)
self.set_surface_material(0, mat)