Adding count in Runtime

I am trying to draw mesh for location points by adding new location to array

But i wanted to update the triangles array automatically in runtime as per the vertice added can anyone give me some suggestions

307945-sample.png

Something like this maybe:

307940-procmesh.gif

( I know you’re not trying to draw lots of little triangles, it’s just the concept… )

yea but I am trying to create single mesh that is connecting to all the points

You can’t go smaller than a triangle…

I am trying like this – Here Every vertices point and triangles are given manually

307980-sample.png

but what I am trying is whenever i add new vertices point here triangle points should be updated procedurally to draw that shape

Here i gave my points along with text doc

[link text][3]

307992-vertpoints.png

[link text][5]

I am not able to understand how to connect with previous point count or so confused :smiley:

Right, a few things:

You only every need three entries in the triangles array. You’re only every connecting 3 points, so only every need 3 entries there.

Once you have made a shape appear, for the next polygon, you need to increment the ‘section index’ on the draw call, otherwise it overwirtes your previous triangle.

I was assuming you could specify the points in any circular order, but it seems to be a bit fussy about that. Haven’t quite figured it out yet.

EDIT: Ah, I have it. The triangle order changes the way the normal is facing. If you can’t see the triangle, have a look from underneath… :wink:

Please let me know where I am going wrong here

Initially i gave 3 vertices and triangles as zero

when i call event for first time it will create a traingle
later if add new vertice and i call the event it is adding but it is not facing UP

yes when i am seeing from down that part is having material but how can i fix that
When i change to Unlit eveything is fine but problem is in Lit mode

It’s because of the normals. If you process the points clockwise you get a normal pointing one way, if you do them anti-clockwise, the normal points the other way.