コード例 #1
0
void CCTDebugData::addAABB(const NxBounds3& bounds, NxU32 color, bool renderFrame)
{
	// Reuse OBB code...
	NxVec3 center;	bounds.getCenter(center);
	NxVec3 extents;	bounds.getExtents(extents);
	NxMat33 id;	id.id();
	addOBB(NxBox(center, extents, id), color, renderFrame);
}
コード例 #2
0
//-----------------------------------------------------------------------------
//  CalcBBox
//-----------------------------------------------------------------------------
NxBox   CPhysicModelSimple::CalcBBox (void) const
{
    NxBounds3   bounds;
    for (int i = 0; i < (int)m_ActorDesc.shapes.size(); i++)
    {
        NxShapeDesc* pShapeDesc = m_ActorDesc.shapes[i];
        switch (pShapeDesc->getType())
        {
            case NX_SHAPE_BOX:
			{
				NxBoxShapeDesc* pBoxShape = (NxBoxShapeDesc*) pShapeDesc;
				NxBox shapeBBox (pBoxShape->localPose.t, pBoxShape->dimensions, pBoxShape->localPose.M);
				NxBounds3 shapeBounds;
				shapeBounds.boundsOfOBB( shapeBBox.rot, shapeBBox.center, shapeBBox.extents );
				bounds.combine (shapeBounds);
			}
            break;
            case NX_SHAPE_SPHERE:
			{
				NxSphereShapeDesc* pSphereShape = (NxSphereShapeDesc*) pShapeDesc;
				NxBox shapeBBox (pSphereShape->localPose.t, NxVec3(pSphereShape->radius), pSphereShape->localPose.M);
				NxBounds3 shapeBounds;
				shapeBounds.boundsOfOBB( shapeBBox.rot, shapeBBox.center, shapeBBox.extents );
				bounds.combine (shapeBounds);
			}
            break;
            default:
                // Caso no soportado
                assert(0);
            break;
        }
    }

    NxBox   result;
    bounds.getCenter (result.center);
    bounds.getExtents (result.extents);
    return result;
}