本文整理汇总了C++中OBB::getAxis方法的典型用法代码示例。如果您正苦于以下问题:C++ OBB::getAxis方法的具体用法?C++ OBB::getAxis怎么用?C++ OBB::getAxis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OBB
的用法示例。
在下文中一共展示了OBB::getAxis方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: collision
bool OBB::collision(const CollisionObject * pCollisionObject, bool calculateNormal)
{
if(pCollisionObject->getCollisionType()==CollisionType_OBB)
{
OBB * pOBB = (OBB*) pCollisionObject;
for(unsigned int aIndex=0; aIndex<3; aIndex++)
{
D3DXVECTOR3 axis = mAxis[aIndex];
float min1 = 1000000.0f;
float max1 = -1000000.0f;
float min2 = 1000000.0f;
float max2 = -1000000.0f;
for(unsigned int cIndex=0; cIndex<8; cIndex++)
{
float pos = D3DXVec3Dot(&axis, &mCorners[cIndex]);// axis.x * mCorners[cIndex].x + axis.y * mCorners[cIndex].y + axis.z * mCorners[cIndex].z;
if(pos < min1)
{
min1 = pos;
}
else if(pos > max1)
{
max1 = pos;
}
}
for(unsigned int cIndex=0; cIndex<8; cIndex++)
{
D3DXVECTOR3 corner = pOBB->getCorner(cIndex);
float pos = D3DXVec3Dot(&axis, &corner);//axis.x * corner.x + axis.y * corner.y + axis.z * corner.z;
if(pos < min2)
{
min2 = pos;
}
else if(pos > max2)
{
max2 = pos;
}
}
if(max1 < min2 || min1 > max2)
{
return false;
}
}
for(unsigned int aIndex=0; aIndex<3; aIndex++)
{
D3DXVECTOR3 axis = pOBB->getAxis(aIndex);
float min1 = 1000000.0f;
float max1 = -1000000.0f;
float min2 = 1000000.0f;
float max2 = -1000000.0f;
for(unsigned int cIndex=0; cIndex<8; cIndex++)
{
float pos = D3DXVec3Dot(&axis, &mCorners[cIndex]);//axis.x * mCorners[cIndex].x + axis.y * mCorners[cIndex].y + axis.z * mCorners[cIndex].z;
if(pos < min1)
{
min1 = pos;
}
else if(pos > max1)
{
max1 = pos;
}
}
for(unsigned int cIndex=0; cIndex<8; cIndex++)
{
D3DXVECTOR3 corner = pOBB->getCorner(cIndex);
float pos = D3DXVec3Dot(&axis, &corner);//axis.x * corner.x + axis.y * corner.y + axis.z * corner.z;
if(pos < min2)
{
min2 = pos;
}
else if(pos > max2)
{
max2 = pos;
}
}
if(max1 < min2 || min1 > max2)
{
return false;
}
}
if(calculateNormal)
{
setCollisionNormal(pOBB->getCenter() - mCenter);
pOBB->setCollisionNormal(mCenter - pOBB->getCenter());
//.........这里部分代码省略.........