Beispiel #1
0
static INode *FindObjectsNode(ReferenceTarget *ths, Object *obj) 
{
	if (NULL == ths) {
		return NULL;
	}
	DependentIterator di(ths);
	ReferenceMaker* maker = NULL;
	while ((maker = di.Next()) != NULL) {
		if (maker->SuperClassID()==BASENODE_CLASS_ID) {
			// Verify that we are this node's object
			INode  *node   = (INode*)maker;
			Object *nobj   = node->GetObjectRef();
			if (nobj) nobj = nobj->FindBaseObject();
			if (nobj==obj)
				return (INode*)maker;
			}

		if (maker->IsRefTarget()) {
			INode *node = FindObjectsNode((ReferenceTarget*)maker, obj);
			if (node) return node;
			}
	}

	return NULL;
}
ParamDimension* BaseLimitCtrl::GetParamDimension(int in_sub)
{
	ParamDimension* dim = defaultDim;
	if (in_sub == BASELIMIT_LIMITEDCTRL_SUBANIM) {
		// The dimension of our limited controller should be whatever our  
		// own dimension is.  Finding that out is tricky.  We do it by  
		// asking whoever it is we are animating.
		ReferenceMaker* refMaker = NULL;
		DependentIterator di(this);
		while ((refMaker = di.Next()) != NULL) {
			// Enumerate its subAnims to find out which one WE are
			int nbSubs = refMaker->NumSubs();
			for (int i = 0; i < nbSubs; i++) {
				// If any is ourselves, bingo!
				Animatable* anim = refMaker->SubAnim(i);
				if (anim == (Animatable*)this) {
					// Ask IT what our dimension is
					dim = refMaker->GetParamDimension(i);
					return dim;
				}
			}
		}
	}

	return dim;
}
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
}
void mrGeomShaderObject::UserDlgProc::SetThing(ReferenceTarget *m) {

	ReferenceMaker* owner = m;
	if((owner == NULL) || ((owner->SuperClassID() == GEOMOBJECT_CLASS_ID) && (owner->ClassID() == MRGEOMETRYOBJECT_CLASS_ID))) {
		m_theObject = static_cast<mrGeomShaderObject*>(owner);
	}
	else {
		DbgAssert(false);
		m_theObject = NULL;
	}
}
Beispiel #5
0
void Texmaps::RescaleWorldUnits(float f) {
	if (TestAFlag(A_WORK1))
		return;
	SetAFlag(A_WORK1);
	// This code will be replaced in particular implementations
	for (int i=0; i<NumRefs(); i++) {
		if ( (i&1) ==0) 
			continue;  // skip the amount controllers
		ReferenceMaker *srm = GetReference(i);
		if (srm) {
			srm->RescaleWorldUnits(f);
			}
		}
		
	}
Beispiel #6
0
INode *plAnimStealthNode::GetINode()
{
    // Go through the reflist looking for RefMakers with a ref to this component.
    // There should only be one INode in this list.
    DependentIterator di(this);
    ReferenceMaker* item = di.Next();
    while( item )
    {
        if( item->SuperClassID() == BASENODE_CLASS_ID )
            return (INode *)item;

        item = di.Next();
    }

    return nil;
}
Beispiel #7
0
plMaxNodeBase *plComponentBase::GetINode()
{
    // Go through the reflist looking for RefMakers with a ref to this component.
    // There should only be one INode in this list.
    DependentIterator di(this);
    ReferenceMaker* rm = di.Next();
    while (rm != nil) 
    {
        if (rm->SuperClassID() == BASENODE_CLASS_ID)
            return (plMaxNodeBase*)rm;

        rm = di.Next();
    }

    return nil;
}
void mrGeomShaderObject::UserDlgProc::SetThingToOwner(IParamMap2 *map) {

	if(map != NULL) {
		ReferenceMaker* owner = map->GetParamBlock()->GetOwner();
		if(owner->IsRefTarget()) {
			SetThing(static_cast<ReferenceTarget*>(owner));
		}
		else {
			DbgAssert(false);
			SetThing(NULL);
		}
	}
	else {
		SetThing(NULL);
	}
}
Beispiel #9
0
// World scaling
void EditPatchMod::RescaleWorldUnits(float f) 
{
	if (TestAFlag(A_WORK1))
		return;
	SetAFlag(A_WORK1);
	
	// rescale all our references
	for (int i = 0; i < NumRefs(); i++)
	{
		ReferenceMaker *srm = GetReference(i);
		if (srm) 
			srm->RescaleWorldUnits(f);
	}
	
	// Now rescale stuff inside our data structures
	EPModContextEnumProc proc(f);
	EnumModContexts(&proc);
	NotifyDependents(FOREVER, PART_GEOM, REFMSG_CHANGE);
}
Beispiel #10
0
static ICustAttribContainer * GetOwnerContainer(ReferenceTarget * owner)
{
	if (NULL == owner) {
		return NULL;
	}

	//Lets find our Parent - which should be a custom Attribute Container
	DependentIterator di(owner);
	ReferenceMaker* maker = NULL;
	while ((maker = di.Next()) != NULL) 
	{
		if (maker->SuperClassID() == REF_MAKER_CLASS_ID &&
				maker->ClassID() == CUSTATTRIB_CONTAINER_CLASS_ID ) 
		{
			return (ICustAttribContainer*)maker;
		}
	}
	
	return NULL;
}
plComponentBase *plMaxNodeBase::IRefMakerToComponent(ReferenceMaker *maker, bool all)
{
    if (!maker)
        return nil;

    // Is the refmaker a paramblock?  If so, it may be the
    // targets block of a component
    if (maker->SuperClassID() == PARAMETER_BLOCK2_CLASS_ID)
    {
        IParamBlock2 *pb = (IParamBlock2*)maker;
        ReferenceMaker *pbowner = pb->GetOwner();

        // Is the owner of the paramblock a helper object (component superclass)?
        if (pbowner && pbowner->SuperClassID() == HELPER_CLASS_ID)
        {
            Object *obj = (Object*)pbowner;
            // Is the owner of the paramblock a component?
            if (IsComponent(obj))
            {
                plComponentBase *comp = (plComponentBase*)obj;

                if (!all)
                {
                    // Does this component actually ref us? (A component can have other
                    // refs to a node, like a proxy object, so we want to make sure this
                    // node is actually in the target list.)
                    for (uint32_t i = 0; i < comp->NumTargets(); i++)
                    {
                        if (comp->GetTarget(i) == this)
                            return comp;
                    }
                }
                else
                    return comp;
            }
        }
    }

    return nil;
}
Beispiel #12
0
INode* FindNodeRef(ReferenceTarget *Rt) 
{
	DependentIterator Di(Rt);
	ReferenceMaker	*Rm;
	INode	*Nd = NULL;

	while (Rm = Di.Next()) 
	{	
		if(Rm->SuperClassID() == BASENODE_CLASS_ID) 
		{
			return (INode *)Rm;
		}

		Nd = FindNodeRef((ReferenceTarget *)Rm);

		if(Nd)
		{
			 return(Nd);
		}
	}

	return(NULL);
}
Beispiel #13
0
bool        plAnimStealthNode::IsParentUsedInScene( void )
{
    if( GetParentMtl() == nil )
        return false;

    // There are two possibilities: either a node uses us and thus has a ref to us,
    // or a multi-sub uses us that a node has a ref to us.

    // Note: we could do the loop as a helper function, but we only do it twice,
    // so it's not *really* worth the effort...
    //// NOTE: the following doesn't seem to work, but keeping here in case it ever does. 
    //// What really actually finds something is the enum dependents loop below
    const char *mtlName = GetParentMtl()->GetName();

    DependentIterator di(this);
    ReferenceMaker* item = di.Next();
    while( item != nil )
    {
        TSTR s;
        item->GetClassName( s );

        if( item->SuperClassID() == BASENODE_CLASS_ID && !CanConvertToStealth( (INode *)( item ) ) )
            return true;        // Horray, a node has a ref to us!

        else if( item->ClassID() == Class_ID(MULTI_CLASS_ID,0) )
        {
            // Multi-sub, run the refs on that guy (we only go one up)
            Mtl *multisub = (Mtl *)item;

            DependentIterator sub(multisub);
            ReferenceMaker* item2 = sub.Next();
            while( item2 != nil )
            {
                if( item2->SuperClassID() == BASENODE_CLASS_ID )
                    return true;        // Horray, a node has a ref to us!
                item2 = sub.Next();
            }

            // No go, keep trying
        }
        else if( item->SuperClassID() == MATERIAL_CLASS_ID )
        {
            int q = 0;
        }

        item = di.Next();
    }

    // Enum dependents
    plGetRefs callback;
    ENUMDEPENDENTS(GetParentMtl(), &callback);
    for(int i = 0; i < callback.fList.GetCount(); i++ )
    {
        ReferenceMaker *maker = callback.fList[ i ];

        TSTR s;
        maker->GetClassName( s );

        if( maker->SuperClassID() == BASENODE_CLASS_ID && !CanConvertToStealth( (INode *)maker ) )
            return true;        // Horray, a node has a ref to us!
    }
    return false;
}
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
}