OK so in order to add graphics to bodies, I would have to create the graphic, then move it with the bodies, right?
So how would I do this? Should I create a body list, then for every body, draw something. And then how would I draw it, I've read about using openGL witch seems to be my best bet, but I cant find a tutorial on image rendering. Can anyone help me?
This really has very little to do with Box2d, so you'll have more success asking in a graphics related forum on a site like gamedev.net. The answer really depends on what you want to do. Are you on windows, mac, linux? Do you want vector type graphics or images? Are you using a library like SFML or Haaf's game engine or an api like directX, OpenGL, or XNA. Once you answer all those questions, just google for basic tutorials.
Right. Ok so first of all I'm on a mac, and I'm going to use simple tiextures for my objects using openGL. So do you think that I should just add the texture in the debut draw or do I have to make a whole new system using body lists. If I used the bodie lists, would I put it in the display function?
Thanks for the help,
Kcaz
Keep things out of the debug draw. How is your game "engine" organized? I would just keep references to your bodies and/or shapes. Then, in your game loop, render each entity based on its body location (accounting for translation to screen coordinates of course). Box2D is called by your game engine, it's not the engine itself.
For example, I have something akin to a BulletManager/Factory. When a Bullet is needed, its initialization includes creating the Box2D body, position and velocities are set. I keep references to these objects around, in the Bullet class. In the game loop, the Box2D world is updated, and the BulletManager is responsible then for rendering each active Bullet, obtaining such necessary information such as position and orientation from the Bullet object itself.
Bill
Ok thanks I think that helped. The only thing I'm wondering is how to render the image. Do you add it as a texture? Or add it some other way?
Someone has to know...how do you create an image using openGL and attach it to a body?
In OpenGL you would render the image as a texture, yes.
Per my IM, you would get the position of the body (or shape) that the texture represents. From that location, you derive the vertex coordinates, and along with the texture coordinates send those down the OpenGL pipeline.
If this is where you're stuck, you might try an OpenGL forum. It's not really appropriate (beyond body/shape position and scaling) to get rendering "how to" advice here.
Bill
OK that makes lots of sense, I was just about to go learn how to texture something :p
Thanks,
Kcaz