Exemplo n.º 1
0
void PaintDeformTest::BeginEditParams( IObjParam *ip, ULONG flags,Animatable *prev )
{
	this->ip = ip;
	PaintDeformTestDesc.BeginEditParams(ip, this, flags, prev);
	paintdeformtest_param_blk.SetUserDlgProc(new PaintDeformTestDlgProc(this));

	pPainter = NULL;

	ReferenceTarget *painterRef = (ReferenceTarget *) GetCOREInterface()->CreateInstance(REF_TARGET_CLASS_ID,PAINTERINTERFACE_CLASS_ID);
	
//set it to the correct verion
	if (painterRef)
		{
		pPainter = (IPainterInterface_V7 *) painterRef->GetInterface(PAINTERINTERFACE_V7);
		}

	TimeValue t = ip->GetTime();

	NotifyDependents(Interval(t,t), PART_ALL, REFMSG_BEGIN_EDIT);
	NotifyDependents(Interval(t,t), PART_ALL, REFMSG_MOD_DISPLAY_ON);
	SetAFlag(A_MOD_BEING_EDITED);

	

}
Exemplo n.º 2
0
void CMaxMaterialCollection::OnPreFileLinkEvent()
{
	//stash all FileLinked materials int a tab. When the event is complete,
	//we need to update refcounts and notify any clients or removals

	//assert(mCacheLinkedMtls.size() == 0);
	if(mCacheLinkedMtls.size() != 0)
		return; //this can happen on PRE_NEW which spawns a PRE_BIND, no need to collect again

	IVizLinkTable* linktbl = 
    static_cast<IVizLinkTable*>(GetCOREInterface(FILELINKMGR_INTERFACE_ID));
	if(!linktbl)
		return;

	//Iterate through the linked materials. For any new material, create a COM wrapper.
	//Creating the wrapper will also fire and event to the palette system.
	int numlinks = linktbl->NumLinkedFiles();
	IVizLinkTable::Iterator it;

	for(int i =0; i<numlinks; i++)
	{
		if(!linktbl->GetLinkID(i, it))
			continue;
		LinkTableRecord *pLTR = linktbl->RecordAt(it);
		if((pLTR == NULL) || (pLTR->ClassID() != DWGTABLERECORD_CLASSID))
			continue; 
		ReferenceMaker* pMtls = pLTR->GetReference(DTR_MTLTABLE_REF);
		if((pMtls == NULL) || (pMtls->ClassID() != VZMATERIALTABLE_CLASSID))
			continue;


		int numMtls = pMtls->NumRefs();

		//enlarge our tab
//		mCacheLinkedMtls.Resize(mCacheLinkedMtls.Count() + numMtls);
		
		for(int i=0; i< numMtls; i++)
		{
			//get the max material to be wrapped
			ReferenceTarget *rtarg = pMtls->GetReference(i);
			if((rtarg == NULL) || (rtarg->SuperClassID() != MATERIAL_CLASS_ID))
				continue;
			Mtl* pMtl = (Mtl*)rtarg;
			assert(pMtl);

			//find the wrapper, which we should have already
			ifxClxnType::iterator it = mMtlMap.find((DWORD_PTR)pMtl);
			if(it != mMtlMap.end())
				mCacheLinkedMtls.insert(*it);
			else 
				assert(0);

			//mCacheLinkedMtls.Append(1, &pMtl);
		}//next mtl
	}//next link
}
Exemplo n.º 3
0
void FEVersionFix::proc (ILoad *iload) {
	int type;
	// See if we're dealing with an old parameter block:
	ReferenceTarget* ref = mod->GetReference (kFEX_PBLOCK_REF);
	if (ref != NULL && ref->ClassID() != Class_ID(PARAMETER_BLOCK2_CLASS_ID, 0)) {
		// Must be an old param block.
		IParamBlock *mp_pblock = (IParamBlock*) ref;
		mp_pblock->GetValue (kFexType, TimeValue(0), type, FOREVER);
		mp_pblock->SetValue (kFexType, TimeValue(0), type+1);
	}
	delete this;
}
Exemplo n.º 4
0
void  PainterTextureSample::InitUI(HWND hWnd)
	{
	hwnd = hWnd;
	if (iPaintButton) ReleaseICustButton(iPaintButton);
	iPaintButton = NULL;

	iPaintButton = GetICustButton(GetDlgItem(hWnd,IDC_PAINT));
	iPaintButton->SetType(CBT_CHECK);
	iPaintButton->SetHighlightColor(GREEN_WASH);

	pPainter = NULL;

	ReferenceTarget *painterRef = (ReferenceTarget *) GetCOREInterface()->CreateInstance(REF_TARGET_CLASS_ID,PAINTERINTERFACE_CLASS_ID);
	
//set it to the correct verion
	if (painterRef)
		{
		pPainter = (IPainterInterface_V5 *) painterRef->GetInterface(PAINTERINTERFACE_V5);
		}

	}
Exemplo n.º 5
0
const TCHAR *RefWatch::GetName() {
   SClass_ID sID = watchMe->SuperClassID();
   if ((sID == MATERIAL_CLASS_ID) || (sID == TEXMAP_CLASS_ID))
      return ((MtlBase *)watchMe)->GetName();
   else if (sID == BASENODE_CLASS_ID)
      return ((INode *)watchMe)->GetName();
   else if (sID == ATMOSPHERIC_CLASS_ID)
      return ((Atmospheric *)watchMe)->GetName();
   else if ((sID == OSM_CLASS_ID) || (sID == WSM_CLASS_ID) ||
      (sID == GEOMOBJECT_CLASS_ID) || (sID == WSM_OBJECT_CLASS_ID))
      return ((BaseObject *)watchMe)->GetObjectName();
   return _T("(Unknown)");
}
Exemplo n.º 6
0
void CMaxMaterialCollection::OnFileLinkMtlsChanged()
{


	//look for any new materials (i.e unwrapped) and add them
	//existing ones should be updated

	IVizLinkTable* linktbl = 
    static_cast<IVizLinkTable*>(GetCOREInterface(FILELINKMGR_INTERFACE_ID));
	if(!linktbl)
		return;

	//Iterate through the linked materials. For any new material, create a COM wrapper.
	//Creating the wrapper will also fire and event to the palette system.
	int numlinks = linktbl->NumLinkedFiles();
	IVizLinkTable::Iterator it;

	for(int j =0; j<numlinks; j++)
	{
		if(!linktbl->GetLinkID(j, it))
			continue;
		LinkTableRecord *pLTR = linktbl->RecordAt(it);
		if((pLTR == NULL) || (pLTR->ClassID() != DWGTABLERECORD_CLASSID))
			continue; 
		ReferenceMaker* pMtls = pLTR->GetReference(DTR_MTLTABLE_REF);
		if((pMtls == NULL) || (pMtls->ClassID() != VZMATERIALTABLE_CLASSID))
			continue;


		int numMtls = pMtls->NumRefs();
		for(int i=0; i< numMtls; i++)
		{
			//get the max material to be wrapped
			ReferenceTarget *rtarg = pMtls->GetReference(i);
			if((rtarg == NULL) || (rtarg->SuperClassID() != MATERIAL_CLASS_ID))
				continue;
			Mtl* pMtl = (Mtl*)rtarg;
			assert(pMtl);

			DWORD_PTR key = (DWORD_PTR) pMtl;

			CMaxMaterial* pWrapper = findItemKey(key);
			if (pWrapper != NULL)
			{
				pWrapper->CheckReference(false, true);
#ifdef TP_SUSPEND_FOR_FILELINK
				//processed so remove it from the cache
				mCacheLinkedMtls.erase(key);
#endif
				continue;
			}

			//Create the wrapper
			CComObject<CMaxMaterial> *pWrapperObject;
			HRESULT hr = CComObject<CMaxMaterial>::CreateInstance(&pWrapperObject);
			assert(SUCCEEDED(hr));
			if(!SUCCEEDED(hr))
			{
				s_PreventRecursion = false;
				return;
			}

			//Initalize the new wrapper
			pWrapperObject->setCollection(this);
			//TODO validate the downcast
			pWrapperObject->setMtl((Mtl *)pMtl);

		}//next mtl
	}//next link
	
#ifdef TP_SUSPEND_FOR_FILELINK

	//Note that if a material is removed by filelink, we should really remove entirely
	//anything left in mCacheLinkedMtls at this point is a candidate for destructo
	//or at least an update

	ifxClxnType::iterator iter=mCacheLinkedMtls.begin();
	while(iter!=mCacheLinkedMtls.end())
	{
		MtlWrapper *pWrapper = (*iter).second;
		assert(pWrapper);

		OnMtlDeleted(pWrapper, (*iter).first);
//			pMtlWrapper->CheckReference(false, true);
		iter++;
	}
	mCacheLinkedMtls.clear();
#endif
}
Exemplo n.º 7
0
void ViewportLoader::LoadEffectsList()
{
	// loads static shader list with name-sorted Shader ClassDesc*'s
	bool bdx9 = false;

	GraphicsWindow *gw = NULL;

	ViewExp& vpt = GetCOREInterface()->GetActiveViewExp();	

	if(vpt.IsAlive())
	{
		gw = vpt.getGW();
		if(gw && gw->GetInterface(D3D9_GRAPHICS_WINDOW_INTERFACE_ID))
	{
		bdx9 = true;
	}
		
	}

	effectsList.ZeroCount();
	SubClassList* scList = GetCOREInterface()->GetDllDir().ClassDir().GetClassList(REF_TARGET_CLASS_ID);
	theHold.Suspend(); // LAM - 3/24/03 - defect 446356 - doing a DeleteThis on created effects, need to make sure hold is off
	for (long i = 0, j = 0; i < scList->Count(ACC_ALL); ++i) {
		if ( (*scList)[ i ].IsPublic() ) {
			ClassDesc* pClassD = (*scList)[ i ].CD();
			const TCHAR *cat = pClassD->Category();
			TCHAR *defcat = GetString(IDS_DX_VIEWPORT_EFFECT);
			if ((cat) && (_tcscmp(cat,defcat) == 0)) 
			{
			
				ReferenceTarget * effect = (ReferenceTarget *)pClassD->Create(TRUE);
				if(effect)
				{

					IDX9DataBridge * vp = (IDX9DataBridge*)effect->GetInterface(VIEWPORT_SHADER9_CLIENT_INTERFACE);
					if( vp)
					{
						if(bdx9)
						{
							
							if(vp->GetDXVersion() >=9.0f || vp->GetDXVersion() == 1.0f)
							{
								effectsList.Append(1, &pClassD);
							}
						}
						else
						{
							if(vp->GetDXVersion() < 9.0f)
							{
								effectsList.Append(1, &pClassD);
							}

						}
					}
					else
					{
						IDXDataBridge * vp = (IDXDataBridge*)effect->GetInterface(VIEWPORT_SHADER_CLIENT_INTERFACE);
						if(vp && !bdx9)
						{
							effectsList.Append(1, &pClassD);
						}
					}

					effect->MaybeAutoDelete();
				}
			}

		}
	}
	theHold.Resume();
	effectsList.Sort(&classDescListCompare);
}
void Unreal3DExport::WriteScript()
{
    // Write script file
    {

        fScript = _tfopen(ScriptFileName,_T("wb"));
        if( !fScript )
        {
            ProgressMsg.printf(GetString(IDS_ERR_FSCRIPT),ScriptFileName);
            throw MAXException(ProgressMsg.data());
        }

        TSTR buf;


        // Write class def     
        _ftprintf( fScript, _T("class %s extends Object;\n\n"), FileName ); 

        // write import
        _ftprintf( fScript, _T("#exec MESH IMPORT MESH=%s ANIVFILE=%s_a.3D DATAFILE=%s_d.3D \n"), FileName, FileName, FileName ); 
        
        // write origin & rotation
        // TODO: figure out why it's incorrect without -1
        Point3 porg = OptOffset * OptScale * -1; 
        _ftprintf( fScript, _T("#exec MESH ORIGIN MESH=%s X=%f Y=%f Z=%f PITCH=%d YAW=%d ROLL=%d \n"), FileName, porg.x, porg.y, porg.z, (int)OptRot.x, (int)OptRot.y, (int)OptRot.z ); 
        
        // write mesh scale
        Point3 psc( Point3(1.0f/OptScale.x,1.0f/OptScale.y,1.0f/OptScale.z));
        _ftprintf( fScript, _T("#exec MESH SCALE MESH=%s X=%f Y=%f Z=%f \n"), FileName, psc.x, psc.y, psc.z ); 
        
        // write meshmap
        _ftprintf( fScript, _T("#exec MESHMAP NEW MESHMA=P%s MESH=%smap \n"), FileName, FileName ); 
        
        // write meshmap scale
        _ftprintf( fScript, _T("#exec MESHMAP SCALE MESHMAP=%s X=%f Y=%f Z=%f \n"), FileName, psc.x, psc.y, psc.z ); 

        // write sequence
        _ftprintf( fScript, _T("#exec MESH SEQUENCE MESH=%s SEQ=%s STARTFRAME=%d NUMFRAMES=%d \n"), FileName, _T("All"), 0, FrameCount-1 ); 

        // Get World NoteTrack
        ReferenceTarget *rtscene = pInt->GetScenePointer();
        for( int t=0; t<rtscene->NumNoteTracks(); ++t )
        {
            DefNoteTrack* notetrack = static_cast<DefNoteTrack*>(rtscene->GetNoteTrack(t));
            for( int k=0; k<notetrack->keys.Count(); ++k )
            {


                NoteKey* notekey = notetrack->keys[k];                        
                TSTR text = notekey->note;
                int notetime = notekey->time / pScene->GetSceneTicks();

                while( !text.isNull() )
                {
                    TSTR cmd = SplitStr(text,_T('\n'));
                    
                    if( MatchPattern(cmd,TSTR(_T("a *")),TRUE) )
                    {
                        SplitStr(cmd,_T(' '));
                        TSTR seq = SplitStr(cmd,_T(' '));
                        int end = _ttoi(SplitStr(cmd,_T(' ')));;
                        TSTR rate = SplitStr(cmd,_T(' '));
                        TSTR group = SplitStr(cmd,_T(' '));

                        if( seq.isNull() )
                        {
                            ProgressMsg.printf(_T("Missing animation name in notekey #%d"),notetime);
                            throw MAXException(ProgressMsg.data());
                        }
                        
                        if( end <= notetime )
                        {
                            ProgressMsg.printf(_T("Invalid animation endframe (%d) in notekey #%d"),end,notetime);
                            throw MAXException(ProgressMsg.data());
                        }

                        int startframe = notetime;
                        int numframes = end - notetime;

                        buf.printf( _T("#exec MESH SEQUENCE MESH=%s SEQ=%s STARTFRAME=%d NUMFRAMES=%d"), FileName, seq, notetime, numframes );

                        if( !rate.isNull() )
                            buf.printf( _T("%s RATE=%f"), buf, rate );
                        
                        if( !group.isNull() )
                            buf.printf( _T("%s GROUP=%f"), buf, rate );
                        
                        SeqName = seq;
                        SeqFrame = startframe;

                        buf.printf( _T("%s \n"), buf );
                        _fputts( buf, fScript ); 

                    }
                    else if( MatchPattern(cmd,TSTR(_T("n *")),TRUE) )
                    {
                        SplitStr(cmd,_T(' '));
                        TSTR func = SplitStr(cmd,_T(' '));
                        TSTR time = SplitStr(cmd,_T(' '));
                        
                        if( func.isNull() )
                        {
                            ProgressMsg.printf(_T("Missing notify name in notekey #%d"),notetime);
                            throw MAXException(ProgressMsg.data());
                        }

                        if(  time.isNull() )
                        {
                            ProgressMsg.printf(_T("Missing notify time in notekey #%d"),notetime);
                            throw MAXException(ProgressMsg.data());
                        }

                        buf.printf( _T("#exec MESH NOTIFY MESH=%s SEQ=%s TIME=%s FUNCTION=%s"), FileName, SeqName, time, func );
                        
                        _fputts( buf, fScript ); 
                    }




                }
            }
        }


        // TODO: write materials
        if( Materials.Count() > 0 )
        {
            for( int i=0; i<Materials.Count(); ++i )
            {
                IGameMaterial* mat = Materials[i].Mat;
                if( mat == NULL )
                    continue;

                _ftprintf( fScript, _T("#exec MESHMAP SETTEXTURE MESHMAP=%s NUM=%d TEXTURE=%s \n"), FileName, i, _T("DefaultTexture") ); 
            }
        }

    }
}