예제 #1
0
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];
    }
}
예제 #2
0
파일: wind.cpp 프로젝트: artemeliy/inf4715
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];
}
int MorphByBone::GetMirrorBone(int id)
{

	int whichBone = 0;
	if (id == -1)
		whichBone = currentBone;
	else whichBone = id;

//make sure it is a valid node
	if ((whichBone < 0) || (whichBone >= boneData.Count()) 	)
			{
			return -1;
			}
	if (GetNode(whichBone) == NULL) return -1;


	Matrix3 itm = Inverse(localDataList[0]->selfObjectTM);

	Point3 mirrorMin, mirrorMax;

	Box3 mbox;
	mbox.Init();
	mbox += boneData[whichBone]->localBounds.pmin * boneData[whichBone]->currentBoneObjectTM * itm;
	mbox += boneData[whichBone]->localBounds.pmax * boneData[whichBone]->currentBoneObjectTM * itm;
	
	mirrorMin = mbox.pmin;
	mirrorMax = mbox.pmax;


	int closestBone = -1;
	float closestDist = 0.0f;
	for (int i = 0; i < boneData.Count(); i++)
		{
		INode *node = GetNode(i);
		if (node)
			{
			Box3 box;
			box.Init();
			box += boneData[i]->localBounds.pmin * boneData[i]->currentBoneObjectTM * itm * mirrorTM;
			box += boneData[i]->localBounds.pmax * boneData[i]->currentBoneObjectTM * itm * mirrorTM;
			Point3 min, max;

			min = box.pmin;// * boneData[i]->currentBoneObjectTM * itm * mirrorTM;
			max = box.pmax;// * boneData[i]->currentBoneObjectTM * itm * mirrorTM;

			float dist = Length(mirrorMin - min) + Length(mirrorMax - max);

			if ((closestBone == -1) || (dist < closestDist))
				{
				closestBone = i;
				closestDist = dist;
				}
			}
		}
	return closestBone;

}
예제 #4
0
void BendManip::GetLocalBoundBox(TimeValue t, INode* inode, ViewExp* vp,  Box3& box )
{
	if ( ! vp || ! vp->IsAlive() )
	{
		box.Init();
		return;
	}

	if(inode == NULL)
		return;

	ModContext* mc = FindModContext( inode, modifier );
	
	if( mc==NULL ) 
		return;

	Interval valid;

  if (!vp)
		vp = GetCOREInterface()->GetActiveViewExp().ToPointer();

	if ( ! vp || ! vp->IsAlive() )
	{
		box.Init();
		return;
	}


	GraphicsWindow *gw = vp->getGW();

	Matrix3 modmat, ntm = inode->GetObjTMBeforeWSM(t), off, invoff;

	if (mc->box->IsEmpty()) {
		return;
	}

	//Lets get the Modifier do all the work here

	modmat = modifier->CompMatrix(t,*mc,ntm,valid,FALSE);
	modifier->CompOffset(t,off,invoff);	
	BoxLineProc bp1(&modmat);	
	DoModifiedBox(*mc->box, modifier->GetDeformer(t,*mc,invoff,off), bp1);
	box = bp1.Box();

	box = *(mc->box);

	Eval(t);

}
예제 #5
0
//Get a bounding box.  This is used for when we display the formation continously.
void FormationBhvr::GetWorldBoundBox(TimeValue t, ViewExp *vpt, Box3& box)
{
	if ( ! vpt || ! vpt->IsAlive() )
	{
		box.Init();
		return;
	}

	//make sure we have everything we need...
	if(DisplayFormation(t)==FALSE) return;
	if(GetFollowerCount(t)<=0) return;
	if(GetFollowerMatrixCount(t)<=0) return; //possible to not have this set when the follower is set..

	INode *leaderNode;
	leaderNode = GetLeader(t);
	if(leaderNode==NULL) return;



	//for each follower we need to increase the bounding box by it's
	//world position location...
	for(int i =0;i<GetFollowerCount(t);i++)
	{
		if(GetFollower(t,i)) //if we have a a node...
		{
			Matrix3 worldSpace = GetFollowerMatrix(t,i)*GetCurrentMatrix(leaderNode,t);
			Point3 trans(worldSpace.GetTrans());
			//expand the box by the worldposition...
			box += trans;
		}
	}
}
예제 #6
0
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];
    }
}
예제 #7
0
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;
}
예제 #8
0
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;
}
예제 #9
0
void TriObject::GetDeformBBox(TimeValue t, Box3& box, Matrix3 *tm, BOOL useSel ) 
	{	
	if ( tm || useSel ) {
		box.Init();
		BitArray sel;
		BitArray vhide;
		float *vssel = NULL;
		if ( useSel ) {
			sel = mesh.VertexTempSel();
			vssel = mesh.getVSelectionWeights ();
		} else {
			vhide = mesh.vertHide;
			if (vhide.NumberSet ()) {
				for (int i=0; i<mesh.getNumFaces(); i++) {
					if (mesh.faces[i].Hidden ()) continue;
					for (int j=0; j<3; j++) vhide.Clear (mesh.faces[i].v[j]);
				}
			}
			}
		for ( int i = 0; i < mesh.getNumVerts(); i++ ) {
			if (!useSel && vhide[i]) continue;
			if ( !useSel || sel[i] || (vssel&&vssel[i])) {
				if ( tm ) {
					box += *tm * mesh.getVert(i);
				} else {
					box += mesh.getVert(i);
					}
				}
			}
	} else {
		box = mesh.getBoundingBox();
		}
	}
예제 #10
0
/*
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);
      }

   }
예제 #11
0
void PointHelpObject::GetWorldBoundBox(
		TimeValue t, INode* inode, ViewExp* vpt, Box3& box )
	{

	if ( ! vpt || ! vpt->IsAlive() )
	{
		box.Init();
		return;
	}

	Matrix3 tm;
	tm = inode->GetObjectTM(t);
	Box3 lbox;

	GetLocalBoundBox(t, inode, vpt, lbox);
	box = Box3(tm.GetTrans(), tm.GetTrans());
	for (int i=0; i<8; i++) {
		box += lbox * tm;
		}
	/*
	if(!(extDispFlags & EXT_DISP_ZOOM_EXT) && showAxis)
		box = GetAxisBox(vpt,tm,showAxis?axisLength:0.0f, FALSE);
	else
		box = Box3(tm.GetTrans(), tm.GetTrans());
		*/
	}
예제 #12
0
int UVW_ChannelClass::EdgeIntersect(Point3 p, float threshold, int i1,int i2)
{

 static int startEdge = 0;
 if (startEdge >= ePtrList.Count()) startEdge = 0;
 if (ePtrList.Count() == 0) return -1;

 int ct = 0;
 BOOL done = FALSE;


 int hitEdge = -1;
 while (!done) 
	{
 //check bounding volumes

	Box3 bounds;
	bounds.Init();

	int index1 = ePtrList[startEdge]->a;
	int index2 = ePtrList[startEdge]->b;
	if (v[index1].IsHidden() && v[index2].IsHidden())
		{
		}
	else if (v[index1].IsFrozen() && v[index1].IsFrozen()) 
		{
		}
	else
		{
		Point3 p1(0.0f,0.0f,0.0f);
		p1[i1] = v[index1].GetP()[i1];
		p1[i2] = v[index1].GetP()[i2];
//		p1.z = 0.0f;
		bounds += p1;
		Point3 p2(0.0f,0.0f,0.0f);
		p2[i1] = v[index2].GetP()[i1];
		p2[i2] = v[index2].GetP()[i2];
//		p2.z = 0.0f;
		bounds += p2;
		bounds.EnlargeBy(threshold);
		if (bounds.Contains(p))
			{
//check edge distance
			if (LineToPoint(p, p1, p2) < threshold)
				{
				hitEdge = startEdge;
				done = TRUE;
//				LineToPoint(p, p1, p2);
				}
			}
		}
 	ct++;
	startEdge++;
	if (ct == ePtrList.Count()) done = TRUE;
	if (startEdge >= ePtrList.Count()) startEdge = 0;
	}
 
 return hitEdge;
}
예제 #13
0
void ParticleMesherObject::UpdateUI()
{
   Point3 min,max;
   pblock2->GetValue(particlemesher_customboundsa,0,min,FOREVER);
   pblock2->GetValue(particlemesher_customboundsb,0,max,FOREVER);


   Box3 box;
   box.Init();
   box += min;
   box += max;

   
   TSTR text;
   BOOL useBounds;
   pblock2->GetValue(particlemesher_usecustombounds, 0, useBounds, FOREVER);

   if (useBounds)
      {
      if (box.IsEmpty())
         text.printf(_T("%s"),GetString(IDS_EMPTY));
      else 
         {
         text.printf(_T("(%0.0f,%0.0f,%0.0f)"),min.x,min.y,min.z);
         SetWindowText(GetDlgItem(hParams,IDC_BOUNDSTEXT),
            text);
         text.printf(_T("(%0.0f,%0.0f,%0.0f)"),max.x,max.y,max.z);
         SetWindowText(GetDlgItem(hParams,IDC_BOUNDSTEXT2),
            text);
         }

//make sure we only enable the button in the modify panel
// bug 257747 1/30/01 watje
      if (ip)
         {
         ICustButton *iBut = GetICustButton(GetDlgItem(hParams,IDC_PICKBB));
         if (ip->GetCommandPanelTaskMode()==TASK_MODE_MODIFY)
            {
            if (iBut) iBut->Enable(TRUE);
            }
         ReleaseICustButton(iBut);
         }

      }
   else
      {
      text.printf(_T(" "));
      SetWindowText(GetDlgItem(hParams,IDC_BOUNDSTEXT),
         text);
      text.printf(_T(" "));
      SetWindowText(GetDlgItem(hParams,IDC_BOUNDSTEXT2),
         text);
      ICustButton *iBut = GetICustButton(GetDlgItem(hParams,IDC_PICKBB));
      if (iBut) iBut->Enable(FALSE);
      ReleaseICustButton(iBut);

      }
   
}
예제 #14
0
void TargetObject::GetWorldBoundBox(TimeValue t, INode* inode, ViewExp* vpt, Box3& box )
	{

	if ( ! vpt || ! vpt->IsAlive() )
	{
		box.Init();
		return;
	}

	int i,nv;
	Matrix3 m;
	GetMat(t,inode,*vpt,m);
	nv = mesh.getNumVerts();
	box.Init();
	for (i=0; i<nv; i++) 
		box += m*mesh.getVert(i);
	}
예제 #15
0
void FExtrudeMod::GetWorldBoundBox (TimeValue t, INode* inode,
									ViewExp * /*vpt*/, Box3& box, ModContext *mc) {
	Matrix3 tm = CompMatrix(t,inode,mc);
	Point3 pt;
	box.Init();
	mp_base->GetValue(t,&pt,FOREVER,CTRL_ABSOLUTE);
	box += pt * tm;		
}
예제 #16
0
void TriPatchObject::GetWorldBoundBox(TimeValue t, INode *inode, ViewExp* vpt, Box3& box )
{

	if ( ! vpt || ! vpt->IsAlive() )
	{
		box.Init();
		return;
	}

	Box3	patchBox;

	Matrix3 mat = inode->GetObjectTM(t);

	GetLocalBoundBox(t,inode,vpt,patchBox);
	box.Init();
	for(int i = 0; i < 8; i++)
		box += mat * patchBox[i];
}
예제 #17
0
파일: prox.cpp 프로젝트: artemeliy/inf4715
void
ProxSensorObject::GetWorldBoundBox(TimeValue t, INode* inode, ViewExp* vpt,
                                   Box3& box )
{
    if ( ! vpt || ! vpt->IsAlive() )
		{
			// why are we here?
			box.Init();
			return;
		}
		
		Matrix3 tm;
    BuildMesh(t);            // 000829  --prs.
    GetMat(t,inode,*vpt,tm);

    int nv = mesh.getNumVerts();
    box.Init();
    for (int i=0; i<nv; i++) 
        box += tm*mesh.getVert(i);
}
예제 #18
0
void ProtHelpObject::GetWorldBoundBox(TimeValue t, INode* inode, ViewExp* vpt, Box3& box )
{
   if ( ! vpt || ! vpt->IsAlive() )
	{
		box.Init();
		return;
	}
	 int i, nv;
   Matrix3 tm;
   Point3 pt;
   GetMat(t,inode,*vpt,tm);
   nv = mesh.getNumVerts();
   box.Init();
   for (i=0; i<nv; i++) 
      box += tm*mesh.getVert(i);

   if (GetTargetPoint(0, t, &pt))
      box += pt;
   if (GetTargetPoint(1, t, &pt))
      box += pt;
}
예제 #19
0
void BombObject::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();
	if (hParam && GetWindowLongPtr(hParam,GWLP_USERDATA)==(LONG_PTR)this &&
		GetFalloffOn(t)) {
			BoxLineProc bproc(&mat);
			DrawFalloffSphere(GetFalloff(t),bproc);
			box = bproc.Box();
	}
	GetLocalBoundBox(t,inode,vpt,meshBox);	
	for(int i = 0; i < 8; i++)
		box += mat * meshBox[i];
}
예제 #20
0
void TargetObject::GetLocalBoundBox(TimeValue t, INode* inode, ViewExp* vpt, Box3& box ){
	if ( ! vpt || ! vpt->IsAlive() )
	{
		box.Init();
		return;
	}
	
	Matrix3 m = inode->GetObjectTM(t);
	float scaleFactor = vpt->NonScalingObjectSize()*vpt->GetVPWorldWidth(m.GetTrans())/(float)360.0;
	box = mesh.getBoundingBox();
	box.Scale(scaleFactor);
	}
예제 #21
0
void
UniformGrid::ClosestPoint(Point3 p, float radius, int &pindex, float &d)
{
	xHitList.ClearAll();
	yHitList.ClearAll();
	zHitList.ClearAll();
	hitList.SetCount(0);

	//find the cell in the XGrid
	TagCells(p,radius, 0);
	//find the cell in the YGrid
	TagCells(p,radius, 1);
	//find the cell in the ZGrid
	TagCells(p,radius, 2);

	BitArray usedList;
	usedList.SetSize(pointBase.Count());
	usedList.ClearAll();

	int closest = -1;
	d = 0.0f;
	Box3 localBounds;
	localBounds.Init();
	localBounds += p;
	localBounds.EnlargeBy(radius);


	for (int i = 0; i < hitList.Count(); i++)
	{
		int index = hitList[i];
		if (!usedList[index])  //check to see if we have processed this one or not
		{
			if (xHitList[index] && yHitList[index] && zHitList[index])
			{
				usedList.Set(index);
				Point3 source = pointBase[index];
				if (localBounds.Contains(source))
				{
					float dist = LengthSquared(source-p);
					if ((dist < d) || (closest == -1))
					{
						d = dist;
						closest = index;
					}
				}
			}
		}
	}
	pindex = closest;
	d = sqrt(d);


}
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);
}
예제 #23
0
int	  BonesDefMod::GetMirrorBone(Point3 center, int axis)
	{
	//get current bone
	INode *node = BoneData[ModeBoneIndex].Node;
	if (node)
		{
	//get tm
		Matrix3 iMirrorTM(1);
		iMirrorTM.SetRow(3,center);
		iMirrorTM = Inverse(iMirrorTM);
		TimeValue t = GetCOREInterface()->GetTime();
		Matrix3 tm = node->GetNodeTM(t);
		Point3 mirrorPoint = Point3(0.0f,0.0f,0.0f) * tm;
		mirrorPoint = mirrorPoint * iMirrorTM;
	//mirror its location
		mirrorPoint[axis] *= -1.0f;




	//loop through all the bones
		int closestBone = -1;
		float closestDist= 0.0f;
		Box3 bounds;
		bounds.Init();
		for (int i = 0; i < BoneData.Count(); i++)
			{
			node = BoneData[i].Node;
	//get there tm
			if ((node) && (i!=ModeBoneIndex))
				{	
	//find closest bone
				tm = node->GetNodeTM(t);
				Point3 bonePoint = Point3(0.0f,0.0f,0.0f) * tm;
				bonePoint = bonePoint * iMirrorTM;
				bounds += bonePoint;
				float dist = Length(bonePoint-mirrorPoint);
				if ( (closestBone == -1) || (dist < closestDist) )
					{
					closestDist = dist;
					closestBone = i;
					}
				}
			}
		float threshold = Length(bounds.pmax-bounds.pmin)/100.0f;
		if (closestDist < threshold)
			return closestBone;

		}
	
	return -1;
	}
void VRayCamera::GetWorldBoundBox(TimeValue t, INode *node, ViewExp *vpt, Box3& box) {
  int i,nv;
  Matrix3 tm;
  Point3 pt;

  getTM(t, node, vpt, tm);
  nv=mesh.getNumVerts();
  box.Init();
  if (!(extendedDisplayFlags & EXT_DISP_ZOOM_EXT)) for (i=0; i<nv; i++) box+=tm*mesh.getVert(i);
  else box+=tm.GetTrans();

  box+=node->GetObjectTM(t)*Point3(0.0f, 0.0f, -GetTDist(t));
}
예제 #25
0
void TriObject::GetWorldBoundBox(TimeValue t, INode *inode, ViewExp* vpt, Box3& box )
	{

	if ( ! vpt || ! vpt->IsAlive() )
	{
		box.Init();
		return;
	}

	Box3	meshBox;

	Matrix3 mat = inode->GetObjectTM(t);
	
	GetLocalBoundBox(t,inode,vpt,meshBox);
	if(meshBox.IsEmpty())
		box = meshBox;
	else {
		box.Init();
		for(int i = 0; i < 8; i++)
			box += mat * meshBox[i];
		}
	}
예제 #26
0
파일: backgrnd.cpp 프로젝트: 2asoft/xray
void
BackgroundObject::GetWorldBoundBox(TimeValue t, INode* inode, ViewExp* vpt,
                                   Box3& box )
{
    Matrix3 tm;
    BuildMesh(t);            // 000829  --prs.
    GetMat(t,inode,vpt,tm);

    int nv = mesh.getNumVerts();
    box.Init();
    for (int i=0; i<nv; i++) 
        box += tm*mesh.getVert(i);
}
예제 #27
0
void BendManip::GetWorldBoundBox(TimeValue t, INode* inode, ViewExp* vpt, Box3& box )
{
		if ( ! vpt || ! vpt->IsAlive() )
		{
			box.Init();
			return;
		}

    Matrix3 mat = inode->GetObjectTM(t);
    GetLocalBoundBox(t, inode, vpt, box);
    box = box * mat;

}
예제 #28
0
void SymmetryMod::GetWorldBoundBox (TimeValue t,INode* inode, ViewExp *vpt, Box3& box, ModContext *mc) {	

	if ( ! vpt || ! vpt->IsAlive() )
	{
		box.Init();
		return;
	}

	GraphicsWindow *gw = vpt->getGW();
	Matrix3 tm = CompMatrix(t,inode,mc);
	BoxLineProc bproc(&tm);
	DrawGizmo (vpt->GetScreenScaleFactor(tm.GetTrans())*SCREEN_SCALE, bproc);
	box = bproc.Box();
}
예제 #29
0
BOOL PickControlNode::Pick(IObjParam *ip,ViewExp *vpt)
   {

	 if ( ! vpt || ! vpt->IsAlive() )
	{
		// why are we here
		DbgAssert(!_T("Invalid viewport!"));
		return FALSE;
	}

   INode *node = vpt->GetClosestHit();
   if (node) {
      // RB 3/1/99: This should use the node tm not the object TM. See ModifyObject() imp.
      Matrix3 ourTM,ntm = node->GetNodeTM(GetCOREInterface()->GetTime()); //node->GetObjectTM(ip->GetTime());  

      ModContextList mcList;
      INodeTab nodes;
      ip->GetModContexts(mcList,nodes);
      if (nodes.Count())
         {
         ourTM = nodes[0]->GetObjectTM(GetCOREInterface()->GetTime());
         ourTM    = Inverse(ourTM);
         Box3 bounds;
         bounds.Init();
         ObjectState os = node->EvalWorldState(GetCOREInterface()->GetTime());
         ViewExp& vp = GetCOREInterface()->GetActiveViewExp();
         if ( ! vp.IsAlive() )
				 {
				 	// why are we here
				 	DbgAssert(!_T("Invalid viewport!"));
				 	return FALSE;
				 }
				 os.obj->GetWorldBoundBox(GetCOREInterface()->GetTime(), node, vp.ToPointer(), bounds );
         
         Point3 min = bounds.pmin * ourTM;
         Point3 max = bounds.pmax * ourTM;
         theHold.Begin();
         mod->pblock2->SetValue(particlemesher_customboundsa,0,min);
         mod->pblock2->SetValue(particlemesher_customboundsb,0,max);
         theHold.Accept(GetString(IDS_BOUNDS));
         mod->NotifyDependents(FOREVER,0,REFMSG_CHANGE);
         mod->UpdateUI();


         }

      nodes.DisposeTemporary();
      }
   return TRUE;
   }
예제 #30
0
void SContext::CalcBoundObj()
{
	if (!mesh)
		return;

	boundingObj.Init();

	// Include each vertex in the bounding box
	for (int nf = 0; nf < mesh->numFaces; nf++) {
		Face* f = &(mesh->faces[nf]);

		boundingObj += mesh->getVert(f->getVert(0));
		boundingObj += mesh->getVert(f->getVert(1));
		boundingObj += mesh->getVert(f->getVert(2));
	}
}