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; }
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"); }
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)); }
void EditFaceDataMod::ChangeBegin () { if (selLevel == SEL_OBJECT) return; if (efdRestore) { delete efdRestore; efdRestore = NULL; } // Find the modcontext with the selected faces. // NOTE that as currently written, this modifier won't // support setting FaceFloats on more than one node at a time. ModContextList mcList; INodeTab nodes; ip->GetModContexts(mcList,nodes); int numSelected=0, whichFace; float value; bool valueDetermined=true; EditFaceDataModData *relevantMD; if (selLevel) { for (int i = 0; i < mcList.Count(); i++) { EditFaceDataModData *meshData = (EditFaceDataModData*)mcList[i]->localData; if (!meshData) continue; meshData->DescribeSelection (numSelected, whichFace, value, valueDetermined); if (!numSelected) continue; relevantMD = meshData; break; } } nodes.DisposeTemporary (); if (!numSelected) return; efdRestore = new EditFaceDataRestore (this, relevantMD); }
void EditPatchMod::ChangeSelVerts(int type) { ModContextList mcList; INodeTab nodes; TimeValue t = ip->GetTime(); BOOL holdNeeded = FALSE; BOOL hadSelected = FALSE; if (!ip) return; ip->GetModContexts(mcList, nodes); ClearPatchDataFlag(mcList, EPD_BEENDONE); theHold.Begin(); for (int i = 0; i < mcList.Count(); i++) { BOOL altered = FALSE; EditPatchData *patchData =(EditPatchData*)mcList[i]->localData; if (!patchData) continue; if (patchData->GetFlag(EPD_BEENDONE)) continue; // If the mesh isn't yet cache, this will cause it to get cached. RPatchMesh *rpatch; PatchMesh *patch = patchData->TempData(this)->GetPatch(t, rpatch); if (!patch) continue; // If this is the first edit, then the delta arrays will be allocated patchData->BeginEdit(t); // If any bits are set in the selection set, let's DO IT!! if (patch->vertSel.NumberSet()) { altered = holdNeeded = TRUE; if (theHold.Holding()) theHold.Put(new PatchRestore(patchData, this, patch, rpatch, "ChangeSelVerts")); // Call the vertex type change function patch->ChangeVertType(-1, type); patchData->UpdateChanges(patch, rpatch, FALSE); patchData->TempData(this)->Invalidate(PART_TOPO); } patchData->SetFlag(EPD_BEENDONE, TRUE); } if (holdNeeded) theHold.Accept(GetString(IDS_TH_VERTCHANGE)); else { ip->DisplayTempPrompt(GetString(IDS_TH_NOVERTSSEL), PROMPT_TIME); theHold.End(); } nodes.DisposeTemporary(); ClearPatchDataFlag(mcList, EPD_BEENDONE); NotifyDependents(FOREVER, PART_TOPO, REFMSG_CHANGE); ip->RedrawViews(ip->GetTime(), REDRAW_NORMAL); }
void EditFaceDataMod::ClearSelection(int selLevel) { ModContextList list; INodeTab nodes; ip->GetModContexts(list,nodes); EditFaceDataModData *d; for (int i=0; i<list.Count(); i++) { d = (EditFaceDataModData*)list[i]->localData; if (!d) continue; // Check if we have anything selected first: switch (selLevel) { case SEL_FACE: if (!d->GetFaceSel().NumberSet()) continue; else break; } if (theHold.Holding() && !d->GetHeld()) theHold.Put (new SelectRestore (this, d)); d->SynchSize (); switch (selLevel) { case SEL_FACE: d->GetFaceSel().ClearAll(); break; } } nodes.DisposeTemporary(); SelectionChanged (); }
void EditPatchMod::RemoveSubSelSet(TSTR &setName) { MaybeFixupNamedSels(); ModContextList mcList; INodeTab nodes; if (!ip) return; ip->GetModContexts(mcList, nodes); for (int i = 0; i < mcList.Count(); i++) { EditPatchData *patchData =(EditPatchData*)mcList[i]->localData; if (!patchData) continue; patchData->BeginEdit(ip->GetTime()); GenericNamedSelSetList &sel = patchData->GetSelSet(this); sel.RemoveSet(setName); } // Remove the modifier's entry RemoveSet(setName, selLevel); ip->ClearCurNamedSelSet(); SetupNamedSelDropDown(); nodes.DisposeTemporary(); }
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()); }
//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 EditPatchMod::RecordTopologyTags() { ModContextList mcList; INodeTab nodes; TimeValue t = ip->GetTime(); ip->GetModContexts(mcList, nodes); ClearPatchDataFlag(mcList, EPD_BEENDONE); for (int i = 0; i < mcList.Count(); i++) { EditPatchData *patchData =(EditPatchData*)mcList[i]->localData; if (!patchData) continue; if (patchData->GetFlag(EPD_BEENDONE)) continue; // If the mesh isn't yet cache, this will cause it to get cached. RPatchMesh *rpatch; PatchMesh *patch = patchData->TempData(this)->GetPatch(t, rpatch); if (!patch) continue; patch->RecordTopologyTags(); patchData->SetFlag(EPD_BEENDONE, TRUE); } nodes.DisposeTemporary(); ClearPatchDataFlag(mcList, EPD_BEENDONE); }
static void ResetSel() { INodeTab selNodes; GetCOREInterface7()->GetSelNodeTab(selNodes); if (selNodes.Count() > 0) { ResetXForm::ResetNodes(selNodes); } }
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; }
void plClickDragComponent::CollectNonDrawables(INodeTab& nonDrawables) { INode* boundsNode = fCompPB->GetINode(kClickDragProxy); if(boundsNode && fCompPB->GetInt(kClickDragUseProxy)) nonDrawables.Append(1, &boundsNode); boundsNode = fCompPB->GetINode(kClickDragProxyRegion); if(boundsNode ) nonDrawables.Append(1, &boundsNode); }
// Note: don't return DEP_ENUM_SKIP when we hit a node. From review comments: // It wants to gather all the dependant particle groups which are base nodes and have a particle group interface. // This could skip groups that are not direct descendants to the head Particle Flow Object. // So if you had a Particle Flow object that had a test that referenced another particle group, then that // second group had test that referenced another group. That second particle group would get skipped. int MyEnumProc::proc(ReferenceMaker *rmaker) { if ((rmaker != nullptr) && (rmaker->SuperClassID()==BASENODE_CLASS_ID)) { INode* inode = dynamic_cast<INode*>(rmaker); if (!Nodes.Contains(inode)) { Nodes.Append(1, (INode **)&rmaker); } } return DEP_ENUM_CONTINUE; }
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; }
void EditPolyMod::GetPaintHosts( Tab<MeshPaintHost*>& hosts, Tab<INode*>& paintNodes ) { ModContextList mcList; INodeTab nodes; ip->GetModContexts(mcList,nodes); EditPolyData* modData = NULL; for (int i=0; i<mcList.Count(); i++ ) { if( (modData=(EditPolyData*)mcList[i]->localData)== NULL) continue; MeshPaintHost* host = modData; hosts.Append( 1, &(host) ); INode *pNode = nodes[i]->GetActualINode(); paintNodes.Append( 1, &pNode ); } nodes.DisposeTemporary(); }
Value* ExportCalSkel_cf(Value** arg_list, int count) { int i; INodeTab tabnode; std::tstring fullpathfilename; int ArraySize ; bool bShowUI ; check_arg_count(ExportCalSkel, 3, count); type_check(arg_list[0], String, _T("[The first argument of ExportCalSkel should be a string that is a full path name of the file to export]")); type_check(arg_list[1], Array , _T("[The 2nd argument of ExportCalSkel should be an array of nodes]")); type_check(arg_list[2], Boolean,_T("[The 3rd argument of ExportCalSkel should be a boolean that tells if you want to use the UI or not to select nodes of skeleton]")); try { fullpathfilename = arg_list[0]->to_string(); //Get Array Array* BonesArray = static_cast<Array*>(arg_list[1]); ArraySize = BonesArray->size; bShowUI = !!(arg_list[2]->to_bool()); if (fullpathfilename.length() == 0) return new Integer (1); if (! ArraySize) return new Integer (2); for (i=0;i<ArraySize;i++) { if (BonesArray->data[i]->is_kind_of(class_tag(MAXNode)) ) { INode* _node = BonesArray->data[i]->to_node(); if (! _node)return new Integer (3); tabnode.Append(1,&_node); } } //Call the exporter from Maxscript if (CMaxSkeletonExport::ExportSkeletonFromMaxscriptCall(fullpathfilename.c_str(), tabnode, bShowUI) ) return new Integer (0); return new Integer (-1); } catch(...) { //MessageBox(NULL,"Exception catched in ExportCalSkel C++ function","Error",MB_OK); return new Integer (-2); } }
INodeTab GR2ImportImpl::ImportSkeleton(Skeleton& skel) { Point3 zAxis(0,0,1); INodeTab nodes; nodes.SetCount(int(skel.Bones.size())); float scale = 1.0f; for (size_t i=0, n=skel.Bones.size(); i<n; ++i) { Bone& bone = skel.Bones[i]; INode *node = o->gi->GetINodeByName(bone.Name.c_str()); if (node != NULL) { nodes[i] = node; continue; } Point3 pp(0.0f,0.0f,0.0f); Matrix3 tm = GetWorldTransform(skel, i); Point3 p = tm.GetTrans(); Quat q = tm; if (bone.ParentIndex >= 0) { Matrix3 m3 = GetWorldTransform(skel, bone.ParentIndex); pp = m3.GetTrans(); //pp = skel.Bones[bone.ParentIndex].Transform.Origin; } node = CreateBone(bone.Name.c_str(), p, pp, zAxis); node->SetUserPropInt("GR2BoneIndex", int(i)); nodes[i] = node; //OutputDebugString(FormatText("GR2BoneIndex: %d %s\n", i, bone.Name.c_str())); PosRotScaleNode(node, p, q, scale, PosRotScale(prsPos|prsRot)); if (bone.ParentIndex >= 0) { if (INode *pn = nodes[bone.ParentIndex]) pn->AttachChild(node, 1); } } return nodes; }
bool IIsNodeInTab(INodeTab &tab, INode *node) { for (int i = 0; i < tab.Count(); i++) if (tab[i] == node) return true; return false; }
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(); }
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(); }
void EditFaceDataMod::ResetSelection () { ModContextList list; INodeTab nodes; ip->GetModContexts(list,nodes); EditFaceDataModData *d; theHold.Begin (); for (int i=0; i<list.Count(); i++) { d = (EditFaceDataModData*)list[i]->localData; if (!d) continue; EditFaceDataRestore *efd = new EditFaceDataRestore (this, d); d->ResetFace (d->GetFaceSel()); efd->After (); theHold.Put (efd); } nodes.DisposeTemporary(); theHold.Accept (GetString (IDS_RESET_SELECTED)); ValueChanged (); }
void EditPatchMod::ActivateSubSelSet(TSTR &setName) { MaybeFixupNamedSels(); ModContextList mcList; INodeTab nodes; int index = FindSet(setName, selLevel); if (index < 0 || !ip) return; ip->GetModContexts(mcList, nodes); theHold.Begin(); for (int i = 0; i < mcList.Count(); i++) { EditPatchData *patchData =(EditPatchData*)mcList[i]->localData; if (!patchData) continue; RPatchMesh *rpatch; PatchMesh *patch = patchData->TempData(this)->GetPatch(ip->GetTime(), rpatch); if (!patch) continue; patchData->BeginEdit(ip->GetTime()); // If that set exists in this context, deal with it GenericNamedSelSetList &sel = patchData->GetSelSet(this); BitArray *set = sel.GetSet(setName); if (set) { if (theHold.Holding()) theHold.Put(new PatchSelRestore(patchData, this, patch)); BitArray *psel = GetLevelSelectionSet(patch, rpatch); // Get the appropriate selection set AssignSetMatchSize(*psel, *set); PatchSelChanged(); } patchData->UpdateChanges(patch, rpatch, FALSE); if (patchData->tempData) patchData->TempData(this)->Invalidate(PART_SELECT); } theHold.Accept(GetString(IDS_DS_SELECT)); nodes.DisposeTemporary(); NotifyDependents(FOREVER, PART_SELECT, REFMSG_CHANGE); ip->RedrawViews(ip->GetTime()); }
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; } } } } } }
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 EditFaceDataMod::InvertSelection(int selLevel) { ModContextList list; INodeTab nodes; ip->GetModContexts(list,nodes); EditFaceDataModData *d; for (int i=0; i<list.Count(); i++) { d = (EditFaceDataModData*)list[i]->localData; if (!d) continue; if (theHold.Holding() && !d->GetHeld()) theHold.Put(new SelectRestore(this,d)); d->SynchSize(); switch (selLevel) { case SEL_FACE: d->GetFaceSel() = ~d->GetFaceSel(); break; } } nodes.DisposeTemporary(); SelectionChanged (); }
void plComponentDlg::ISelectTreeSelection() { INodeTab nodes; INode *curComponent = (INode*)IGetTreeSelection(); if (curComponent) { nodes.Append(1, &curComponent); } else { HWND hTree = GetDlgItem(fhDlg, IDC_TREE); HTREEITEM hRoot = TreeView_GetSelection(hTree); IGetComponentsRecur(hTree, hRoot, nodes); } SelectComponentTargs(nodes); }
void plComponentBase::AddTargetsToList(INodeTab& list) { int i; for( i = 0; i < NumTargets(); i++ ) { INode* targ = GetTarget(i); if( targ ) list.Append(1, &targ); } }
// 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; }
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]); } } }