# Trying to build a simple mesh, could I get some pointers?

Hi All!

I’m trying to create a fence in my game and I want it to follow the landscape so i was thinking of making it like this -

Only thing is I really have no idea how to do the third part, but I figure it couldn’t be that hard?? Could someone point me in the right direction here?

Thanks
Pete

How many points do you want to have? Lets say 5 as in your example

So, vertices 0-4 are your initial points. We want to add 5 more points to it, adding 2 to the Y on each point.

So, points 5-9 are now the upper points.

Now triangulation…

numberofrays is 5
count is 0 to numberofrays-1
Triangle 0 is count, count+1 and numberofrays+count
Triangle 1 is numberofrays+count, count+1 and numberofrays+count+1

Next big thing, triangulation is always counter clockwise. So all faces drawn outwards are spun in counter clockwise fashion. So 0, 1, 5 are counter clockwise

Of course it takes two triangles to make up 1 section of fence. 4 if you want to make it double sided. (just draw them clockwise.)

Next up, you will need to know UV…

There’s a section in the manual here that goes into mesh creation in some detail. The link to the page with the example is broken but has been fixed and is now available in the public beta.

I got it happening! The code probably looks a bit scary though well at least i have a better idea of how it works now.
Thanks Guys,
P.