|
@@ -33,26 +33,27 @@ func genMesh():
|
|
var arr = []
|
|
var arr = []
|
|
arr.resize(Mesh.ARRAY_MAX)
|
|
arr.resize(Mesh.ARRAY_MAX)
|
|
arr[Mesh.ARRAY_VERTEX] = verts
|
|
arr[Mesh.ARRAY_VERTEX] = verts
|
|
- arr[Mesh.ARRAY_TEX_UV] = genUV()
|
|
|
|
|
|
+ #arr[Mesh.ARRAY_TEX_UV] = genUV()
|
|
arr[Mesh.ARRAY_NORMAL] = genNormals(verts)
|
|
arr[Mesh.ARRAY_NORMAL] = genNormals(verts)
|
|
arr[Mesh.ARRAY_INDEX] = genIndex()
|
|
arr[Mesh.ARRAY_INDEX] = genIndex()
|
|
mesh = Mesh.new()
|
|
mesh = Mesh.new()
|
|
mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, arr)
|
|
mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, arr)
|
|
|
|
|
|
-
|
|
|
|
- var i = 0.0
|
|
|
|
- for vert in verts:
|
|
|
|
- var point = Point.instance()
|
|
|
|
- point.translate(vert)
|
|
|
|
- var mat = SpatialMaterial.new()#point.mesh.surface_get_material(0)
|
|
|
|
- mat.albedo_color = Color(i,0,0,1)
|
|
|
|
- i+=0.1
|
|
|
|
- point.mesh.surface_set_material(0,mat)
|
|
|
|
- .get_parent().add_child(point)
|
|
|
|
|
|
+ var drawBubbles = true
|
|
|
|
+ if drawBubbles:
|
|
|
|
+ var i = 0.0
|
|
|
|
+ for vert in verts:
|
|
|
|
+ var point = Point.instance()
|
|
|
|
+ point.translate(vert)
|
|
|
|
+ var mat = SpatialMaterial.new()#point.mesh.surface_get_material(0)
|
|
|
|
+ mat.albedo_color = Color(i,0,0,1)
|
|
|
|
+ i+=0.1
|
|
|
|
+ point.mesh.surface_set_material(0,mat)
|
|
|
|
+ .get_parent().add_child(point)
|
|
|
|
|
|
func genNormals(verts:PoolVector3Array):
|
|
func genNormals(verts:PoolVector3Array):
|
|
var normals = PoolVector3Array()
|
|
var normals = PoolVector3Array()
|
|
- normals.resize((resolution+1) * (resolution+1))
|
|
|
|
|
|
+ normals.resize(len(verts))
|
|
var v_idx = 0
|
|
var v_idx = 0
|
|
for vert in verts:
|
|
for vert in verts:
|
|
normals[v_idx] = vert.normalized()
|
|
normals[v_idx] = vert.normalized()
|
|
@@ -76,11 +77,11 @@ func genUV():
|
|
|
|
|
|
func genIndex():
|
|
func genIndex():
|
|
var indices = PoolIntArray()
|
|
var indices = PoolIntArray()
|
|
- indices.resize(6* ((resolution+1) * (resolution+1)))
|
|
|
|
|
|
+ indices.resize(6* ((resolution) * (resolution)))
|
|
|
|
|
|
var i_idx = 0
|
|
var i_idx = 0
|
|
- for row in range(0, resolution+1):
|
|
|
|
- for col in range(0,resolution+1):
|
|
|
|
|
|
+ for row in range(0, resolution):
|
|
|
|
+ for col in range(0,resolution):
|
|
var v_idx = row*(resolution+1)+col
|
|
var v_idx = row*(resolution+1)+col
|
|
|
|
|
|
indices[i_idx] = v_idx
|
|
indices[i_idx] = v_idx
|