本文整理汇总了C++中AABB::getCorner方法的典型用法代码示例。如果您正苦于以下问题:C++ AABB::getCorner方法的具体用法?C++ AABB::getCorner怎么用?C++ AABB::getCorner使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AABB
的用法示例。
在下文中一共展示了AABB::getCorner方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getSpatialBounds
AABB AnimatedTransform::getSpatialBounds(const AABB &aabb) const {
AABB result;
if (m_tracks.size() == 0) {
for (int j=0; j<8; ++j)
result.expandBy(m_transform(aabb.getCorner(j)));
} else {
/* Compute approximate bounds */
int nSteps = 100;
AABB1 timeBounds = getTimeBounds();
Float step = timeBounds.getExtents().x / (nSteps-1);
for (int i=0; i<nSteps; ++i) {
const Transform &trafo = eval(timeBounds.min.x + step * i);
for (int j=0; j<8; ++j)
result.expandBy(trafo(aabb.getCorner(j)));
}
}
return result;
}
示例2: collision
bool Frustum::collision(const CollisionObject * pCollisionObject, bool calculateNormal)
{
calculateNormal;
if(pCollisionObject->getCollisionType()==CollisionType_Sphere)
{
Sphere * pSphere = (Sphere*) pCollisionObject;
float x = pSphere->getX();
float y = pSphere->getY();
float z = pSphere->getZ();
float r = pSphere->getR();
for(int i=0;i<6;i++)
{
if(mPlanes[i].a * x + mPlanes[i].b * y + mPlanes[i].c * z + mPlanes[i].d <= -r)
{
return false;
}
}
return true;
}
else if(pCollisionObject->getCollisionType()==CollisionType_AABB)
{
AABB * pAABB = (AABB*) pCollisionObject;
for(unsigned int j=0;j<6;j++)
{
unsigned int cornersInside = 8;
for(unsigned int i=0;i<8;i++)
{
D3DXVECTOR3 corner = pAABB->getCorner(i);
/*
if(mPlanes[j].a * corner.x + mPlanes[j].b * corner.y + mPlanes[j].c * corner.z + mPlanes[j].d <= 0)
{
cornersInside--;
}
*/
if(D3DXPlaneDotNormal(&mPlanes[j], &corner) + mPlanes[j].d <= 0)
{
cornersInside--;
}
}
if(cornersInside==0)
{
return false;
}
}
return true;
}
if(pCollisionObject->getCollisionType()==CollisionType_OBB)
{
OBB * pOBB = (OBB*)pCollisionObject;
for(unsigned int j=0;j<6;j++)
{
unsigned int cornersInside = 8;
for(unsigned int i=0; i<8; i++)
{
D3DXVECTOR3 corner = pOBB->getCorner(i);
if(D3DXPlaneDotNormal(&mPlanes[j], &corner) + mPlanes[j].d <= 0)
{
cornersInside--;
}
}
if(cornersInside==0)
{
return false;
}
}
return true;
}
return false;
}
示例3: 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());
//.........这里部分代码省略.........