Example #1
0
void ClustMod::GetWorldBoundBox(
		TimeValue t,INode* inode, ViewExp *vpt, 
		Box3& box, ModContext *mc)
	{

	// Need the correct bound box for proper damage rect calcs.
	#ifdef DESIGN_VER
	TimeValue rt = GetCOREInterface()->GetTime();
	Matrix3 obtm = inode->GetObjectTM(rt);
	#else
	Matrix3 obtm = inode->GetObjectTM(t);
    #endif
	GraphicsWindow *gw = vpt->getGW();
	
	Matrix3 ptm(1), ctm(1);
	if (posControl) posControl->GetValue(t,&ptm,FOREVER,CTRL_RELATIVE);
	if (tmControl) tmControl->GetValue(t,&ctm,FOREVER,CTRL_RELATIVE);	
	//Matrix3 tm = DEFORMER_TM;
	Matrix3 tm = CompTM(ptm,ctm,mc->tm,1);
	ClustDeformer deformer(tm);	
	
	BoxLineProc bp1(&obtm);
	DoModifiedBox(MakeBoxNotEmpty(*mc->box), deformer, bp1);
	box = bp1.Box();

	//obtm = ctm * obtm;
	if (mc->tm) obtm = ctm * Inverse(*mc->tm) * obtm;
	else obtm = ctm * obtm;

	BoxLineProc bp2(&obtm);		
	DrawCenterMark(bp2,MakeBoxNotEmpty(*mc->box));
	box += bp2.Box();
	}
Example #2
0
int BendManip::Display(TimeValue t, INode* pNode, ViewExp *pVpt, int flags)
{

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


	Interval valid;
	GraphicsWindow *gw = pVpt->getGW();
	Matrix3 modmat, ntm = pNode->GetObjTMBeforeWSM(t), off, invoff;

	if (mc->box->IsEmpty()) return 0;

	//Lets get the Modifier do all the work here
	modmat = modifier->CompMatrix(t,*mc,ntm,valid,FALSE);
	modifier->CompOffset(t,off,invoff);
	gw->setTransform(modmat);
	if(mouseWithin)
		gw->setColor( LINE_COLOR, (float)1.0, (float)0.0, (float)0.0);
	else
		gw->setColor( LINE_COLOR, (float)0.0, (float)1.0, (float)0.0);

	DoModifiedBox(*mc->box,modifier->GetDeformer(t,*mc,invoff,off),DrawLineProc(gw));

	
	return 1;
	
}
Example #3
0
int ClustMod::Display(
		TimeValue t, INode* inode, ViewExp *vpt, 
		int flags, ModContext *mc)
	{
	// Transform the gizmo with the node.
	#ifdef DESIGN_VER
	TimeValue rt = GetCOREInterface()->GetTime();
	Matrix3 obtm = inode->GetObjectTM(rt);
	#else
	Matrix3 obtm = inode->GetObjectTM(t);
    #endif

	GraphicsWindow *gw = vpt->getGW();
	gw->setTransform(obtm);

	Matrix3 ptm(1), ctm(1);
	if (posControl) posControl->GetValue(t,&ptm,FOREVER,CTRL_RELATIVE);
	if (tmControl) tmControl->GetValue(t,&ctm,FOREVER,CTRL_RELATIVE);	
	//Matrix3 tm = DEFORMER_TM;
	Matrix3 tm = CompTM(ptm,ctm,mc->tm,1);	

	ClustDeformer deformer(tm);	
	if (ip && ip->GetSubObjectLevel() == 1) {
		//gw->setColor( LINE_COLOR, (float)1.0, (float)1.0, (float)0.0);		
		gw->setColor(LINE_COLOR,GetUIColor(COLOR_SEL_GIZMOS));
	} else {
		//gw->setColor( LINE_COLOR, (float).85, (float).5, (float)0.0);
		gw->setColor(LINE_COLOR,GetUIColor(COLOR_GIZMOS));
		}
	if (mc->box->pmin==mc->box->pmax) {
		Point3 pt = mc->box->pmin * tm;
		gw->marker(&pt,ASTERISK_MRKR);		
	} else {
		DoModifiedBox(MakeBoxNotEmpty(*mc->box),deformer,DrawLineProc(gw));
		}

	//obtm = ctm * obtm;
	if (mc->tm) obtm = ctm * Inverse(*mc->tm) * obtm;
	else obtm = ctm * obtm;
	
	gw->setTransform(obtm);
	if ( ip && (ip->GetSubObjectLevel() == 1 ||
	            ip->GetSubObjectLevel() == 2) ) {		
		//gw->setColor( LINE_COLOR, (float)1.0, (float)1.0, (float)0.0);
		gw->setColor(LINE_COLOR,GetUIColor(COLOR_SEL_GIZMOS));
	} else {
		//gw->setColor( LINE_COLOR, (float).85, (float).5, (float)0.0);
		gw->setColor(LINE_COLOR,GetUIColor(COLOR_GIZMOS));
		}	
	DrawCenterMark(DrawLineProc(gw),MakeBoxNotEmpty(*mc->box));	
	return 0;
	}
Example #4
0
int BendManip::HitTest(TimeValue t, INode* pNode, int type, int crossing,
			int flags, IPoint2 *p, ViewExp *pVpt)
{
	ModContext* mc = FindModContext( pNode, modifier );
	if( mc==NULL ) return 0;

// From SimpleMod - Removed the centre drawing section
	Interval valid;
	int savedLimits;	
	GraphicsWindow *gw = pVpt->getGW();
	HitRegion hr;
	MakeHitRegion(hr,type, crossing,4,p);
	gw->setHitRegion(&hr);
	Matrix3 modmat, ntm = pNode->GetObjTMBeforeWSM(t);

	if (mc->box->IsEmpty()) return 0;

	gw->setRndLimits(((savedLimits = gw->getRndLimits()) | GW_PICK) & ~GW_ILLUM);
	gw->clearHitCode();

	//Lets get the Modifier do all the work here

	Matrix3 off, invoff;
	modmat = modifier->CompMatrix(t,*mc,ntm,valid,FALSE);
	modifier->CompOffset(t,off,invoff);
	gw->setTransform(modmat);		
	DoModifiedBox(*mc->box,modifier->GetDeformer(t,*mc,invoff,off),DrawLineProc(gw));
	

	gw->setRndLimits(savedLimits);	

	if (gw->checkHitCode()) {
		pVpt->LogHit(pNode, mc, gw->getHitDistance(), 0, NULL); 

	}

// Setup the Hit data from the Manipulator system into the HitRecord
	if(  pVpt->NumSubObjHits() ) {
		ManipHitData* pHitData = new ManipHitData(this);
		HitRecord* hit = pVpt->GetSubObjHitList().First();

		hit->hitData = pHitData; //Add the manip hit data
		return TRUE;
	}

	else 
	{
		return FALSE;
	}
}
Example #5
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);

}
Example #6
0
int ClustMod::HitTest(
		TimeValue t, INode* inode, int type, int crossing, 
		int flags, IPoint2 *p, ViewExp *vpt, ModContext* mc)
	{	
	int savedLimits;
	Matrix3 obtm = inode->GetObjectTM(t);
	GraphicsWindow *gw = vpt->getGW();
	HitRegion hr;
	MakeHitRegion(hr,type, crossing,4,p);
	gw->setHitRegion(&hr);
	gw->setRndLimits(((savedLimits = gw->getRndLimits()) | GW_PICK) & ~GW_ILLUM);
	gw->clearHitCode();	
	gw->setTransform(obtm);

	Matrix3 ptm(1), ctm(1);
	if (posControl) posControl->GetValue(t,&ptm,FOREVER,CTRL_RELATIVE);
	if (tmControl) tmControl->GetValue(t,&ctm,FOREVER,CTRL_RELATIVE);	

	if (ip && ip->GetSubObjectLevel() == 1) {		
		//Matrix3 tm = DEFORMER_TM;
		Matrix3 tm = CompTM(ptm,ctm,mc->tm,1);

		ClustDeformer deformer(tm);
		if (mc->box->pmin==mc->box->pmax) {
			Point3 pt = mc->box->pmin * tm;
			gw->marker(&pt,ASTERISK_MRKR);
		} else {
			DoModifiedBox(MakeBoxNotEmpty(*mc->box),deformer,DrawLineProc(gw));
			}
		}

	if (ip && (ip->GetSubObjectLevel() == 1 ||
	           ip->GetSubObjectLevel() == 2)) {		
		//obtm = ctm * obtm;
		if (mc->tm) obtm = ctm * Inverse(*mc->tm) * obtm;
		else obtm = ctm * obtm;

		gw->setTransform(obtm);
		DrawCenterMark(DrawLineProc(gw),MakeBoxNotEmpty(*mc->box));
		}

	gw->setRndLimits(savedLimits);	
	if (gw->checkHitCode()) {
		vpt->LogHit(inode, mc, gw->getHitDistance(), 0, NULL); 
		return 1;
		}
	return 0;
	}
Example #7
0
void ClustMod::GetSubObjectCenters(
		SubObjAxisCallback *cb,TimeValue t,INode *node,ModContext *mc)
	{
	Matrix3 obtm = node->GetObjectTM(t);
	Matrix3 ptm(1), ctm(1);
	if (posControl) posControl->GetValue(t,&ptm,FOREVER,CTRL_RELATIVE);	
	if (tmControl) tmControl->GetValue(t,&ctm,FOREVER,CTRL_RELATIVE);

	if (cb->Type()==SO_CENTER_PIVOT) {
		//Matrix3 mat = ctm * obtm;
		Matrix3 mat;		
		if (mc->tm) mat = ctm * Inverse(*mc->tm) * obtm;
		else mat = ctm * obtm;
		cb->Center(mat.GetTrans(),0);
	} else {		
		//Matrix3 tm = DEFORMER_TM;
		Matrix3 tm = CompTM(ptm,ctm,mc->tm,1);
		ClustDeformer deformer(tm);
		BoxLineProc bp1(&obtm);
		DoModifiedBox(MakeBoxNotEmpty(*mc->box), deformer, bp1);
		cb->Center(bp1.Box().Center(),0);
		}
	}