7

I have a randomly generated series of EdgeShapes, as shown here:

enter image description here

My question is, how can I fill that bottom area with a texture in order to make it look like the ground?

Derek
  • 882
  • 1
  • 14
  • 36

2 Answers2

0

As suggested by someone in IRC:

Create a polyon using OpenGL and then map it 1:1 onto the Box2D shape and texture the polygon.

Derek
  • 882
  • 1
  • 14
  • 36
  • Hi! I will upvote and share if you could provide an example on this. – Kimi Feb 17 '12 at 09:01
  • I'm not to sure how to do it myself, but I would create an OpenGL shape at the same time as you create the box2D shape and give it the same variables. – Derek Feb 19 '12 at 15:52
-1

From ancient memory, and looking at the code, this can't be done with edge shapes. You can chain them together, but even then there is no self-colision, which would allow the shape to overlap itself, and be . . . what? There are no normals created, nor centroid.

This is just a guess -- it has been a while since I used box2d -- but can you create a polygon instead? You would first create the N number of points in an array, and use that array as y-values along the top to simulate ground. Then you would make each point's y-value equal it's neighboring (left or right) point's y-value over time. As the points reach the end, they are moved off the array, and a new value is moved onto the other end of the array.
Can this be done, and would this adversely affect the contact points with other objects?

iND
  • 2,663
  • 1
  • 16
  • 36