本文整理汇总了C++中Box3::Center方法的典型用法代码示例。如果您正苦于以下问题:C++ Box3::Center方法的具体用法?C++ Box3::Center怎么用?C++ Box3::Center使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Box3
的用法示例。
在下文中一共展示了Box3::Center方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
Box3<Real> Wml::ContOrientedBox (int iQuantity, const Vector3<Real>* akPoint)
{
Box3<Real> kBox;
GaussPointsFit(iQuantity,akPoint,kBox.Center(),kBox.Axes(),
kBox.Extents());
// Let C be the box center and let U0, U1, and U2 be the box axes. Each
// input point is of the form X = C + y0*U0 + y1*U1 + y2*U2. The
// following code computes min(y0), max(y0), min(y1), max(y1), min(y2),
// and max(y2). The box center is then adjusted to be
// C' = C + 0.5*(min(y0)+max(y0))*U0 + 0.5*(min(y1)+max(y1))*U1 +
// 0.5*(min(y2)+max(y2))*U2
Vector3<Real> kDiff = akPoint[0] - kBox.Center();
Real fY0Min = kDiff.Dot(kBox.Axis(0)), fY0Max = fY0Min;
Real fY1Min = kDiff.Dot(kBox.Axis(1)), fY1Max = fY1Min;
Real fY2Min = kDiff.Dot(kBox.Axis(2)), fY2Max = fY2Min;
for (int i = 1; i < iQuantity; i++)
{
kDiff = akPoint[i] - kBox.Center();
Real fY0 = kDiff.Dot(kBox.Axis(0));
if ( fY0 < fY0Min )
fY0Min = fY0;
else if ( fY0 > fY0Max )
fY0Max = fY0;
Real fY1 = kDiff.Dot(kBox.Axis(1));
if ( fY1 < fY1Min )
fY1Min = fY1;
else if ( fY1 > fY1Max )
fY1Max = fY1;
Real fY2 = kDiff.Dot(kBox.Axis(2));
if ( fY2 < fY2Min )
fY2Min = fY2;
else if ( fY2 > fY2Max )
fY2Max = fY2;
}
kBox.Center() += (((Real)0.5)*(fY0Min+fY0Max))*kBox.Axis(0) +
(((Real)0.5)*(fY1Min+fY1Max))*kBox.Axis(1) +
(((Real)0.5)*(fY2Min+fY2Max))*kBox.Axis(2);
kBox.Extent(0) = ((Real)0.5)*(fY0Max - fY0Min);
kBox.Extent(1) = ((Real)0.5)*(fY1Max - fY1Min);
kBox.Extent(2) = ((Real)0.5)*(fY2Max - fY2Min);
return kBox;
}
示例2: TestIntersection
//----------------------------------------------------------------------------
bool Mgc::TestIntersection (const Line3& rkLine, const Box3& rkBox)
{
Real fAWdU[3], fAWxDdU[3], fRhs;
Vector3 kDiff = rkLine.Origin() - rkBox.Center();
Vector3 kWxD = rkLine.Direction().Cross(kDiff);
fAWdU[1] = Math::FAbs(rkLine.Direction().Dot(rkBox.Axis(1)));
fAWdU[2] = Math::FAbs(rkLine.Direction().Dot(rkBox.Axis(2)));
fAWxDdU[0] = Math::FAbs(kWxD.Dot(rkBox.Axis(0)));
fRhs = rkBox.Extent(1)*fAWdU[2] + rkBox.Extent(2)*fAWdU[1];
if ( fAWxDdU[0] > fRhs )
return false;
fAWdU[0] = Math::FAbs(rkLine.Direction().Dot(rkBox.Axis(0)));
fAWxDdU[1] = Math::FAbs(kWxD.Dot(rkBox.Axis(1)));
fRhs = rkBox.Extent(0)*fAWdU[2] + rkBox.Extent(2)*fAWdU[0];
if ( fAWxDdU[1] > fRhs )
return false;
fAWxDdU[2] = Math::FAbs(kWxD.Dot(rkBox.Axis(2)));
fRhs = rkBox.Extent(0)*fAWdU[1] + rkBox.Extent(1)*fAWdU[0];
if ( fAWxDdU[2] > fRhs )
return false;
return true;
}
示例3: GetSubObjectTMs
void EditFaceDataMod::GetSubObjectTMs (SubObjAxisCallback *cb,TimeValue t,INode *node,ModContext *mc) {
if (!mc->localData) return;
if (selLevel == SEL_OBJECT) return; // shouldn't happen.
EditFaceDataModData *modData = (EditFaceDataModData *) mc->localData;
Mesh *mesh = modData->GetCacheMesh();
MNMesh *mnmesh = modData->GetCacheMNMesh();
if (!mesh && !mnmesh) return;
Matrix3 tm = node->GetObjectTM(t);
Box3 box;
if (mesh) {
BitArray sel = mesh->VertexTempSel ();
if (!sel.NumberSet()) return;
for (int i=0; i<mesh->numVerts; i++) if (sel[i]) box += mesh->verts[i] * tm;
} else {
int numSel, which;
float value;
bool valueDetermined;
modData->DescribeSelection (numSel, which, value, valueDetermined);
if (!numSel) return;
if (numSel==1) {
for (int j=0; j<mnmesh->f[which].deg; j++) box += mnmesh->P(mnmesh->f[which].vtx[j]) * tm;
} else {
for (int i=0; i<mnmesh->numf; i++) {
if (mnmesh->f[i].GetFlag (MN_DEAD)) continue;
if (!modData->GetFaceSel()[i]) continue;
for (int j=0; j<mnmesh->f[i].deg; j++) box += mnmesh->P(mnmesh->f[i].vtx[j]) * tm;
}
}
}
Matrix3 ctm(1);
ctm.SetTrans (box.Center());
cb->TM (ctm,0);
}
示例4:
void plRTProjDirLight::GetLocalBoundBox( TimeValue t, INode *node, ViewExp *vpt, Box3 &box )
{
Point3 loc = node->GetObjectTM( t ).GetTrans();
float scaleFactor = vpt->NonScalingObjectSize() * vpt->GetVPWorldWidth( loc ) / 360.0f;
float width, height, depth;
box = fMesh.getBoundingBox();
// Because we want to scale about the origin, not the box center, we have to do this funky offset
Point3 boxCenter = box.Center();
box.Translate( -boxCenter );
box.Scale( scaleFactor );
boxCenter *= scaleFactor;
box.Translate( boxCenter );
if( ( extDispFlags & EXT_DISP_ONLY_SELECTED ) )
{
fProjPB->GetValue( kWidth, t, width, FOREVER );
fProjPB->GetValue( kHeight, t, height, FOREVER );
fProjPB->GetValue( kRange, t, depth, FOREVER );
width /= 2.f;
height /= 2.f;
box += Point3( -width, -height, 0.f );
box += Point3( width, height, -depth );
}
}
示例5: BuildColBox
void bhkProxyObject::BuildColBox()
{
Box3 box; box.Init();
for (int i = 0;i < pblock2->Count(PB_MESHLIST); i++) {
INode *tnode = NULL;
pblock2->GetValue(PB_MESHLIST,0,tnode,FOREVER,i);
if (tnode)
{
ObjectState os = tnode->EvalWorldState(0);
Matrix3 wm = tnode->GetNodeTM(0);
TriObject *tri = (TriObject *)os.obj->ConvertToType(0, Class_ID(TRIOBJ_CLASS_ID, 0));
if (tri)
{
Box3 box2; box2.Init();
Mesh& mesh = tri->GetMesh();
CalcAxisAlignedBox(mesh, box2, &wm);
box += box2;
}
}
}
BuildBox(proxyMesh, box.Max().y-box.Min().y, box.Max().x-box.Min().x, box.Max().z-box.Min().z);
MNMesh mn(proxyMesh);
Matrix3 tm(true);
tm.SetTranslate(box.Center());
mn.Transform(tm);
mn.OutToTri(proxyMesh);
//proxyPos = box.Center();
proxyPos = Point3::Origin;
forceRedraw = true;
}
示例6: GetAtten
void plRTSpotLight::GetLocalBoundBox( TimeValue t, INode *node, ViewExp *vpt, Box3 &box )
{
Point3 loc = node->GetObjectTM( t ).GetTrans();
float scaleFactor = vpt->NonScalingObjectSize() * vpt->GetVPWorldWidth( loc ) / 360.0f;
float width, depth;
box = fMesh.getBoundingBox();
// Because we want to scale about the origin, not the box center, we have to do this funky offset
Point3 boxCenter = box.Center();
box.Translate( -boxCenter );
box.Scale( scaleFactor );
boxCenter *= scaleFactor;
box.Translate( boxCenter );
// Include points for the spotlight. That means either the attenuated cone or
// our unattenuated cone display
if( ( extDispFlags & EXT_DISP_ONLY_SELECTED ) )
{
if( GetUseAtten() )
depth = GetAtten( t, ATTEN_END );
else
depth = 100.f + 50.f; // Include arrows
width = depth * tan( DegToRad( GetFallsize( t ) / 2.f ) );
box += Point3( -width, -width, 0.f );
box += Point3( width, width, -depth );
}
}
示例7:
static inline void normalizeBox3(const Box3& target, const Box3& env, Box3& output)
{
auto scale = env.Diagonal();
auto center = env.Center();
output.Set((target.Min()-center)/scale*2.0,
(target.Max()-center)/scale*2.0);
}
示例8: FindIntersection
//----------------------------------------------------------------------------
bool Mgc::FindIntersection (const Segment3& rkSegment, const Box3& rkBox,
int& riQuantity, Vector3 akPoint[2])
{
// convert segment to box coordinates
Vector3 kDiff = rkSegment.Origin() - rkBox.Center();
Vector3 kOrigin(
kDiff.Dot(rkBox.Axis(0)),
kDiff.Dot(rkBox.Axis(1)),
kDiff.Dot(rkBox.Axis(2))
);
Vector3 kDirection(
rkSegment.Direction().Dot(rkBox.Axis(0)),
rkSegment.Direction().Dot(rkBox.Axis(1)),
rkSegment.Direction().Dot(rkBox.Axis(2))
);
Real fT0 = 0.0f, fT1 = 1.0f;
bool bIntersects = FindIntersection(kOrigin,kDirection,rkBox.Extents(),
fT0,fT1);
if ( bIntersects )
{
if ( fT0 > 0.0f )
{
if ( fT1 < 1.0f )
{
riQuantity = 2;
akPoint[0] = rkSegment.Origin() + fT0*rkSegment.Direction();
akPoint[1] = rkSegment.Origin() + fT1*rkSegment.Direction();
}
else
{
riQuantity = 1;
akPoint[0] = rkSegment.Origin() + fT0*rkSegment.Direction();
}
}
else // fT0 == 0
{
if ( fT1 < 1.0f )
{
riQuantity = 1;
akPoint[0] = rkSegment.Origin() + fT1*rkSegment.Direction();
}
else // fT1 == 1
{
// segment entirely in box
riQuantity = 0;
}
}
}
else
{
riQuantity = 0;
}
return bIntersects;
}
示例9: BuildColBox
void bhkRigidBodyModifier::BuildColBox(Mesh& mesh)
{
Box3 box; box.Init();
CalcAxisAlignedBox(mesh, box, NULL);
BuildBox(mesh, box.Max().y-box.Min().y, box.Max().x-box.Min().x, box.Max().z-box.Min().z);
MNMesh mn(mesh);
Matrix3 tm(true);
tm.Translate(box.Center());
mn.Transform(tm);
mn.OutToTri(mesh);
}
示例10: InBox
bool Wml::InBox (const Vector3<Real>& rkPoint, const Box3<Real>& rkBox,
Real fEpsilon)
{
Vector3<Real> kDiff = rkPoint - rkBox.Center();
for (int i = 0; i < 3; i++)
{
Real fCoeff = kDiff.Dot(rkBox.Axis(i));
if ( Math<Real>::FAbs(fCoeff) > rkBox.Extent(i) + fEpsilon )
return false;
}
return true;
}
示例11: BoxProjection
void Wml::BoxProjection (const Vector3<Real>& rkAxis,
const Box3<Real>& rkBox, Real& rfMin, Real& rfMax)
{
Real fOrigin = rkAxis.Dot(rkBox.Center());
Real fMaximumExtent =
Math<Real>::FAbs(rkBox.Extent(0)*rkAxis.Dot(rkBox.Axis(0))) +
Math<Real>::FAbs(rkBox.Extent(1)*rkAxis.Dot(rkBox.Axis(1))) +
Math<Real>::FAbs(rkBox.Extent(2)*rkAxis.Dot(rkBox.Axis(2)));
rfMin = fOrigin - fMaximumExtent;
rfMax = fOrigin + fMaximumExtent;
}
示例12: Culled
bool Wml::Culled (const Plane3<Real>& rkPlane, const Box3<Real>& rkBox)
{
Real fTmp[3] =
{
rkBox.Extent(0)*(rkPlane.GetNormal().Dot(rkBox.Axis(0))),
rkBox.Extent(1)*(rkPlane.GetNormal().Dot(rkBox.Axis(1))),
rkBox.Extent(2)*(rkPlane.GetNormal().Dot(rkBox.Axis(2)))
};
Real fRadius = Math<Real>::FAbs(fTmp[0]) + Math<Real>::FAbs(fTmp[1]) +
Math<Real>::FAbs(fTmp[2]);
Real fPseudoDistance = rkPlane.DistanceTo(rkBox.Center());
return fPseudoDistance <= -fRadius;
}
示例13: PlanarMapNoScale
void MeshTopoData::PlanarMapNoScale(Point3 gNormal, UnwrapMod *mod )
{
Matrix3 gtm;
mod->UnwrapMatrixFromNormal(gNormal,gtm);
gtm = Inverse(gtm);
BitArray tempVSel;
DetachFromGeoFaces(mFSel, tempVSel, mod);
TimeValue t = GetCOREInterface()->GetTime();
Box3 bounds;
bounds.Init();
for (int i = 0; i < TVMaps.v.Count(); i++)
{
if (tempVSel[i])
{
bounds += TVMaps.v[i].GetP();
}
}
Point3 gCenter = bounds.Center();
for (int i = 0; i < TVMaps.v.Count(); i++)
{
if (tempVSel[i])
{
TVMaps.v[i].SetFlag(0);
TVMaps.v[i].SetInfluence(0.0f);
Point3 tp = TVMaps.v[i].GetP() - gCenter;
tp = tp * gtm;
tp.z = 0.0f;
SetTVVert(t,i,tp,mod);
}
}
mVSel = tempVSel;
}
示例14: MinimalBoxForAngles
//----------------------------------------------------------------------------
static void MinimalBoxForAngles (int iQuantity, const Vector3* akPoint,
Real afAngle[3], Box3& rkBox)
{
Real fCos0 = Math::Cos(afAngle[0]);
Real fSin0 = Math::Sin(afAngle[0]);
Real fCos1 = Math::Cos(afAngle[1]);
Real fSin1 = Math::Sin(afAngle[1]);
Vector3 kAxis(fCos0*fSin1,fSin0*fSin1,fCos1);
Matrix3 kRot;
kRot.FromAxisAngle(kAxis,afAngle[2]);
Vector3 kMin = akPoint[0]*kRot, kMax = kMin;
for (int i = 1; i < iQuantity; i++)
{
Vector3 kTest = akPoint[i]*kRot;
if ( kTest.x < kMin.x )
kMin.x = kTest.x;
else if ( kTest.x > kMax.x )
kMax.x = kTest.x;
if ( kTest.y < kMin.y )
kMin.y = kTest.y;
else if ( kTest.y > kMax.y )
kMax.y = kTest.y;
if ( kTest.z < kMin.z )
kMin.z = kTest.z;
else if ( kTest.z > kMax.z )
kMax.z = kTest.z;
}
Vector3 kMid = 0.5f*(kMax + kMin);
Vector3 kRng = 0.5f*(kMax - kMin);
rkBox.Center() = kRot*kMid;
rkBox.Axis(0) = kRot.GetColumn(0);
rkBox.Axis(1) = kRot.GetColumn(1);
rkBox.Axis(2) = kRot.GetColumn(2);
rkBox.Extent(0) = kRng.x;
rkBox.Extent(1) = kRng.y;
rkBox.Extent(2) = kRng.z;
}
示例15: if
void MinBox3<Real>::MinimalBoxForAngles (int iQuantity,
const Vector3<Real>* akPoint, Real afAngle[3], Box3<Real>& rkBox)
{
Real fCos0 = Math<Real>::Cos(afAngle[0]);
Real fSin0 = Math<Real>::Sin(afAngle[0]);
Real fCos1 = Math<Real>::Cos(afAngle[1]);
Real fSin1 = Math<Real>::Sin(afAngle[1]);
Vector3<Real> kAxis(fCos0*fSin1,fSin0*fSin1,fCos1);
Matrix3<Real> kRot(kAxis,afAngle[2]);
Vector3<Real> kMin = akPoint[0]*kRot, kMax = kMin;
for (int i = 1; i < iQuantity; i++)
{
Vector3<Real> kTest = akPoint[i]*kRot;
if ( kTest.X() < kMin.X() )
kMin.X() = kTest.X();
else if ( kTest.X() > kMax.X() )
kMax.X() = kTest.X();
if ( kTest.Y() < kMin.Y() )
kMin.Y() = kTest.Y();
else if ( kTest.Y() > kMax.Y() )
kMax.Y() = kTest.Y();
if ( kTest.Z() < kMin.Z() )
kMin.Z() = kTest.Z();
else if ( kTest.Z() > kMax.Z() )
kMax.Z() = kTest.Z();
}
Vector3<Real> kMid = ((Real)0.5)*(kMax + kMin);
Vector3<Real> kRng = ((Real)0.5)*(kMax - kMin);
rkBox.Center() = kRot*kMid;
rkBox.Axis(0) = kRot.GetColumn(0);
rkBox.Axis(1) = kRot.GetColumn(1);
rkBox.Axis(2) = kRot.GetColumn(2);
rkBox.Extent(0) = kRng.X();
rkBox.Extent(1) = kRng.Y();
rkBox.Extent(2) = kRng.Z();
}