本文整理汇总了C++中Box3类的典型用法代码示例。如果您正苦于以下问题:C++ Box3类的具体用法?C++ Box3怎么用?C++ Box3使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Box3类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 );
}
}
示例2: IntersectBox
bool Ray::IntersectBox( Box3 a_box, matrix a_mat_transform )
{
// translate by position
a_mat_transform = a_mat_transform * matrix::Translation( a_box.GetCenter() );
v3 halfsize = a_box.Size()*0.5f;
float tmin = -FLT_MAX;
float tmax = FLT_MAX;
v4 nmin;
v4 nmax;
const v4 p = a_mat_transform.w - v4(m_pos,1.0f);
for ( size_t i=0; i!=3; ++i )
{
v4 box_basis_vector = a_mat_transform[i];
const float e = dot( box_basis_vector, p );
float f = dot( box_basis_vector, v4(m_dir,0.0f) );
if ( fabs(f) > EPSILON )
{
f = 1.0f/f;
float t1 = ( e + halfsize[i] ) * f;
float t2 = ( e - halfsize[i] ) * f;
float flip = 1.f;
if ( t1 > t2 )
{
// swap
float tmp = t1;
t1 = t2;
t2 = tmp;
flip = -flip;
}
if ( t1 > tmin ) { tmin = t1; nmin = a_mat_transform[i] * flip; }
if ( t2 < tmax ) { tmax = t2; nmax =-a_mat_transform[i] * flip; }
if ( tmin > tmax ) return false;
if ( tmax < 0.f ) return false;
}
else if ( ( ( -e - halfsize[i] ) > 0.f ) ||
( ( -e + halfsize[i] ) < 0.f ) )
{
// ray parallel to the stab
return false;
}
}
if ( tmin > 0.f )
return NewHit( tmin, nmin.xyz() );
return NewHit( tmax, nmax.xyz() );
}
示例3: rangeBox
void WindObject::GetWorldBoundBox(TimeValue t, INode* inode, ViewExp* vpt, Box3& box )
{
if ( ! vpt || ! vpt->IsAlive() )
{
box.Init();
return;
}
Box3 meshBox;
Matrix3 mat = inode->GetObjectTM(t);
box.Init();
int hoopson;
pblock2->GetValue(PB_HOOPSON,t,hoopson,FOREVER);
if (hoopson)
{ float decay; pblock2->GetValue(PB_DECAY,t,decay,FOREVER);
if (decay>0.0f)
{ float range,xy; range=2.0f*(decay > 0.0f?0.6931472f / decay:0.0f);
int type;pblock2->GetValue(PB_TYPE,t,type,ivalid);
if (type==FORCE_PLANAR)
{ pblock2->GetValue(PB_DISPLENGTH,t,xy,FOREVER);
xy*=3.0f;
}
else
xy=range;
Box3 rangeBox(Point3(-xy,-xy,-range),Point3(xy,xy,range));
for(int i = 0; i < 8; i++)
box += mat * rangeBox[i];
}
}
GetLocalBoundBox(t,inode,vpt,meshBox);
for(int i = 0; i < 8; i++)
box += mat * meshBox[i];
}
示例4: a
/*
void ParticleMesherObject::GetWorldBoundBox(TimeValue t, INode * inode, ViewExp* vp, Box3& box )
{
box.Init();
Matrix3 mat = inode->GetObjectTM(t);
Point3 a(-10.0f,-10.0f,-10.0f);
Point3 b(10.0f,10.0f,10.0f);
a = a * mat;
b = b * mat;
box+= a;
box+= b;
}
void ParticleMesherObject::GetLocalBoundBox(TimeValue t, INode* inode, ViewExp* vp, Box3& box )
{
box.Init();
Point3 a(-10.0f,-10.0f,-10.0f);
Point3 b(10.0f,10.0f,10.0f);
box+= a;
box+= b;
}
*/
void ParticleMesherObject::GetDeformBBox(TimeValue t, Box3& box, Matrix3 *tm, BOOL useSel )
{
BOOL useBounds;
pblock2->GetValue(particlemesher_usecustombounds, 0, useBounds, FOREVER);
if (useBounds)
{
box.Init();
Point3 a(-10.0f,-10.0f,-10.0f);
Point3 b(10.0f,10.0f,10.0f);
pblock2->GetValue(particlemesher_customboundsa, 0, a, FOREVER);
pblock2->GetValue(particlemesher_customboundsb, 0, b, FOREVER);
if (tm)
{
a = a * *tm;
b = b * *tm;
}
box+= a;
box+= b;
if (box.IsEmpty())
SimpleObject2::GetDeformBBox(t,box,tm,useSel);
}
else
{
SimpleObject2::GetDeformBBox(t,box,tm,useSel);
}
}
示例5: IOTM
BOOL plDistributor::IConformCheck(Matrix3& l2w, int iRepNode, plMeshCacheTab& cache, int& iCache) const
{
Matrix3 OTM = IOTM(iRepNode);
Mesh* mesh = cache[iRepNode].fMesh;
Point3 dir = l2w.VectorTransform(Point3(0.f, 0.f, 1.f));
dir = FNormalize(dir);
const float kOneOverSqrt2 = 0.707107f;
Point3 scalePt(kOneOverSqrt2, kOneOverSqrt2, 0.f);
scalePt = l2w.VectorTransform(scalePt);
float maxScaledDist = fMaxConform * scalePt.Length();
Box3 bnd = mesh->getBoundingBox() * OTM;
bnd = Box3(Point3(bnd.Min().x, bnd.Min().y, -bnd.Max().z), bnd.Max());
bnd = bnd * l2w;
Tab<int32_t> faces;
IFindFaceSet(bnd, faces);
int i;
for( i = 0; i < mesh->getNumVerts(); i++ )
{
Point3 pt = mesh->getVert(i) * OTM;
pt.z = 0;
pt = pt * l2w;
Point3 projPt;
if( !IProjectVertex(pt, dir, maxScaledDist, faces, projPt) )
return false;
}
return true;
}
示例6: UpdatePatchMesh
Mesh* TriPatchObject::GetRenderMesh(TimeValue t, INode *inode, View& view, BOOL& needDelete) {
UpdatePatchMesh(t);
TessApprox tess = patch.GetProdTess();
if (tess.type == TESS_SET) {
needDelete = FALSE;
patch.InvalidateMesh(); // force this...
// temporarlily set the view tess to prod tess
TessApprox tempTess = patch.GetViewTess();
patch.SetViewTess(tess);
PrepareMesh(t);
patch.SetViewTess(tempTess);
return &patch.GetMesh();
} else {
Mesh *nmesh = new Mesh/*(mesh)*/;
Matrix3 otm = inode->GetObjectTM(t);
Box3 bbox;
GetDeformBBox(t, bbox);
tess.merge *= Length(bbox.Width())/1000.0f;
TessApprox disp = patch.GetDispTess();
disp.merge *= Length(bbox.Width())/1000.0f;
GetGTessFunction();
(*psGTessFunc)(&patch, BEZIER_PATCH, &otm, nmesh, &tess, &disp, &view, inode->GetMtl(), FALSE, FALSE);
if (tess.merge > 0.0f && patch.GetProdTessWeld())
WeldMesh(nmesh, tess.merge);
needDelete = TRUE;
return nmesh;
}
}
示例7: 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);
}
示例8: GetLocalBoundBox
void TapeHelpObject::GetLocalBoundBox(TimeValue t, INode* inode, ViewExp* vpt, Box3& box )
{
if ( ! vpt || ! vpt->IsAlive() )
{
box.Init();
return;
}
Matrix3 m = inode->GetObjectTM(t);
Point3 pt;
Point3 q[4];
float scaleFactor = vpt->NonScalingObjectSize()*vpt->GetVPWorldWidth(m.GetTrans())/(float)360.0;
box = mesh.getBoundingBox();
box.Scale(scaleFactor);
float d;
if (GetTargetPoint(t,inode,pt)) {
d = Length(m.GetTrans()-pt)/Length(inode->GetObjectTM(t).GetRow(2));
box += Point3(float(0),float(0),-d);
}
if(GetSpecLen()) {
GetLinePoints(t, q, GetLength(t) );
box += q[0];
box += q[1];
}
}
示例9: overlayBoundingBox
/******************************************************************************
* Computes the bounding box of the 3d visual viewport overlay rendered by the input mode.
******************************************************************************/
Box3 ParticleInformationInputMode::overlayBoundingBox(Viewport* vp, ViewportSceneRenderer* renderer)
{
Box3 bbox = ViewportInputMode::overlayBoundingBox(vp, renderer);
for(const auto& pickedParticle : _pickedParticles)
bbox.addBox(selectionMarkerBoundingBox(vp, pickedParticle));
return bbox;
}
示例10: GetWorldBoundBox
void TapeHelpObject::GetWorldBoundBox(TimeValue t, INode* inode, ViewExp* vpt, Box3& box )
{
if ( ! vpt || ! vpt->IsAlive() )
{
box.Init();
return;
}
int i, nv;
Matrix3 tm;
float dtarg;
Point3 pt;
Point3 q[2];
GetMat(t,inode,*vpt,tm);
nv = mesh.getNumVerts();
box.Init();
for (i=0; i<nv; i++)
box += tm*mesh.getVert(i);
if (GetTargetPoint(t,inode,pt)) {
tm = inode->GetObjectTM(t);
dtarg = Length(tm.GetTrans()-pt)/Length(tm.GetRow(2));
box += tm*Point3(float(0),float(0),-dtarg);
}
if(GetSpecLen()) {
GetLinePoints(t, q, GetLength(t) );
box += tm * q[0];
box += tm * q[1];
}
}
示例11: Box3
/******************************************************************************
* Renders the modifier's visual representation and computes its bounding box.
******************************************************************************/
Box3 SliceModifier::renderVisual(TimePoint time, ObjectNode* contextNode, SceneRenderer* renderer)
{
TimeInterval interval;
Box3 bb = contextNode->localBoundingBox(time);
if(bb.isEmpty())
return Box3();
Plane3 plane = slicingPlane(time, interval);
FloatType sliceWidth = 0;
if(_widthCtrl) sliceWidth = _widthCtrl->getFloatValue(time, interval);
ColorA color(0.8f, 0.3f, 0.3f);
if(sliceWidth <= 0) {
return renderPlane(renderer, plane, bb, color);
}
else {
plane.dist += sliceWidth / 2;
Box3 box = renderPlane(renderer, plane, bb, color);
plane.dist -= sliceWidth;
box.addBox(renderPlane(renderer, plane, bb, color));
return box;
}
}
示例12: hsGuardBegin
plLayerInterface* plLayerConverter::IConvertAngleAttenLayer(plPlasmaMAXLayer *layer,
plMaxNode *maxNode, uint32_t blendFlags,
bool preserveUVOffset, bool upperLayer)
{
hsGuardBegin( "plPlasmaMAXLayer::IConvertAngleAttenLayer" );
if( !upperLayer )
{
fErrorMsg->Set(true, maxNode->GetName(), "Angle Attenuation layers can only be used as a top layer").Show();
fErrorMsg->Set();
return nil;
}
plAngleAttenLayer* aaLay = (plAngleAttenLayer*)layer;
Box3 fade = aaLay->GetFade();
float tr0 = cosf(DegToRad(180.f - fade.Min().x));
float op0 = cosf(DegToRad(180.f - fade.Min().y));
float tr1 = cosf(DegToRad(180.f - fade.Max().x));
float op1 = cosf(DegToRad(180.f - fade.Max().y));
int loClamp = aaLay->GetLoClamp();
int hiClamp = aaLay->GetHiClamp();
int uvwSrc = aaLay->Reflect() ? plLayerInterface::kUVWReflect : plLayerInterface::kUVWNormal;
plLayer* lut = ICreateAttenuationLayer(plString::FromUtf8(layer->GetName()), maxNode, uvwSrc, tr0, op0, tr1, op1, loClamp, hiClamp);
return lut;
hsGuardEnd;
}
示例13:
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 );
}
}
示例14: while
Box3 SceneEnumProc::Bound()
{
Box3 bound;
bound.Init();
MySceneEntry *e = head;
#if _3DSMAX_VERSION >= 2013
ViewExp &vpt = i->GetViewExp(NULL);
#else
ViewExp *vpt = i->GetViewport(NULL);
#endif
while(e)
{
Box3 bb;
#if _3DSMAX_VERSION >= 2013
e->obj->GetWorldBoundBox(time, e->node, &vpt, bb);
#else
e->obj->GetWorldBoundBox(time, e->node, vpt, bb);
#endif
bound += bb;
e = e->next;
}
return bound;
}
示例15: EvalWorldState
hsBool plMaxNodeBase::Contains(const Point3& worldPt)
{
TimeValue currTime = 0;//hsConverterUtils::Instance().GetTime(GetInterface());
Object *obj = EvalWorldState(currTime).obj;
if( !obj )
return false;
Matrix3 l2w = GetObjectTM(currTime);
Matrix3 w2l = Inverse(l2w);
Point3 pt = w2l * worldPt;
if( obj->ClassID() == Class_ID(DUMMY_CLASS_ID,0) )
{
DummyObject* dummy = (DummyObject*)obj;
Box3 bnd = dummy->GetBox();
return bnd.Contains(pt);
}
if( obj->CanConvertToType(triObjectClassID) )
{
TriObject *meshObj = (TriObject *)obj->ConvertToType(currTime, triObjectClassID);
if( !meshObj )
return false;
Mesh& mesh = meshObj->mesh;
Box3 bnd = mesh.getBoundingBox();
if( !bnd.Contains(pt) )
{
if( meshObj != obj )
meshObj->DeleteThis();
return false;
}
hsBool retVal = true;
int i;
for( i = 0; i < mesh.getNumFaces(); i++ )
{
Face& face = mesh.faces[i];
Point3 p0 = mesh.verts[face.v[0]];
Point3 p1 = mesh.verts[face.v[1]];
Point3 p2 = mesh.verts[face.v[2]];
Point3 n = CrossProd(p1 - p0, p2 - p0);
if( DotProd(pt, n) > DotProd(p0, n) )
{
retVal = false;
break;
}
}
if( meshObj != obj )
meshObj->DeleteThis();
return retVal;
}
// If we can't figure out what it is, the point isn't inside it.
return false;
}