コード例 #1
0
void VMFImport()
{

	Application app;

	CStatus	st;

	Property prop;
	prop = app.GetActiveSceneRoot().GetProperties().GetItem( L"VMFImportProperty" );
	if (!prop.IsValid())
		prop = app.GetActiveSceneRoot().AddProperty( L"VMFImportProperty" ) ;

	CValueArray args(5);
	args[0] = prop;
	args[1] = L"";
	args[2] = L"VMFImportProperty";
	args[3] = (long)4;
	args[4] = true;
	CValue ret;
	st = app.ExecuteCommand(L"InspectObj",args,ret);
	if ( CStatus::OK == st ) {
		//
		// FileName
		//
		char l_szFilename[MAX_PATH];
		memset ( l_szFilename,0,MAX_PATH );

		Parameter parm = prop.GetParameters().GetItem(L"Filename" );
		CString	str = parm.GetValue();
		const wchar_t	* p = str.GetWideString();
		wcstombs( l_szFilename, p, wcslen (p));

		parm = prop.GetParameters().GetItem(L"TexturePath" );
		str = parm.GetValue();
		p = str.GetWideString();
		wcstombs( ___gTexturePathOverride, p, wcslen (p));

		

		//
		// Bools
		//
		parm = prop.GetParameters().GetItem(L"UseMaterials");
		g_iImportMaterials = (bool) parm.GetValue();

		if (l_szFilename && strlen( l_szFilename ) > 0)
		{
			CMapParser	p;
			p.Read ( l_szFilename );
			p.ConvertToSemanticLayer();

		}
		else
		{
			XSILogMessage ( L"Error - Invalid file specified", XSI::siErrorMsg );

		}

	}
}
コード例 #2
0
void DeleteObj( const CValue& in_inputobj )
{
	Application app;
	CValueArray args(1);
	CValue retval;
	long i(0);

	args[i++]= in_inputobj;

	CStatus st = app.ExecuteCommand( L"DeleteObj", args, retval );

	return;
}
コード例 #3
0
// Callback for the siOnActivateEvent event.
SICALLBACK siOnActivateEvent_OnEvent( CRef& in_ctxt )
{
	Context ctxt( in_ctxt );
	//Application().LogMessage(L"siOnActivateEvent_OnEvent called",siVerboseMsg);
	//Application().LogMessage(L"State: " + CString(ctxt.GetAttribute(L"State")),siVerboseMsg);

	bool bState = ctxt.GetAttribute(L"State");
	if(bState)
	{
		CustomProperty prop = app.GetActiveSceneRoot().GetProperties().GetItem(L"AppLink_3DCoat");
		if (prop.IsValid())
		{
			if(prop.GetParameter("bEvent").GetValue())
			{
				CString s_CoatLocation = prop.GetParameter(L"coatLocation").GetValue();
				CString exportPath = CUtils::BuildPath(s_CoatLocation, L"export.txt");
				CString objPath;

				std::ifstream fileref(exportPath.GetAsciiString());
				bool bfile = false;
				if(fileref.good())
				{
					std::string row;
					std::getline(fileref, row);
					objPath = row.c_str();
					bfile = true;
				}
				fileref.close();

				if(bfile)
				{				
					UIToolkit uitool = Application().GetUIToolkit();
					LONG out;
					uitool.MsgBox(L"Import file?", siMsgOkCancel|siMsgInformation|MB_APPLMODAL, L"", (LONG) out);
					if(out == siMsgOk)
					{
						app.LogMessage(L"Start Import!");
						CValueArray args(2);
						args[0] = objPath;
						args[1] = prop.GetParameterValue( L"bReplace" );
						CValue noret;
						app.ExecuteCommand( L"Coat3DImport", args, noret ) ;
					}
				}				
			}
		}
	}

// 	Return value is ignored as this event can not be aborted.
	return CStatus::OK;
}
コード例 #4
0
SICALLBACK coatClicked( CRef& in_ref)
{	
	CustomProperty prop = Get3DCoatProp();

	CValue retVal;
	
	CValueArray args(5);
	args[0] = prop;
	args[3] = (LONG)siLock;
	
	app.ExecuteCommand( L"InspectObj", args, retVal );

	return CStatus::OK;
}
コード例 #5
0
CStatus Popup( const CString& in_inputobjs, const CString& in_keywords, const CString& in_title, const CValue& /*number*/ in_mode, bool in_throw )
{
	Application app;
	CValueArray args(5);
	CValue retval;
	long i(0);

	args[i++]= in_inputobjs;
	args[i++]= in_keywords;
	args[i++]= in_title;
	args[i++]= in_mode;
	args[i++]= in_throw;

	return app.ExecuteCommand( L"InspectObj", args, retval );

}
コード例 #6
0
SICALLBACK AppLink_3DCoat_PPGEvent( const CRef& in_ctxt )
{	
	//Application app;
	PPGEventContext ctxt( in_ctxt ) ;
	CustomProperty prop = ctxt.GetSource();
	PPGEventContext::PPGEvent eventID = ctxt.GetEventID() ;

	//CString s_ExeLocation = prop.GetParameter(L"coatExe").GetValue();

	if ( eventID == PPGEventContext::siOnInit )
	{
		CString s_ExportLocation = prop.GetParameter(L"tempLocation").GetValue();
		CString s_CoatLocation = prop.GetParameter(L"coatLocation").GetValue();

		Plugin pl(app.GetPlugins().GetItem(L"AppLink_3DCoat_Plugin"));
		pluginPath = CUtils::BuildPath(app.GetInstallationPath(pl.GetOrigin()), L"AppLink_3DCoat", L"Application", L"Plugins");

		if(prop.GetParameter(L"tempLocation").GetValue() == L"")
		{
			Project prj = app.GetActiveProject();
			Scene scn = prj.GetActiveScene();
			CString tempPath = CUtils::BuildPath(app.GetInstallationPath(siProjectPath), L"3DCoat", scn.GetName(), scn.GetName() + L".obj");
			prop.GetParameter(L"tempLocation").PutValue(tempPath);
			prop.GetParameter(L"tempLocation").PutCapabilityFlag(siReadOnly, true);
		}

		if(prop.GetParameter(L"coatLocation").GetValue() == L"")
		{
			TCHAR Path[MAX_PATH];
			if(SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, Path))) 
			{
				CString exchPath = CUtils::BuildPath(Path, L"3D-CoatV3", L"Exchange");
				prop.GetParameter(L"coatLocation").PutValue(exchPath);
			}
		}

		//prop.GetParameter(L"bImpNorm").PutCapabilityFlag(siNotInspectable, true);
		//prop.GetParameter(L"bImpNewMat").PutCapabilityFlag(siReadOnly, true);

		ctxt.PutAttribute(L"Refresh",true);

	}
	else if ( eventID == PPGEventContext::siButtonClicked )
	{
		CValue buttonPressed = ctxt.GetAttribute( L"Button" );
		CString tempLocation = prop.GetParameter(L"tempLocation").GetValue();
		CString coatLocation = prop.GetParameter(L"coatLocation").GetValue();
	
		if( buttonPressed.GetAsText() == L"Coat3DExport" )
		{
			CustomProperty in_pset = ctxt.GetSource();

			if(CUtils::EnsureFolderExists(tempLocation, true))
			{
				CValueArray args(6);
				args[0] = tempLocation;
				args[1] = coatLocation;
				args[2] = in_pset.GetParameterValue( L"typePaint" );
				//args[3] = in_pset.GetParameterValue( L"bCopyTexE" );
				args[3] = in_pset.GetParameterValue( L"bExpMat" );
				args[4] = in_pset.GetParameterValue( L"bExpUV" );
				args[5] = in_pset.GetParameterValue( L"bExpNorm" );
				
				CValue retVal;

				app.ExecuteCommand( L"Coat3DExport", args, retVal );
				
				CString exeLocation = prop.GetParameter(L"exeLocation").GetValue();
				bool bStart = prop.GetParameter(L"bStart").GetValue();

				if(exeLocation != L"" && bStart)
				{
					if(!Find3DCoat())
					{
						if((int)::ShellExecute(NULL, TEXT("open"), exeLocation.GetAsciiString(), NULL, NULL, SW_SHOWNORMAL) <= 32)
						{
							app.LogMessage(L"3D-Coat.exe not found!", siWarningMsg);
						}
					}
					else
					{
						app.LogMessage(L"3D-Coat.exe is run!", siWarningMsg);
					}
				}

			}
			else
			{
				app.LogMessage(L"Note temp path exists!", siErrorMsg);
			}
		}
		else if( buttonPressed.GetAsText() == L"Coat3DImport" )
		{
			CustomProperty in_pset = ctxt.GetSource();

			CString exportPath = CUtils::BuildPath(coatLocation, L"export.txt");
			CString objPath;

			std::ifstream mfrExportTxt;
			mfrExportTxt.open (exportPath.GetAsciiString());//c:\Documents and Settings\user\My Documents\3D-CoatV3\Exchange\export.txt
			//app.LogMessage(L"Export.txt is it! :" + strOut);
			if(mfrExportTxt.good())
			{
				std::string row;
				std::getline(mfrExportTxt, row);
				objPath = row.c_str();
				//app.LogMessage(L"first row: " + CString(row.c_str()));
			}
			else
			{
				UIToolkit uitool = app.GetUIToolkit();
				LONG out;
				uitool.MsgBox(L"import file not found!", siMsgOkOnly|siMsgExclamation, L"", (LONG) out);
				if(out == siMsgOk)
				{
					return CStatus::False;
				}
			}
			mfrExportTxt.close();
			app.LogMessage(coatLocation);
			app.LogMessage(exportPath);

			if(objPath != L"")
			{
				CValueArray args(2);
				args[0] = objPath;
				args[1] = in_pset.GetParameterValue( L"bReplace" );

				CValue noret;
				app.ExecuteCommand( L"Coat3DImport", args, noret );
			}
		}
	}
	else if ( eventID == PPGEventContext::siParameterChange )
	{
		Parameter changed = ctxt.GetSource();
		CustomProperty prop = changed.GetParent();		
		CString   paramName = changed.GetScriptName();

		if ( paramName == L"bImpMat" )
		{
			CValue bFlag = prop.GetParameter(L"bImpMat").GetValue();
			//prop.GetParameter(L"swMap").PutCapabilityFlag(siNotInspectable, !bFlag);
			prop.GetParameter(L"swMap").PutCapabilityFlag(siReadOnly, !bFlag);
		}
		ctxt.PutAttribute(L"Refresh",true);
	}

	return CStatus::OK ;
}