Ejemplo n.º 1
0
MeshTopoData *TweakMouseProc::HitTest(ViewExp& vpt, IPoint2 m, int &hitVert)
{
	if ( ! vpt.IsAlive() )
	{
		// why are we here
		DbgAssert(!_T("Invalid viewport!"));
		return NULL;
	}

	int savedLimits;
	TimeValue t = GetCOREInterface()->GetTime();

	GraphicsWindow *gw = vpt.getGW();

	HitRegion hr;

	int crossing = TRUE;
	int type = HITTYPE_POINT;
	MakeHitRegion(hr,type, crossing,8,&m);
	gw->setHitRegion(&hr);
	hitVert = -1;
	MeshTopoData *hitLD = NULL;
	mHitLDIndex = -1;

	//			else gw->setRndLimits(gw->getRndLimits() & ~GW_BACKCULL);

	savedLimits = gw->getRndLimits();
	for (int ldID = 0; ldID < mod->GetMeshTopoDataCount(); ldID++)
	{
		MeshTopoData *ld = mod->GetMeshTopoData(ldID);
		INode *inode = mod->GetMeshTopoDataNode(ldID);

		Matrix3 mat = inode->GetObjectTM(t);
		gw->setTransform(mat);	
		gw->setRndLimits(((gw->getRndLimits() | GW_PICK) & ~GW_ILLUM) |  GW_BACKCULL);
		ModContext mc;

		int hindex = mod->peltData.HitTestPointToPointMode(mod,ld,vpt,gw,&m,hr,inode,&mc);
		if (hindex != -1)
		{
			hitVert = hindex;
			hitLD = ld;
			mHitLDIndex = ldID;
		}
	}

	gw->setRndLimits(savedLimits);

	return hitLD;

}
Ejemplo n.º 2
0
int EditFaceDataMod::HitTest (TimeValue t, INode* inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt, ModContext* mc) {
	Interval valid;
	int savedLimits, res = 0;
	GraphicsWindow *gw = vpt->getGW();
	HitRegion hr;
	
	// Setup GW
	MakeHitRegion(hr,type, crossing,4,p);
	gw->setHitRegion(&hr);
	Matrix3 mat = inode->GetObjectTM(t);
	gw->setTransform(mat);	
	gw->setRndLimits(((savedLimits = gw->getRndLimits()) | GW_PICK) & ~GW_ILLUM);
	gw->clearHitCode();

	if (!mc->localData) return 0;
	EditFaceDataModData *md = (EditFaceDataModData*)mc->localData;
	Mesh *mesh = md->GetCacheMesh ();
	MNMesh *mnmesh = md->GetCacheMNMesh ();

	SubObjHitList hitList;
	if (mesh) {
		res = mesh->SubObjectHitTest(gw, gw->getMaterial(), &hr, flags|hitLevel[selLevel], hitList);
	} else if (mnmesh) {
		res = mnmesh->SubObjectHitTest (gw, gw->getMaterial(), &hr, flags|mnhitLevel[selLevel], hitList);
	}

	MeshSubHitRec *rec = hitList.First();
	while (rec) {
		vpt->LogHit(inode,mc,rec->dist,rec->index,NULL);
		rec = rec->Next();
	}

	gw->setRndLimits(savedLimits);	
	return res;	
}
Ejemplo n.º 3
0
Value*
wMarker_cf(Value** arg_list, int count)
{
	check_arg_count_with_keys(wMarker, 2, count);	
	def_marker_types();

	Value*			col_val = key_arg(color);	
	MarkerType		mt = (MarkerType)GetID(markerTypes, elements(markerTypes), arg_list[1]);
	GraphicsWindow* gw = MAXScript_interface->GetActiveViewExp().getGW();

	if (MaxSDK::Graphics::IsRetainedModeEnabled() && gw->querySupport(GW_SPT_NUM_LIGHTS) == 0)
	{
		return &undefined;
	}

	// LAM - 8/19/03 - defect 470189
	DWORD			lim		= gw->getRndLimits();
	BOOL			resetLimit = lim & GW_Z_BUFFER;
	if (resetLimit) gw->setRndLimits(lim & ~GW_Z_BUFFER);

	gw->setColor(LINE_COLOR, 
		(col_val == &unsupplied) ? Point3(1, 0, 0) : col_val->to_point3()/255.f);
	gw->wMarker(&(to_ipoint3(arg_list[0])), mt);

	if (resetLimit) gw->setRndLimits(lim);

	return &ok;
}
Ejemplo n.º 4
0
int
FogObject::Display(TimeValue t, INode* inode, ViewExp *vpt, int flags)
{
    if ( ! vpt || ! vpt->IsAlive() )
		{
			// why are we here?
			DbgAssert(!"Doing Display() on invalid view port!");
			return FALSE;
		}
		
		
		float radius;
    pblock->GetValue(PB_FOG_SIZE, t, radius, FOREVER);
    if (radius <= 0.0)
        return 0;
    BuildMesh(t);
    Matrix3 m;
    GraphicsWindow *gw = vpt->getGW();
    Material *mtl = gw->getMaterial();

    DWORD rlim = gw->getRndLimits();
    gw->setRndLimits(GW_WIREFRAME|GW_EDGES_ONLY|GW_BACKCULL| (rlim&GW_Z_BUFFER) );
    GetMat(t,inode,*vpt,m);
    gw->setTransform(m);
    if (inode->Selected()) 
        gw->setColor( LINE_COLOR, 1.0f, 1.0f, 1.0f);
    else if(!inode->IsFrozen())
        gw->setColor( LINE_COLOR, 1.0f, 0.0f, 0.0f);
    mesh.render( gw, mtl, NULL, COMP_ALL);

    gw->setRndLimits(rlim);
    return(0);
}
Ejemplo n.º 5
0
int FExtrudeMod::HitTest(
		TimeValue t, INode* inode, int type, int crossing, 
		int flags, IPoint2 *p, ViewExp *vpt, ModContext* mc)
	{	

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

	GraphicsWindow *gw = vpt->getGW();
	Point3 pt;
	HitRegion hr;
	int savedLimits, res = 0;
	Matrix3 tm = CompMatrix(t,inode,mc);

	MakeHitRegion(hr,type, crossing,4,p);
	gw->setHitRegion(&hr);	
	gw->setRndLimits(((savedLimits = gw->getRndLimits()) | GW_PICK) & ~GW_ILLUM);	
	gw->setTransform(tm);

	gw->clearHitCode();
	base->GetValue(t,&pt,FOREVER,CTRL_ABSOLUTE);
	gw->marker(&pt,HOLLOW_BOX_MRKR);
	if (gw->checkHitCode()) {
		vpt->LogHit(inode, mc, gw->getHitDistance(), 0, NULL); 
		res = 1;
		}			

	gw->setRndLimits(savedLimits);
	return res;
	}
Ejemplo n.º 6
0
// From BaseObject
int SimpleWSMObject::HitTest(TimeValue t, INode *inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt) 
	{

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

	Point2 pt( (float)p[0].x, (float)p[0].y );
	HitRegion hitRegion;
	GraphicsWindow *gw = vpt->getGW();	
	Material *mtl = gw->getMaterial();
		
	UpdateMesh(t);
	gw->setTransform(inode->GetObjectTM(t));
	MakeHitRegion(hitRegion, type, crossing, 4, p);
	DWORD rlim  = gw->getRndLimits();	
	int res;

	gw->setRndLimits((rlim|GW_PICK|GW_WIREFRAME) 
		& ~(GW_ILLUM|GW_BACKCULL|GW_FLAT|GW_SPECULAR));

	res = mesh.select(gw, mtl, &hitRegion, flags & HIT_ABORTONHIT);
	
	gw->setRndLimits(rlim);
	return res;
	}
Ejemplo n.º 7
0
int
BackgroundObject::Display(TimeValue t, INode* inode, ViewExp *vpt, int flags)
{
    float radius;
    pblock->GetValue(PB_BG_SIZE, t, radius, FOREVER);
    if (radius <= 0.0)
        return 0;
    BuildMesh(t);
    Matrix3 m;
    GraphicsWindow *gw = vpt->getGW();
    Material *mtl = gw->getMaterial();

    DWORD rlim = gw->getRndLimits();
    gw->setRndLimits(GW_WIREFRAME|GW_EDGES_ONLY|GW_BACKCULL);
    GetMat(t,inode,vpt,m);
    gw->setTransform(m);
    if (inode->Selected()) 
        gw->setColor( LINE_COLOR, 1.0f, 1.0f, 1.0f);
    else if(!inode->IsFrozen())
        gw->setColor( LINE_COLOR, 1.0f, 1.0f, 0.0f);
    mesh.render( gw, mtl, NULL, COMP_ALL);

    gw->setRndLimits(rlim);
    return(0);
}
Ejemplo n.º 8
0
int ProtHelpObject::HitTest(TimeValue t, INode *inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt) 
{
   if ( ! vpt || ! vpt->IsAlive() )
	{
		// why are we here
		DbgAssert(!_T("Invalid viewport!"));
		return FALSE;
	}
	 
	 HitRegion hitRegion;
   DWORD savedLimits;
   int res;
   Matrix3 m;
   GraphicsWindow *gw = vpt->getGW();  
   Material *mtl = gw->getMaterial();
   MakeHitRegion(hitRegion,type,crossing,4,p);  
   gw->setRndLimits(((savedLimits = gw->getRndLimits()) | GW_PICK) & ~GW_ILLUM);
   GetMat(t,inode,*vpt,m);
   gw->setTransform(m);
   // if we get a hit on the mesh, we're done
   gw->clearHitCode();
   if (mesh.select( gw, mtl, &hitRegion, flags & HIT_ABORTONHIT )) 
      return TRUE;
   // if not, check the target line, and set the pair flag if it's hit
   gw->clearHitCode();
   res = DrawLines(t, inode, gw, 1);
   gw->setRndLimits(savedLimits);
   return res;
}
Ejemplo n.º 9
0
int MirrorMod::Display(
		TimeValue t, INode* inode, ViewExp *vpt, 
		int flagst, ModContext *mc)
	{
	GraphicsWindow *gw = vpt->getGW();
	Point3 pt[4];
	Matrix3 tm = CompMatrix(t,inode,mc);
	int savedLimits;

	gw->setRndLimits((savedLimits = gw->getRndLimits()) & ~GW_ILLUM);
	gw->setTransform(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));
		}
	
	DrawLineProc lp(gw);
	DrawGizmo(
		vpt->GetScreenScaleFactor(tm.GetTrans())*SCREEN_SCALE,lp);
	
	gw->setRndLimits(savedLimits);
	return 0;
	}
Ejemplo n.º 10
0
int RainParticle::Display( TimeValue t, INode* inode, ViewExp *vpt, int flags )
{
	if (!OKtoDisplay(t)) 
		return 0;

	GraphicsWindow *gw = vpt->getGW();
	DWORD rlim  = gw->getRndLimits();

	// Draw emitter
	gw->setRndLimits(GW_WIREFRAME | GW_EDGES_ONLY | (rlim & GW_Z_BUFFER) );

	if (inode->Selected())
	{
		gw->setColor( LINE_COLOR, GetSelColor());
	}
	else if(!inode->IsFrozen())
	{
		gw->setColor(LINE_COLOR,GetUIColor(COLOR_PARTICLE_EM));
	}

	Material *mtl = gw->getMaterial();   
	if (mtl && !inode->Selected() && !inode->IsFrozen())
	{
		gw->setColor(LINE_COLOR, mtl->Kd[0], mtl->Kd[1], mtl->Kd[2]);
	}

	gw->setTransform(inode->GetObjTMBeforeWSM(t));  
	mesh.render(gw, mtl, (flags & USE_DAMAGE_RECT) ? &vpt->GetDammageRect() : NULL, COMP_ALL);
	
	return 0;
}
void SnapPivot_Mode::DrawAxisLock(ViewExp *vpt, int axis, float size, bool hightLight, bool hitTest, float& dist)
{
	GraphicsWindow *gw = vpt->getGW();

	if (hitTest)
	{
		gw->setRndLimits(gw->getRndLimits() | GW_PICK);
		gw->clearHitCode();		
	}

	
	Point3 p(0, 0, 0);
	p[axis] = size+ size*0.1f;

	if (axis == mLockedAxis)
		gw->setColor(ColorType::LINE_COLOR, mLockedColor);
	else
		gw->setColor(ColorType::LINE_COLOR, mLockColor);
	gw->startMarkers();
	gw->marker(&p, MarkerType::CIRCLE_MRKR);
	gw->endMarkers();


	dist = -1.0f;
	if (hitTest)
	{
		if (gw->checkHitCode())
		{
			if (gw->getHitDistance())
				dist = gw->getHitDistance();
		}
	}


}
void SnapPivot_Mode::DrawCenter(ViewExp *vpt, float size, bool hightLight, bool hitTest, float& dist)
{
	GraphicsWindow *gw = vpt->getGW();
	if (hitTest)
	{
		gw->setRndLimits(gw->getRndLimits() | GW_PICK);
		gw->clearHitCode();		
	}

	
	Point3 p(0, 0, 0);
	gw->setColor(ColorType::LINE_COLOR, mCenterColor);
	gw->startMarkers();
	gw->marker(&p, MarkerType::BIG_BOX_MRKR);
	gw->endMarkers();

	dist = -1.0f;
	if (hitTest)
	{
		if (gw->checkHitCode()) 
		{
			if (gw->getHitDistance() )
				dist = gw->getHitDistance();
		}		
	}

}
Ejemplo n.º 13
0
// From BaseObject
int TargetObject::HitTest(TimeValue t, INode *inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt) {
	if ( ! vpt || ! vpt->IsAlive() )
	{
		// why are we here
		DbgAssert(!_T("Invalid viewport!"));
		return FALSE;
	}
	
	HitRegion hitRegion;
	DWORD savedLimits;
	Matrix3 m;
	GraphicsWindow *gw = vpt->getGW();	
	MakeHitRegion(hitRegion,type,crossing,4,p);	
	gw->setRndLimits(((savedLimits = gw->getRndLimits()) | GW_PICK) & ~GW_ILLUM);
	GetMat(t,inode,*vpt,m);
	gw->setTransform(m);
	if(mesh.select( gw, gw->getMaterial(), &hitRegion, flags & HIT_ABORTONHIT ))
		return TRUE;
	gw->setRndLimits( savedLimits );
	return FALSE;

#if 0
	gw->setHitRegion(&hitRegion);
	gw->clearHitCode();
	gw->fWinMarker(&pt, HOLLOW_BOX_MRKR);
	return gw->checkHitCode();
#endif

	}
Ejemplo n.º 14
0
int SimpleParticle::Display(TimeValue t, INode* inode, ViewExp *vpt, int flags) 
	{
	if (!OKtoDisplay(t)) return 0;
	Update(t,inode);
	GraphicsWindow *gw = vpt->getGW();
	DWORD rlim  = gw->getRndLimits();	
	
	// Draw emitter
	gw->setRndLimits(GW_WIREFRAME|GW_EDGES_ONLY|GW_BACKCULL| (rlim&GW_Z_BUFFER) );
	if (inode->Selected()) 
		gw->setColor( LINE_COLOR, GetSelColor());
	else if(!inode->IsFrozen())
		//gw->setColor( LINE_COLOR, particleMtl.Kd[0], particleMtl.Kd[1], particleMtl.Kd[2]);
		gw->setColor(LINE_COLOR,GetUIColor(COLOR_PARTICLE_EM));

	if (EmitterVisible()) {
		gw->setTransform(inode->GetObjTMBeforeWSM(t));	
		mesh.render(gw, &particleMtl, 
			(flags&USE_DAMAGE_RECT) ? &vpt->GetDammageRect() : NULL, COMP_ALL);
		}
			
	// Draw particles
	gw->setRndLimits(GW_WIREFRAME|GW_EDGES_ONLY|GW_BACKCULL| (rlim&(GW_Z_BUFFER|GW_BOX_MODE)) );
	Material *mtl = gw->getMaterial();	
	if (!inode->Selected() && !inode->IsFrozen())
		gw->setColor( LINE_COLOR, mtl->Kd[0], mtl->Kd[1], mtl->Kd[2]);

	gw->setTransform(ident);
	parts.Render(gw,GetMarkerType());

	gw->setRndLimits(rlim);
	return(0);
	}
Ejemplo n.º 15
0
int SimpleParticle::HitTest(
		TimeValue t, INode *inode, int type, int crossing, int flags, 
		IPoint2 *p, ViewExp *vpt) 
	{	
	Update(t,inode);
	Point2 pt( (float)p[0].x, (float)p[0].y );
	HitRegion hitRegion;
	GraphicsWindow *gw = vpt->getGW();	
	MakeHitRegion(hitRegion, type, crossing, 4, p);
	DWORD rlim  = gw->getRndLimits();
	int res;

	gw->setTransform(ident);
	if (parts.HitTest(gw,&hitRegion,flags&HIT_ABORTONHIT,GetMarkerType())) {
		return TRUE;
		}
	
	if (EmitterVisible()) {
		gw->setRndLimits((rlim|GW_PICK|GW_WIREFRAME) 
			& ~(GW_ILLUM|GW_BACKCULL|GW_FLAT|GW_SPECULAR));
		gw->setTransform(inode->GetObjTMBeforeWSM(t));
		res = mesh.select(gw, &particleMtl, &hitRegion, flags & HIT_ABORTONHIT);

		gw->setRndLimits(rlim);
	} else {
		res = 0;
		}
	return res;
	}
Ejemplo n.º 16
0
int bhkCapsuleObject::Display(TimeValue t, INode* inode, ViewExp *vpt, int flags) 
{
   Matrix3 m;
   Color color = Color(inode->GetWireColor());
   GraphicsWindow *gw = vpt->getGW();
   Material *mtl = gw->getMaterial();
   m = inode->GetObjectTM(t);
   gw->setTransform(m);
   DWORD rlim = gw->getRndLimits();

   DWORD newrlim = GW_WIREFRAME/*|GW_Z_BUFFER*/;
#if VERSION_3DSMAX >= ((5000<<16)+(15<<8)+0) // Version 5+
   newrlim |= GW_EDGES_ONLY;
#endif
   gw->setRndLimits(newrlim);

   if (inode->Selected()) 
      gw->setColor( LINE_COLOR, GetSelColor());
   else if(!inode->IsFrozen() && !inode->Dependent())
      gw->setColor( LINE_COLOR, color);

   UpdateMesh(t);
   mesh.render( gw, mtl, NULL, COMP_ALL);	
   gw->setRndLimits(rlim);
   return 0;
}
Ejemplo n.º 17
0
int PBombObject::Display(TimeValue t, INode* inode, ViewExp *vpt, int flags)
{	GraphicsWindow *gw = vpt->getGW();
	Material *mtl = &swMtl;
	Matrix3 mat = inode->GetObjectTM(t);
//	UpdateMesh(t);		
 	DWORD rlim = gw->getRndLimits();
	gw->setRndLimits(GW_WIREFRAME|GW_EDGES_ONLY|/*GW_BACKCULL|*/ (rlim&GW_Z_BUFFER?GW_Z_BUFFER:0) );//removed BC 2/16/99 DB
	gw->setTransform(mat);

	if (inode->Selected()) 
		gw->setColor( LINE_COLOR, GetSelColor());
	else if(!inode->IsFrozen())
		gw->setColor(LINE_COLOR,GetUIColor(COLOR_SPACE_WARPS));
	mesh.render(gw, mtl, NULL, COMP_ALL);
	int dorange,hoopson;
	pblock->GetValue(PB_RANGEON,0,hoopson,FOREVER);
	pblock->GetValue(PB_DECAYTYPE,0,dorange,FOREVER);
	float length;
	if (hoopson && dorange)
	{ pblock->GetValue(PB_DECAY,t,length,FOREVER);
	  float range;
	  range=length;
	  BombDrawLineProc lp(gw);
	  DrawFalloffSphere(range,lp);
	}
	gw->setRndLimits(rlim);
	return(0);
}
Ejemplo n.º 18
0
int BombObject::Display(TimeValue t, INode* inode, ViewExp *vpt, int flags)
	{
	if ( ! vpt || ! vpt->IsAlive() )
	{
		// why are we here
		DbgAssert(!_T("Invalid viewport!"));
		return FALSE;
	}
	GraphicsWindow *gw = vpt->getGW();
	Material *mtl = &swMtl;
	Matrix3 mat = inode->GetObjectTM(t);
 	DWORD rlim = gw->getRndLimits();
	gw->setRndLimits(GW_WIREFRAME|GW_EDGES_ONLY|/*GW_BACKCULL|*/ (rlim&GW_Z_BUFFER?GW_Z_BUFFER:0) );//removed BC 2/16/99 DB

	gw->setTransform(mat);
	if (inode->Selected()) 
		gw->setColor( LINE_COLOR, GetSelColor());
	else if(!inode->IsFrozen())
		//gw->setColor( LINE_COLOR, swMtl.Kd[0], swMtl.Kd[1], swMtl.Kd[2]);
		gw->setColor(LINE_COLOR,GetUIColor(COLOR_SPACE_WARPS));
	mesh.render(gw, mtl, NULL, COMP_ALL);
		
	if (hParam && GetWindowLongPtr(hParam,GWLP_USERDATA)==(LONG_PTR)this &&
		GetFalloffOn(t)) {
		DrawLineProc lp(gw);
		DrawFalloffSphere(GetFalloff(t),lp);
		}

	gw->setRndLimits(rlim);
	return(0);
	}
Ejemplo n.º 19
0
int LuminaireObject::Display(TimeValue t, INode* inode, ViewExp *vpt, int flags) 
{
	if ( ! vpt || ! vpt->IsAlive() )
	{
		// why are we here
		DbgAssert(!_T("Invalid viewport!"));
		return FALSE;
	}

	Matrix3 m;
	if (dumFlags&DISABLE_DISPLAY)
		return 0;
	GraphicsWindow *gw = vpt->getGW();
	Material *mtl = gw->getMaterial();
	m = inode->GetObjectTM(t);
	gw->setTransform(m);
	DWORD rlim = gw->getRndLimits();
	gw->setRndLimits(GW_WIREFRAME|GW_EDGES_ONLY|GW_BACKCULL| (rlim&GW_Z_BUFFER) );
	if (inode->Selected()) 
		gw->setColor( LINE_COLOR, GetSelColor());
	else if(!inode->IsFrozen() && !inode->Dependent())
		gw->setColor( LINE_COLOR, color.x, color.y, color.z);

	UpdateMesh();
	mesh.render( gw, mtl, NULL, COMP_ALL);	
	gw->setRndLimits(rlim);
	return 0;
}
Ejemplo n.º 20
0
int
FogObject::HitTest(TimeValue t, INode *inode, int type, int crossing,
                          int flags, IPoint2 *p, ViewExp *vpt)
{
    if ( ! vpt || ! vpt->IsAlive() )
		{
			// why are we here?
			DbgAssert(!"Doing HitTest() on invalid view port!");
			return FALSE;
		}
		
		HitRegion hitRegion;
    DWORD	savedLimits;
    int res = FALSE;
    Matrix3 m;
    GraphicsWindow *gw = vpt->getGW();	
    Material *mtl = gw->getMaterial();
    MakeHitRegion(hitRegion,type,crossing,4,p);	
    gw->setRndLimits(((savedLimits = gw->getRndLimits()) | GW_PICK) & ~GW_ILLUM);
    GetMat(t,inode,*vpt,m);
    gw->setTransform(m);
    gw->clearHitCode();
    if (mesh.select( gw, mtl, &hitRegion, flags & HIT_ABORTONHIT )) 
        return TRUE;
    gw->setRndLimits(savedLimits);
    return res;
}
Ejemplo n.º 21
0
int SymmetryMod::HitTest (TimeValue t, INode* inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt, ModContext* mc) {

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


	GraphicsWindow *gw = vpt->getGW();
	Point3 pt;
	HitRegion hr;
	int savedLimits, res = 0;
	Matrix3 tm = CompMatrix(t,inode,mc);

	MakeHitRegion(hr,type, crossing,4,p);
	gw->setHitRegion(&hr);	
	gw->setRndLimits(((savedLimits = gw->getRndLimits()) | GW_PICK) & ~GW_ILLUM);	
	gw->setTransform(tm);
	gw->clearHitCode();
	DrawLineProc lp(gw);
	DrawGizmo(
		vpt->GetScreenScaleFactor(tm.GetTrans())*SCREEN_SCALE,lp);
	gw->setRndLimits(savedLimits);
	if (gw->checkHitCode()) {
		vpt->LogHit(inode, mc, gw->getHitDistance(), 0, NULL); 
		return 1;
		}
	return 0;
}
Ejemplo n.º 22
0
int SimpleWSMObject::Display(TimeValue t, INode* inode, ViewExp *vpt, int flags) 
	{
	if ( ! vpt || ! vpt->IsAlive() )
	{
		// why are we here
		DbgAssert(!_T("Invalid viewport!"));
		return FALSE;
	}

	if (!OKtoDisplay(t)) return 0;
	GraphicsWindow *gw = vpt->getGW();	
	Matrix3 mat = inode->GetObjectTM(t);	 
	UpdateMesh(t);		
	gw->setTransform(mat);

	//mesh.render(gw, inode->Mtls(), 
	DWORD rlim  = gw->getRndLimits();
	
	gw->setRndLimits(GW_WIREFRAME|GW_EDGES_ONLY|/*GW_BACKCULL|*/(rlim&GW_Z_BUFFER?GW_Z_BUFFER:0));
	if (inode->Selected()) 
		gw->setColor( LINE_COLOR, GetSelColor());
	else if(!inode->IsFrozen())
		//gw->setColor( LINE_COLOR, wsmMtl.Kd[0], wsmMtl.Kd[1], wsmMtl.Kd[2]);
		gw->setColor(LINE_COLOR,GetUIColor(COLOR_SPACE_WARPS));

	mesh.render(gw, &wsmMtl, 
		(flags&USE_DAMAGE_RECT) ? &vpt->GetDammageRect() : NULL, COMP_ALL);
	
	gw->setRndLimits(rlim);
	return(0);
	}
Ejemplo n.º 23
0
int SymmetryMod::Display (TimeValue t, INode* inode, ViewExp *vpt, int flagst, ModContext *mc) {

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


	GraphicsWindow *gw = vpt->getGW();
	Point3 pt[4];
	Matrix3 tm = CompMatrix(t,inode,mc);
	int savedLimits;

	gw->setRndLimits((savedLimits = gw->getRndLimits()) & ~GW_ILLUM);
	gw->setTransform(tm);
	if (mp_ip && mp_ip->GetSubObjectLevel() == 1) {
		gw->setColor(LINE_COLOR,GetUIColor(COLOR_SEL_GIZMOS));
	} else {
		gw->setColor(LINE_COLOR,GetUIColor(COLOR_GIZMOS));
	}
	
	DrawLineProc lp(gw);
	DrawGizmo (vpt->GetScreenScaleFactor(tm.GetTrans())*SCREEN_SCALE,lp);

	gw->setRndLimits(savedLimits);
	return 0;
}
Ejemplo n.º 24
0
int FExtrudeMod::Display(
		TimeValue t, INode* inode, ViewExp *vpt, 
		int flagst, ModContext *mc)
	{
	if ( ! vpt || ! vpt->IsAlive() )
	{
		// why are we here
		DbgAssert(!_T("Invalid viewport!"));
		return FALSE;
	}

	GraphicsWindow *gw = vpt->getGW();
	Point3 pt;
	Matrix3 tm = CompMatrix(t,inode,mc);
	int savedLimits;

	gw->setRndLimits((savedLimits = gw->getRndLimits()) & ~GW_ILLUM);
	gw->setTransform(tm);
	
	// Draw start point
	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));
		}	
	base->GetValue(t,&pt,FOREVER,CTRL_ABSOLUTE);
	gw->marker(&pt,HOLLOW_BOX_MRKR);
	
	gw->setRndLimits(savedLimits);
	return 0;
	}
Ejemplo n.º 25
0
int mrGeomShaderObject::HitTest(TimeValue t, INode* inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt) {

	if (MaxSDK::Graphics::IsHardwareHitTesting(vpt))
	{
		return 0;
	}

    if ( ! vpt || ! vpt->IsAlive() )
		{
			// why are we here
			DbgAssert(!_T("Doing Display() on invalid viewport!"));
			return FALSE;
		}
	
		GraphicsWindow* gw = vpt->getGW();
    DWORD rlim = gw->getRndLimits();

    if(DisplayAsWireframe()) {
        gw->setRndLimits(GW_WIREFRAME|GW_EDGES_ONLY|GW_BACKCULL);
    }

    HitRegion hitRegion;
    MakeHitRegion(hitRegion, type, crossing, 4, p);
    Matrix3 tm = inode->GetObjectTM(t);

    gw->setTransform(tm);
    UpdateMesh(t);

    int res = m_mesh.select(gw, inode->Mtls(), &hitRegion, (flags & HIT_ABORTONHIT), inode->NumMtls());

    gw->setRndLimits(rlim);

    return res;
}
Ejemplo n.º 26
0
int bhkProxyObject::Display(TimeValue t, INode* inode, ViewExp *vpt, int flags) 
{
	if (forceRedraw)
	{
		Interface *gi = GetCOREInterface();
		gi->ForceCompleteRedraw();
	}

	Matrix3 m;
	Color color = Color(inode->GetWireColor());
	GraphicsWindow *gw = vpt->getGW();
	Material *mtl = gw->getMaterial();
	m = inode->GetObjectTM(t);
	gw->setTransform(m);
	DWORD rlim = gw->getRndLimits();

	DWORD newrlim = GW_WIREFRAME|GW_Z_BUFFER;
#if VERSION_3DSMAX >= ((5000<<16)+(15<<8)+0) // Version 5+
	newrlim |= GW_EDGES_ONLY;
#endif
	gw->setRndLimits(newrlim);

	if (inode->Selected()) 
		gw->setColor( LINE_COLOR, GetSelColor());
	else if(!inode->IsFrozen() && !inode->Dependent())
		gw->setColor( LINE_COLOR, color);

	Matrix3 m3(true);

	float size = 20.0f;
	Point3 pts[5];
	// X
	pts[0] = Point3(-size, 0.0f, 0.0f); pts[1] = Point3(size, 0.0f, 0.0f);
	vpt->getGW()->polyline(2, pts, NULL, NULL, FALSE, NULL);

	// Y
	pts[0] = Point3(0.0f, -size, 0.0f); pts[1] = Point3(0.0f, size, 0.0f);
	vpt->getGW()->polyline(2, pts, NULL, NULL, FALSE, NULL);

	// Z
	pts[0] = Point3(0.0f, 0.0f, -size); pts[1] = Point3(0.0f, 0.0f, size);
	vpt->getGW()->polyline(2, pts, NULL, NULL, FALSE, NULL);

	//UpdateMesh(t);

	int bvType = 0;
	pblock2->GetValue(PB_BOUND_TYPE, 0, bvType, FOREVER, 0);
	if (bvType != 0)
	{
		Matrix3 tm = gw->getTransform();
		Matrix3 proxyTM(true);
		proxyTM.SetTranslate(proxyPos);
		gw->setTransform(proxyTM);
		proxyMesh.render( gw, mtl, NULL, COMP_ALL);	
		gw->setTransform(tm);
	}
	gw->setRndLimits(rlim);
	return 0;
}
int SplineData::HitTest(ViewExp *vpt,INode *node, ModContext *mc, Matrix3 tm, HitRegion hr, int flags, SplineMapProjectionTypes projType, BOOL selectCrossSection )
{
	if ( ! vpt || ! vpt->IsAlive() )
	{
		// why are we here?
		DbgAssert(!_T("Doing HitTest() on invalid viewport!"));
		return FALSE;
	}

	int res = 0;

	GraphicsWindow *gw = vpt->getGW();
	DWORD limit = gw->getRndLimits();
	gw->setRndLimits(( limit | GW_PICK) & ~GW_ILLUM);
	if (selectCrossSection)
	{
		Tab<int> hitSplines;
		Tab<int> hitCrossSections;

		if (HitTestCrossSection(gw, hr,  projType, hitSplines,hitCrossSections))
		{
			for (int i = 0; i < hitSplines.Count(); i++)
			{
				int splineIndex = hitSplines[i];
				int crossSectionIndex = hitCrossSections[i];
				if ( (mSplineElementData[splineIndex]->CrossSectionIsSelected(crossSectionIndex) && (flags&HIT_SELONLY)) ||
					!(flags&(HIT_UNSELONLY|HIT_SELONLY)))
					vpt->LogHit(node,mc,crossSectionIndex,splineIndex,NULL);
				else if ( (!mSplineElementData[splineIndex]->CrossSectionIsSelected(crossSectionIndex) && (flags&HIT_UNSELONLY)) ||
					!(flags&(HIT_UNSELONLY|HIT_SELONLY)))
					vpt->LogHit(node,mc,crossSectionIndex,splineIndex,NULL);
			}
		}
	}
	else
	{
		for (int splineIndex = 0; splineIndex < mSplineElementData.Count();splineIndex++)
		{
			gw->clearHitCode();
			mSplineElementData[splineIndex]->Display(gw,Matrix3(1),projType );
			if (gw->checkHitCode())
			{
				if ( (mSplineElementData[splineIndex]->IsSelected() && (flags&HIT_SELONLY)) ||
					!(flags&(HIT_UNSELONLY|HIT_SELONLY)))
					vpt->LogHit(node,mc,0,splineIndex,NULL);
				else if ( (!mSplineElementData[splineIndex]->IsSelected() && (flags&HIT_UNSELONLY)) ||
					!(flags&(HIT_UNSELONLY|HIT_SELONLY)))
					vpt->LogHit(node,mc,0,splineIndex,NULL);
			}

		}

	}

	gw->setRndLimits(limit);
	return res;
}
Ejemplo n.º 28
0
int ProtHelpObject::Display(TimeValue t, INode* inode, ViewExp *vpt, int flags) 
{
   if ( ! vpt || ! vpt->IsAlive() )
	{
		// why are we here
		DbgAssert(!_T("Invalid viewport!"));
		return FALSE;
	}
	 
	 Matrix3 m;
   GraphicsWindow *gw = vpt->getGW();
   Material *mtl = gw->getMaterial();

   created = TRUE;
   GetMat(t,inode,*vpt,m);
   gw->setTransform(m);
   DWORD rlim = gw->getRndLimits();
   gw->setRndLimits(GW_WIREFRAME|GW_EDGES_ONLY|GW_BACKCULL| (rlim&GW_Z_BUFFER) );
   if (inode->Selected()) 
      gw->setColor( LINE_COLOR, GetSelColor());
   else if(!inode->IsFrozen() && !inode->Dependent())
      gw->setColor( LINE_COLOR, GetUIColor(COLOR_TAPE_OBJ));
   mesh.render( gw, mtl, NULL, COMP_ALL);
   
   // calc angle
   lastAngle = 0.0;
   #define RadToDegDbl  (180.0 / 3.141592653589793)
   if(refNode[0] && refNode[1]) {
      Point3 origin = m.GetTrans();
      Point3 vec1 = refNode[0]->GetObjectTM(t).GetTrans() - origin;
      Point3 vec2 = refNode[1]->GetObjectTM(t).GetTrans() - origin;
      float len1 = Length(vec1);
      float len2 = Length(vec2);
      if(len1 > 0.00001f && len2 > 0.00001f) {
         double cosAng = (double)DotProd(vec1, vec2) / (double)(len1 * len2);
         if(fabs(cosAng) <= 0.999999)  // beyond float accuracy!
            lastAngle = acos(cosAng) * RadToDegDbl;
         else
            lastAngle = 180.0;
      }
   }
#if 0
   Point3 pt(0,0,0);
   TCHAR buf[32];
   _stprintf(buf, "%g", lastAngle);
   gw->setColor(TEXT_COLOR, GetUIColor(COLOR_TAPE_OBJ));
   gw->text(&pt, buf);
#endif
   DrawLines(t, inode, gw, 1);
   UpdateUI(t);
   gw->setRndLimits(rlim);
   return(0);
}
Ejemplo n.º 29
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;
	}
}
Ejemplo n.º 30
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;
	}