本文整理汇总了C++中AABB3::size方法的典型用法代码示例。如果您正苦于以下问题:C++ AABB3::size方法的具体用法?C++ AABB3::size怎么用?C++ AABB3::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AABB3
的用法示例。
在下文中一共展示了AABB3::size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
bool Ned3DObjectManager::enforcePositions(GameObject &obj1, GameObject &obj2)
{
const AABB3 &box1 = obj1.getBoundingBox(), &box2 = obj2.getBoundingBox();
AABB3 intersectBox;
if(AABB3::intersect(box1, box2, &intersectBox))
{
// Collision: Knock back both objects
// - Kludge method: Push back on smallest dimension
Vector3 delta = intersectBox.size();
Vector3 obj1Pos = obj1.getPosition(), obj2Pos = obj2.getPosition();
if(delta.x <= delta.y)
if(delta.x <= delta.z)
{
// Push back on x
float dx = (box1.min.x < box2.min.x) ? -delta.x : delta.x;
obj1Pos.x += dx;
obj2Pos.x -= dx;
}
else
{
// Push back on z
float dz = (box1.min.z < box2.min.z) ? -delta.z : delta.z;
obj1Pos.z += dz;
obj2Pos.z -= dz;
}
else if(delta.y <= delta.z)
{
// Push back on y
float dy = (box1.min.y < box2.min.y) ? -delta.y : delta.y;
obj1Pos.y += dy;
obj2Pos.y -= dy;
}
else
{
// Push back on z
float dz = (box1.min.z < box2.min.z) ? -delta.z : delta.z;
obj1Pos.z += dz;
obj2Pos.z -= dz;
}
obj1.setPosition(obj1Pos);
obj2.setPosition(obj2Pos);
return true;
}
return false;
}
示例2: v
bool Ned3DObjectManager::enforcePositions(GameObject &obj1, GameObject &obj2)
{ // TODO: replace with http://code.google.com/p/bullet/source/browse/trunk/src/BulletCollision/NarrowPhaseCollision/btPolyhedralContactClipping.cpp HullAgainstHull for OOBBs
/*
// Bullet stuff:
btVector3 v(0.0f,0.0f,0.0f);
const btConvexPolyhedron* cP = NULL;
const btConvexPolyhedron* cP2 = NULL;
if ( obj1.colOb->getCollisionShape()->isPolyhedral() ) {
btPolyhedralConvexShape* pCS = ((btPolyhedralConvexShape*) obj1.colOb->getCollisionShape());
//pCS->initializePolyhedralFeatures();
cP = pCS->getConvexPolyhedron();
}
if (obj2.colOb->getCollisionShape()->isPolyhedral() ) {
btPolyhedralConvexShape* pCS = ((btPolyhedralConvexShape*) obj2.colOb->getCollisionShape());
//pCS->initializePolyhedralFeatures();
cP2 = pCS->getConvexPolyhedron();
}
bool collision = false;
if (cP && cP2) {
collision = btPolyhedralContactClipping::findSeparatingAxis(*cP,*cP2,
obj1.colOb->getWorldTransform(),obj2.colOb->getWorldTransform(),
v,renderCallback);
}
btVector3 v1 = obj1.colOb->getWorldTransform().getOrigin();
btVector3 v2 = obj2.colOb->getWorldTransform().getOrigin();
bool invert = false;
if (obj1.getType() == ObjectTypes::BOX || obj2.getType() == ObjectTypes::BOX) {
invert = true;
}
if (collision) {
if (!invert) {
//normal collision stuff
} else {
}
}
return collision;*/
bool invert = false;
if (obj1.getType() == ObjectTypes::BOX || obj2.getType() == ObjectTypes::BOX) {
invert = true;
}
const AABB3 &box1 = obj1.getBoundingBox(), &box2 = obj2.getBoundingBox();
AABB3 intersectBox;
if(! invert && AABB3::intersect(box1, box2, &intersectBox))
{
// Collision: Knock back both objects
// - Kludge method: Push back on smallest dimension
Vector3 delta = intersectBox.size();
Vector3 obj1Pos = obj1.getPosition(), obj2Pos = obj2.getPosition();
if(delta.x <= delta.y)
if(delta.x <= delta.z)
{
// Push back on x
float dx = (box1.min.x < box2.min.x) ? -delta.x : delta.x;
obj1Pos.x += dx;
obj2Pos.x -= dx;
}
else
{
// Push back on z
float dz = (box1.min.z < box2.min.z) ? -delta.z : delta.z;
obj1Pos.z += dz;
obj2Pos.z -= dz;
}
else if(delta.y <= delta.z)
{
// Push back on y
float dy = (box1.min.y < box2.min.y) ? -delta.y : delta.y;
obj1Pos.y += dy;
obj2Pos.y -= dy;
}
else
{
// Push back on z
float dz = (box1.min.z < box2.min.z) ? -delta.z : delta.z;
obj1Pos.z += dz;
obj2Pos.z -= dz;
}
obj1.setPPosition(obj1Pos);
obj2.setPPosition(obj2Pos);
return true;
} else if (AABB3::intersect(box1, box2, &intersectBox) ) { // inverted bounding box collision)
char* tp = (char*)malloc(sizeof(char*)*500); // allocate char
sprintf_s(tp,500,"hello world %f\n\0",box1.min.x);
//.........这里部分代码省略.........