Godot Version
4.6
Question
I’m trying to add ints from loop into this indices variable but not sure how could I do it
for now I used print and manually copy/paste
for i in numbers_of_steps:
current_step_iteration += 1
my_vertices.push_back(Vector3(start_vector.rotated(Vector3.DOWN, rotation_degree_value/float(current_step_iteration))))
my_uvs.push_back(Vector2(0,0))
my_normals.push_back(Vector3.UP)
var a = 0
var b = 1
var c = 2
var d = 3
print(str(a + current_indices_iteration) +",", str(c + current_indices_iteration) + ",",str(b + current_indices_iteration )+ ",")
print(str(a + current_indices_iteration) +",", str( d + current_indices_iteration) + ",",str( b + current_indices_iteration) + ",")
current_indices_iteration += 1
variable I trying to assign those values is : var my_indices = PackedInt32Array()
some advice how to format it , I saw append , but should it be as first or second option .
If second then how can I format it to have “,” between int’s ?
for i in numbers_of_steps:
current_step_iteration += 1
my_vertices.push_back(Vector3(start_vector.rotated(Vector3.UP, rotation_degree_value/float(current_step_iteration))))
my_uvs.push_back(Vector2(0,0))
my_normals.push_back(Vector3.UP)
var a = 0
var b = 1
var c = 2
var d = 3
my_indices.append(a +current_indices_iteration)
my_indices.append(c +current_indices_iteration)
my_indices.append(b +current_indices_iteration)
my_indices.append(a +current_indices_iteration)
my_indices.append(d +current_indices_iteration)
my_indices.append(b +current_indices_iteration)
current_indices_iteration += 1
looks a bit ugly is a way to reformat it ?
You don’t need any indices for drawing a circle. Just don’t use index array.
1 Like
thanks .
Just wonder why one side have more points then other .
extends MeshInstance3D
func _ready() -> void:
var surface_array = []
surface_array.resize(Mesh.ARRAY_MAX)
var uvs = PackedVector2Array()
var indices = PackedInt32Array()
# circle vars
var start_vector = Vector3(1.0, 0 ,0)
var rotation_degree_value = 360
var current_step_iteration = 0
var current_indices_iteration = 0
var numbers_of_steps = 360
var my_vertices = PackedVector3Array()
var my_uvs = PackedVector2Array()
var my_normals = PackedVector3Array()
#var my_indices = PackedInt32Array()
# loop
for i in numbers_of_steps:
current_step_iteration += 1
my_vertices.push_back(Vector3(start_vector.rotated(Vector3.UP, rotation_degree_value/float(current_step_iteration))))
my_uvs.push_back(Vector2(0,0))
my_normals.push_back(Vector3.UP)
#var a = 0
#var b = 1
#var c = 2
#var d = 3
#my_indices.append(a +current_indices_iteration)
#my_indices.append(c +current_indices_iteration)
#my_indices.append(b +current_indices_iteration)
#my_indices.append(a +current_indices_iteration)
#my_indices.append(d +current_indices_iteration)
#my_indices.append(b +current_indices_iteration)
#current_indices_iteration += 1
# uv is something to figure out
#uvs = PackedVector2Array([
#Vector2(0, 0),
#Vector2(1, 0),
#Vector2(0, 1),
#Vector2(1, 1),
#])
surface_array[Mesh.ARRAY_VERTEX] = my_vertices
surface_array[Mesh.ARRAY_TEX_UV] = my_uvs
surface_array[Mesh.ARRAY_NORMAL] = my_normals
#surface_array[Mesh.ARRAY_INDEX] = my_indices
mesh.add_surface_from_arrays(Mesh.PRIMITIVE_POINTS, surface_array)
Start with small number of steps, say 32.
Rotate the same vector for the same step angle each iteration.
1 Like