-1

I have a render engine built using directx 9c and the d3dxsprite interface. My renderer takes a d3dxmatrix and i was wondering how to get that info from Box2d? Its not the best but it renders from the identity matrix. It works pretty well for what i'm using it for but im having trouble integrating box2d into my render system. Can anyone help?? What im looking to do is get a 4x4 matrix from box2d so i can draw the sprite at that location every frame after b2d chews up the physics math.

Scott Jasin
  • 117
  • 6

1 Answers1

1

You could try these:

b2Vec2 p = body->GetPosition();
p.x // x coordinate of body position
p.y // y coordinate of body position

b2Transform t = body->GetTransform();
t.q.s // sin of the rotation angle
t.q.c // cos of the rotation angle
iforce2d
  • 8,194
  • 3
  • 29
  • 40
  • Thanks! What i ended up doing was double math... (one for the body and one for the image transforms) this worked but i have to believe there is a better way. Thanks! – Scott Jasin Oct 21 '14 at 12:43