使用Box2d来翻译d3dxsprite

using Box2d to translate d3dxsprites?

本文关键字:d3dxsprite 翻译 Box2d 使用      更新时间:2023-10-16

我有一个使用directx 9c和d3dxsprite接口构建的渲染引擎。我的渲染器需要一个d3dx矩阵,我想知道如何从Box2d中获得这些信息?它不是最好的,但它从单位矩阵中呈现出来。对于我使用它的目的来说,它运行得很好,但我在将box2d集成到渲染系统中时遇到了问题。有人能帮忙吗??我想做的是从box2d中获得一个4x4矩阵,这样我就可以在b2d分解物理数学后的每一帧都在那个位置绘制精灵。

你可以试试这些:

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