Heightfield terrain polygon problem

I'v written a function that slices a terrain shape and ad pushes the vertices into an array, and then builds polygons for each 'slice' of terrain. Although i'm having a problem creating the actual polygons for each slice.

Take a look at the attached files to see what i mean.

I'd really appreciate it if someone could help me with this. 🙂

http://www.mediafire.com/download.php?hvdfqo2hd4l
perhaps use EdgeShapes for the terrain? it's very easy that way.

Code:
b2Body *ground = m_world->CreateBody(&bd);

b2EdgeChainDef sd;
sd.vertexCount = 250;
sd.isALoop = false;
sd.vertices = new b2Vec2[250];
for(int i = 0; i < 250; i++) {
   sd.vertices[i].x = 1250.0f - (i*10.0f);
   if(i == 0) {
      sd.vertices[i].y = -1.0f + (float)(rand()%20)/10.0f;
   } else {
       sd.vertices[i].y = sd.vertices[i-1].y + ((float)(rand()%40)/10.0f) - 2.0f;
   }
}
sd.friction = 1.0f;
sd.restitution = 0.0f;
ground->CreateShape(&sd);
possible to upload CS3 version for those who don't have CS4 yet @.@?
sorry, i forgot about a CS3 version. 😛 lol, here ya go...

http://www.mediafire.com/download.php?5y5djjq00tu
Still throws an unexcepted file error :s
ah sorry about that, i figured it out now tho. i wrote a bita code that traces a shape and splits it into sections of polygons, just doesn't support 'holes' in the shapes yet, but it does the job fine for what i need it for 😀

Original thread: https://box2d.org/forum/viewtopic.php?t=1947