コード例 #1
0
bool AutoProcessor::process(const char *in_str, string &out_str)
{
    if (!bInit)
        return false;
    CComBSTR str(in_str);
    CComVariant vArg(str);
    CComVariant vRes;
    HRESULT hResult = disp.Invoke1(L"Process", &vArg, &vRes);
    if (FAILED(hResult))
        return false;
    CComBSTR out(vRes.bstrVal);
    if (out.Length()){
        size_t size = WideCharToMultiByte(CP_ACP, 0, out, wcslen(out), 0, 0, NULL, NULL);
        char *res = new char[size + 1];
        size = WideCharToMultiByte(CP_ACP, 0, out, wcslen(out), res, size, NULL, NULL);
        res[size] = 0;
        out_str = res;
        delete[] res;
    }else{
        return false;
    }
    return true;
}
コード例 #2
0
/////////////////////////////////////////////////////////////////////////////
// CMaxMaterialCollection
STDMETHODIMP CMaxMaterialCollection::FinalConstruct()
{
	HRESULT hr = E_FAIL, hr2 = E_FAIL;
	//simply make a reference to the scene material collection
	MtlBaseLib* pMtlLib = GetCOREInterface()->GetSceneMtls();
	mLastSceneMtlLibSize = 0;

#ifdef PERSIST_SCRATCH
	mpScratchMtlLib = NULL;
#endif

	assert(pMtlLib);

	//RK: 10/21/04 -- this forces ACT toolkit to initialize at startup and avoids delays during material assignment.
	CComDispatchDriver act;
	/*
		FIXME: Use the .NET wrappers directly instead of this;
		act.CoCreateInstance( L"Autodesk.Act.Core.ContentSerializer" );

		For some reason, the prog ID above is not being registered with the version
		we now install with Max 9, and I've had to resort to using the CLSID directly.

		Either we have the wrong version, or the new DLL just doesn't register its
		prog ID.  (more likely it's the former)
	*/
	CLSID clsidCore;
	hr = CLSIDFromString(L"{978C551B-5919-42F7-81AB-690D66AB7B78}", &clsidCore);

	if( SUCCEEDED(hr) )
		hr = act.CoCreateInstance( clsidCore );

	if (SUCCEEDED(hr))
	{
		CComVariant xml(L"<Material><StandardMtl name=\"Test\" /></Material>");
		CComPtr<IUnknown> mtl;
		hr2 = mtl.CoCreateInstance( L"Autodesk.Act.Content.Material");
		hr2 = act.Invoke1( L"DeserializeString", &xml );
	}
	if ( FAILED(hr) || FAILED(hr2) )
	{
		if (GetCOREInterface()->GetQuietMode())
			GetCOREInterface()->Log()->LogEntry(SYSLOG_ERROR,NO_DIALOG, TSTR(GetString(IDS_PROJNAME)), TSTR(GetString(IDS_ACT_REGISTRATION_FAILED)));
		else
			MaxMsgBox( GetCOREInterface()->GetMAXHWnd(), TSTR(GetString(IDS_ACT_REGISTRATION_FAILED)), TSTR(GetString(IDS_PROJNAME)), MB_OK );
	}
	assert(SUCCEEDED(hr) && SUCCEEDED(hr2));

	//RK: This forces XMlmtl to initialize at startup.
	CComPtr<IVIZPointerClient> pPointerClient;
	hr = GetXMLImpExp(&pPointerClient);
	assert(SUCCEEDED(hr));

#ifdef RECYCLE_MATS
#endif

	RegisterNotification(NotifyProc, this, NOTIFY_FILE_PRE_OPEN);
	RegisterNotification(NotifyProc, this, NOTIFY_FILE_POST_OPEN);
    RegisterNotification(NotifyProc, this, NOTIFY_FILE_OPEN_FAILED);
	RegisterNotification(NotifyProc, this, NOTIFY_FILE_PRE_MERGE);
	RegisterNotification(NotifyProc, this, NOTIFY_FILE_POST_MERGE);
	RegisterNotification(NotifyProc, this, NOTIFY_FILE_PRE_SAVE);
	RegisterNotification(NotifyProc, this, NOTIFY_FILE_POST_SAVE);
	RegisterNotification(NotifyProc, this, NOTIFY_PRE_IMPORT);
	RegisterNotification(NotifyProc, this, NOTIFY_POST_IMPORT);
	RegisterNotification(NotifyProc, this, NOTIFY_SYSTEM_PRE_NEW);
	RegisterNotification(NotifyProc, this, NOTIFY_SYSTEM_POST_NEW);
	RegisterNotification(NotifyProc, this, NOTIFY_SYSTEM_PRE_RESET);
	RegisterNotification(NotifyProc, this, NOTIFY_SYSTEM_POST_RESET);
	RegisterNotification(NotifyProc, this, NOTIFY_SCENE_UNDO);
	RegisterNotification(NotifyProc, this, NOTIFY_SCENE_REDO);
#ifdef SUSPEND_UNDO
	RegisterNotification(NotifyProc, this, NOTIFY_SCENE_PRE_UNDO);
	RegisterNotification(NotifyProc, this, NOTIFY_SCENE_PRE_REDO);
#endif

	RegisterNotification(NotifyProc, (void *)this, NOTIFY_MEDIT_SHOW);

#ifdef TP_SUSPEND_FOR_FILELINK
	RegisterNotification(NotifyProc, this, NOTIFY_FILELINK_PRE_BIND		);
	RegisterNotification(NotifyProc, this, NOTIFY_FILELINK_POST_BIND	);
	RegisterNotification(NotifyProc, this, NOTIFY_FILELINK_PRE_DETACH	);
	RegisterNotification(NotifyProc, this, NOTIFY_FILELINK_POST_DETACH	);
	RegisterNotification(NotifyProc, this, NOTIFY_FILELINK_PRE_RELOAD	);
	RegisterNotification(NotifyProc, this, NOTIFY_FILELINK_POST_RELOAD	);
	RegisterNotification(NotifyProc, this, NOTIFY_FILELINK_PRE_ATTACH	);
	RegisterNotification(NotifyProc, this, NOTIFY_FILELINK_POST_ATTACH	);
#endif

	//and finally a mechanism for other parts of the system to actively suspend TP
	RegisterNotification(NotifyProc, this, NOTIFY_TOOLPALETTE_MTL_SUSPEND	);
	RegisterNotification(NotifyProc, this, NOTIFY_TOOLPALETTE_MTL_RESUME	);

	//for DID 642266, pre and post cloning 
	RegisterNotification(NotifyProc, this, NOTIFY_PRE_NODES_CLONED	);
	RegisterNotification(NotifyProc, this, NOTIFY_POST_NODES_CLONED	);
	


	RefResult res = ReplaceReference(SCENE_MTLLIB_REFNUM, (RefTargetHandle) pMtlLib);
#ifdef PERSIST_SCRATCH
	res = ReplaceReference(SCRATCH_MTLLIB_REFNUM, (RefTargetHandle) &theScratchMtlLib);
#endif

	Resume();
	if(res == REF_SUCCEED)
		hr = S_OK;
	return hr;
}