hsBool plMaxNodeBase::CanConvert(bool recalculate)
{
    // Try and find a cached return value
    plMaxNodeData *md = GetMaxNodeData();
    if (md && !recalculate)
        return md->CanConvert();

    if (UserPropExists("IGNORE"))
        return false;

    Object *obj = EvalWorldState(0/*hsConverterUtils::Instance().GetTime(GetInterface())*/).obj;
    if (obj)
    {
        if  (  obj->CanConvertToType(triObjectClassID)      // MeshObjs are accepted here
            || obj->ClassID() == Class_ID(DUMMY_CLASS_ID,0) // Dummy boxes are accepted here
            || obj->SuperClassID() == CAMERA_CLASS_ID       // All Camera types are accepted here
            || obj->ClassID() == Class_ID(UTILITY_CLASS_ID, 0)      // All Camera targets are accepted here
            || (  obj->ClassID() ==  RTOMNI_LIGHT_CLASSID
                || obj->ClassID() == RTSPOT_LIGHT_CLASSID
                || obj->ClassID() == RTDIR_LIGHT_CLASSID 
                || obj->ClassID() == RTPDIR_LIGHT_CLASSID )
            || (  obj->SuperClassID() == LIGHT_CLASS_ID     // All run time lights are accepted here
               && UserPropExists("RunTimeLight"))

            || IsGroupMember()                              // Group objects are accepted here
            )
        return true;
    }
    return false;
}
Example #2
0
//=============================================================
// Returns TRUE if a node should be ignored during tree traversal.
//
BOOL FUndesirableNode(INode *pnode)
{
	// Get Node's underlying object, and object class name
	Object *pobj = pnode->GetObjectRef();

	// Don't care about lights, dummies, and cameras
	if (pobj->SuperClassID() == CAMERA_CLASS_ID)
		return TRUE;
	if (pobj->SuperClassID() == LIGHT_CLASS_ID)
		return TRUE;

	return FALSE;
}
Example #3
0
int TargetObject::Display(TimeValue t, INode* inode, ViewExp *vpt, int flags) {
	if ( ! vpt || ! vpt->IsAlive() )
	{
		// why are we here
		DbgAssert(!_T("Invalid viewport!"));
		return FALSE;
	}
	
	if (MaxSDK::Graphics::IsRetainedModeEnabled())
	{
		// 11/15/2010 
		// In Nitrous view port, do not draw the target when seeing from the target's camera
		if (NULL != vpt && NULL != vpt->GetViewCamera() && vpt->GetViewCamera()->GetTarget() == inode)
		{
			return 0;
		}
	}

	Matrix3 m;
	GraphicsWindow *gw = vpt->getGW();
	GetMat(t,inode,*vpt,m);
	gw->setTransform(m);
	DWORD rlim = gw->getRndLimits();
	gw->setRndLimits(GW_WIREFRAME|GW_EDGES_ONLY|GW_BACKCULL| (rlim&GW_Z_BUFFER) );
	if (inode->Selected()) 
		gw->setColor( LINE_COLOR, GetSelColor());
	else if(!inode->IsFrozen() && !inode->Dependent() && inode->GetLookatNode()) {
		const ObjectState& os = inode->GetLookatNode()->EvalWorldState(t);
		Object* ob = os.obj;

		// 6/25/01 3:32pm --MQM-- 
		// set color to wire-frame color, 
		// instead of COLOR_LIGHT_OBJ or COLOR_CAMERA_OBJ
		if ( (ob!=NULL) && ( (ob->SuperClassID()==LIGHT_CLASS_ID) ||
							 (ob->SuperClassID()==CAMERA_CLASS_ID) ) )
		{													
			Color color(inode->GetWireColor());
			gw->setColor( LINE_COLOR, color );
		}
		else
			gw->setColor( LINE_COLOR, GetUIColor(COLOR_CAMERA_OBJ)); // default target color, just use camera targ color
	}

	mesh.render( gw, gw->getMaterial(), NULL, COMP_ALL);	
    gw->setRndLimits(rlim);
//	gw->fWinMarker(&pt,HOLLOW_BOX_MRKR);
	return(0);
	}
Example #4
0
/*
====================
GetModifier
====================
*/
static Modifier* GetModifier( INode* i_node, Class_ID cid )
{
	// Get object from node. Abort if no object.
	Object* object = i_node->GetObjectRef();
	if(!object) return NULL;

	// Is derived object ?
	if( object->SuperClassID() == GEN_DERIVOB_CLASS_ID )
	{
		// Yes -> Cast.
		IDerivedObject* derived_object = static_cast< IDerivedObject* >( object );

		// Iterate over all entries of the modifier stack.
		int modStackIndex = 0;
		while( modStackIndex < derived_object->NumModifiers() )
		{
			// Get current modifier.
			Modifier* modifier = derived_object->GetModifier( modStackIndex );

			// Is this ?
			if( modifier->ClassID() == cid )
			{
				// Yes -> Exit.
				return modifier;
			}

			// Next modifier stack entry.
			modStackIndex++;
		}
	}

	// Not found.
	return NULL;
}
Example #5
0
Modifier *CMaxMesh::FindPhysiqueModifier(INode *pINode)
{
    // get the object reference of the node
    Object *pObject;
    pObject = pINode->GetObjectRef();
    if(pObject == 0) return 0;

    // loop through all derived objects
    while(pObject->SuperClassID() == GEN_DERIVOB_CLASS_ID)
    {
        IDerivedObject *pDerivedObject;
        pDerivedObject = static_cast<IDerivedObject *>(pObject);

        // loop through all modifiers
        int stackId;
        for(stackId = 0; stackId < pDerivedObject->NumModifiers(); stackId++)
        {
            // get the modifier
            Modifier *pModifier;
            pModifier = pDerivedObject->GetModifier(stackId);

            // check if we found the physique modifier
            if(pModifier->ClassID() == Class_ID(PHYSIQUE_CLASS_ID_A, PHYSIQUE_CLASS_ID_B)) return pModifier;
        }

        // continue with next derived object
        pObject = pDerivedObject->GetObjRef();
    }

    return 0;
}
Example #6
0
// ================================================== FindPhysiqueModifier()
// Find if a given node contains a Physique Modifier
// DerivedObjectPtr requires you include "modstack.h" from the MAX SDK
Modifier* FindPhysiqueModifier (INode* nodePtr)
{
	// Get object from node. Abort if no object.
	Object* ObjectPtr = nodePtr->GetObjectRef();

	if ( NULL == ObjectPtr) return NULL;

	// Is derived object ?
	if (ObjectPtr->SuperClassID() == GEN_DERIVOB_CLASS_ID){
		// Yes -> Cast.
		IDerivedObject* DerivedObjectPtr = static_cast<IDerivedObject*>(ObjectPtr);

		// Iterate over all entries of the modifier stack.
		int ModStackIndex = 0;
		while (ModStackIndex < DerivedObjectPtr->NumModifiers()){
			// Get current modifier.
			Modifier* ModifierPtr = DerivedObjectPtr->GetModifier(ModStackIndex);
			Class_ID clsid = ModifierPtr->ClassID();
			// Is this Physique ?
			if (ModifierPtr->ClassID() == Class_ID(PHYSIQUE_CLASS_ID_A, PHYSIQUE_CLASS_ID_B))
			{
				// Yes -> Exit.
				return ModifierPtr;
			}

			// Next modifier stack entry.
			ModStackIndex++;
		}
	}

	// Not found.
	return NULL;
}
//// FindSkinModifier ///////////////////////////////////////////////////////
//  Given an INode, gets the ISkin object of that node, or nil if there is
//  none. Taken from the Max4 SDK, ISkin.h
ISkin* plMaxNodeBase::FindSkinModifier()
{
    int modStackIndex;

    // Get object from node. Abort if no object.
    Object *pObj = GetObjectRef();
    if( pObj == nil )
        return nil;

    // Is derived object ?
    while( pObj->SuperClassID() == GEN_DERIVOB_CLASS_ID )
    {
        IDerivedObject *pDerObj = (IDerivedObject *)pObj;

        // Iterate over all entries of the modifier stack.
        for( modStackIndex = 0; modStackIndex < pDerObj->NumModifiers(); modStackIndex++ )
        {
            // Get current modifier.
            Modifier *mod = pDerObj->GetModifier( modStackIndex );

            // Is this Skin ?
            if( mod->ClassID() == SKIN_CLASSID )
            {
                ISkin* skin = (ISkin*)mod->GetInterface(I_SKIN);
                if( skin->GetNumBones() > 0 )
                    return skin;
            }
        }
        pObj = pDerObj->GetObjRef();
    }

    // Not found.
    return nil;
}
Example #8
0
Modifier *CMaxMesh::FindSkinModifier(INode *pINode)
{
#if MAX_RELEASE >= 4000
    // get the object reference of the node
    Object *pObject;
    pObject = pINode->GetObjectRef();
    if(pObject == 0) return 0;

    // loop through all derived objects
    while(pObject->SuperClassID() == GEN_DERIVOB_CLASS_ID)
    {
        IDerivedObject *pDerivedObject;
        pDerivedObject = static_cast<IDerivedObject *>(pObject);

        // loop through all modifiers
        int stackId;
        for(stackId = 0; stackId < pDerivedObject->NumModifiers(); stackId++)
        {
            // get the modifier
            Modifier *pModifier;
            pModifier = pDerivedObject->GetModifier(stackId);

            // check if we found the skin modifier
            if(pModifier->ClassID() == SKIN_CLASSID) return pModifier;
        }

        // continue with next derived object
        pObject = pDerivedObject->GetObjRef();
    }
#endif

    return 0;
}
//----------------------------------------------------------------------------
void SceneBuilder::CollectModifiers (INode *node, 
								 std::vector<Modifier*> &modifiers)
{
	// 确定这个节点是否有修改器。如果有,存储起来。
	//
	// node:
	//		Max场景中节点指针。
	// modifiers:
	//		存储所有修改器指针。

	Object *obj = node->GetObjectRef();
	if (!obj)
		return;

	while (obj->SuperClassID() == GEN_DERIVOB_CLASS_ID)
	{
		IDerivedObject* derObj = static_cast<IDerivedObject*>(obj);

		int modStackIndex = 0;
		while (modStackIndex < derObj->NumModifiers())
		{
			Modifier *mod = derObj->GetModifier(modStackIndex);
			if (mod)
			{
				modifiers.push_back(mod);
			}

			modStackIndex++;
		}

		obj = derObj->GetObjRef();
	}
}
Example #10
0
Modifier* SGP_MaxInterface::FindModifier(INode *pINode, Class_ID id)
{
	// get the object reference of the node
	Object *pObject;
	pObject = pINode->GetObjectRef();
	if(pObject == NULL) 
		return NULL;

	// loop through all derived objects
	while(pObject->SuperClassID() == GEN_DERIVOB_CLASS_ID)
	{
		IDerivedObject *pDerivedObject;
		pDerivedObject = static_cast<IDerivedObject *>(pObject);

		// loop through all modifiers
		int stackId;
		for(stackId = 0; stackId < pDerivedObject->NumModifiers(); stackId++)
		{
			// get the modifier
			Modifier *pModifier;
			pModifier = pDerivedObject->GetModifier(stackId);

			// check if we found the modifier
			if(pModifier->ClassID() == id) 
				return pModifier;
		}

		// continue with next derived object
		pObject = pDerivedObject->GetObjRef();
	}

	return NULL;
}
Example #11
0
ISkin* MaxExportPlugin::FindSkinModifier(INode* node)
{
	Object* object = node->GetObjectRef();

	if (!object)
		return 0;

	while (object->SuperClassID() == GEN_DERIVOB_CLASS_ID && object)
	{
		IDerivedObject* derivedObject = (IDerivedObject*)object;

		int modStackId = 0;
		while (modStackId < derivedObject->NumModifiers())
		{
			Modifier* mod = derivedObject->GetModifier(modStackId);

			//file << "MODIFIER: " << std::to_wstring(mod->ClassID().PartA()) << " " << std::to_wstring(mod->ClassID().PartB()) << "\n";
			if (mod->ClassID() == SKIN_CLASS_ID)
			{
				return (ISkin*)(mod->GetInterface(I_SKIN));
			}
			modStackId++;
		}
		object = derivedObject->GetObjRef();
	}

	return 0;
}
Example #12
0
Object *GetBaseObjectFromNode (INode *node)
{
    Object *ob;
    IDerivedObject *od;
    SClass_ID cid;

    ob=node->GetObjectRef();
    if (ob)
        cid=ob->SuperClassID();
    else return (NULL);
    while ((cid==GEN_DERIVOB_CLASS_ID) && (ob))
    {
        od=(IDerivedObject *)ob;
        ob=od->GetObjRef();
        cid=ob->SuperClassID();
    }
    return(ob);
}
Example #13
0
//=============================================================
// Returns TRUE if a node should be ignored during tree traversal.
//
BOOL FUndesirableNode(INode *pnode)
{
	// Get Node's underlying object, and object class name
	Object *pobj = pnode->GetObjectRef();

	// Don't care about lights, dummies, and cameras
	if (pobj->SuperClassID() == CAMERA_CLASS_ID)
		return TRUE;
	if (pobj->SuperClassID() == LIGHT_CLASS_ID)
		return TRUE;

	return FALSE;

	// Actually, if it's not selected, pretend it doesn't exist!
	//if (!pnode->Selected())
	//	return TRUE;
	//return FALSE;
}
void HavokImport::HandleRagdollOnNonAccum(INode* accumChild, INode* ragdollParent)
{
	const int MaxChar = 512;
	char buffer[MaxChar];

	//Fix for nonaccumNodes

	//TSTR name(A2THelper(buffer, parent->GetName().c_str(), _countof(buffer)));
	ragdollParent->SetName(FormatText(TEXT("Ragdoll_%s"), accumChild->GetName()));

	Object *Obj = ragdollParent->GetObjectRef();

	if (Obj->SuperClassID() == GEN_DERIVOB_CLASS_ID)
	{
		while (Obj->SuperClassID() == GEN_DERIVOB_CLASS_ID) {
		
			IDerivedObject *DerObj = static_cast<IDerivedObject *> (Obj);
			const int nMods = DerObj->NumModifiers();
			for (int i = 0; i < nMods; i++)
			{
				Modifier *Mod = DerObj->GetModifier(i);
				if (Mod->ClassID() == HK_RIGIDBODY_MODIFIER_CLASS_ID)
				{
					ICustAttribContainer* cc = Mod->GetCustAttribContainer();
					if (cc)
					{
					//reset
						Mod->DeleteCustAttribContainer();

					}
					Mod->AllocCustAttribContainer();
					cc = Mod->GetCustAttribContainer();
					CustAttrib* c = (CustAttrib*)CreateInstance(CUST_ATTRIB_CLASS_ID, Class_ID(0x6e663460, 0x32682c72));
					IParamBlock2* custModParameters = c->GetParamBlock(0);
					custModParameters->SetValue(0, 0, accumChild, 0);

					cc->InsertCustAttrib(0, c);
				}
			}
			Obj = DerObj->GetObjRef();
		}
	}
}
Example #15
0
BOOL
TriggerPick::HitTest(IObjParam *ip, HWND hWnd, ViewExp *vpt, IPoint2 m,
                     int flags)
{
    INode *node = ip->PickNode(hWnd, m);
    if (node == NULL)
        return FALSE;
    Object *obj = node->EvalWorldState(0).obj;
    if ((obj->SuperClassID() == HELPER_CLASS_ID && obj->ClassID() == Class_ID(Anchor_CLASS_ID1, Anchor_CLASS_ID2)))
        return FALSE;
    return TRUE;
}
Example #16
0
void CExportNel::getLights (std::vector<CLight>& vectLight, TimeValue time, INode* node)
{
	// Get the root node
	if (node==NULL)
		node=_Ip->GetRootNode();

	// Get a pointer on the object's node
    ObjectState os = node->EvalWorldState(time);
    Object *obj = os.obj;

	// Check if there is an object
	if (obj)
	{
		// Get a GenLight from the node
		if (obj->SuperClassID()==LIGHT_CLASS_ID)
		{
			/*GenLight *maxLight = (GenLight *) obj->ConvertToType(time, Class_ID(OMNI_LIGHT_CLASS_ID , 0));
			if (!maxLight)
				maxLight = (GenLight *) obj->ConvertToType(time, Class_ID(SPOT_LIGHT_CLASS_ID, 0));
			if (!maxLight)
				maxLight = (GenLight *) obj->ConvertToType(time, Class_ID(DIR_LIGHT_CLASS_ID, 0));
			if (!maxLight)
				maxLight = (GenLight *) obj->ConvertToType(time, Class_ID(FSPOT_LIGHT_CLASS_ID, 0));
			if (!maxLight)
				maxLight = (GenLight *) obj->ConvertToType(time, Class_ID(TDIR_LIGHT_CLASS_ID, 0));*/
			//if (maxLight)
			GenLight *maxLight = (GenLight *) obj;

			// Note that the TriObject should only be deleted
			// if the pointer to it is not equal to the object
			// pointer that called ConvertToType()
			bool deleteIt=false;
			if (obj != maxLight) 
				deleteIt = true;

			// Build a light
			CLight nelLight;

			// If build succesful
			if (buildLight (*maxLight, nelLight, *node, time))
				// Add the light in the list
				vectLight.push_back (nelLight);

			// Delete the GenLight if we should...
			if (deleteIt)
				maxLight->DeleteThis();
		}
	}

	// Recurse sub node
	for (int i=0; i<node->NumberOfChildren(); i++)
		getLights (vectLight, time, node->GetChildNode(i));
}
Example #17
0
int PhyExporter::callback(INode *node)
{
	switch (pass)
	{
	case exportPass:
		if (node->Selected())
		{
			Object* obj = node->EvalWorldState(0).obj;
			if (obj->SuperClassID() == GEOMOBJECT_CLASS_ID && obj->CanConvertToType(Class_ID(TRIOBJ_CLASS_ID, 0)))
			{
				TriObject *triObj = (TriObject*)obj->ConvertToType(0, Class_ID(TRIOBJ_CLASS_ID, 0));
				Mesh* mesh = &triObj->mesh;
				int numFaces = mesh->numFaces;
				Face* faces = mesh->faces;
				Point3* verts = mesh->verts;
				Matrix3 worldMat = node->GetObjTMAfterWSM(0);

				indices.reserve(numFaces * 3);
				for (int faceIdx = 0; faceIdx < numFaces; faceIdx++)
				{
					Face* face = &faces[faceIdx];
					for (int corner = 0; corner < 3; corner++)
					{
						int vertIdx = face->v[corner];
						Point3 vert = verts[vertIdx] * worldMat;
						
						int i = 0;
						for (; i < numVertices; i++)
						{
							if (vert != pos[i]) continue;
							break;
						}

						if (i == numVertices)
						{
							pos[i] = vert;
							numVertices++;
						}

						indices.push_back(i);
					}
				}
			}
			return TREE_CONTINUE;
		}
		return TREE_IGNORECHILDREN;
	};

	return TREE_IGNORECHILDREN;
}
Example #18
0
static void
GetCameras(INode *inode, Tab<INode *> *list)
{
    const ObjectState &os = inode->EvalWorldState(0);
    Object *ob = os.obj;
    if (ob != NULL)
    {
        if (ob->SuperClassID() == CAMERA_CLASS_ID)
        {
            list->Append(1, &inode);
        }
    }
    int count = inode->NumberOfChildren();
    for (int i = 0; i < count; i++)
        GetCameras(inode->GetChildNode(i), list);
}
PaintDefromModData *PaintDeformTest::GetPMD(INode *pNode)
{
	ModContext *mc = NULL;

	Object* pObj = pNode->GetObjectRef();

	if (!pObj) return NULL;

	
	while (pObj->SuperClassID() == GEN_DERIVOB_CLASS_ID && mc == NULL)
	{
		IDerivedObject* pDerObj = (IDerivedObject *)(pObj);
			
		int Idx = 0;

		while (Idx < pDerObj->NumModifiers())
		{
			// Get the modifier. 
			Modifier* mod = pDerObj->GetModifier(Idx);

			
			if (mod->ClassID() == PAINTDEFORMTEST_CLASS_ID)
			{
				// is this the correct Physique Modifier based on index?
				PaintDeformTest *pmod = (PaintDeformTest*)mod;
				if (pmod == this)
					{
					mc = pDerObj->GetModContext(Idx);
					break;
					}
			}

			Idx++;
		}

		pObj = pDerObj->GetObjRef();
	}

	if(!mc) return NULL;

	if ( !mc->localData ) return NULL;

	PaintDefromModData *bmd = (PaintDefromModData *) mc->localData;

	return bmd;

}
Example #20
0
// We want to survive a collapsed stack so we reapply ourselves here
void FaceDataToColorMod::NotifyPostCollapse(INode *node,Object *obj, IDerivedObject *derObj, int index) {
	BOOL collapsable;
	mpParams->GetValue (pb_collapsable, TimeValue(0), collapsable, FOREVER);
	if (collapsable) return;

	Object *bo = node->GetObjectRef();
	IDerivedObject *derob = NULL;
	if(bo->SuperClassID() != GEN_DERIVOB_CLASS_ID) {
		derob = CreateDerivedObject(obj);
		node->SetObjectRef(derob);
	} else derob = (IDerivedObject*) bo;

	// Add ourselves to the top of the stack
	derob->AddModifier(this,NULL,derob->NumModifiers());

	// Reengage modification:
	mDisabled = false;
}
Example #21
0
File: mesh.cpp Project: skopp/rush
bool RBExport::MeshModStackIsValid( INode* node )
{
    Object* pObj = node->GetObjectRef();
    if (pObj->SuperClassID() == GEN_DERIVOB_CLASS_ID)
    {
        IDerivedObject* pDerivedObj = (IDerivedObject*)pObj;
        int nMod = pDerivedObj->NumModifiers();
        if (nMod == 0) return true;
        if (nMod > 1) return false;
        Class_ID id = pDerivedObj->GetModifier( 0 )->ClassID(); 
        return (id == SKIN_CLASSID || id == Class_ID( PHYSIQUE_CLASS_ID_A, PHYSIQUE_CLASS_ID_B ));
    }
    else
    {
        return true;
    }
    return false;
} // RBExport::MeshModStackIsValid
Example #22
0
void XModifier::NotifyPostCollapse(INode *node,Object *obj, IDerivedObject *derObj, int index)
{
	// We don't allow a stack collapse, to delete us. 
	// We're going to apply ourselves to the collapsed object

	Object *bo = node->GetObjectRef();
	IDerivedObject *derob = NULL;
	if(bo->SuperClassID() != GEN_DERIVOB_CLASS_ID)
	{
		derob = CreateDerivedObject(obj);
		node->SetObjectRef(derob);
	}
	else
		derob = (IDerivedObject*) bo;

	derob->AddModifier(this,NULL,derob->NumModifiers());
	bModDisabled = false;
}
Example #23
0
BOOL PickForceMode::Filter(INode *node)
{
	if (node->TestForLoop(FOREVER,(ReferenceMaker *) dlg->cont)!=REF_SUCCEED) return FALSE;
	
	Object* obj = node->GetObjectRef();
	if (obj && (obj = obj->FindBaseObject()) != NULL) 
	{	
		if (obj->SuperClassID()==WSM_OBJECT_CLASS_ID)
		{
			ForceField *ff = ((WSMObject*)obj)->GetForceField(node);
			if (ff)
			{
				ff->DeleteThis();
				return TRUE;
			}
			//return (BOOL)((WSMObject*)obj)->SupportsDynamics();
		}
	}
	return FALSE;	
}
bool plMaxNodeBase::IsXRef()
{
    // Is this an XRef'd object?
    Object *obj = GetObjectRef();
    if (obj->SuperClassID() == SYSTEM_CLASS_ID && obj->ClassID() == XREFOBJ_CLASS_ID)
        return true;

    //
    // Is this part of an XRef'd scene?
    //
    // Walk up to our root node
    INode *root = GetParentNode();
    while (!root->IsRootNode())
        root = root->GetParentNode();
    // If our root isn't the main root, we're in an XRef'd scene.
    if (root != GetCOREInterface()->GetRootNode())
        return true;

    return false;
}
Example #25
0
BOOL
ProxSensorObjPick::HitTest(IObjParam *ip, HWND hWnd, ViewExp *vpt, IPoint2 m,
                           int flags)
{
    if ( ! vpt || ! vpt->IsAlive() )
		{
			// why are we here?
			DbgAssert(!"Doing HitTest() on invalid view port!");
			return FALSE;
		}
		
		INode *node = ip->PickNode(hWnd, m);
    if (node == NULL)
        return FALSE;
    Object* obj = node->EvalWorldState(0).obj;
    if ((obj->SuperClassID() == HELPER_CLASS_ID &&
         obj->ClassID() == Class_ID(ProxSensor_CLASS_ID1, ProxSensor_CLASS_ID2)))
        return FALSE;
    return TRUE;
}
Example #26
0
Modifier *FindSkinModifier (INode *node)
{
    Object* ObjectPtr = node->GetObjectRef();
    if (!ObjectPtr) return NULL;

    while (ObjectPtr->SuperClassID() == GEN_DERIVOB_CLASS_ID && ObjectPtr)
    {
        IDerivedObject *DerivedObjectPtr = (IDerivedObject *)(ObjectPtr);
        int ModStackIndex = 0;
        while (ModStackIndex < DerivedObjectPtr->NumModifiers())
        {
            Modifier* ModifierPtr = DerivedObjectPtr->GetModifier(ModStackIndex);
            if (ModifierPtr->ClassID() == SKIN_CLASSID)
                return ModifierPtr;
            ModStackIndex++;
        }
        ObjectPtr = DerivedObjectPtr->GetObjRef();
    }
    return NULL;
}
Example #27
0
// We want to survive a collapsed stack so we reapply ourselves here
void EditFaceDataMod::NotifyPostCollapse(INode *node,Object *obj, IDerivedObject *derObj, int index) {
	if (mCollapsable) return;

	Object *bo = node->GetObjectRef();
	IDerivedObject *derob = NULL;
	if(bo->SuperClassID() != GEN_DERIVOB_CLASS_ID) {
		derob = CreateDerivedObject(obj);
		node->SetObjectRef(derob);
	} else derob = (IDerivedObject*) bo;

	// Add ourselves to the top of the stack
	derob->AddModifier(this,NULL,derob->NumModifiers());

	// Reinsert our local mod data
	ModContext* mc = derob->GetModContext(derob->NumModifiers()-1);
	mc->localData = mpModDataCollapseCache;
	mpModDataCollapseCache = NULL;

	// Reengage modification:
	mDisabled = false;
}
Example #28
0
Modifier *CMaxMesh::FindMorpherModifier(INode *pINode)
{
    // get the object reference of the node
    Object *pObject;
    pObject = pINode->GetObjectRef();
    if(pObject == 0) return 0;

    // loop through all derived objects
    while(pObject->SuperClassID() == GEN_DERIVOB_CLASS_ID)
    {
        IDerivedObject *pDerivedObject;
        pDerivedObject = static_cast<IDerivedObject *>(pObject);

        // loop through all modifiers
        int stackId;
        for(stackId = 0; stackId < pDerivedObject->NumModifiers(); stackId++)
        {
            // get the modifier
            Modifier *pModifier;
            pModifier = pDerivedObject->GetModifier(stackId);

      Class_ID id = pModifier->ClassID();
      char buf[512];
      sprintf(buf, "node %s modifier %d class %d:%d/0x%x:0x%x\n",
        pINode->GetName(), stackId, id.PartA(), id.PartB(), id.PartA(), id.PartB());
      ::OutputDebugStringA(buf);
            // check if we found the physique modifier
            if(pModifier->ClassID() == MR3_CLASS_ID)
      {
        ::OutputDebugStringA("that was it! the morpher I was looking for!\n");
        return pModifier;
      }
        }

        // continue with next derived object
        pObject = pDerivedObject->GetObjRef();
    }

    return 0;
}
Example #29
0
Modifier *FindBonesProModifier (INode *nodePtr)
{
	// Get object from node. Abort if no object.
	Object *ObjectPtr = nodePtr->GetObjectRef();
	if (!ObjectPtr) return NULL;

	// Is derived object ?
	if (ObjectPtr->SuperClassID() == GEN_DERIVOB_CLASS_ID)
	{
		// Yes -> Cast.
		IDerivedObject *DerivedObjectPtr = static_cast<IDerivedObject*>(ObjectPtr);

		// Iterate over all entries of the modifier stack.
		int ModStackIndex = 0;
		while (ModStackIndex < DerivedObjectPtr->NumModifiers())
		{
			// Get current modifier.
			Modifier *ModifierPtr = DerivedObjectPtr->GetModifier(ModStackIndex);

			// Is this Bones Pro OSM?
			if (ModifierPtr->ClassID() == BP_CLASS_ID_OSM )
			{
				// Yes -> Exit.
				return ModifierPtr;
			}
			// Is this Bones Pro WSM?
			if (ModifierPtr->ClassID() == BP_CLASS_ID_WSM )
			{
				// Yes -> Exit.
				return ModifierPtr;
			}
			// Next modifier stack entry.
			ModStackIndex++;
		}
	}
	// Not found.
	return NULL;
}
Example #30
0
Point3 Jiggle::GetDynamicsForces(TimeValue t, Point3 pos, Point3 vel)
{
	INode *aforce;
	Point3 f(0.0f,0.0f,0.0f);

	for( int i=0;i<force_pb->Count(jig_force_node);i++)
	{
		Interval for_ever = FOREVER;
		force_pb->GetValue(jig_force_node, 0, aforce, for_ever, i);
		
		if (aforce)
		{
			Object* obref = aforce->GetObjectRef();

			ForceField* ff = NULL;
			if (obref != NULL)
			{
				WSMObject* wsmObj = static_cast<WSMObject*>(obref->GetInterface(I_WSMOBJECT));
				if (NULL == wsmObj && WSM_OBJECT_CLASS_ID == obref->SuperClassID()) {
					wsmObj = static_cast<WSMObject*>(obref);
				}

				if (wsmObj != NULL) 
				{
					ff = wsmObj->GetForceField(aforce);
				}
			}

		
			if (ff)
			{
				f += ff->Force(t, pos, vel, 0);
				ff->DeleteThis();
			}
		}
	}
	return f;
}