本文整理汇总了C++中AABB::SetFromCorners方法的典型用法代码示例。如果您正苦于以下问题:C++ AABB::SetFromCorners方法的具体用法?C++ AABB::SetFromCorners怎么用?C++ AABB::SetFromCorners使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AABB
的用法示例。
在下文中一共展示了AABB::SetFromCorners方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
AABB <float> BEZIER::GetAABB() const
{
float maxv[3];
float minv[3];
bool havevals[6];
for (int n = 0; n < 6; n++)
havevals[n] = false;
for (int x = 0; x < 4; x++)
{
for (int y = 0; y < 4; y++)
{
MATHVECTOR<float,3> temp(points[x][y]);
//cache for bbox stuff
for ( int n = 0; n < 3; n++ )
{
if (!havevals[n])
{
maxv[n] = temp[n];
havevals[n] = true;
}
else if (temp[n] > maxv[n])
maxv[n] = temp[n];
if (!havevals[n+3])
{
minv[n] = temp[n];
havevals[n+3] = true;
}
else if (temp[n] < minv[n])
minv[n] = temp[n];
}
}
}
MATHVECTOR<float,3> bboxmin(minv[0], minv[1], minv[2]);
MATHVECTOR<float,3> bboxmax(maxv[0], maxv[1], maxv[2]);
AABB <float> box;
box.SetFromCorners(bboxmin, bboxmax);
return box;
}
示例2: Init
//----------------------------------------------------------------------------------------------------------------------------------
/// Init dynamics
//----------------------------------------------------------------------------------------------------------------------------------
void CARDYNAMICS::Init(
class SETTINGS* pSet1, class Scene* pScene1, class FluidsXml* pFluids1,
COLLISION_WORLD & world,
const MODEL & chassisModel, const MODEL & wheelModelFront, const MODEL & wheelModelRear,
const MATHVECTOR<Dbl,3> & position, const QUATERNION<Dbl> & orientation)
{
pSet = pSet1; pScene = pScene1; pFluids = pFluids1;
this->world = &world;
MATHVECTOR<Dbl,3> zero(0, 0, 0);
body.SetPosition(position);
body.SetOrientation(orientation);
body.SetInitialForce(zero);
body.SetInitialTorque(zero);
// init engine
engine.SetInitialConditions();
// init chassis
btTransform tr;
tr.setIdentity();
AABB <float> box = chassisModel.GetAABB();
for (int i = 0; i < 4; i++)
{
MATHVECTOR<float,3> wheelpos = GetLocalWheelPosition(WHEEL_POSITION(i), 0);
const MODEL * wheelmodel = &wheelModelFront;
if (i > 1) wheelmodel = &wheelModelRear;
AABB <float> wheelaabb;
float sidefactor = 1.0;
if (i == 1 || i == 3) sidefactor = -1.0;
wheelaabb.SetFromCorners(
wheelpos - wheelmodel->GetAABB().GetSize() * 0.5 * sidefactor,
wheelpos + wheelmodel->GetAABB().GetSize() * 0.5 * sidefactor);
box.CombineWith(wheelaabb);
}
/// chassis shape ---------------------------------------------------------
const MATHVECTOR<Dbl,3> verticalMargin(0, 0, 0.3);
btVector3 origin = ToBulletVector(box.GetCenter() + verticalMargin - center_of_mass);
btVector3 size = ToBulletVector(box.GetSize() - verticalMargin);
//btCompoundShape * chassisShape = new btCompoundShape(false);
#if 0
//btBoxShape * hull = new btBoxShape( btVector3(1.8,0.8,0.5) );
btBoxShape * hull = new btBoxShape( btVector3(1.7,0.7,0.3) );
tr.setOrigin(origin + btVector3(0,0,0.2));
chassisShape->addChildShape(tr, hull);
#else
/// todo: all params in .car
// y| length x- width z^ height
btScalar w = size.getX()*0.2, r = size.getZ()*0.3, h = 0.45;
/// spheres
btScalar l0 = 0.f, w0 = 0.f, h0 = 0.f;
if (coll_R > 0.f) r = coll_R; l0 = coll_Lofs;
if (coll_W > 0.f) w = coll_W; w0 = coll_Wofs;
if (coll_H > 0.f) h = coll_H; h0 = coll_Hofs;
origin = btVector3(l0, w0, h0);
btScalar r2 = r*0.6;
btScalar l1 = coll_posLfront, l2 = coll_posLback, l1m = l1*0.5, l2m = l2*0.5;
//LogO("Car shape dims: r="+toStr(r)+" w="+toStr(w)+" h="+toStr(h)+" h0="+toStr(h0));
//LogO("Car offset: x="+toStr(origin.x())+" y="+toStr(origin.y())+" z="+toStr(origin.z()));
const int numSph = 14; int i = 0;
btScalar rad[numSph]; btVector3 pos[numSph];
pos[i] = btVector3( l1 , -w, -h); rad[i] = r2; ++i; // front
pos[i] = btVector3( l1 , w, -h); rad[i] = r2; ++i;
pos[i] = btVector3( l1m, -w, -h); rad[i] = r; ++i; // front near
pos[i] = btVector3( l1m, w, -h); rad[i] = r; ++i;
pos[i] = btVector3( l2m, -w, -h); rad[i] = r; ++i; // rear near
pos[i] = btVector3( l2m, w, -h); rad[i] = r; ++i;
pos[i] = btVector3( l2 , -w, -h); rad[i] = r2; ++i; // rear
pos[i] = btVector3( l2 , w, -h); rad[i] = r2; ++i;
pos[i] = btVector3( 0.4, -w*0.8, h*0.2); rad[i] = r2; ++i; // top
pos[i] = btVector3( 0.4, w*0.8, h*0.2); rad[i] = r2; ++i;
pos[i] = btVector3(-0.3, -w*0.8, h*0.4); rad[i] = r2; ++i;
pos[i] = btVector3(-0.3, w*0.8, h*0.4); rad[i] = r2; ++i;
pos[i] = btVector3(-1.1, -w*0.8, h*0.2); rad[i] = r2; ++i; // top rear
pos[i] = btVector3(-1.1, w*0.8, h*0.2); rad[i] = r2; ++i;
for (i=0; i < numSph; ++i)
pos[i] += origin;
btMultiSphereShape* chassisShape = new btMultiSphereShape(pos, rad, numSph);
//chassisShape->setMargin(0.2f);
#endif
//.........这里部分代码省略.........