예제 #1
0
Value*
my_file_in_cf(Value** arg_list, int count)
{
	// myFileIn "filename" [quiet:true]

	// pick up arguments
	check_arg_count_with_keys(myFileIn, 1, count);
	two_typed_value_locals(ReadonlyTextFileStream* file, Value* result);
	Value* quiet = key_arg_or_default(quiet, &true_value);
	type_check(quiet, Boolean, _T("myFileIn quiet:"));

	// open a fileStream instance on the file
	vl.file = new ReadonlyTextFileStream();
	vl.file = vl.file->open(arg_list[0]->to_string());
	if (vl.file == (CharStream*)&undefined)
		throw RuntimeError (_T("fileIn cannot open file: "), arg_list[0]);

	// pass it to the stream-based fileIn utility function
	try
	{
		vl.result = file_in(vl.file, (quiet == &true_value));
	}
	catch (...)
	{
		// catch any errors and close the temp filestream
		vl.file->close();
		throw;
	}

	// pop value locals & return fileIn result
	return_value(vl.result);
}
예제 #2
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);
}
예제 #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;
}
예제 #4
0
Value*
GetVPWorldWidth_cf(Value** arg_list, int count)
{
	check_arg_count_with_keys(GetVPWorldWidth, 1, count);
	Point3 val = arg_list[0]->to_point3();
	float ret = MAXScript_interface->GetActiveViewExp().GetVPWorldWidth(val);
	return Float::intern(ret);
}
예제 #5
0
Value*
getTextExtent_gw_cf(Value** arg_list, int count)
{
	check_arg_count_with_keys(getTextExtent, 1, count);
	const TCHAR			*text	= arg_list[0]->to_string();
	GraphicsWindow	*gw		= MAXScript_interface->GetActiveViewExp().getGW();	
	SIZE size;
	gw->getTextExtents(text, &size);
	return new Point2Value((float)size.cx, (float)size.cy);
}
예제 #6
0
Value*
clearScreen_cf(Value** arg_list, int count)
{
	check_arg_count_with_keys(clearScreen, 1, count);
	Box2			rect	= arg_list[0]->to_box2();
	GraphicsWindow	*gw		= MAXScript_interface->GetActiveViewExp().getGW();
	
	if (MaxSDK::Graphics::IsRetainedModeEnabled() && gw->querySupport(GW_SPT_NUM_LIGHTS) == 0)
	{
		return &undefined;
	}

	gw->clearScreen(&rect, key_arg_or_default(useBkg, &false_value)->to_bool());
	return &ok;
}
예제 #7
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;
}
예제 #8
0
Value*
setPos_cf(Value** arg_list, int count)
{
	check_arg_count_with_keys(setPos, 4, count);
	GraphicsWindow *gw = MAXScript_interface->GetActiveViewExp().getGW();
	
	if (MaxSDK::Graphics::IsRetainedModeEnabled() && gw->querySupport(GW_SPT_NUM_LIGHTS) == 0)
	{
		return &undefined;
	}

	gw->setPos(
		arg_list[0]->to_int(),
		arg_list[1]->to_int(),
		arg_list[2]->to_int(),
		arg_list[3]->to_int());
	return &ok;
}
예제 #9
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;
}
예제 #10
0
Value* ExportCalMesh_cf(Value** arg_list, int count)
{	
	char*	Filefullpathfilename		;
	char*	Skeletonfullpathfilename	;
	int		MaxNumOfBones				;
	float	WeightThreshold				;
	int		bUseLODCreation				;
	int		bUseSpringsystem			;
	INode*	MeshNode					;
  bool bUseAxisGL=false;


  // Cedric Pinson, now we can export in gl coordinates
	check_arg_count_with_keys(ExportCalMesh, 7, count);
	Value* transform= key_arg_or_default(transform, &false_value);
	type_check(transform, Boolean, "[The axisGL argument of ExportCalMesh should be a boolean that is true if you want to export in openGL axis]");

  type_check(arg_list[0], String		, "[The first argument of ExportCalMesh should be a string that is a full path name of the file to export]");
	type_check(arg_list[1], String		, "[The 2nd argument of ExportCalMesh should be a string that is the fullpath name of the skeleton file]");
	type_check(arg_list[2], MAXNode		, "[The 3rd argument of ExportCalMesh should be an mesh node that is the mesh to be exported]");
	type_check(arg_list[3], Integer		, "[The 3rd argument of ExportCalMesh should be an integer that is the maximum number of bones per vertex]");
	type_check(arg_list[4], Float		, "[The 4th argument of ExportCalMesh should be a float that is the weight threshold]");
	type_check(arg_list[5], Boolean		, "[The 5th argument of ExportCalMesh should be a boolean that is true if you want LOD creation]");
	type_check(arg_list[6], Boolean		, "[The 6th argument of ExportCalMesh should be a boolean that is true if you want to use spring system]");
	
	try
	{
		Filefullpathfilename		= arg_list[0]->to_string();
		Skeletonfullpathfilename	= arg_list[1]->to_string();
		MeshNode					= arg_list[2]->to_node();
		MaxNumOfBones				= arg_list[3]->to_int();
		WeightThreshold				= arg_list[4]->to_float();
		bUseLODCreation				= arg_list[5]->to_bool();
		bUseSpringsystem			= arg_list[6]->to_bool();
    bUseAxisGL       = (transform->to_bool() != 0);


		if (! strcmp(Filefullpathfilename,"")) return new Integer(1);
		if (! strcmp(Skeletonfullpathfilename,"")) return new Integer(2);

		//Does skeleton file exist ? 
		FILE* _stream;
		_stream = fopen(Skeletonfullpathfilename,"r");
		if (! _stream)return new Integer(3); //Error code number 3
		fclose(_stream);

		if ((MaxNumOfBones <= 0))return new Integer (4);

		if (WeightThreshold < 0.f) return new Integer (5);  

		if (! MeshNode) return new Integer (6); //Null pointer

		//Check if it is a mesh ?
		Object *obj = MeshNode->EvalWorldState(GetCOREInterface()->GetTime()).obj;
		if (! obj->CanConvertToType(Class_ID(TRIOBJ_CLASS_ID, 0))) return new Integer (7); //Not a Mesh
				
		//Create the parameter structure to be sent to the function ExportMeshFromMaxscriptCall
		MeshMaxscriptExportParams	param ( MeshNode, Skeletonfullpathfilename,	MaxNumOfBones, WeightThreshold,bUseLODCreation,bUseSpringsystem);

    theExporter.SetAxisGL(bUseAxisGL); // set axis wanted
    if ( CMaxMeshExport::ExportMeshFromMaxscriptCall(Filefullpathfilename, param) ) {
      // reset to default
      theExporter.SetAxisGL(false);
			return new Integer(0);
    }
		
    theExporter.SetAxisGL(false);
		return new Integer(-1);
	}


	catch(...)
	{	
    theExporter.SetAxisGL(false);

		//MessageBox(NULL,"Exception catched in ExportCalMesh C++ function","Error",MB_OK);
		return new Integer(-2);
	}
}
예제 #11
0
Value* ExportCalSkel_cf(Value** arg_list, int count)
{	
	int			i;
	INodeTab	tabnode;
	char*		fullpathfilename;
	int			ArraySize		;
	bool		bShowUI			;
  bool bUseAxisGL=false; 

  // Cedric Pinson, now we can export in gl coordinates
	check_arg_count_with_keys(ExportCalSkel, 3, count);
	Value* transform= key_arg_or_default(transform, &false_value);
	type_check(transform, Boolean, "[The axisGL argument of ExportCalSkel should be a boolean that is true if you want to export in openGL axis]");

	type_check(arg_list[0], String, "[The first argument of ExportCalSkel should be a string that is a full path name of the file to export]");
	type_check(arg_list[1], Array , "[The 2nd argument of ExportCalSkel should be an array of nodes]");
	type_check(arg_list[2], Boolean,"[The 3rd argument of ExportCalSkel should be a boolean that tells if you want to use the UI or not to select nodes of skeleton]");
	
	try
	{
		fullpathfilename	= arg_list[0]->to_string();
    bUseAxisGL       = (transform->to_bool() != 0);

		//Get Array
		Array* BonesArray	= static_cast<Array*>(arg_list[1]);
		ArraySize			= BonesArray->size;	

		bShowUI				= !!(arg_list[2]->to_bool());

		if (! strcmp(fullpathfilename,"")) return new Integer (1);
		if (! ArraySize)		return new Integer (2);
 
		for (i=0;i<ArraySize;i++)
		{
			if (BonesArray->data[i]->is_kind_of(class_tag(MAXNode)) )
			{
				INode* _node	= 	BonesArray->data[i]->to_node();
				if (! _node)return new Integer (3);

				tabnode.Append(1,&_node);
			}
		}

    theExporter.SetAxisGL(bUseAxisGL);


		//Call the exporter from Maxscript
    if (CMaxSkeletonExport::ExportSkeletonFromMaxscriptCall(fullpathfilename,tabnode, bShowUI) ) {
      // reset axis gl
      theExporter.SetAxisGL(false);
			return new Integer (0);
    }
    theExporter.SetAxisGL(false);
		return new Integer (-1);
	}
	catch(...)
	{	
    theExporter.SetAxisGL(false);

		//MessageBox(NULL,"Exception catched in ExportCalSkel C++ function","Error",MB_OK);
		return new Integer (-2);
	}
}
예제 #12
0
Value* ExportCalAnim_cf(Value** arg_list, int count)
{	
	int i								;
	char*	Filefullpathfilename		;
	char*	Skeletonfullpathfilename	;
	Array*	BonesArray					;
	int		StartFrame					;
	int		EndFrame					;
	int		FrameOffset					;
	int		FrameRate					;
  bool   bUseAxisGL=false;

  // Cedric Pinson, now we can export in gl coordinates
	check_arg_count_with_keys(ExportCalAnim, 7, count);
	Value* transform= key_arg_or_default(transform, &false_value);
	type_check(transform, Boolean, "[The axisGL argument of ExportCalAnim should be a boolean that is true if you want to export in openGL axis]");

	type_check(arg_list[0], String	, "[The first argument of ExportCalAnim should be a string that is a full path name of the file to export]");
	type_check(arg_list[1], String	, "[The 2nd argument of ExportCalAnim should be a string that is the fullpath name of the skeleton file]");
	type_check(arg_list[2], Array	, "[The 3rd argument of ExportCalAnim should be an array of nodes to get anim from]");
	type_check(arg_list[3], Integer	, "[The 4th argument of ExportCalAnim should be an integer that is the start frame number]");
	type_check(arg_list[4], Integer	, "[The 5th argument of ExportCalAnim should be an integer that is the end frame number]");
	type_check(arg_list[5], Integer , "[The 6th argument of ExportCalAnim should be an integer that is the frame offset]");
	type_check(arg_list[6], Integer , "[The 7th argument of ExportCalAnim should be an integer that is the framerate]");
	
	try
	{
  bool   bUseAxisGL=false;

  // Cedric Pinson, now we can export in gl coordinates
	check_arg_count_with_keys(ExportCalAnim, 7, count);
	Value* transform= key_arg_or_default(transform, &false_value);
	type_check(transform, Boolean, "[The axisGL argument of ExportCalAnim should be a boolean that is true if you want to export in openGL axis]");
		Filefullpathfilename		= arg_list[0]->to_string();
		Skeletonfullpathfilename	= arg_list[1]->to_string();
		BonesArray					= static_cast<Array*>(arg_list[2]);
		StartFrame					= arg_list[3]->to_int();
		EndFrame					= arg_list[4]->to_int();
		FrameOffset					= arg_list[5]->to_int();
		FrameRate					= arg_list[6]->to_int();

		if (! strcmp(Filefullpathfilename,""))return new Integer(1);

		if (! strcmp(Skeletonfullpathfilename,"")) return new Integer(2);

		//Does skeleton file exist ?
		FILE* _stream;
		_stream = fopen(Skeletonfullpathfilename,"r");
		if (! _stream)return new Integer(3); //Error code number 3
		fclose(_stream);

		//Get the elements of the bones array
		int ArraySize;
    bUseAxisGL       = (transform->to_bool() != 0);

		ArraySize = BonesArray->size;

		if (! ArraySize) return new Integer(4);
		
		if (StartFrame < 0)	return new Integer(5);

		if (EndFrame < 0)return new Integer(6);

		if (StartFrame > EndFrame ) return new Integer(7);

		if (FrameOffset < 0) return new Integer(8);

		if (FrameRate < 0) return new Integer(9);

		INodeTab	tabnode;
		for (i=0;i<ArraySize;i++)
		{
			if (BonesArray->data[i]->is_kind_of(class_tag(MAXNode)) )
			{
				INode* _node	= 	BonesArray->data[i]->to_node();
				if (! _node)return new Integer(10);
				tabnode.Append(1,&_node);
			}
		}		
		
		AnimExportParams param(Skeletonfullpathfilename, tabnode, StartFrame, EndFrame, FrameOffset, FrameRate);

    theExporter.SetAxisGL(bUseAxisGL); // set axis wanted
    if (CMaxAnimationExport::ExportAnimationFromMaxscriptCall(Filefullpathfilename, &param)) {
      //reset to default
      theExporter.SetAxisGL(false);
			return new Integer(0);
    }


    theExporter.SetAxisGL(false);
		return new Integer(-1);
	}


	catch(...)
	{	
    theExporter.SetAxisGL(false);
		//MessageBox(NULL,"Exception catched in ExportCalAnim C++ function","Error",MB_OK);
		return new Integer(-2);
	}
}