# HG changeset patch # User sam # Date 1713029644 -25200 # Node ID 2f92d7e8059745ad4c91ba35f826aa2494bd166e # Parent 892aa207a5b03038087542e2b2bc8baa9c1519d5 add: temporary helper function, maybe need to do this better anyways diff -r 892aa207a5b0 -r 2f92d7e80597 semicongine/mesh.nim --- a/semicongine/mesh.nim Sat Apr 13 21:31:40 2024 +0700 +++ b/semicongine/mesh.nim Sun Apr 14 00:34:04 2024 +0700 @@ -515,6 +515,20 @@ result[].initVertexAttribute("uv", uv) `material=`(result[], material) +proc circleMesh*(width = 1'f32, height = 1'f32, nSegments = 12): (seq[Vec3f], seq[array[3, uint16]]) = + assert nSegments >= 3 + result[0] = newSeq[Vec3f](3 + nSegments) + + let + rX = width / 2 + rY = height / 2 + step = (2'f32 * PI) / float32(nSegments) + result[0][0] = newVec3f(0, 0) + result[0][1] = newVec3f(rX, 0) + for i in 1 .. nSegments: + result[0][i + 1] = newVec3f(cos(float32(i) * step) * rX, sin(float32(i) * step) * rY) + result[1].add [uint16(0), uint16(i), uint16(i + 1)] + proc grid*(columns, rows: uint16, cellSize = 1.0'f32, color = "ffffffff", material = EMPTY_MATERIAL.initMaterialData()): Mesh = result = Mesh(