如果有两个矩形图片,如何利用OBB包围盒对图形进行包围。
看着就好心塞,都没人回答我,哎。
pt1 = m_Sprite2->convertToWorldSpace(ccp(0, 0));
pt2 = m_Sprite2->convertToWorldSpace(ccp(64, 0));
pt3 = m_Sprite2->convertToWorldSpace(ccp(64, 64));
pt4 = m_Sprite2->convertToWorldSpace(ccp(0, 64));
obb2._center = Vec3(m_Sprite2->getPosition().x, m_Sprite2->getPosition().y, 0);
obb2._xAxis = Vec3(pt2.x - pt1.x, pt2.y - pt1.y, 0);
obb2._yAxis = Vec3(pt4.x - pt1.x, pt4.y - pt1.y, 0);
obb2._zAxis = Vec3(0, 0, 1);
obb2._extents = Vec3(0.5, 0.5, 1);
if (obb1.intersects(obb2))
{
MessageBox(“碰撞”, “”);
}
对于2d图形利用OBB碰撞检测,注意Z轴不能设为0.
1赞
obb对象怎么创建的?