Ejemplo n.º 1
0
Value*
SnapPoint_cf(Value** arg_list, int count)
{
	check_arg_count_with_keys(SnapPoint, 1, count);
	def_snap_types();
	IPoint2 out;
	IPoint2 loc = to_ipoint2(arg_list[0]);

	Value	*val = key_arg(snapType);
	int		flags = (val == &unsupplied) ? 0 : GetID(snapTypes, elements(snapTypes), val);

	Value *snapPlane = key_arg(snapPlane);
	Matrix3* plane = NULL;
	if (snapPlane != &unsupplied) {
		if (!snapPlane->is_kind_of(class_tag(Matrix3Value)))
			throw TypeError (_T("snapPlane requires a Matrix3 value"), snapPlane);

		Matrix3Value* mv = static_cast<Matrix3Value*>(snapPlane);
		plane = new Matrix3(mv->m);
	}
	Point3	ret = MAXScript_interface->GetActiveViewExp().SnapPoint(loc, out, plane, flags);
	if (plane != NULL)
		delete plane;
	return new Point3Value(ret);
}
Ejemplo n.º 2
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.º 3
0
Value*
wPolyline_cf(Value** arg_list, int count)
{
	check_arg_count_with_keys(wPolyline, 2, count);
	type_check(arg_list[0], Array, _T("wPolyline"));

	Array*			pts_val	= (Array*)arg_list[0];
	int				ct		= pts_val->size; if (!ct) return &undefined; // Return if an empty array is passed			 	
	GraphicsWindow	*gw		= MAXScript_interface->GetActiveViewExp().getGW();
	Point3*			col		= NULL;
	
	if (MaxSDK::Graphics::IsRetainedModeEnabled() && gw->querySupport(GW_SPT_NUM_LIGHTS) == 0)
	{
		return &undefined;
	}

	IPoint3* pts = new IPoint3[ct]; 
	for (int i=0; i < ct; i++)
		pts[i] = to_ipoint3(pts_val->data[i]);

	if (key_arg(rgb) != &unsupplied) {
		type_check(key_arg(rgb), Array, _T("wPolyline"));		
		Array* col_val = (Array*)key_arg(rgb);		 		
		if (ct != col_val->size)
			throw RuntimeError(MaxSDK::GetResourceStringAsMSTR(IDS_RK_INVALID_RGB_ARRAY_SIZE));
		col = new Point3[ct];
		for (int i=0; i < ct; i++)
			col[i] = col_val->data[i]->to_point3()/255.f;
	}

	// 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->wPolyline(ct, pts, col, arg_list[1]->to_bool(), NULL);	

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

	delete [] pts;
	if (col) delete [] col;
	return &ok;
}
Ejemplo n.º 4
0
Value*
hText_cf(Value** arg_list, int count)
{
	check_arg_count_with_keys(hText, 2, count);
	Value*			col_val = key_arg(color);
	GraphicsWindow	*gw		= MAXScript_interface->GetActiveViewExp().getGW();	
	
	if (MaxSDK::Graphics::IsRetainedModeEnabled() && gw->querySupport(GW_SPT_NUM_LIGHTS) == 0)
	{
		return &undefined;
	}

	gw->setColor(TEXT_COLOR, 
		(col_val == &unsupplied) ? Point3(1, 0, 0) : (col_val->to_point3()/255.0f));	
	gw->hText(&(to_ipoint3(arg_list[0])), arg_list[1]->to_string());	
	return &ok;
}
Ejemplo n.º 5
0
Value*
mouse_track_cf(Value** arg_list, int count)
{
	// mouseTrack [on:node|#any] [prompt:"msg"] [snap:#2D|#3D] [trackCallback:fn|#(fn,arg)]

	// set up value local array to hold mouse tracker command mode Value*'s
	Value** vavl;
	value_local_array(vavl, sizeof(tmvl) / sizeof(Value*));
	tmvl* vl = (tmvl*)vavl;
	// show any prompt
	Value*	pv = key_arg(prompt);
	const TCHAR*	prompt = NULL;
	if  (pv != &unsupplied)
	{
		prompt = pv->to_string();
		mprintf(_T("%s "), prompt);
		mflush();
	}
	// setup snap
	Value* sv = key_arg_or_default(snap, n_2D);
	if (sv != n_2D && sv != n_3D)
		throw RuntimeError (MaxSDK::GetResourceStringAsMSTR(IDS_BAD_SNAP_MODE), sv);
	// setup track callback fn
	Value* tcb = NULL;
	Value* tcbarg = NULL;
	Value *tcbv = key_arg(trackCallback);
	if (tcbv != &unsupplied)
	{
		if (is_array(tcbv))  // an array,  #(fn, arg), dig out fn & arg
		{
			Array* tcba = (Array*)tcbv;
			if (tcba->size != 2)
				throw RuntimeError (MaxSDK::GetResourceStringAsMSTR(IDS_BAD_MOVE_CALLBACK_ARGS), tcbv);
			tcb = tcba->data[0];
			if (!is_function(tcb))
				throw RuntimeError (MaxSDK::GetResourceStringAsMSTR(IDS_BAD_MOVE_CALLBACK_ARGS), tcb);
			tcbarg = tcba->data[1];
		}
		else  // just the fn
		{
			tcb = tcbv;
			if (!is_function(tcb))
				throw RuntimeError (MaxSDK::GetResourceStringAsMSTR(IDS_BAD_MOVE_CALLBACK_ARGS), tcbv);
		}
	}

	// pickup any node to track on
	vl->node_val = key_arg(on);

	NodeTab& nodeTab = theTrackMouseCommandMode.proc.nodeTab;
	nodeTab.SetCount(0);
	if( vl->node_val->_is_collection() ) { //Multiple nodes specified
		Value* args[2] = { NULL, (Value*)&nodeTab };
		node_map m = { NULL, collect_nodes, args, 2 };
		vl->node_val->map(m);
	}
	else if( vl->node_val != &unsupplied ) { //Single node specified
		INode* node = vl->node_val->to_node();
		nodeTab.Append( 1, &node );
	}
	for( int i=(nodeTab.Count()-1); i>=0; i--)
		if( nodeTab[i]==NULL ) nodeTab.Delete(i,1); //Delete null nodes

	// set up pickpoint options, enter trackmouse command mode & wait for it to signal completion
	end_track_mouse = FALSE;
	theTrackMouseCommandMode.proc.vl = vl;
	theTrackMouseCommandMode.proc.snap_mode = sv;
	theTrackMouseCommandMode.proc.track_callback = tcb;
	theTrackMouseCommandMode.proc.track_callback_arg = tcbarg;
	theTrackMouseCommandMode.proc.start_track();
	//Changed from Set to Push to prevent an exception when the maxscript code changes the command mode
	//Similar to fix done to MouseTool.cpp - line 661
	MAXScript_interface->PushCommandMode(&theTrackMouseCommandMode);

	// process windows messages until point picked or canceled or keyboard message
    MSG wmsg;
    while (GetMessage(&wmsg, NULL, 0,0))
	{		
		if (wmsg.message == WM_KEYUP && (TCHAR)wmsg.wParam == VK_ESCAPE)
			end_track_mouse = TRUE;
		else if (wmsg.message == WM_KEYUP || wmsg.message == WM_KEYDOWN)
			continue;
		else if (wmsg.message != WM_RBUTTONUP)  // ignore rmousebuttonup's - they mess focus
			MAXScript_interface->TranslateAndDispatchMAXMessage(wmsg);

		if (end_track_mouse)
			break;
	}
	if (!end_track_mouse)
	{
		// we came out of message loop because of a quit, repost the quit and throw a SignalException
		theTrackMouseCommandMode.proc.end_track();
		MAXScript_interface->DeleteMode(&theTrackMouseCommandMode);
		throw SignalException();
	}

	// pickup result value & dismiss input modes
	theTrackMouseCommandMode.proc.end_track();
	MAXScript_interface->DeleteMode(&theTrackMouseCommandMode);
	Value* result = vl->result;
	pop_value_local_array(vavl);
	return_protected(result);
}