Beispiel #1
0
    bool GetComponents()
    {
        fSelectedNodes.ZeroCount();
        fSharedComps.ZeroCount();

        Interface *ip = GetCOREInterface();

        int nodeCount = ip->GetSelNodeCount();
        if (nodeCount == 0)
            return false;
        
        // Get the components shared among the selected nodes
        int i;
        fSelectedNodes.SetCount(nodeCount);
        for (i = 0; i < nodeCount; i++)
            fSelectedNodes[i] = ip->GetSelNode(i);

        INodeTab sharedComps;
        if (plSharedComponents(fSelectedNodes, sharedComps) == 0)
            return false;

        // Put the shared components in a list
        fSharedComps.SetCount(sharedComps.Count());
        for (i = 0; i < sharedComps.Count(); i++)
            fSharedComps[i] = ((plMaxNode*)sharedComps[i])->ConvertToComponent();

        return true;
    }
Beispiel #2
0
int plSharedComponents(INodeTab& nodes, INodeTab& components)
{
    components.ZeroCount();

    if (nodes.Count() == 0)
        return 0;

    plMaxNodeBase *firstNode = (plMaxNodeBase*)nodes[0];
    int num = firstNode->NumAttachedComponents();
    
    // Resize the list to it's max size to be more efficient
    components.SetCount(num);

    int i;

    // Put all the components on the first node into a list
    for (i = 0; i < num; i++)
        components[i] = firstNode->GetAttachedComponent(i)->GetINode();

    // Delete any components that aren't on all the other nodes
    for (i = 1; i < nodes.Count(); i++)
    {
        plMaxNodeBase *node = (plMaxNodeBase*)nodes[i];
        uint32_t count = node->NumAttachedComponents();

        for (int j = components.Count()-1; j >= 0; j--)
        {
            if (!INodeHasComponent(node, (plMaxNodeBase*)components[j]))
                components.Delete(j, 1);
        }
    }

    return components.Count();
}
Beispiel #3
0
void plComponentDlg::SelectComponentTargs(INodeTab& nodes)
{
    // Make an INode tab with all the targets in it
    INodeTab targets;
    for (int i = 0; i < nodes.Count(); i++)
    {
        plComponentBase *comp = ((plMaxNode*)nodes[i])->ConvertToComponent();

        for (int j = 0; j < comp->NumTargets(); j++)
        {
            INode *node = comp->GetTarget(j);
            if (node && !FindNodeInTab(node, targets))
                targets.Append(1, &node);
        }
    }

    // If the user is selecting a single component, make sure it is selected in the rollup too
    if (plComponentUtil::Instance().IsOpen() && nodes.Count() == 1)
        plComponentUtil::Instance().fLastComponent = ((plMaxNode*)nodes[0])->ConvertToComponent();
    
    theHold.Begin();
    fInterface->RedrawViews(fInterface->GetTime(), REDRAW_BEGIN);
    fInterface->ClearNodeSelection(FALSE);              // Deselect current nodes

    // If there is at least one valid target, select it
    if (targets.Count() > 0)
        fInterface->SelectNodeTab(targets, TRUE, FALSE);

    fInterface->RedrawViews(fInterface->GetTime(), REDRAW_END);
    theHold.Accept("Select");
}
Beispiel #4
0
void DumpHitDialog::proc(INodeTab &nodeTab)

{


int nodeCount = nodeTab.Count(); 

if (nodeCount == 0) return;

theHold.Begin();

for (int i=0;i<nodeTab.Count();i++)
	{

	eo->pblock2->Append(pb_nodelist,1,&nodeTab[i]);
	macroRecorder->FunctionCall(_T("$.blobMeshOps.AddBlob"), 1, 0, 
											mr_reftarg,nodeTab[i]);

	}

theHold.Accept(GetString(IDS_ADD));
eo->NotifyDependents(FOREVER, PART_GEOM, REFMSG_CHANGE);
eo->ip->RedrawViews(eo->ip->GetTime());

}
void PFOperatorForceSpaceWarp::proc(INodeTab &nodeTab)
{
	if (nodeTab.Count() == 0) return;
	theHold.Begin();
	pblock()->Append(kForceSpaceWarp_ForceNodeList, nodeTab.Count(), nodeTab.Addr(0));
	theHold.Accept(GetString(IDS_PARAMETERCHANGE));
}
Beispiel #6
0
void GR2ImportImpl::OrderBones(INodeTab& bones)
{
   if (info.Skeletons.size() == 1)
   {
      NameNodeMap nodes;
      INodeTab rv = ImportSkeleton(*info.Skeletons[0]);
      // Strip out auto-generated bones.  Place in order found in ini file
      for (size_t i = 0, n = rv.Count(); i<n; ++i)
      {
         INode *node = rv[i];

         bool found = false;
         for (stringlist::const_iterator itr=boneMatch.begin(), end=boneMatch.end(); itr != end; ++itr)
         {
            if (wildmatch(*itr, node->GetName())) {
               nodes[*itr].Append(1, &node);
               found = true;
            }
         }
         if (!found)
         {
            node->SetUserPropInt("MDBBoneIndex", int(bones.Count()));
            bones.Append(1, &node);
         }
      }
      for (stringlist::const_iterator itr=boneMatch.begin(), end=boneMatch.end(); itr != end; ++itr)
      {
         INodeTab& map = nodes[*itr];
         for (size_t i = 0, n = map.Count(); i<n; ++i)
         {
            INode *node = map[i];
            node->SetUserPropInt("MDBBoneIndex", int(bones.Count()));
            bones.Append(1, &node);
         }
      }
      // When in face mode, swap the Face Bones for the first N bones in the skeleton.  
      //   Some of the later bones like Head, Neck, Ribcage are still used so we cannot 
      //   discard the whole skeleton.
      if (enableFaceMode)
      {
         size_t curIdx = 0;
         for (size_t i = 0, n = bones.Count(); i<n; ++i)
         {
            INode *node = bones[i];
            for (stringlist::const_iterator itr=faceBoneMatch.begin(), end=faceBoneMatch.end(); itr != end; ++itr)
            {
               if (wildmatch(*itr, node->GetName())) {
                  bones[i] = bones[curIdx];
                  bones[curIdx] = node;
                  node->SetUserPropInt("MDBBoneIndex", int(curIdx));
                  ++curIdx;
                  break;
               }
            }
         }
      }
   }
}
//we need to not only check the expose node and reference node to see if there flags are set, but 
//we also need to check their parents since a call on node->GetNodeTM may call node->parent->UpdateTM
//node->parent->parent->UpdateTM.. etc... So all of the parents need to get checked to.
BOOL BaseExposeControl::AreNodesOrParentsInTMUpdate()
{
	//collect expose node parents.
	if(exposeTransform)
	{
		INode *exposeNode = exposeTransform->GetExposeNode();
		if(exposeNode)
		{
			INodeTab nodes;
			nodes.Append(1,&exposeNode);
			CollectParents(nodes,exposeNode);
	
			//simple check to see if referenceNode isn't exposeNodeParent.. if not.. collect them too
			INode *refNode = exposeTransform->GetReferenceNode();
			if(refNode&&refNode!=exposeNode->GetParentNode())
			{
				nodes.Append(1,&refNode);
				CollectParents(nodes,refNode);
			}

			for(int i=0;i<nodes.Count();++i)
			{
				if(nodes[i]->TestAFlag(A_INODE_IN_UPDATE_TM)==TRUE)
					return TRUE;
			}
		}
	}

	return FALSE;
}
void TestSplitBySourceDlgProc::SelectSources( HWND hWnd, IParamBlock2* pblock )
{
	if (pblock == NULL) return;
	if (selectionUpdateInProgress) return;

	int allCount = GetPFSystemPool()->NumPFSystems();
	HWND hWndSystem = GetDlgItem(hWnd, IDC_SOURCELIST);
	int listCount = SendMessage(hWndSystem, LB_GETCOUNT, 0, 0);
	if (listCount == LB_ERR) return; // dialog error
	if (allCount != listCount) return; // async

	selectionUpdateInProgress = true;
	
	INodeTab selNodes;
	for(int i=0; i<listCount; i++) {
		int selected = SendMessage(hWndSystem, LB_GETSEL, i, 0);
		if (selected > 0) {
			INode* selNode = GetPFSystemPool()->GetPFSystem(i);
			if (selNode != NULL)
				selNodes.Append(1, &selNode);
		}
	}

	bool resetSelected = ( selNodes.Count() != pblock->Count(kSplitBySource_sources) );
	if (!resetSelected) {
		for(int i=0; i<selNodes.Count(); i++)
			if (!SBSIsSelectedSource(selNodes[i], pblock))
			{ resetSelected = true; break; }
	}
	
	if (resetSelected) {
		macroRec->Disable();
		theHold.Begin();
		pblock->ZeroCount(kSplitBySource_sources);
		if (selNodes.Count() > 0) {
			for(int i=0; i<selNodes.Count(); i++) {
				int nodeHandle = (int)selNodes[i]->GetHandle();
				pblock->Append(kSplitBySource_sources, 1, &nodeHandle);
			}
		}
		theHold.Accept(GetString(IDS_PARAMETERCHANGE));
		macroRec->Enable();
		pblock->NotifyDependents( FOREVER, 0, kSplitBySource_RefMsg_MacrorecSources );
	}

	selectionUpdateInProgress = false;
}
Beispiel #9
0
bool IIsNodeInTab(INodeTab &tab, INode *node)
{
    for (int i = 0; i < tab.Count(); i++)
        if (tab[i] == node)
            return true;

    return false;
}
Beispiel #10
0
static void ResetSel()
{
	INodeTab selNodes;
	GetCOREInterface7()->GetSelNodeTab(selNodes);
	if (selNodes.Count() > 0) {
		ResetXForm::ResetNodes(selNodes);
	}
}
void DumpHitDialog::proc(INodeTab &nodeTab)

{


int nodeCount = nodeTab.Count(); 

if (nodeCount == 0) return;

TimeValue t = GetCOREInterface()->GetTime();

for (int i=0;i<nodeTab.Count();i++)
{
	macroRecorder->FunctionCall(_T("$.modifiers[#Skin_Morph].skinMorphOps.addBone"), 1, 0,mr_reftarg,nodeTab[i]);
	eo->AddBone(nodeTab[i]);
}
eo->BuildTreeList();
}
INode* MaterialUIHandler::GetNode (EPolyMod *pMod){
	if (!pMod || !pMod->EpModGetIP()) return NULL;

	ModContextList mcList;
	INodeTab nodes;
	pMod->EpModGetIP()->GetModContexts (mcList, nodes);
	INode* objnode = nodes.Count() == 1 ? nodes[0]->GetActualINode(): NULL;
	nodes.DisposeTemporary();
	return objnode;
}
Beispiel #13
0
 virtual void proc(INodeTab &nodeTab)
 {
     for (int i = 0; i < nodeTab.Count(); i++)
     {
         for (int j = 0; j < fSharedComps.Count(); j++)
         {
             fSharedComps[j]->AddTarget((plMaxNodeBase*)nodeTab[i]);
         }
     }
 }
Beispiel #14
0
// Wow, this INodeTab class is very thorough
bool FindNodeInTab(INode *node, INodeTab& nodes)
{
    for (int i = 0; i < nodes.Count(); i++)
    {
        if (node == nodes[i])
            return true;
    }

    return false;
}
Beispiel #15
0
    virtual int filter(INode *node)
    {
        // Make sure this node doesn't already have the components
        for (int i = 0; i < fSelectedNodes.Count(); i++)
        {
            if (fSelectedNodes[i] == node)
                return FALSE;
        }

        return TRUE;
    }
Beispiel #16
0
	void proc(INodeTab &nodeTab)
	{
		int i;
		Tab<int>	freeC;
		freeC.ZeroCount();


		// find available channels
		for(i=0;i<100;i++)
		{
			int tI = i;
			if(!mp->chanBank[i].mModded) freeC.Append(1,&tI,0);
		}

		// If there are less channels than incoming targets, tell the user and quit out
		if(nodeTab.Count()>freeC.Count())
		{
			TSTR buf1(GetString(IDS_NOFREE));
			TSTR buf2(GetString(IDS_CANNOT));
			MessageBox(mp->hwChannelList,buf1,buf2,MB_ICONSTOP | MB_OK);
			goto leapOut;
		}

		// Do the assignment of nodes
		for(i=0;i<nodeTab.Count();i++)
		{
			UI_MAKEBUSY

			if (theHold.Holding()) 
				theHold.Put(new Restore_FullChannel(mp, i ));

			mp->ReplaceReference(101+freeC[i],nodeTab[i]);
			mp->chanBank[freeC[i]].buildFromNode(nodeTab[i]);
			mp->chanBank[freeC[i]].ReNormalize();

			UI_MAKEFREE
		}

		leapOut:
		i=0;
	}
Beispiel #17
0
void FormationBhvr::PickWhom()
{
   int i;

	// first set the nodetab to equal the existing nodes to flee
	// so that they are selected in the dialog
	if (pblock->Count(follower) > 0)
	{
	    INode *node;
		SelMaxNodes.Resize(pblock->Count(follower));
		SelMaxNodes.SetCount(0);
		for (i=0; i<pblock->Count(follower); i++)
		{
		    pblock->GetValue(follower,0,node,FOREVER,i);
			SelMaxNodes.Append(1,&node);
		}
	}
	else SelMaxNodes.ZeroCount(); 

	// let the user pick
	DoHitObjInMAX.SetSingleSelect(FALSE); // allow multiple selection
	if (!GetCOREInterface()->DoHitByNameDialog(&DoHitObjInMAX)) return;

    // Set follower to the returned nodes
	theHold.Begin();
	pblock->Resize(follower,SelMaxNodes.Count());
	pblock->SetCount(follower,0);
	for (i=0; i<SelMaxNodes.Count(); i++)
		pblock->Append(follower,1,&SelMaxNodes[i]);


	//zero out the formation matrix that's used for saving it out.
	pblock->ZeroCount(follower_matrix1);
	pblock->ZeroCount(follower_matrix2);
	pblock->ZeroCount(follower_matrix3);
	pblock->ZeroCount(follower_matrix4);

    theHold.Accept(GetString(IDS_UN_WHOM));
}
BOOL PickControlNode::Pick(IObjParam *ip,ViewExp *vpt)
   {

	 if ( ! vpt || ! vpt->IsAlive() )
	{
		// why are we here
		DbgAssert(!_T("Invalid viewport!"));
		return FALSE;
	}

   INode *node = vpt->GetClosestHit();
   if (node) {
      // RB 3/1/99: This should use the node tm not the object TM. See ModifyObject() imp.
      Matrix3 ourTM,ntm = node->GetNodeTM(GetCOREInterface()->GetTime()); //node->GetObjectTM(ip->GetTime());  

      ModContextList mcList;
      INodeTab nodes;
      ip->GetModContexts(mcList,nodes);
      if (nodes.Count())
         {
         ourTM = nodes[0]->GetObjectTM(GetCOREInterface()->GetTime());
         ourTM    = Inverse(ourTM);
         Box3 bounds;
         bounds.Init();
         ObjectState os = node->EvalWorldState(GetCOREInterface()->GetTime());
         ViewExp& vp = GetCOREInterface()->GetActiveViewExp();
         if ( ! vp.IsAlive() )
				 {
				 	// why are we here
				 	DbgAssert(!_T("Invalid viewport!"));
				 	return FALSE;
				 }
				 os.obj->GetWorldBoundBox(GetCOREInterface()->GetTime(), node, vp.ToPointer(), bounds );
         
         Point3 min = bounds.pmin * ourTM;
         Point3 max = bounds.pmax * ourTM;
         theHold.Begin();
         mod->pblock2->SetValue(particlemesher_customboundsa,0,min);
         mod->pblock2->SetValue(particlemesher_customboundsb,0,max);
         theHold.Accept(GetString(IDS_BOUNDS));
         mod->NotifyDependents(FOREVER,0,REFMSG_CHANGE);
         mod->UpdateUI();


         }

      nodes.DisposeTemporary();
      }
   return TRUE;
   }
AnimExportParams::AnimExportParams(const char* _skeletonfilepath, INodeTab& _tabbones, int _startframe, int _endframe, int _frameoffset, int _framerate)
{
	int i = 0;

	m_skeletonfilepath	= strdup(_skeletonfilepath);
	m_startframe		= _startframe;
	m_endframe			= _endframe;
	m_frameoffset		= _frameoffset;
	m_framerate			= _framerate;

	//Copy thr array of nodes
	m_tabbones.ZeroCount();
	const int num = _tabbones.Count();
	for (i=0;i<num;i++)
	{
		INode* node = _tabbones[i];
		m_tabbones.Append(1,&node);
	}
}
Beispiel #20
0
void VertexPaint::TurnVCOn(BOOL shaded)
{
	ModContextList list;
	INodeTab NodeTab;
	
	// Only the selected nodes will be affected
	ip->GetModContexts(list,NodeTab);

	for( int i = 0 ; i < NodeTab.Count() ; i++)
	{
		if(shaded)
			NodeTab[i]->SetShadeCVerts(!NodeTab[i]->GetShadeCVerts());
		else
			NodeTab[i]->SetCVertMode(!NodeTab[i]->GetCVertMode());	
		
	}
	NotifyDependents(FOREVER, PART_VERTCOLOR, REFMSG_CHANGE);
	ip->RedrawViews(ip->GetTime());
}
void FaceDataToColorMod::DisplayColors () {
	if (!mpInterface) return;

	int channel = 0;
	if (mpParams) mpParams->GetValue (pb_channel, TimeValue(0), channel, FOREVER);

	ModContextList mcList;
	INodeTab nodes;
	mpInterface->GetModContexts(mcList,nodes);

	for (int nd = 0; nd<nodes.Count(); nd++) {
		nodes[nd]->SetCVertMode (true);
		nodes[nd]->SetShadeCVerts (true);
		if (channel) nodes[nd]->SetVertexColorType (nvct_illumination);
		else nodes[nd]->SetVertexColorType (nvct_color);
		//nodes[nd]->NotifyDependents (FOREVER, PART_DISPLAY, REFMSG_CHANGE);
	}

	// KLUGE: above notify dependents call only seems to set a limited refresh region.  Result looks bad.
	// So we do this instead:
	NotifyDependents (FOREVER, PART_DISPLAY, REFMSG_CHANGE);
	mpInterface->RedrawViews (mpInterface->GetTime());
}
bool CollisionImport::ImportPackedNiTriStripsShape(INode *rbody, bhkRigidBodyRef body, bhkPackedNiTriStripsShapeRef shape, INode *parent, Matrix3& tm)
{
	if (hkPackedNiTriStripsDataRef data = shape->GetData())
	{
		Matrix3 ltm(true);
		vector<Vector3> verts = data->GetVertices();
		vector<Triangle> tris = data->GetTriangles();
		vector<Vector3> norms = data->GetNormals();

		vector<Niflib::OblivionSubShape> subshapes = (ni.IsFallout3() || ni.IsSkyrim()) ? shape->GetSubShapes() : data->GetSubShapes();
		if (subshapes.size() == 0)
		{
			// Is this possible?
			INode *inode = ImportCollisionMesh(verts, tris, norms, tm, parent);
			CreatebhkCollisionModifier(inode, bv_type_packed, HavokMaterial(NP_DEFAULT_HVK_MATERIAL), OL_UNIDENTIFIED, 0);
			ImportBase(body, shape, parent, inode, ltm);
			AddShape(rbody, inode);
		}
		else
		{
			unsigned int voff = 0;
			unsigned int toff = 0;

			INodeTab nodes;
			for (int i = 0, n = subshapes.size(); i<n; ++i) {
				Niflib::OblivionSubShape& s = subshapes[i];
				
				vector<Vector3> subverts;
				vector<Triangle> subtris;
				vector<Vector3> subnorms;
				
				subverts.reserve(s.numVertices);
				for (unsigned int v=voff; v < (voff + s.numVertices); ++v) {
					subverts.push_back( verts[v] );
				}
				unsigned int vend = (voff + s.numVertices );

				// TODO: Fix algorithm.  I do not know how to split the triangles here
				//       Basically, greedily take all triangles until next subshape
				//       This is not correct but seems to work with most meshes tested.
				subtris.reserve( s.numVertices / 2 );
				subnorms.reserve( s.numVertices / 2 );
				while ( toff < tris.size() ){
					Triangle t = tris[toff];
					if ( t.v1 >= vend || t.v2 >= vend || t.v3 >= vend )
						break;
					// remove offset for mesh
					t.v1 -= voff; t.v2 -= voff; t.v3 -= voff;
					subtris.push_back( t );	
					subnorms.push_back( norms[toff] );	
					++toff;
				}
				voff += s.numVertices;

				INode *inode = ImportCollisionMesh(subverts, subtris, subnorms, tm, parent);

				CreatebhkCollisionModifier(inode, bv_type_packed, HavokMaterial(s.material), s.layer, s.colFilter);
				ImportBase(body, shape, parent, inode, ltm);

				if (n > 1)
					inode->SetName( FormatText("%s:%d", "OblivionSubShape", i).data() );

				nodes.Append(1, &inode);
			}
			// TODO: Group nodes on import
			if (  nodes.Count() > 1 )
			{
				TSTR shapeName = "bhkPackedNiTriStripsShape";
				INode *group = ni.gi->GroupNodes(&nodes, &shapeName, 0);			
				AddShape(rbody, group);
			}
			else if (  nodes.Count() == 1 )
			{
				AddShape(rbody, nodes[0]);
			}
		}
		return true;
	}

	return false;
}
Beispiel #23
0
inline void xref_low(std::wstring project_path, std::wstring pname) {
	FPInterface* iObjXrefMGR = GetCOREInterface(OBJXREFMGR_INTERFACE_ID);
	FPParams p(1, DUPOBJNAMEACTION_IOBJXREFMGR_TYPEPARAM, OBJXREFMGR_ENUM3::deleteOld);
	iObjXrefMGR->Invoke(DUPOBJNAMEACTION_IOBJXREFMGR_SETTER, &p);

	auto* ip = GetCOREInterface16();
	INodeTab selectedINodes;
	ip->GetSelNodeTab(selectedINodes);

	Tab<const MCHAR*> objNames;
	auto numNodeSelection = selectedINodes.Count();
	objNames.Resize(numNodeSelection);

	FPParams pAddXrefItemFromFile;
	FPValue pFileName;
	std::wstring filename = (project_path + L"\\" + pname + L"_high.max");
	pFileName.type = FILENAME_ADDXREFITEMSFROMFILE_IOBJXREFMGR_PARAM1_TYPE;
	pFileName.s = filename.data();
	pAddXrefItemFromFile.params.append(pFileName);

	FPValue pPromptObjNames;
	pPromptObjNames.type = PROMPTOBJNAMES_ADDXREFITEMSFROMFILE_IOBJXREFMGR_PARAM2_TYPE;
	pPromptObjNames.b = false;
	pAddXrefItemFromFile.params.append(pPromptObjNames);

	FPValue pObjName;
	pObjName.InitTab(OBJNAMES_ADDXREFITEMSFROMFILE_IOBJXREFMGR_PARAM3_TYPE, numNodeSelection);
	auto ptr = pObjName.s_tab;
	for (int i = 0; i < ptr->Count(); ++i) {
		auto selectedNode = selectedINodes[i];
		(*ptr)[i] = selectedNode->GetName();
	}
	pAddXrefItemFromFile.params.append(pObjName);

	FPValue pxrefOptions;
	pxrefOptions.InitTab(XREFOPTIONS_ADDXREFITEMSFROMFILE_IOBJXREFMGR_PARAM4_TYPE, 0);
	pAddXrefItemFromFile.params.append(pxrefOptions);

	FPValue result;
	iObjXrefMGR->Invoke(ADDXREFITEMSFROMFILE_IOBJXREFMGR, result, &pAddXrefItemFromFile);

	FPInterface* IXrefRecord = result.fpi;

	if (IXrefRecord != nullptr)
	{
		FPParams pGetItems;
		FPValue pTypes;

		pGetItems.params.append(&pTypes, 1);
		auto& param1 = pGetItems.params[0];
		param1.InitTab(TYPES_GETITEMS_IIXREFRECORD_PARAM1_TYPE, 1);
		(*param1.i_tab)[0] = (int)ENUM1_IXREFRECORD::XRefObjectType;

		FPValue pXrefItems;
		pGetItems.params.append(&pXrefItems, 1);
		auto& param2 = pGetItems.params[1];
		param2.InitTab(XREFITEMS_GETITEMS_IIXREFRECORD_PARAM2_TYPE, 0);

		IXrefRecord->Invoke(GETITEMS_IIXREFRECORD, result, &pGetItems);
		if (param2.r_tab != nullptr)
		{
			for (int i = 0; i < param2.r_tab->Count(); i++)
			{
				auto item = (*param2.r_tab)[i];

				FPParams pSetProxyItemSrcFile;
				FPValue pitem;
				pSetProxyItemSrcFile.params.append(&pitem, 1);
				auto& p1 = pSetProxyItemSrcFile.params[0];
				p1.type = PROXYITEM_SETPROXYITEMSRCFILE_IOBJXREFMGR_PARAM1_TYPE;
				p1.r = item;

				FPValue pFileName;
				pSetProxyItemSrcFile.params.append(&pFileName, 1);
				auto& p2 = pSetProxyItemSrcFile.params[1];
				p2.type = FILENAME_SETPROXYITEMSRCFILE_IOBJXREFMGR_PARAM2_TYPE;
				std::wstring proxyFile = (project_path + L"\\" + pname + L"_low0.max");
				p2.s = proxyFile.c_str();

				FPValue result;
				iObjXrefMGR->Invoke(SETPROXYITEMSRCFILE_IOBJXREFMGR, result, &pSetProxyItemSrcFile);


				IXRefObject *ix = (IXRefObject8 *)item;

				auto objName = ix->GetCurObjName();

				auto iXrefProxy = IXRefProxy::GetInterface(*item);

				FPParams proxyItemName(1, PROXYITEMNAME_IIXREFPROXY_TYPEPARAM, objName.data());
				iXrefProxy->Invoke(PROXYITEMNAME_IIXREFPROXY_SETTER, &proxyItemName);
			}
		}
		else LOG("r_tab is nullptr\n");
	}
}
Beispiel #24
0
inline void xref_low_2(std::wstring project_path, std::wstring pname) {
	FPInterface* iObjXrefMGR = GetCOREInterface(OBJXREFMGR_INTERFACE_ID);
	FPParams p(1, DUPOBJNAMEACTION_IOBJXREFMGR_TYPEPARAM, OBJXREFMGR_ENUM3::deleteOld);
	iObjXrefMGR->Invoke(DUPOBJNAMEACTION_IOBJXREFMGR_SETTER, &p);

	auto* ip = GetCOREInterface16();
	INodeTab selectedINodes;
	ip->GetSelNodeTab(selectedINodes);

	Tab<const MCHAR*> objNames;
	auto numNodeSelection = selectedINodes.Count();
	objNames.Resize(numNodeSelection);
	
	FPParams pAddXrefItemFromFile;
	FPValue pFileName;
	std::wstring filename = (project_path + L"\\" + pname + L"_high.max");
	pFileName.type = FILENAME_ADDXREFITEMSFROMFILE_IOBJXREFMGR_PARAM1_TYPE;
	pFileName.s = filename.data();
	pAddXrefItemFromFile.params.append(pFileName);

	FPValue pPromptObjNames;
	pPromptObjNames.type = PROMPTOBJNAMES_ADDXREFITEMSFROMFILE_IOBJXREFMGR_PARAM2_TYPE;
	pPromptObjNames.b = false;
	pAddXrefItemFromFile.params.append(pPromptObjNames);

	FPValue pObjName;
	pObjName.InitTab(OBJNAMES_ADDXREFITEMSFROMFILE_IOBJXREFMGR_PARAM3_TYPE, numNodeSelection);
	auto ptr = pObjName.s_tab;
	for (int i = 0; i < ptr->Count(); ++i) {
		auto selectedNode = selectedINodes[i];		
		(*ptr)[i] = selectedNode->GetName();
	}
	pAddXrefItemFromFile.params.append(pObjName);

	FPValue pxrefOptions;
	pxrefOptions.InitTab(XREFOPTIONS_ADDXREFITEMSFROMFILE_IOBJXREFMGR_PARAM4_TYPE, 0);
	pAddXrefItemFromFile.params.append(pxrefOptions);
	
	FPValue result;
	iObjXrefMGR->Invoke(ADDXREFITEMSFROMFILE_IOBJXREFMGR, result, &pAddXrefItemFromFile);

	FPInterface* IXrefRecord = result.fpi;
	
	if (IXrefRecord != nullptr)
	{
		FPParams pGetItems;	
		FPValue pTypes;

		//FPInterfaceDesc* interfaceDesc = IXrefRecord->GetDesc();
		//generateInterfaceFuntionsID2(interfaceDesc);
		

// 		pTypes.InitTab(TYPES_GETITEMS_IIXREFRECORD_PARAM1_TYPE, 1);		
// 		(*pTypes.i_tab)[0] = (int)ENUM1_IXREFRECORD::XRefObjectType;
// 		pGetItems.params.append(&pTypes,1);		

		pGetItems.params.append(&pTypes, 1);	
		auto& param1 = pGetItems.params[0];
		param1.InitTab(TYPES_GETITEMS_IIXREFRECORD_PARAM1_TYPE, 1);
		(*param1.i_tab)[0] = (int)ENUM1_IXREFRECORD::XRefObjectType;
	
//  		FPValue pXrefItems;		
//  		pXrefItems.InitTab(XREFITEMS_GETITEMS_IIXREFRECORD_PARAM2_TYPE, 1);
//  		pGetItems.params.append(&pXrefItems,1);
	
 	//	FPValue pXrefItems;
		//Tab<ReferenceTarget*>* tabRefTarg = new Tab<ReferenceTarget*>();
		//tabRefTarg->SetCount(1,true);
		////tabRefTarg->Init();
		////tabRefTarg->ZeroCount();
		////tabRefTarg->Delete(0, 1);
 	//	LOG("Count tabRefTarg element is {}\n", tabRefTarg->Count());
 	//	pXrefItems.type = XREFITEMS_GETITEMS_IIXREFRECORD_PARAM2_TYPE;
 	//	pXrefItems.r_tab = tabRefTarg;
 	//	pGetItems.params.append(&pXrefItems, 1);
		//pGetItems.params[1].r_tab->Delete(0, 1);
		//FPValue result;
		//IXrefRecord->Invoke(GETITEMS_IIXREFRECORD, result, &pGetItems);
		
		FPValue pXrefItems;				
		pGetItems.params.append(&pXrefItems,1);
		auto& param2 = pGetItems.params[1];
		param2.InitTab(XREFITEMS_GETITEMS_IIXREFRECORD_PARAM2_TYPE, 0);

		IXrefRecord->Invoke(GETITEMS_IIXREFRECORD, result, &pGetItems);
		//LOG("first item in original is {}\n", (*pXrefItems.r_tab)[0] != nullptr);
		//LOG("number of item in original is {}\n", pXrefItems.r_tab->Count());
		if (param2.r_tab != nullptr)
		{			
			for (int i = 0; i < param2.r_tab->Count(); i++)
			{
				auto item = (*param2.r_tab)[i];				
		
				FPParams pSetProxyItemSrcFile;
				FPValue pitem;
				pSetProxyItemSrcFile.params.append(&pitem, 1);
				auto& p1 = pSetProxyItemSrcFile.params[0];
				p1.type = PROXYITEM_SETPROXYITEMSRCFILE_IOBJXREFMGR_PARAM1_TYPE;
				p1.r = item;

				FPValue pFileName;
				pSetProxyItemSrcFile.params.append(&pFileName,1);
				auto& p2 = pSetProxyItemSrcFile.params[1];
				p2.type = FILENAME_SETPROXYITEMSRCFILE_IOBJXREFMGR_PARAM2_TYPE;
				std::wstring proxyFile = (project_path + L"\\" + pname + L"_low0.max");
				p2.s = proxyFile.c_str();

				FPValue result;
				iObjXrefMGR->Invoke(SETPROXYITEMSRCFILE_IOBJXREFMGR, result, &pSetProxyItemSrcFile);
				
				
				IXRefObject *ix = (IXRefObject8 *)item;

				auto objName = ix->GetCurObjName();				
				
				auto iXrefProxy = IXRefProxy::GetInterface(*item);

				FPParams proxyItemName(1, PROXYITEMNAME_IIXREFPROXY_TYPEPARAM, objName.data());
				iXrefProxy->Invoke(PROXYITEMNAME_IIXREFPROXY_SETTER,&proxyItemName);
			}
		}
		else LOG("r_tab is nullptr\n"); 		
	}
		

	//const wchar_t* vfilename = s2ws(filename).data();
	//Tab<int> a;
	//LOG(vfilename);
	//FPParams AddXRefItemsFromFile(4, FILENAME_ADDXREFITEMSFROMFILE_IOBJXREFMGR_PARAM1_TYPE, vfilename,
	//	PROMPTOBJNAMES_ADDXREFITEMSTORECORD_IOBJXREFMGR_PARAM2_TYPE, false,
	//	OBJNAMES_ADDXREFITEMSFROMFILE_IOBJXREFMGR_PARAM3_TYPE, objNames_mchartype,
	//	XREFOPTIONS_ADDXREFITEMSFROMFILE_IOBJXREFMGR_PARAM4_TYPE,a
	//);
		
// 	FPValue result;
// 	fpInterface->Invoke(ADDXREFITEMSFROMFILE_IOBJXREFMGR, result, &AddXRefItemsFromFile);
}
Beispiel #25
0
// which names to hilite in the dialog when it comes up
BOOL SelectObjectsInMAX::doHilite(INode *node)
{
    for (int i=0; i<SelMaxNodes.Count(); i++)
        if (SelMaxNodes[i] == node) return TRUE;
    return FALSE;
}
Beispiel #26
0
void ResetXForm::ResetNodes(const INodeTab& nodesToReset)
{
	Interface *ip = GetCOREInterface();
	for (int i = 0; i < nodesToReset.Count(); i++) {
		INode *node = nodesToReset[i];
		if (!node || node->IsGroupMember() || node->IsGroupHead()) 
			continue;
		if (SelectedAncestor(node)) 
			continue;

		Matrix3 ntm, ptm, rtm(1), piv(1), tm;
		
		// Get Parent and Node TMs
		ntm = node->GetNodeTM(ip->GetTime());
		ptm = node->GetParentTM(ip->GetTime());
		
		// Compute the relative TM
		ntm = ntm * Inverse(ptm);
		
		// The reset TM only inherits position
		rtm.SetTrans(ntm.GetTrans());
		
		// Set the node TM to the reset TM		
		tm = rtm*ptm;
		node->SetNodeTM(ip->GetTime(), tm);

		// Compute the pivot TM
		piv.SetTrans(node->GetObjOffsetPos());
		PreRotateMatrix(piv,node->GetObjOffsetRot());
		ApplyScaling(piv,node->GetObjOffsetScale());
		
		// Reset the offset to 0
		node->SetObjOffsetPos(Point3(0,0,0));
		node->SetObjOffsetRot(IdentQuat());
		node->SetObjOffsetScale(ScaleValue(Point3(1,1,1)));

		// Take the position out of the matrix since we don't reset position
		ntm.NoTrans();

		// Apply the offset to the TM
		ntm = piv * ntm;

		// Apply a derived object to the node's object
		Object *obj = node->GetObjectRef();
		IDerivedObject *dobj = CreateDerivedObject(obj);
		
		// Create an XForm mod
		SimpleMod *mod = (SimpleMod*)ip->CreateInstance(
			OSM_CLASS_ID,
			Class_ID(CLUSTOSM_CLASS_ID,0));

		// Apply the transformation to the mod.
		SetXFormPacket pckt(ntm);
		mod->tmControl->SetValue(ip->GetTime(),&pckt);

		// Add the modifier to the derived object.
		dobj->SetAFlag(A_LOCK_TARGET); // RB 3/11/99: When the macro recorder is on the derived object will get deleted unless it is locked.
		dobj->AddModifier(mod);
		dobj->ClearAFlag(A_LOCK_TARGET);

		// Replace the node's object
		node->SetObjectRef(dobj);
	}
	
//	Why on earth were we clearing the undo stack?
//	GetSystemSetting(SYSSET_CLEAR_UNDO);
	ip->RedrawViews(ip->GetTime());
	SetSaveRequiredFlag(TRUE);
}
Beispiel #27
0
inline void xref_low_old(std::wstring project_path, std::wstring pname) {
	FPInterface* fpInterface = GetCOREInterface(OBJXREFMGR_INTERFACE_ID);
	FPParams p(1, DUPOBJNAMEACTION_IOBJXREFMGR_TYPEPARAM, OBJXREFMGR_ENUM3::deleteOld);
	fpInterface->Invoke(DUPOBJNAMEACTION_IOBJXREFMGR_SETTER, &p);

	auto* ip = GetCOREInterface16();
	INodeTab inodetab;
	ip->GetSelNodeTab(inodetab);
	Tab<MSTR*> obj_names;
	Tab<const MCHAR*> obj_names_mchartype;
	auto numNodeSelection = inodetab.Count();
	obj_names_mchartype.Resize(numNodeSelection);
	obj_names.Resize(numNodeSelection);
	LOG("count is {}\n", numNodeSelection);
	for (int i = 0; i < numNodeSelection; i++)
	{
		auto inode = inodetab[i];
		//auto name = const_cast<wchar_t*>(inode->GetName());
		auto name = inode->NodeName();
		auto pname = &name;
		obj_names.Append(1, &pname);
		//LOG(obj_names[i]->data());
		LOG(obj_names[i]->data()); LOG("\n");
		auto name_wcharType = inode->GetName();
		obj_names_mchartype.Append(1, &name_wcharType);
		LOG(obj_names_mchartype[i]); LOG("\n");
	}
	//obj_names.SetCount(inodetab.Count(), true);
	//obj_names.Shrink();

	// 	FILENAME_ADDXREFITEMSFROMFILE_IOBJXREFMGR_PARAM1_TYPE;
	FPParams fnParams;
	//FPValue result, param1, param3;

	std::wstring filename = (project_path + L"\\" + pname + L"_low0.max");
	MSTR a = filename.data();


	Tab<MCHAR*> sourceFile_Files;
	auto file = const_cast<wchar_t*>(filename.c_str());
	sourceFile_Files.Append(1, &file);
	//FPParams pSourceFileFiles(1, TYPE_STRING_TAB_BV, sourceFile_Files);
	//pSourceFileFiles.GetFPValue(0)->type;

	//param1.tstr = &a;	
	//FPValue param1(FILENAME_ADDXREFITEMSFROMFILE_IOBJXREFMGR_PARAM1_TYPE, s2ws(filename).data());
	FPValue param1;
	////	param1.Load(FILENAME_ADDXREFITEMSFROMFILE_IOBJXREFMGR_PARAM1_TYPE, s2ws(filename).data());
	//auto isPtrType = param1.IsPointerBasedType(FILENAME_ADDXREFITEMSFROMFILE_IOBJXREFMGR_PARAM1_TYPE);
	//LOG("is Pointer base type ?? {0}\n", isPtrType);
	param1.LoadPtr(FILENAME_ADDXREFITEMSFROMFILE_IOBJXREFMGR_PARAM1_TYPE, filename.data());
	////param1.type = FILENAME_ADDXREFITEMSFROMFILE_IOBJXREFMGR_PARAM1_TYPE;
	////param1.s = s2ws(filename).data();	
	LOG("param1.s here= "); LOG(param1.s); LOG("\n");
	//LOG("param1.s here= "); LOG(param1.tstr->data()); LOG("\n");
	////LOG("param1.tstr = {0}.\n",(param1.tstr==NULL));
	////FPValue param3(ParamType2::TYPE_STRING_TAB, 20);
	//isPtrType = param1.IsPointerBasedType(TYPE_STRING_TAB_BV);
	//LOG("is Pointer base type ?? {0}\n", isPtrType);
	FPValue param3;
	//param3.InitTab(ParamType2::TYPE_STRING_TAB,numNodeSelection);
	//param3.s_tab = &obj_names_mchartype;
	//const wchar_t* p1 = L"dsdsdsa";	
	OBJNAMES_ADDXREFITEMSFROMFILE_IOBJXREFMGR_PARAM3_TYPE;
	//param3.InitTab(OBJNAMES_ADDXREFITEMSFROMFILE_IOBJXREFMGR_PARAM3_TYPE,0);
	//param3.s_tab = &obj_names_mchartype;

	//param3.LoadPtr(ParamType2::TYPE_STRING_TAB_BV, &sourceFile_Files);
	//param3.Load(ParamType2::TYPE_STRING_TAB_BV,&sourceFile_Files);
	param3.LoadPtr(ParamType2::TYPE_STRING_TAB, &sourceFile_Files);
	//param3.LoadPtr(ParamType2::TYPE_STRING_TAB_BV, &sourceFile_Files);
	//SYSTEM_CALL(param3.LoadPtr(ParamType2::TYPE_STRING_TAB_BV, &sourceFile_Files);)

	//param3.Load(ParamType2::TYPE_STRING_TAB, &sourceFile_Files);
	auto s_tab = param3.s_tab;
	auto count = s_tab->Count();
	LOG("count here is {}\n", count);
	for (int i = 0; i < count; i++)
	{
		auto sp = (*s_tab)[i];
		LOG("Name {} from param3.s_tab ", i); LOG(sp); LOG("\n");
	}
	if (s_tab == nullptr)
		LOG("ffffffffffffffffffff\n");
	else
		LOG("uha\n");

	//param3.Free();

	//auto s_tab = param3.tstr_tab;
	//LOG("count here is {}\n", s_tab->Count());
	//auto mstr = (*s_tab)[0];
	//if (mstr == nullptr)
	//{
	//	LOG("oh f*****g shit time 1\n");
	//	MSTR a1(p1);
	//	mstr = &a1;
	//}
	//	if (mstr != nullptr){
	//		auto str = param3.s_tab;
	//		auto str0 = (*str)[0];
	//		if (str0 == nullptr)
	//			LOG("oh Ffffffffffffffff ");
	//	}





	/*auto s = (*s_tab)[0];
	if (s == nullptr)
	{
	LOG("f*****g shit");
	}*/

	//LOG("count here is {}\n", ws2s(std::wstring((*s_tab)[0])));
	//param3.LoadPtr(ParamType2::TYPE_STRING_TAB,obj_names);
	//param3.type = ParamType2::TYPE_STRING_TAB;
	//param3.s_tab = &obj_names_mchartype;
	// 	param3.InitTab(ParamType2::TYPE_STRING_TAB, obj_names.Count());
	//  	Tab<MSTR*>* t = &obj_names;
	// 	param3.tstr_tab = t;
	//FPValue v(ParamType2::TYPE_STRING_TAB, obj_names);
	//LOG("type is {}\n",param3.type);
	//auto s_tab = param3.s_tab;

}
Beispiel #28
0
void plSaveSelected()
{
    Interface *ip = GetCOREInterface();

    // Get the Max filename to save to
    char buf[256];
    memset(&buf, 0, sizeof(buf));
    OPENFILENAME ofn = {0};
    ofn.lStructSize = sizeof(OPENFILENAME);
    ofn.hwndOwner = ip->GetMAXHWnd();
    ofn.lpstrFilter = "3ds max (*.max)\0*.max\0\0";
    ofn.nFilterIndex = 1;
    ofn.lpstrFile = buf;
    ofn.nMaxFile = sizeof(buf);
//  ofn.lpstrInitialDir = ip->GetDir(APP_SCENE_DIR);
    ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
    ofn.lpstrDefExt = "max";

    if (GetSaveFileName(&ofn))
    {
        int count = ip->GetSelNodeCount();
        int i;
        
        // Put all the selected nodes in a list
        INodeTab selected;
        for (i = 0; i < count; i++)
        {
            plMaxNode *node = (plMaxNode*)ip->GetSelNode(i);
            selected.Append(1, (INode**)&node);
        }

        // Put all the components attached to those nodes in a list
        INodeTab components;
        for (i = 0; i < count; i++)
        {
            plMaxNode *node = (plMaxNode*)ip->GetSelNode(i);

            uint32_t compCount = node->NumAttachedComponents();
            for (int j = 0; j < compCount; j++)
            {
                INode *compNode = node->GetAttachedComponent(j)->GetINode();//Node(j);

                if (!IIsNodeInTab(components, compNode))
                    components.Append(1, &compNode);
            }
        }

        // Find the objects that the components are reffing that are not part of the selection.
        // Back them up, and delete them out of the components ref list so they won't be saved too.
        std::vector<ComponentRefs> out;
        for (i = 0; i < components.Count(); i++)
        {
            plComponentBase *comp = ((plMaxNode*)components[i])->ConvertToComponent();

            for (int j = comp->NumTargets() - 1; j >= 0; --j)
            {
                plMaxNodeBase *node = comp->GetTarget(j);

                if (!node)
                    continue;
                
                const char *t1 = components[i]->GetName();
                const char *t2 = node->GetName();

                if (!IIsNodeInTab(selected, node))
                {
                    uint32_t idx = -1;
                    for (uint32_t k = 0; k < out.size(); k++)
                    {
                        if (out[k].comp == comp)
                            idx = k;
                    }

                    if (idx == -1)
                    {
                        idx = out.size();
                        out.resize(idx+1);
                        out[idx].comp = comp;
                    }

                    out[idx].refs.Append(1, (INode**)&node);

                    comp->DeleteTarget(node);
                }
            }
        }

        // Save the selected objects and their components
        INodeTab allNodes;
        allNodes.Append(selected.Count(), &selected[0]);
        allNodes.Append(components.Count(), &components[0]);

        ip->FileSaveNodes(&allNodes, buf);

        // Restore the component refs to objects that weren't selected
        for (i = 0; i < out.size(); i++)
        {
            for (int j = 0; j < out[i].refs.Count(); j++)
                out[i].comp->AddTarget((plMaxNode*)out[i].refs[j]);
        }
    }
}