本文整理汇总了C++中AABB::extent方法的典型用法代码示例。如果您正苦于以下问题:C++ AABB::extent方法的具体用法?C++ AABB::extent怎么用?C++ AABB::extent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AABB
的用法示例。
在下文中一共展示了AABB::extent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fitmesh
bool VolMeshIO::fitmesh(VolMesh* vm, const AABB& toBox) {
if(!toBox.isValid())
return false;
AABB curBox = vm->computeAABB();
vec3f s = vec3f::div(toBox.extent(), curBox.extent());
double minScaleFactor = MATHMIN(MATHMIN(s.x, s.y), s.z);
vec3d scale(minScaleFactor);
vec3f t = toBox.lower() - curBox.lower();
vec3d translate(t.x, t.y, t.z);
//first translate all nodes
for(U32 i=0; i < vm->countNodes(); i++) {
NODE& p = vm->nodeAt(i);
//translate
p.pos = p.pos + translate;
p.restpos = p.restpos + translate;
//scale
p.pos = p.pos * minScaleFactor;
p.restpos = p.restpos * minScaleFactor;
}
return true;
}
示例2: add
void AABBRenderer::add(const AABB& aabb) {
AABBData data;
data.middle = aabb.middle();
data.extent = aabb.extent();
m_aabbs.push_back(data);
}
示例3: sweptCCD
bool PhysicsCollision::sweptCCD(vector<AABB*> boxes, Octree* octree, float &timeOfImpact)
{
/******************************************************
* Function Name: sweptCCD()
* Programmer: Josh Archer
*
* Determines if there was a collision at any point
* between the previous position and current position
* of two AABB's.
*
* Also assigns a normalized time of impact value
* to pass-by-reference parameter "timeOfImpact"
*
******************************************************/
vector<AABBPair> bps;
bool collisionOccurred = false;
_octree->potentialBoxBoxCollision(bps, boxes, octree);
for(unsigned int i = 0; i < bps.size(); i++)
{
_octree->add(boxes[i]);
AABBPair bp = bps[i];
AABB* boxA = bp.aabb1;
AABB* boxB = bp.aabb2;
//Check if box A and box B were already overlapping in their previous positions:
D3DXVECTOR3 AB_separation = boxA->centerPointPrevious - boxB->centerPointPrevious;
if( (fabs(AB_separation.x) <= fabs(boxA->extent().x + boxB->extent().x))
&& (fabs(AB_separation.y) <= fabs(boxA->extent().y + boxB->extent().y))
&& (fabs(AB_separation.z) <= fabs(boxA->extent().z + boxB->extent().z)) )
{
//The boxes were already overlapping at their previous positions
collisionOccurred = true;
core._collisions->currentCollision.boxA_ID = boxA->ID;
core._collisions->currentCollision.boxB_ID = boxB->ID;
core._collisions->currentCollision.impactPoint.x = -FLT_MAX;
core._collisions->currentCollision.impactPoint.y = -FLT_MAX;
core._collisions->currentCollision.impactPoint.z = -FLT_MAX;
core._collisions->currentCollision.timeOfImpact = 0.0f;
core._collisions->currentCollision.boxA_movementVector = boxA->center() - boxA->centerPointPrevious;
core._collisions->currentCollision.boxB_movementVector = boxB->center() - boxB->centerPointPrevious;
core._collisions->addToList();
timeOfImpact = 0.0f;
}
//We know they weren't overlapping at thier previous positions, so let's set up for detecting potential times of impact
D3DXVECTOR3 displacementA = boxA->center() - boxA->centerPointPrevious; //Displacement of box A between previous and current positions
D3DXVECTOR3 displacementB = boxB->center() - boxB->centerPointPrevious; //Displacement of box B between previous and current positions
D3DXVECTOR3 relativeVelocity = displacementB - displacementA; //Relative velocity between box A and box B
D3DXVECTOR3 aMin = boxA->centerPointPrevious - boxA->extent(); //Previous min point of box A
D3DXVECTOR3 aMax = boxA->centerPointPrevious + boxA->extent(); //Previous max point of box A
D3DXVECTOR3 bMin = boxB->centerPointPrevious - boxB->extent(); //Previous min point of box B
D3DXVECTOR3 bMax = boxB->centerPointPrevious + boxB->extent(); //Previous max point of box B
//First time of overlap along all axes
D3DXVECTOR3 t0;
t0.x, t0.y, t0.z = 0, 0, 0;
//Last time of overlap along all axes
D3DXVECTOR3 t1;
t1.x, t1.y, t1.z = 1, 1, 1;
for(int i = 0; i < 3; i++)
{
if(i = 0)
{
//Test x axis
//Test for earliest time of impact:
if( (aMax.x < bMin.x) && (relativeVelocity.x < 0) )
{
t0.x = (aMax.x - bMin.x) / relativeVelocity.x; //Potential time of impact, normalized
}
else if( (bMax.x < aMin.x) && (relativeVelocity.x > 0) )
{
t0.x = (aMin.x - bMax.x) / relativeVelocity.x; //Potential time of impact, normalized
}
//Test for last time of impact:
if( (bMax.x > aMin.x) && (relativeVelocity.x < 0) )
{
t1.x = (aMin.x - bMax.x) / relativeVelocity.x; //Potential time of impact, normalized
}
else if( (aMax.x > bMin.x) && (relativeVelocity.x > 0) )
{
t1.x = (aMax.x - bMin.x) / relativeVelocity.x;
}
}
else if(i = 1)
{
//.........这里部分代码省略.........