Esempio n. 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;
    }
Esempio n. 2
0
void Xrefutil::ConvertSelectedToXrefScene(HWND hWnd)
{
    // *** ConvertSelectedToXrefScene ***
    //
    // Relatively simple -- take the selected nodes, save them out
    // to a new .MAX file, delete the selected nodes from the 
    // current scene, and then do a RootNode->AddNewXRefFile
    // with the just-saved MAX file.
	
    INode * pNode = NULL;
    TSTR filename = _T("");
    int i;
	
    INode * pRootNode = m_pInterface->GetRootNode();
    if (!pRootNode) {
        // well, this is actually _really_ bad, but we just exit
        return;
    }
    if (m_pInterface->GetSelNodeCount() == 0) {
        ::MessageBox(hWnd, GetString(IDS_ERR3), ERROR_TITLE, MB_ICONSTOP | MB_OK);
        return;
    }
	
    Tab<INode *> nodetab;
    nodetab.ZeroCount();
	nodetab.Shrink();
    for (i = 0; i < m_pInterface->GetSelNodeCount(); i++) {
        pNode = m_pInterface->GetSelNode(i);
        nodetab.Append(1, &pNode, 5);
    }
	
    if (!DoOpenSaveDialog(filename)) {
        // either cancel or fail, just return
        return;
    }
	
    m_pInterface->FileSaveSelected(filename);
	
    // delete selected nodes, don't refresh yet
    for (i = 0; i < nodetab.Count(); i++) {
        nodetab[i]->Delete(0,TRUE);
    }

	AssetUser asset = IAssetManager::GetInstance()->GetAsset(filename,kXRefAsset);
    // add in the nodes we saved out as an xref'd scene
    pRootNode->AddNewXRefFile(asset, TRUE);
    
    m_pInterface->RedrawViews(m_pInterface->GetTime());
	
}
Esempio n. 3
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;
	}
void bhkRigidBodyModifier::EndEditParams (IObjParam *ip,ULONG flags,Animatable *next)
{
   Modifier::EndEditParams(ip,flags,next);
   //saveState();
   mNodes.ZeroCount();
	mIP = NULL;

   // NOTE: This flag must be cleared before sending the REFMSG_END_EDIT
   ClearAFlag(A_MOD_BEING_EDITED);
   TimeValue t = ip->GetTime();
   NotifyDependents(Interval(t,t), PART_ALL, REFMSG_END_EDIT);
   NotifyDependents(Interval(t,t), PART_ALL, REFMSG_MOD_DISPLAY_OFF);

   havok_param_blk.SetUserDlgProc();

   if (flags&END_EDIT_REMOVEUI) {
		pmapParam = NULL;
		UpdateBVDialogs();
	}

   // For PB2 we ask the ClassDesc2 to take care of the EndEditParams - NH
   bhkRigidBodyModifierDesc.EndEditParams(ip,this,flags,next);
   //EndEditRBParams(ip, flags, next);
}
void bhkRigidBodyModifier::BeginEditParams(IObjParam  *ip, ULONG flags,Animatable *prev)
{
   Modifier::BeginEditParams(ip, flags, prev);
	mIP = ip;

   TimeValue t = ip->GetTime();
   NotifyDependents(Interval(t,t), PART_ALL, REFMSG_BEGIN_EDIT);
   NotifyDependents(Interval(t,t), PART_ALL, REFMSG_MOD_DISPLAY_ON);
   SetAFlag(A_MOD_BEING_EDITED);
   
   bhkRigidBodyModifierDesc.BeginEditParams(ip,this,flags,prev);
   havok_param_blk.SetUserDlgProc(havok_params, new bhkRigidBodyModifierDlgProc(this));
   havok_param_blk.SetUserDlgProc(clone_params, new CloneMeshDlgProc(this));
   havok_param_blk.SetUserDlgProc(subshape_params, new SubShapeDlgProc(this));

	//pmapParam = pblock->GetMap(havok_params);
	//UpdateBVDialogs();
	//pmapParam->GetIRollup()->Hide(1);
	//pmapParam->GetIRollup()->Hide(3);

   // BeginEditRBParams(ip, flags, prev);

   mNodes.ZeroCount();
}
Esempio n. 6
0
//pelt
void UVW_ChannelClass::EdgeListFromPoints(Tab<int> &selEdges, int source, int target, Point3 vec)
{
	//make sure point a and b are on the same element if not bail
	Tab<VConnections*> ourConnects;
	BOOL del = FALSE;

	BitArray selVerts;
	selVerts.SetSize(geomPoints.Count());
	selVerts.ClearAll();

//	if (TRUE)
	
		//loop through the edges
		Tab<int> numberOfConnections;
		numberOfConnections.SetCount(geomPoints.Count());
		for (int i = 0; i < geomPoints.Count(); i++)
		{
			numberOfConnections[i] = 0;
		}
		//count the number of vertxs connected
		for (int i = 0; i < gePtrList.Count(); i++)
		{
			if (!(gePtrList[i]->flags & FLAG_HIDDENEDGEA))
			{
				int a = gePtrList[i]->a;
				numberOfConnections[a] +=1;
				int b = gePtrList[i]->b;
				numberOfConnections[b] +=1;
			}
		}
		//allocate our connections now

		ourConnects.SetCount(geomPoints.Count());
		for (int i = 0; i < geomPoints.Count(); i++)
		{
			ourConnects[i] = new VConnections();
			ourConnects[i]->closestNode = NULL;
			ourConnects[i]->linkedListChild = NULL;
			ourConnects[i]->linkedListParent = NULL;
			ourConnects[i]->accumDist = 1.0e+9f;
			ourConnects[i]->solved = FALSE;
			ourConnects[i]->vid = i;

			ourConnects[i]->connectingVerts.SetCount(numberOfConnections[i]);
		}

		for (int i = 0; i < geomPoints.Count(); i++)
		{
			numberOfConnections[i] = 0;
		}

		//build our vconnection data
		for (int i = 0; i < gePtrList.Count(); i++)
		{
			if (!(gePtrList[i]->flags & FLAG_HIDDENEDGEA))
			{
				int a = gePtrList[i]->a;
				int b = gePtrList[i]->b;

				int index = numberOfConnections[a];
				ourConnects[a]->connectingVerts[index].vertexIndex = b;
				ourConnects[a]->connectingVerts[index].edgeIndex = i;
				numberOfConnections[a] +=1;

				index = numberOfConnections[b];
				ourConnects[b]->connectingVerts[index].vertexIndex = a;
				ourConnects[b]->connectingVerts[index].edgeIndex = i;
				numberOfConnections[b] +=1;
			}
		}


		del = TRUE;
	
	//	else ourConnects = vConnects;

	//spider out till hit our target or no more left
	BOOL done = FALSE;
	BOOL hit = FALSE;
	Tab<int> vertsToDo;
	BitArray processedVerts;
	processedVerts.SetSize(ourConnects.Count());
	processedVerts.ClearAll();

	//if no more left bail
	int currentVert = source;
	while (!done)
	{
		//	int startingNumberProcessed = processedVerts.NumberSet();

		int ct = ourConnects[currentVert]->connectingVerts.Count();
		processedVerts.Set(currentVert, TRUE);
		for (int j = 0; j < ct; j++)
		{
			int index = ourConnects[currentVert]->connectingVerts[j].vertexIndex;
			if (index == target) 
			{
				done = TRUE;
				hit = TRUE;
			}
			if (!processedVerts[index])
				vertsToDo.Append(1,&index, 10000);
		}

		if (vertsToDo.Count())
		{
			currentVert = vertsToDo[vertsToDo.Count()-1];
			vertsToDo.Delete(vertsToDo.Count()-1,1);
		}

		if (vertsToDo.Count() == 0) done = TRUE;
		//		int endingNumberProcessed = processedVerts.NumberSet();

		if (currentVert == target) 
		{
			done = TRUE;
			hit = TRUE;
		}
		//		if (startingNumberProcessed == endingNumberProcessed)
		//			done = TRUE;
	}
	vertsToDo.ZeroCount();

 	if (hit)
	{
		Tab<VConnections*> solvedNodes;

		ourConnects[source]->accumDist = 0;

		VConnections* unsolvedNodeHead = ourConnects[source];
		VConnections* unsolvedNodeCurrent = unsolvedNodeHead;
		
		//put all our vertices in the unsolved list
		
		for (int i = 0; i < ourConnects.Count(); i++)
		{			
			if (ourConnects[i] != unsolvedNodeHead)
			{
				unsolvedNodeCurrent->linkedListChild = ourConnects[i];
				VConnections *parent = unsolvedNodeCurrent;
				unsolvedNodeCurrent = ourConnects[i];
				unsolvedNodeCurrent->linkedListParent = parent;
			}
		}

		//build our edge distances
		Tab<float> edgeDistances;
		edgeDistances.SetCount(gePtrList.Count());
		for (int i = 0 ; i < gePtrList.Count(); i++)
		{
			int a = gePtrList[i]->a;
			int b = gePtrList[i]->b;
			float d = Length(geomPoints[a] - geomPoints[b]);
			edgeDistances[i] = d;

		}


		BOOL done = FALSE;
		while (!done)
		{
			//pop the top unsolved
			VConnections *top = unsolvedNodeHead;


			unsolvedNodeHead = unsolvedNodeHead->linkedListChild;
			top->linkedListChild = NULL;
			top->linkedListParent = NULL;
			if (unsolvedNodeHead != NULL)
			{
				unsolvedNodeHead->linkedListParent = NULL;
				//mark it as processed
				top->solved = TRUE;
				
				//put it in our solved list
				solvedNodes.Append(1,&top,5000);

				int neighborCount = top->connectingVerts.Count();
				//loop through the neighbors
				for (int i = 0; i < neighborCount; i++)
				{
					int index  = top->connectingVerts[i].vertexIndex;
					int eindex  = top->connectingVerts[i].edgeIndex;
					VConnections *neighbor = ourConnects[index];
					//make sure it is not procssedd
					if (!neighbor->solved)
					{
						//find the distance from the top to this neighbor
						float d = neighbor->accumDist;
						float testAccumDistance = top->accumDist + edgeDistances[eindex];
						//see if it accum dist needs to be relaxed
						if (testAccumDistance<d)
						{
							float originalDist = neighbor->accumDist;
							neighbor->accumDist = testAccumDistance;
							neighbor->closestNode = top;
							//sort this node
							float dist = neighbor->accumDist;


							if (originalDist == 1.0e+9f)
							{
								//start at the top and look down
								VConnections *currentNode = unsolvedNodeHead;
								if (neighbor == currentNode)
								{
									currentNode = currentNode->linkedListChild;
									unsolvedNodeHead = currentNode;
								}
								VConnections *prevNode = NULL;
								//unhook node
								VConnections *parent = neighbor->linkedListParent;
								VConnections *child = neighbor->linkedListChild;
								if (parent)
									parent->linkedListChild = child;
								if (child)
									child->linkedListParent = parent;
									

								while ((currentNode!= NULL) && (currentNode->accumDist < dist))
								{
								
									prevNode = currentNode;
									currentNode = currentNode->linkedListChild;
									SHORT iret = GetAsyncKeyState (VK_ESCAPE);
									if (iret==-32767)
									{
										done = TRUE;
										currentNode= NULL;
									}
								}
								//empty list
								if ((prevNode==NULL) && (currentNode== NULL))
								{
									neighbor->linkedListChild = NULL;
									neighbor->linkedListParent = NULL;
									unsolvedNodeHead = neighbor;
								}
								//at top
								else if (currentNode && (prevNode == NULL))
								{
									unsolvedNodeHead->linkedListParent = neighbor;
									neighbor->linkedListParent = NULL;
									neighbor->linkedListChild =unsolvedNodeHead;
									unsolvedNodeHead = neighbor;

								}
								//at bottom
								else if (currentNode == NULL)
								{
									prevNode->linkedListChild = neighbor;
									neighbor->linkedListParent = currentNode;
									neighbor->linkedListChild = NULL;
								}

								else if (currentNode)
								{
									//insert
									VConnections *parent = currentNode->linkedListParent;
									VConnections *child = currentNode;
		
									parent->linkedListChild = neighbor;
									child->linkedListParent = neighbor;

									neighbor->linkedListParent = parent;
									neighbor->linkedListChild = child;

								}



							}
							else
							{
								//sort smallest to largest
								BOOL moveUp = FALSE;

								if (neighbor->linkedListParent && neighbor->linkedListChild)
								{
									float parentDist = neighbor->linkedListParent->accumDist;
									float childDist = neighbor->linkedListChild->accumDist;
									//walkup up or down the list till find a spot an unlink and relink
									
									if ((dist >= parentDist) && (dist <= childDist))
									{
										//done dont need to move
									}
									else if (dist < parentDist)
										moveUp = FALSE;
								}
								else if (neighbor->linkedListParent && (neighbor->linkedListChild==NULL))
								{
									moveUp = TRUE;
								}
								else if ((neighbor->linkedListParent==NULL) && (neighbor->linkedListChild))
								{
									moveUp = FALSE;
								}

								//unlink the node
								//unhook node
								VConnections *parent = neighbor->linkedListParent;
								VConnections *child = neighbor->linkedListChild;
								if (parent)
									parent->linkedListChild = child;
								else unsolvedNodeHead = child;
								if (child)
									child->linkedListParent = parent;

								VConnections *currentNode = NULL;
								if (moveUp)
									currentNode = neighbor->linkedListParent;
								else currentNode = neighbor->linkedListChild;
								VConnections *prevNode = NULL;

								while ((currentNode!= NULL) && (currentNode->accumDist < dist))
								{							
									prevNode = currentNode;
									if (moveUp)
										currentNode = currentNode->linkedListParent;
									else currentNode = currentNode->linkedListChild;

									SHORT iret = GetAsyncKeyState (VK_ESCAPE);
									if (iret==-32767)
									{
										done = TRUE;
										currentNode= NULL;
									}

								}

								//empty list
								if ((prevNode==NULL) && (currentNode== NULL))
								{
									neighbor->linkedListChild = NULL;
									neighbor->linkedListParent = NULL;
									unsolvedNodeHead = neighbor;
								}
								//at top
								else if (currentNode && (prevNode == NULL))
								{
									unsolvedNodeHead->linkedListParent = neighbor;
									neighbor->linkedListParent = NULL;
									neighbor->linkedListChild =unsolvedNodeHead;
									unsolvedNodeHead = neighbor;

								}
								//at bottom
								else if (currentNode == NULL)
								{
									prevNode->linkedListChild = neighbor;
									neighbor->linkedListParent = currentNode;
									neighbor->linkedListChild = NULL;
								}
								else if (currentNode)
								{
									//insert
									VConnections *parent = currentNode->linkedListParent;
									VConnections *child = currentNode;
		
									parent->linkedListChild = neighbor;
									child->linkedListParent = neighbor;

									neighbor->linkedListParent = parent;
									neighbor->linkedListChild = child;

								}


							}

						}					
					}
				}
			}
			

			if (unsolvedNodeHead == NULL)
				done = TRUE;
			if ((solvedNodes[solvedNodes.Count()-1]) == ourConnects[target])
				done = TRUE;
		}
		//now get our edge list
		selEdges.ZeroCount();
		VConnections *cNode = ourConnects[target];
		while ((cNode->closestNode != NULL) && (cNode != ourConnects[source]))
		{
			VConnections *pNode = cNode->closestNode;
			int ct = cNode->connectingVerts.Count();
			int edgeIndex = -1;
			for (int i = 0; i < ct; i++)
			{
				int vindex = cNode->connectingVerts[i].vertexIndex;
				int eindex = cNode->connectingVerts[i].edgeIndex;
				if (ourConnects[vindex] == pNode)
				{
					edgeIndex = eindex;
					i = ct;
				}
			}
			if (edgeIndex != -1)
				selEdges.Append(1,&edgeIndex,500);

			cNode = pNode;
		}

	}

	if (del)
	{
		for (int i = 0; i < geomPoints.Count(); i++)
		{
			delete ourConnects[i];
		}
	}
}
Esempio n. 7
0
Tab<TSTR *> *GetRefName(RefMessage message,PartID& partID,BOOL bShowpartIDs) {
   static TSTR *pMsgStr, MsgStr;
   static Tab <TSTR *> pMessages;
   pMsgStr = &MsgStr;
   pMessages.ZeroCount();
   switch (message) {
      case 0x00000010:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new TSTR(_T("   REFMSG_LOOPTEST"));
         break;
      case 0x00000020:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR(_T("   REFMSG_TARGET_DELETED"));     
         break;
      case 0x00000021:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR(_T("   REFMSG_MODAPP_DELETING"));    
         break;
      case 0x00000030:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("   REFMSG_EVAL"));        
         break;
      case 0x00000040:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("   REFMSG_RESET_ORIGIN"));
         break;
      case 0x00000050:
         {
            pMessages.SetCount(pMessages.Count() +1);
            pMessages[pMessages.Count() -1] = new  TSTR(_T("REFMSG_CHANGE  "));
            if(bShowpartIDs)
            {
               if(partID&PART_TOPO) 
               {
                  pMessages.SetCount(pMessages.Count() +1);
                  pMessages[pMessages.Count() -1] = new  TSTR(_T("   PART_TOPO"));
               }
               if(partID&PART_GEOM)
               {
                  pMessages.SetCount(pMessages.Count() +1);
                  pMessages[pMessages.Count() -1] = new  TSTR(_T("   PART_GEOM"));
               }
               if(partID&PART_TEXMAP)
               {
                  pMessages.SetCount(pMessages.Count() +1);
                  pMessages[pMessages.Count() -1] = new TSTR(_T("   PART_TEXMAP"));
               }
               if(partID&PART_MTL)
               {
                  pMessages.SetCount(pMessages.Count() +1);
                  pMessages[pMessages.Count() -1] = new  TSTR(_T("   PART_MTL"));
               }
               if(partID&PART_SELECT)
               {
                  pMessages.SetCount(pMessages.Count() +1);
                  pMessages[pMessages.Count() -1] = new TSTR(_T("   PART_SELECT"));
               }
               if(partID&PART_SUBSEL_TYPE)
               {
                  pMessages.SetCount(pMessages.Count() +1);
                  pMessages[pMessages.Count() -1] = new  TSTR(_T("   PART_SUBSEL_TYPE"));
               }
               if(partID&PART_DISPLAY)
               {
                  pMessages.SetCount(pMessages.Count() +1);
                  pMessages[pMessages.Count() -1] = new  TSTR(_T("   PART_DISPLAY"));
               }
               if(partID&PART_VERTCOLOR)
               {
                  pMessages.SetCount(pMessages.Count() +1);
                  pMessages[pMessages.Count() -1] = new TSTR(_T("   PART_VERTCOLOR"));
               }
               if(partID&PART_GFX_DATA)
               {
                  pMessages.SetCount(pMessages.Count() +1);
                  pMessages[pMessages.Count() -1] = new  TSTR(_T("   PART_GFX_DATA"));
               }        
               if(partID&PART_TM_CHAN)
               {
                  pMessages.SetCount(pMessages.Count() +1);
                  pMessages[pMessages.Count() -1] = new TSTR(_T("   PART_TM_CHAN"));
               }
               if(partID&PART_MTL_CHAN)
               {
                  pMessages.SetCount(pMessages.Count() +1);
                  pMessages[pMessages.Count() -1] = new  TSTR(_T("   PART_MTL_CHAN"));
               }           
               if(partID&PART_OBJECT_TYPE)
               {
                  pMessages.SetCount(pMessages.Count() +1);
                  pMessages[pMessages.Count() -1] = new TSTR(_T("   PART_OBJECT_TYPE"));
               }
               if(partID&PART_HIDESTATE)
               {
                  pMessages.SetCount(pMessages.Count() +1);
                  pMessages[pMessages.Count() -1] = new  TSTR(_T("   PART_HIDESTATE"));
               }  
            }
         }
      case 0x00000070:
         {
         
            pMessages.SetCount(pMessages.Count() +1);
            pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_FLAGDEPENDENTS"));
            if(bShowpartIDs)
            {
               if(partID&PART_PUT_IN_FG)
               {
                  pMessages.SetCount(pMessages.Count() +1);
                  pMessages[pMessages.Count() -1] = new  TSTR(_T("   PART_PUT_IN_FG"));
               }           
               if(partID&PART_SHOW_DEPENDENCIES)
               {
                  pMessages.SetCount(pMessages.Count() +1);
                  pMessages[pMessages.Count() -1] = new TSTR(_T("   PART_SHOW_DEPENDENCIES"));
               }
               if(partID&PART_HIDESTATE)
               {
                  pMessages.SetCount(pMessages.Count() +1);
                  pMessages[pMessages.Count() -1] = new  TSTR(_T("   PART_SHOWDEP_ON"));
               }  
            }
         }
         break;
      case 0x00000080:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_TARGET_SELECTIONCHANGE"));
         break;
      case 0x00000090:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_BEGIN_EDIT"));           
         break;
      case 0x000000A0:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_END_EDIT"));
         break;
      case 0x000000B0:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_DISABLE"));           
         break;
      case 0x000000C0:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_ENABLE"));            
         break;
      case 0x000000D0:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_TURNON"));            
         break;
      case 0x000000E0:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_TURNOFF"));  
         break;
      case 0x000000F0:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_LOOKAT_TARGET_DELETED"));
         break;
      case 0x000000F1:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_INVALIDATE_IF_BG"));     
         break;
      case 0x000000F2:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_MOD_DISPLAY_ON"));    
         break;
      case 0x000000F3:
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_MOD_DISPLAY_OFF"));
         pMessages.SetCount(pMessages.Count() +1);
         break;
      case 0x000000F4:
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_MOD_EVAL"));
         pMessages.SetCount(pMessages.Count() +1);
         break;
      case 0x000000F5:
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_IS_OK_TO_CHANGE_TOPOLOGY"));
         pMessages.SetCount(pMessages.Count() +1);
         break;
      case 0x000000F6:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_NODE_LINK"));      
         break;
      case 0x000000F7:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_NODE_NAMECHANGE"));         
         break;
      case 0x000000F8:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_OBREF_CHANGE"));      
         break;
      case 0x000000F9:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_MODIFIER_ADDED"));    
         break;
      case 0x000000FA:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_CONTROLREF_CHANGE"));    
         break;
      case 0x000000FB:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_GET_PARAM_NAME"));       
         break;
      case 0x000000FC:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_GET_PARAM_DIM"));     
         break;
      case 0x000000FD:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_GET_CONTROL_DIM"));
         break;
      case 0x000000FE:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_TM_CHANGE"));         
         break;
      case 0x000000FF:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_RANGE_CHANGE"));      
         break;
      case 0x00000100:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_LINEHEIGHT_CHANGE"));    
         break;
      case 0x00000101:
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_BECOMING_ANIMATED"));
         pMessages.SetCount(pMessages.Count() +1);
         break;
      case 0x00000102:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_SUBANIM_STRUCTURE_CHANGED"));
         break;
      case 0x00000103:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_REF_DELETED"));
         break;
      case 0x00000104:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_REF_ADDED"));
         break;
      case 0x00000105:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_BRANCHED_HISTORY_CHANGED"));
         break;
      case 0x00000106:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_NODEINSELSET_CHANGED"));
         break;
      case 0x00000107:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_TEST_DEPENDENCY"));
         break;
      case 0x00000108:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_WANT_SHOWPARAMLEVEL"));
         break;
      case 0x00000109:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_BEFORE_PASTE"));   
         break;
      case 0x0000010A:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_NOTIFY_PASTE"));   
         break;
      case 0x0000010B:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_UV_SYM_CHANGE")); 
         break;
      case 0x0000010C:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_GET_NODE_NAME"));     
         break;
      case 0x0000010D:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_SEL_NODES_DELETED"));    
         break;
      case 0x0000010E:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_PRENOTIFY_PASTE"));
         break;
      case 0x0000010F:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_SHAPE_START_CHANGE"));   
         break;
      case 0x00000110:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_SHAPE_END_CHANGE"));  
         break;
      case 0x00000111:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_TEXMAP_REMOVED"));
         break;
      case 0x00000112:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_FLAG_NODES_WITH_SEL_DEPENDENTS"));
         break;
      case 0x00000120:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_CONTAINED_SHAPE_POS_CHANGE"));
         break;
      case 0x00000121:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_CONTAINED_SHAPE_SEL_CHANGE"));
         break;
      case 0x00000122:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_CONTAINED_SHAPE_GENERAL_CHANGE"));
         break;
      case 0x00000130:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_SELECT_BRANCH"));
         break;
      case 0x00000140:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_MOUSE_CYCLE_STARTED"));
         break;
      case 0x00000150:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_MOUSE_CYCLE_COMPLETED"));
         break;

      case 0x00000161:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_CHECK_FOR_INVALID_BIND"));
         break;

      case 0x00000162:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_OBJECT_CACHE_DUMPED"));
         break;

      case 0x00000170:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_SFX_CHANGE"));
         break;

      case 0x00000180:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_OBJXREF_UPDATEMAT"));
         break;

      case 0x00000190:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_OBJXREF_GETNODES"));
         break;

      case 0x00000200:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_OBJECT_REPLACED"));
         break;

      case 0x00000210:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_NODE_WIRECOLOR_CHANGED"));
         break;

      case 0x00000240:
      {
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_NODE_RENDERING_PROP_CHANGED"));
         if (bShowpartIDs)
         {
            if (partID&PART_REND_PROP_RENDERABLE)
            {
               pMessages.SetCount(pMessages.Count() +1);
               pMessages[pMessages.Count() -1] = new  TSTR(_T("   PART_REND_PROP_RENDERABLE"));
            }           
            if (partID&PART_REND_PROP_CAST_SHADOW)
            {
               pMessages.SetCount(pMessages.Count() +1);
               pMessages[pMessages.Count() -1] = new  TSTR(_T("   PART_REND_PROP_CAST_SHADOW"));
            }           
            if (partID&PART_REND_PROP_RCV_SHADOW)
            {
               pMessages.SetCount(pMessages.Count() +1);
               pMessages[pMessages.Count() -1] = new  TSTR(_T("   PART_REND_PROP_RCV_SHADOW"));
            }           
            if (partID&PART_REND_PROP_RENDER_OCCLUDED)
            {
               pMessages.SetCount(pMessages.Count() +1);
               pMessages[pMessages.Count() -1] = new  TSTR(_T("   PART_REND_PROP_RENDER_OCCLUDED"));
            }           
            if (partID&PART_REND_PROP_VISIBILITY)
            {
               pMessages.SetCount(pMessages.Count() +1);
               pMessages[pMessages.Count() -1] = new  TSTR(_T("   PART_REND_PROP_VISIBILITY"));
            }           
            if (partID&PART_REND_PROP_INHERIT_VIS)
            {
               pMessages.SetCount(pMessages.Count() +1);
               pMessages[pMessages.Count() -1] = new  TSTR(_T("   PART_REND_PROP_INHERIT_VIS"));
            }           
            if (partID&PART_REND_PROP_PRIMARY_INVISIBILITY)
            {
               pMessages.SetCount(pMessages.Count() +1);
               pMessages[pMessages.Count() -1] = new  TSTR(_T("   PART_REND_PROP_PRIMARY_INVISIBILITY"));
            }           
            if (partID&PART_REND_PROP_SECONDARY_INVISIBILITY)
            {
               pMessages.SetCount(pMessages.Count() +1);
               pMessages[pMessages.Count() -1] = new  TSTR(_T("   PART_REND_PROP_SECONDARY_INVISIBILITY"));
            }           
         }
      } break;

      case 0x00000241:
      {
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T("REFMSG_NODE_DISPLAY_PROP_CHANGED"));
         if (bShowpartIDs)
         {
            if (partID&PART_DISP_PROP_IS_HIDDEN)
            {
               pMessages.SetCount(pMessages.Count() +1);
               pMessages[pMessages.Count() -1] = new  TSTR(_T("   PART_DISP_PROP_IS_HIDDEN"));
            }           
            if (partID&PART_DISP_PROP_IS_FROZEN)
            {
               pMessages.SetCount(pMessages.Count() +1);
               pMessages[pMessages.Count() -1] = new  TSTR(_T("   PART_DISP_PROP_IS_FROZEN"));
            }           
         }
      } break;

      default:
         pMessages.SetCount(pMessages.Count() +1);
         pMessages[pMessages.Count() -1] = new  TSTR( _T(""));
         break;
   };
   MsgStr =  _T("");
   return &pMessages;
}
Esempio n. 8
0
void ParticleMesherObject::BuildMesh(TimeValue t)
   {
//check if render time
//get node
//mkae ivalid interesect with the 
   int isRendering = 0;
   ivalid = FOREVER;

   TimeValue offset;
   float foffset;
   Interval iv;
   pblock2->GetValue(particlemesher_time, 0, foffset, iv);
   foffset = -foffset;
   pblock2->GetValue(particlemesher_radius, 0, radius, iv);
   foffset *= GetTicksPerFrame();
   offset = (TimeValue) foffset;

// pblock2->GetValue(particlemesher_time, 0, foffset, iv);
   if ((lastTime == t)  )
      {
      ivalid.Set(t,t);
      return;
      }


   pblock2->GetValue(particlemesher_rendertimeonly, 0, isRendering, ivalid);
   isRendering = !isRendering;
    if ((isRendering) || (TestAFlag(A_RENDER)))
      {
      INode *node=NULL;
      pblock2->GetValue(particlemesher_pick, 0, node, ivalid);

      
      BOOL reevalGroup = FALSE;
      if ((node != NULL) && (node->IsGroupHead()) )
         {  
         for (int ch=0;ch<node->NumberOfChildren();ch++)
            {  
            INode *cnode= node->GetChildNode(ch);
            Interval iv;
            Matrix3 tm=cnode->GetObjectTM(t,&iv);
      

            if (cnode->IsGroupMember())
               {
               reevalGroup = TRUE;
               for (int groupCount = 0; groupCount < pblock2->Count(particlemesher_extranodes); groupCount++)
                  {
                  INode *extraNode = pblock2->GetINode(particlemesher_extranodes,t,ch);
                  if (cnode == extraNode)
                     {
                     reevalGroup = FALSE;
                     groupCount = pblock2->Count(particlemesher_extranodes);
                     }
                  }
               if (reevalGroup)
                  ch=node->NumberOfChildren();

               }
            }

         if (reevalGroup)
            {
            tmList.ZeroCount();
   
            pblock2->ZeroCount(particlemesher_extranodes);
            for (int ch=0;ch<node->NumberOfChildren();ch++)
               {  
               INode *cnode= node->GetChildNode(ch);
               Interval iv;
               Matrix3 tm=cnode->GetObjectTM(t,&iv);
      

               if (cnode->IsGroupMember())
                  {
                  pblock2->Append(particlemesher_extranodes,1,&cnode);
                  tmList.Append(1,&tm);
                  }
               }

            }
         }

      if (node) 
         {

         if ( (node->IsGroupHead()) && (pblock2->Count(particlemesher_extranodes)!=0))
            {

            int ct = 0;
            Matrix3 ident(1), inverseTm(1);
            mesh.setNumVerts(0);
            mesh.setNumFaces(0);
            for (int ch=0;ch<pblock2->Count(particlemesher_extranodes);ch++)
               {  
               INode *cnode = pblock2->GetINode(particlemesher_extranodes,t,ch);
               if (cnode)
                  {
                  Object *pobj = cnode->EvalWorldState(t+offset).obj;
               
                  if ( (pobj->SuperClassID() == GEOMOBJECT_CLASS_ID) ||
                      (pobj->SuperClassID() == SHAPE_CLASS_ID) )                    
                     {  


                     BOOL needDel;
                     NullView nullView;
                     Mesh *msh = ((GeomObject*)pobj)->GetRenderMesh(t+offset,cnode,nullView,needDel);

                     Mesh tmsh = *msh;

                     ivalid &= pobj->ObjectValidity(t+offset);

                     Matrix3 tm(1);
                     if (ch < tmList.Count())
                        tm = tmList[ch];
                     for (int v = 0; v < msh->numVerts; v++)
                        {
                        tmsh.verts[v] = tmsh.verts[v] * tm;
                        }
                     if (tmsh.numVerts != 0)
                        {
                        if (ct ==0)
                           {
                           mesh = tmsh;
                           }
                        else 
                           mesh = mesh + tmsh;
                  
                        ct++;
                        }

                     if (needDel) delete msh;
                     }

                     
               
                  }
                  
               }
            mesh.InvalidateTopologyCache();

            }
         else
            {
//          Object *tobj =  node->GetObjectRef();
//          macroRecorder->FunctionCall(_T("time"), 1, 0, mr_int, t);
//          macroRecorder->EmitScript();
            ObjectState os = node->EvalWorldState(t+offset);

            IParticleObjectExt* epobj;
            epobj = (IParticleObjectExt*) os.obj->GetInterface(PARTICLEOBJECTEXT_INTERFACE);
            
            if (os.obj->IsParticleSystem() && epobj)
               {
      
               if (epobj) 
                  {
                  BOOL useAllPFEvents;
                  pblock2->GetValue(particlemesher_useallpf,0,useAllPFEvents,FOREVER);
                  
                  pfNodes.ZeroCount();
                  
                  INode *basenode=NULL;
                  pblock2->GetValue(particlemesher_pick, 0, basenode, ivalid);                  

                  tmList.ZeroCount();

                  if (useAllPFEvents)
                     {
                     MyEnumProc dep;              
                     os.obj->DoEnumDependents(&dep);
                     
                     for (int i = 0; i < dep.Nodes.Count(); i++)
                        {
                        Interval valid;
                        INode *node = dep.Nodes[i];

                        Object *obj = node->GetObjectRef();

                        
                        if (ParticleGroupInterface(obj) != nullptr)
                           {
                           pfNodes.Append(1,&node);
                           Matrix3 tm = node->GetNodeTM(t+offset);
                           tmList.Append(1,&tm);
                           }
                        }                 
                     }
                  else
                     {
                     int ct = pblock2->Count(particlemesher_pfeventlist);
                     for (int i = 0; i < ct; i++)
                        {
                        INode *node;
                        pblock2->GetValue(particlemesher_pfeventlist,t,node,FOREVER,i);
                        if (node)
                           {

                           Object *obj = node->GetObjectRef();
                           if (ParticleGroupInterface(obj) != nullptr)
                              {
                              pfNodes.Append(1,&node);
                              Matrix3 tm(1);// = basenode->GetNodeTM(t+offset);
                              Matrix3 ntm = node->GetObjectTM(t+offset);
                              tm = ntm;
                              tmList.Append(1,&ntm);
                              
                              }                          
                           }
                        }
                     }
                     
                  mesh.setNumVerts(0);
                  mesh.setNumFaces(0);
                  int ct = 0;
                  for (int ch=0;ch< pfNodes.Count();ch++)
                     {  
                     INode *cnode = pfNodes[ch];
                     if (cnode)
                        {
                        Object *pobj = cnode->EvalWorldState(t+offset).obj;
                     
                        if ( (pobj->SuperClassID() == GEOMOBJECT_CLASS_ID) ||
                           (pobj->SuperClassID() == SHAPE_CLASS_ID) )                     
                           {  


                           BOOL needDel;
                           NullView nullView;
                           Mesh *msh = ((GeomObject*)pobj)->GetRenderMesh(t+offset,cnode,nullView,needDel);

                           Mesh tmsh = *msh;

                           ivalid &= pobj->ObjectValidity(t+offset);

                           Matrix3 tm(1);
                           if (ch < tmList.Count())
                              tm = tmList[ch];
                           for (int v = 0; v < msh->numVerts; v++)
                              {
                              tmsh.verts[v] = tmsh.verts[v] * tm;
                              }
                           if (tmsh.numVerts != 0)
                              {
                              if (ct ==0)
                                 {
                                 mesh = tmsh;
                                 }
                              else 
                                 {
                                 Mesh tempMesh = mesh;
                                 CombineMeshes(mesh, tempMesh, tmsh);
                                 }
                        
                              ct++;
                              }

                           if (needDel) delete msh;
                           }

                           
                     
                        }
                        
                     }
                  mesh.InvalidateTopologyCache();
                     
                     
                                       
                  }
               }
            else if ( (os.obj->SuperClassID() == GEOMOBJECT_CLASS_ID) ||
             (os.obj->SuperClassID() == SHAPE_CLASS_ID) )
               {

               BOOL needDel;
               NullView nullView;
               Mesh *msh = ((GeomObject*)os.obj)->GetRenderMesh(t+offset,node,nullView,needDel);
               ivalid &= os.obj->ObjectValidity(t);

               if (msh)
                  {
                  mesh = *msh;
                  mesh.InvalidateTopologyCache();
         
                  if (needDel) delete msh;
                  }
               }
            }
         lastTime = t;
         }
      else
         {
//build proxy mesh
         if (node == NULL)
            {
            mesh.setNumVerts(5);
            mesh.setNumFaces(8);

            mesh.setNumMaps(2);
            mesh.setNumMapVerts(0, 0);
            mesh.setNumMapVerts(1, 0);
            mesh.setNumMapFaces(0, 0);
            mesh.setNumMapFaces(1, 0);

            mesh.setVert(0, Point3(-radius,-radius, 0.0f));
            mesh.setVert(1, Point3( radius,-radius, 0.0f));
            mesh.setVert(2, Point3( radius, radius, 0.0f));
            mesh.setVert(3, Point3(-radius, radius, 0.0f));

//          mesh.setVert(4, Point3(0.0f, 0.0f, 0.0f));
            mesh.setVert(4, Point3(0.0f, 0.0f, radius));
   
            mesh.faces[0].setEdgeVisFlags(1,0,1);
            mesh.faces[0].setSmGroup(1);
            mesh.faces[0].setVerts(0,1,3);

            mesh.faces[1].setEdgeVisFlags(1,1,0);
            mesh.faces[1].setSmGroup(1);
            mesh.faces[1].setVerts(1,2,3);   

            mesh.faces[2].setEdgeVisFlags(1,1,1);
            mesh.faces[2].setSmGroup(1);
            mesh.faces[2].setVerts(0,4,1);   

            mesh.faces[3].setEdgeVisFlags(1,1,1);
            mesh.faces[3].setSmGroup(1);
            mesh.faces[3].setVerts(1,4,0);   

            mesh.faces[4].setEdgeVisFlags(1,1,1);
            mesh.faces[4].setSmGroup(1);
            mesh.faces[4].setVerts(2,4,3);   

            mesh.faces[5].setEdgeVisFlags(1,1,1);
            mesh.faces[5].setSmGroup(1);
            mesh.faces[5].setVerts(3,4,2);   

            mesh.faces[6].setEdgeVisFlags(1,0,1);
            mesh.faces[6].setSmGroup(1);
            mesh.faces[6].setVerts(3,1,0);

            mesh.faces[7].setEdgeVisFlags(1,1,0);
            mesh.faces[7].setSmGroup(1);
            mesh.faces[7].setVerts(3,2,1);   


            }

         }
      }  
   else
      {
//build proxy mesh
//build proxy mesh
      INode *node=NULL;
      pblock2->GetValue(particlemesher_pick, 0, node, ivalid);
   // if (node == NULL)
         {
            mesh.setNumVerts(5);
            mesh.setNumFaces(8);

            mesh.setNumMaps(2);
            mesh.setNumMapVerts(0, 0);
            mesh.setNumMapVerts(1, 0);
            mesh.setNumMapFaces(0, 0);
            mesh.setNumMapFaces(1, 0);

            mesh.setVert(0, Point3(-radius,-radius, 0.0f));
            mesh.setVert(1, Point3( radius,-radius, 0.0f));
            mesh.setVert(2, Point3( radius, radius, 0.0f));
            mesh.setVert(3, Point3(-radius, radius, 0.0f));

//          mesh.setVert(4, Point3(0.0f, 0.0f, 0.0f));
            mesh.setVert(4, Point3(0.0f, 0.0f, radius));
   
            mesh.faces[0].setEdgeVisFlags(1,0,1);
            mesh.faces[0].setSmGroup(1);
            mesh.faces[0].setVerts(0,1,3);

            mesh.faces[1].setEdgeVisFlags(1,1,0);
            mesh.faces[1].setSmGroup(1);
            mesh.faces[1].setVerts(1,2,3);   

            mesh.faces[2].setEdgeVisFlags(1,1,1);
            mesh.faces[2].setSmGroup(1);
            mesh.faces[2].setVerts(0,4,1);   

            mesh.faces[3].setEdgeVisFlags(1,1,1);
            mesh.faces[3].setSmGroup(1);
            mesh.faces[3].setVerts(1,4,0);   

            mesh.faces[4].setEdgeVisFlags(1,1,1);
            mesh.faces[4].setSmGroup(1);
            mesh.faces[4].setVerts(2,4,3);   

            mesh.faces[5].setEdgeVisFlags(1,1,1);
            mesh.faces[5].setSmGroup(1);
            mesh.faces[5].setVerts(3,4,2);   

            mesh.faces[6].setEdgeVisFlags(1,0,1);
            mesh.faces[6].setSmGroup(1);
            mesh.faces[6].setVerts(3,1,0);

            mesh.faces[7].setEdgeVisFlags(1,1,0);
            mesh.faces[7].setSmGroup(1);
            mesh.faces[7].setVerts(3,2,1);   

         }
      }

   mesh.InvalidateTopologyCache();
}
Esempio n. 9
0
void
ParticleMesherObject::PickPFEvents(HWND hWnd)
{
   Tab<INode *> pfEvents;
   int numberOfNodes = 1;;

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


   pfNodes.ZeroCount();
   addPFNodes.ZeroCount();
   

   for (int i = 0; i < numberOfNodes; i++)
      {
      INode *node;
      pblock2->GetValue(particlemesher_pick,t,node,ivalid,i);

      if (node)
         {
         ObjectState tos =  node->EvalWorldState(t,TRUE);

         if (tos.obj->IsParticleSystem())
            {
            IParticleObjectExt* epobj;
            epobj = (IParticleObjectExt*) tos.obj->GetInterface(PARTICLEOBJECTEXT_INTERFACE);
   
            if (epobj) 
               {
               MyEnumProc dep;              
               tos.obj->DoEnumDependents(&dep);
               for (int i = 0; i < dep.Nodes.Count(); i++)
                  {
                  Interval valid;
                  INode *node = dep.Nodes[i];

                  Object *obj = node->GetObjectRef();
				  IParticleGroup* iPGroup = ParticleGroupInterface(obj);
				  if (iPGroup != nullptr)
					  {
						 // we need to filter out the global action list events since
						 // they do not carry any actual particle shape geometry
						 if (iPGroup->GetParticleSystem() != iPGroup->GetActionList())
						 {
							 pfNodes.Append(1, &node);
						 }
					  }
			      }
               }

            }

         }
      }
   if (pfNodes.Count() > 0)
      {
      int iret = DialogBoxParam(hInstance,MAKEINTRESOURCE(IDD_ADD_DIALOG),
            hWnd,AddDlgProc,(LPARAM)this);
      if ((iret) && (addPFNodes.Count() > 0))
         {
         theHold.Begin();
         for (int i = 0; i < addPFNodes.Count(); i++)
            {
            int index = addPFNodes[i];
            INode *node = pfNodes[index];
            pblock2->Append(particlemesher_pfeventlist,1,&node);
            }
         theHold.Accept(GetString(IDS_ADDEVENTS));

         }
      }  

}
Esempio n. 10
0
void	UnwrapMod::fnUnfoldSelectedPolygons(int unfoldMethod, BOOL normalize)
	{		
// flatten selected polygons
	BailStart();
	BitArray *polySel = fnGetSelectedPolygons();
	BitArray holdPolySel;
	if (polySel == NULL) 
		return;
	if (TVMaps.f.Count() == 0) return;


	if (!theHold.Holding())
		{
		theHold.SuperBegin();
		theHold.Begin();
		}

	holdPolySel.SetSize(polySel->GetSize());
	holdPolySel = *polySel;

	HoldPointsAndFaces();	

	Point3 normal(0.0f,0.0f,1.0f);

	BitArray oldSel = *fnGetSelectedPolygons();

	Tab<Point3> mapNormal;
	mapNormal.SetCount(0);

	BOOL bContinue = BuildCluster( mapNormal, 5.0f, TRUE, TRUE);
	TSTR statusMessage;

	BitArray sel;
	sel.SetSize(TVMaps.f.Count());

	if (bContinue)
		{
			
		for (int i =0; i < clusterList.Count(); i++)
			{
			sel.ClearAll();
			for (int j = 0; j < clusterList[i]->faces.Count();j++)
				sel.Set(clusterList[i]->faces[j]);
			fnSelectPolygonsUpdate(&sel, FALSE);
			PlanarMapNoScale(clusterList[i]->normal);

			int per = (i * 100)/clusterList.Count();
			statusMessage.printf("%s %d%%.",GetString(IDS_PW_STATUS_MAPPING),per);
			if (Bail(ip,statusMessage))
				{
				i = clusterList.Count();
				bContinue =  FALSE;
				}

			}


		if ( (bContinue) && (clusterList.Count() > 1) )
			{

			if (!ip) return;
			ModContextList mcList;		
			INodeTab nodes;
			ip->GetModContexts(mcList,nodes);

			int objects = mcList.Count();

			MeshTopoData *md = (MeshTopoData*)mcList[0]->localData;

			if (md == NULL) 
				{
				theHold.Cancel();
				theHold.SuperCancel();
				return;
				}

			Tab<Point3> objNormList;
			BuildNormals(md,objNormList);

//remove internal edges
			BitArray *selectedPolygons = fnGetSelectedPolygons();
			Tab<int> clusterGroups;
			clusterGroups.SetCount(TVMaps.f.Count());
			for (i =0; i < clusterGroups.Count(); i++)
				{
				clusterGroups[i] = -1;
				}
		//loop through all tagged edges and remove any that onely have one edhes selected
			for (i = 0; i < clusterList.Count(); i++)
				{
				for (int j = 0; j < clusterList[i]->faces.Count(); j++)
					{
					int faceIndex = clusterList[i]->faces[j];
					clusterGroups[faceIndex] = i;
					}
				}
			BitArray processedClusters;
			processedClusters.SetSize(clusterList.Count());
			processedClusters.ClearAll();

			Tab<BorderClass> edgesToBeProcessed;

			BOOL done = FALSE;
			int currentCluster = 0;

			processedClusters.Set(0);
			clusterList[0]->newX = 0.0f;
			clusterList[0]->newY = 0.0f;
//		clusterList[0]->angle = 0.0f;
			for (int i = 0; i < clusterList[0]->borderData.Count(); i++)
				{
				int outerFaceIndex = clusterList[0]->borderData[i].outerFace;
				int connectedClusterIndex = clusterGroups[outerFaceIndex];
				if ((connectedClusterIndex != 0) && (connectedClusterIndex != -1))
					{
					edgesToBeProcessed.Append(1,&clusterList[0]->borderData[i]);
					}
				}
			BitArray seedFaceList;
			seedFaceList.SetSize(clusterGroups.Count());
			seedFaceList.ClearAll();
			for (i = 0; i < seedFaces.Count(); i++)
				{
				seedFaceList.Set(seedFaces[i]);
				}

			while (!done)
				{
				Tab<int> clustersJustProcessed;
				clustersJustProcessed.ZeroCount();
				done = TRUE;

				int edgeToAlign = -1;
				float angDist = PI*2;
				if (unfoldMethod == 1)
					angDist =  PI*2;
				else if (unfoldMethod == 2) angDist = 0;
				for (i = 0; i < edgesToBeProcessed.Count(); i++)
					{
					int outerFace = edgesToBeProcessed[i].outerFace;
					int connectedClusterIndex = clusterGroups[outerFace];
					if (!processedClusters[connectedClusterIndex])
						{
						int innerFaceIndex = edgesToBeProcessed[i].innerFace;
						int outerFaceIndex = edgesToBeProcessed[i].outerFace;
//get angle
						Point3 innerNorm, outerNorm;
						innerNorm = objNormList[innerFaceIndex];
						outerNorm = objNormList[outerFaceIndex];
						float dot = DotProd(innerNorm,outerNorm);

						float angle = 0.0f;

						if (dot == -1.0f)
							angle = PI;
						else if (dot == 1.0f)
							angle = 0.f;						
						else angle = acos(dot);

						if (unfoldMethod == 1)
							{
							if (seedFaceList[outerFaceIndex])
								angle = 0.0f;
							if (angle < angDist)
								{
								angDist = angle;
								edgeToAlign = i;
								}
							}

						else if (unfoldMethod == 2)
							{
							if (seedFaceList[outerFaceIndex])
								angle = 180.0f;
							if (angle > angDist)
								{
								angDist = angle;
								edgeToAlign = i;
								}
							}

						}
					}
				if (edgeToAlign != -1)
					{
					int innerFaceIndex = edgesToBeProcessed[edgeToAlign].innerFace;
					int outerFaceIndex = edgesToBeProcessed[edgeToAlign].outerFace;
					int edgeIndex = edgesToBeProcessed[edgeToAlign].edge;
					

					int connectedClusterIndex = clusterGroups[outerFaceIndex];

					seedFaceList.Set(outerFaceIndex, FALSE);

					processedClusters.Set(connectedClusterIndex);
					clustersJustProcessed.Append(1,&connectedClusterIndex);
					AlignCluster(i,connectedClusterIndex,innerFaceIndex, outerFaceIndex,edgeIndex);
					done = FALSE;
					}

//build new cluster list
				for (int j = 0; j < clustersJustProcessed.Count(); j++)
					{
					int clusterIndex = clustersJustProcessed[j];
					for (int i = 0; i < clusterList[clusterIndex]->borderData.Count(); i++)
						{
						int outerFaceIndex = clusterList[clusterIndex]->borderData[i].outerFace;
						int connectedClusterIndex = clusterGroups[outerFaceIndex];
						if ((!processedClusters[connectedClusterIndex]) && (connectedClusterIndex != 0) && (connectedClusterIndex != -1))
							{
							edgesToBeProcessed.Append(1,&clusterList[clusterIndex]->borderData[i]);
							}
						}
					}
				}
			}

		vsel.SetSize(TVMaps.v.Count());
		vsel.ClearAll();
		for (i = 0; i < clusterList.Count(); i++)
			{
			for (int j =0; j < clusterList[i]->faces.Count(); j++)
				{
				int faceIndex = clusterList[i]->faces[j];
				for (int k =0; k < TVMaps.f[faceIndex]->count; k++)
					{
					int vertexIndex = TVMaps.f[faceIndex]->t[k];
					vsel.Set(vertexIndex);
					}
				}
			}
//now weld the verts
		if (normalize)
			{
			NormalizeCluster();
			}

		float tempWeld = weldThreshold;
		weldThreshold = 0.001f;
		WeldSelected(FALSE);
		weldThreshold = tempWeld;


		}

	


	FreeClusterList();

	if (bContinue)
		{	
		theHold.Accept(_T(GetString(IDS_PW_PLANARMAP)));
		theHold.SuperAccept(_T(GetString(IDS_PW_PLANARMAP)));

		fnSelectPolygonsUpdate(&holdPolySel, FALSE);
		theHold.Suspend();
		fnSyncTVSelection();
		theHold.Resume();
		}
	else
		{
		theHold.Cancel();
		theHold.SuperCancel();
		}

	RebuildEdges();

	theHold.Suspend();
	fnSyncGeomSelection();
	theHold.Resume();


	NotifyDependents(FOREVER,PART_SELECT,REFMSG_CHANGE);
	InvalidateView();


	}
Esempio n. 11
0
void UnwrapMod::PlanarMapNoScale(Point3 gNormal)

	{
	AlignMap();

//add vertices to our internal vertex list filling in dead spots where appropriate
	int ct = 0;  

//get align normal
//get fit data

	PlanarTM.IdentityMatrix();
	Interval v;
	Point3 identScale(1.0f,1.0f,1.0f);
	if (scaleControl) scaleControl->GetValue(0,&gScale,v);
	PlanarTM.SetScale(identScale);
	if (rotateControl) rotateControl->GetValue(0,&gRotate,v);
	PlanarTM.RotateZ(gRotate);
	if (offsetControl) offsetControl->GetValue(0,&gOffset,v);
	PlanarTM.SetTrans(gOffset);

	ComputeSelectedFaceData();



	Matrix3 gtm;
	UnwrapMatrixFromNormal(gNormal,gtm);

	gtm = Inverse(gtm);

	DeleteVertsFromFace(gfaces);

//unselect all verts
	for (int j=0;j<TVMaps.v.Count();j++)
		{
		if (vsel[j])
			{
			vsel.Clear(j);
			}
		}

//build available list
	Tab<int> alist;
	alist.ZeroCount();

	for (j=0;j<TVMaps.v.Count();j++)
		{
		if (TVMaps.v[j].flags & FLAG_DEAD)
//dead veretx found copy new vert in and note the place
			{
			alist.Append(1,&j,1);
			}
		}


	for (int i = 0; i < gverts.d.Count(); i++)
		{
		BOOL found = FALSE;
		if (gverts.sel[i])
			{
			if (ct < alist.Count() )
				{
				j = alist[ct];
				TVMaps.v[j].flags = 0;
				TVMaps.v[j].influence = 0.0f;
			
				Point3 tp = gverts.d[i].p - gCenter;
				tp = tp * gtm;
				tp.z = 0.0f;

				TVMaps.v[j].p = tp;
				int vcount = vsel.GetSize();
				vsel.Set(j);

				if (TVMaps.cont[j]) TVMaps.cont[j]->SetValue(0,&tp,CTRL_ABSOLUTE);
				gverts.d[i].newindex = j;
				ct++;

				}
			else
				{
				UVW_TVVertClass tempv;

				Point3 tp = gverts.d[i].p - gCenter;
				tp = tp * gtm;
				tp.z = 0.0f;
				tempv.p = tp;


				tempv.flags = 0;
				tempv.influence = 0.0f;
				gverts.d[i].newindex = TVMaps.v.Count();
				TVMaps.v.Append(1,&tempv,1);

				vsel.SetSize(TVMaps.v.Count(), 1);
				vsel.Set(TVMaps.v.Count()-1);

				Control* c;
				c = NULL;
				TVMaps.cont.Append(1,&c,1);
				if (TVMaps.cont[TVMaps.v.Count()-1]) 
					TVMaps.cont[TVMaps.v.Count()-1]->SetValue(0,&TVMaps.v[TVMaps.v.Count()-1].p,CTRL_ABSOLUTE);
				}
			}

		}
//now copy our face data over
	for (i = 0; i < gfaces.Count(); i++)
		{
		int ct = gfaces[i]->FaceIndex;
		TVMaps.f[ct]->flags = gfaces[i]->flags;
		TVMaps.f[ct]->flags |= FLAG_SELECTED;
		int pcount = 3;
		pcount = gfaces[i]->count;
		for (int j = 0; j < pcount; j++)
			{
			int index = gfaces[i]->t[j];
//find spot in our list
			TVMaps.f[ct]->t[j] = gverts.d[index].newindex;
			if ((TVMaps.f[ct]->flags & FLAG_CURVEDMAPPING) && (TVMaps.f[ct]->vecs))
				{
				index = gfaces[i]->vecs->handles[j*2];
//find spot in our list
				TVMaps.f[ct]->vecs->handles[j*2] = gverts.d[index].newindex;

				index = gfaces[i]->vecs->handles[j*2+1];
//find spot in our list
				TVMaps.f[ct]->vecs->handles[j*2+1] = gverts.d[index].newindex;

				if (TVMaps.f[ct]->flags & FLAG_INTERIOR)
					{
					index = gfaces[i]->vecs->interiors[j];
//find spot in our list
					TVMaps.f[ct]->vecs->interiors[j] = gverts.d[index].newindex;
					}
	
				}
			}
		}
		
	CleanUpDeadVertices();

	TVMaps.edgesValid= FALSE;
	}
void BakeRadiosity::DoIt(void)
{
   DebugPrint(_T("Plug-in Start\n"));

   RadiosityInterface *ri;
   RadiosityEffect *re;
   RadiosityMesh *rm;
   INode *node;
   Tab<INode *> selNodes;
   int nbSel;

   // Gets core interface
   ri = static_cast<RadiosityInterface*>(
            GetCOREInterface(RADIOSITY_INTERFACE));
   if(ri == NULL){
	   DebugPrint(_T("RadiosityInterface error\n"));
      return;
   }
   // Returns a pointer to the currently active Advanced Lighting plug-in.
   if((re = ri->GetRadiosity()) == NULL){
      DebugPrint(_T("RadiosityEffect error\n"));
      return;
   }
   // Gets Radiosity Mesh
   if((rm = GetRadiosityMesh(re)) == NULL){
      DebugPrint(_T("RadiosityMesh error\n"));
      return;
   }
   // Resets the container for INode pointers.
    selNodes.ZeroCount();
   // Returns the number of nodes in the selection set.  
   nbSel = ip->GetSelNodeCount();
   // The loop will continue until handling all seletecd nodes...
   for(int i=0; i<nbSel; i++){
      // Returns a pointer to the 'i-th' node in the selection set.
      if((node = ip->GetSelNode(i)) == NULL){
         continue;
      }
      // Gets the mesh for a node.
      Mesh *mesh = NULL;
      if(!rm->GetMesh(node, mesh)||(mesh == NULL)){
	      DebugPrint(_T("GetMesh error\n"));
         continue;
      }
      // Gets the TM for the node.
      // TM is the mesh to world space transform.
      Matrix3 mtx(1);
      if(!rm->GetMeshTM(node, mtx)){
	      DebugPrint(_T("GetMeshTM error\n"));
         continue;
      }
      // Creates a new mesh
      if(!CreateNewMesh(node, mesh, mtx)){
	      DebugPrint(_T("CreateMesh error\n"));
         continue;
      }
      // Appends a INode pointer to the container
      selNodes.Append(1, &node);
   }
   // Deletes original nodes if the flag is set.
   if(keepOrgFlag != true){
      nbSel = selNodes.Count();
      // The loop will continue until handling all appended nodes...
      for(int i=0; i<nbSel; i++){
         if(selNodes[i] == NULL){
            continue;
         }
         // Removes it from the hierarchy, and handle undo. 
         // The position of any children of this node are kept the same.
         selNodes[i]->Delete(ip->GetTime(), TRUE);
      }
   }

   DebugPrint(_T("Plug-in End\n"));
}
Esempio n. 13
0
void  UnwrapMod::fnUnfoldSelectedPolygons(int unfoldMethod, BOOL normalize)
{     

	// flatten selected polygons
	if (!ip) return;
	BailStart();

	theHold.Begin();
	HoldPointsAndFaces();   

	Point3 normal(0.0f,0.0f,1.0f);

	for (int ldID =0; ldID < mMeshTopoData.Count(); ldID++)
	{
		MeshTopoData *ld = mMeshTopoData[ldID];
		ld->HoldFaceSel();
	}

	BOOL bContinue = TRUE;
	for (int ldID =0; ldID < mMeshTopoData.Count(); ldID++)
	{

		Tab<Point3> mapNormal;
		mapNormal.SetCount(0);
		MeshTopoData *ld = mMeshTopoData[ldID];

		for (int ldIDPrep =0; ldIDPrep < mMeshTopoData.Count(); ldIDPrep++)
		{
			MeshTopoData *ldPrep = mMeshTopoData[ldIDPrep];
			if (ld != ldPrep)
				ldPrep->ClearFaceSelection();
			else
				ldPrep->RestoreFaceSel();
		}

		//hold our face selection
		//get our processed list 
		BitArray holdFaces = ld->GetFaceSelection();
		BitArray processedFaces = ld->GetFaceSelection();
		while (processedFaces.NumberSet())
		{
			//select the first one
			int seed = -1;
			for (int faceID = 0; faceID < processedFaces.GetSize(); faceID++)
			{
				if (processedFaces[faceID])
				{
					seed = faceID;
					faceID = processedFaces.GetSize();
				}
			}
			BitArray faceSel = ld->GetFaceSel();
			faceSel.ClearAll();
			//select the element the first one
			faceSel.Set(seed,TRUE);
			//select it
			ld->SetFaceSel(faceSel);
			SelectGeomElement(ld);
			faceSel = ld->GetFaceSel();

//			ld->SelectElement(TVFACEMODE,FALSE);
			faceSel &= holdFaces;			
			//remove that from our process list
			for (int faceID = 0; faceID < faceSel.GetSize(); faceID++)
			{
				if (faceSel[faceID])
				{
					processedFaces.Set(faceID,FALSE);
				}
			}
			ld->SetFaceSel(faceSel);
			
			bContinue = BuildCluster( mapNormal, 5.0f, TRUE, TRUE, MeshTopoData::kFaceAngle);
			TSTR statusMessage;



			if (bContinue)
			{


				for (int i =0; i < clusterList.Count(); i++)
				{
					
					ld->ClearFaceSelection();
					for (int j = 0; j < clusterList[i]->faces.Count();j++)
						ld->SetFaceSelected(clusterList[i]->faces[j],TRUE);//	sel.Set(clusterList[i]->faces[j]);
					ld->PlanarMapNoScale(clusterList[i]->normal,this);


					int per = (i * 100)/clusterList.Count();
					statusMessage.printf(_T("%s %d%%."),GetString(IDS_PW_STATUS_MAPPING),per);
					if (Bail(ip,statusMessage))
					{
						i = clusterList.Count();
						bContinue =  FALSE;
					}
				}

				DebugPrint (_T("Final Vct %d \n"),ld->GetNumberTVVerts());

				if ( (bContinue) && (clusterList.Count() > 1) )
				{




						Tab<Point3> objNormList;
						BuildNormals(ld,objNormList);

						//remove internal edges
						Tab<int> clusterGroups;
						clusterGroups.SetCount(ld->GetNumberFaces());
						for (int i =0; i < clusterGroups.Count(); i++)
						{
							clusterGroups[i] = -1;
						}
						
						for (int i = 0; i < clusterList.Count(); i++)
						{
							for (int j = 0; j < clusterList[i]->faces.Count(); j++)
							{
								int faceIndex = clusterList[i]->faces[j];
								clusterGroups[faceIndex] = i;
							}
						}
						BitArray processedClusters;
						processedClusters.SetSize(clusterList.Count());
						processedClusters.ClearAll();

						Tab<BorderClass> edgesToBeProcessed;

						BOOL done = FALSE;
						processedClusters.Set(0);
						clusterList[0]->newX = 0.0f;
						clusterList[0]->newY = 0.0f;
						//    clusterList[0]->angle = 0.0f;
						for (int i = 0; i < clusterList[0]->borderData.Count(); i++)
						{
							int outerFaceIndex = clusterList[0]->borderData[i].outerFace;
							int connectedClusterIndex = clusterGroups[outerFaceIndex];
							if ((connectedClusterIndex != 0) && (connectedClusterIndex != -1))
							{
								edgesToBeProcessed.Append(1,&clusterList[0]->borderData[i]);
							}
						}
					
						BitArray seedFaceList;
						seedFaceList.SetSize(clusterGroups.Count());
						seedFaceList.ClearAll();
						for (int i = 0; i < seedFaces.Count(); i++)
						{
							seedFaceList.Set(seedFaces[i]);
						}

						while (!done)
						{
							Tab<int> clustersJustProcessed;
							clustersJustProcessed.ZeroCount();
							done = TRUE;

							int edgeToAlign = -1;
							float angDist = PI*2;
							if (unfoldMethod == 1)
								angDist =  PI*2;
							else if (unfoldMethod == 2) angDist = 0;
							int i;
							for (i = 0; i < edgesToBeProcessed.Count(); i++)
							{
								int outerFace = edgesToBeProcessed[i].outerFace;
								int connectedClusterIndex = clusterGroups[outerFace];
								if (!processedClusters[connectedClusterIndex])
								{
									int innerFaceIndex = edgesToBeProcessed[i].innerFace;
									int outerFaceIndex = edgesToBeProcessed[i].outerFace;
									//get angle
									Point3 innerNorm, outerNorm;
									innerNorm = objNormList[innerFaceIndex];
									outerNorm = objNormList[outerFaceIndex];
									float dot = DotProd(innerNorm,outerNorm);

									float angle = 0.0f;

									if (dot == -1.0f)
										angle = PI;
									else if (dot >= 1.0f)
										angle = 0.f;                  
									else angle = acos(dot);

									if (unfoldMethod == 1)
									{
										if (seedFaceList[outerFaceIndex])
											angle = 0.0f;
										if (angle < angDist)
										{
											angDist = angle;
											edgeToAlign = i;
										}
									}

									else if (unfoldMethod == 2)
									{
										if (seedFaceList[outerFaceIndex])
											angle = 180.0f;
										if (angle > angDist)
										{
											angDist = angle;
											edgeToAlign = i;
										}
									}

								}
							}
							if (edgeToAlign != -1)
							{
								int innerFaceIndex = edgesToBeProcessed[edgeToAlign].innerFace;
								int outerFaceIndex = edgesToBeProcessed[edgeToAlign].outerFace;
								int edgeIndex = edgesToBeProcessed[edgeToAlign].edge;


								int connectedClusterIndex = clusterGroups[outerFaceIndex];

								seedFaceList.Set(outerFaceIndex, FALSE);

								processedClusters.Set(connectedClusterIndex);
								clustersJustProcessed.Append(1,&connectedClusterIndex);	
								ld->AlignCluster(clusterList,connectedClusterIndex,innerFaceIndex, outerFaceIndex,edgeIndex,this);
								done = FALSE;
							}

							//build new cluster list
							for (int j = 0; j < clustersJustProcessed.Count(); j++)
							{
								int clusterIndex = clustersJustProcessed[j];
								for (int i = 0; i < clusterList[clusterIndex]->borderData.Count(); i++)
								{
									int outerFaceIndex = clusterList[clusterIndex]->borderData[i].outerFace;
									int connectedClusterIndex = clusterGroups[outerFaceIndex];
									if ((connectedClusterIndex != 0) && (connectedClusterIndex != -1) && (!processedClusters[connectedClusterIndex]))
									{
										edgesToBeProcessed.Append(1,&clusterList[clusterIndex]->borderData[i]);
									}
								}
							}
						}
					
				}

				ld->ClearSelection(TVVERTMODE);

				for (int i = 0; i < clusterList.Count(); i++)
				{
					MeshTopoData *ld = clusterList[i]->ld;
					ld->UpdateClusterVertices(clusterList);
					for (int j =0; j < clusterList[i]->faces.Count(); j++)
					{
						int faceIndex = clusterList[i]->faces[j];
						int degree = ld->GetFaceDegree(faceIndex);
						for (int k =0; k < degree; k++)
						{
							int vertexIndex = ld->GetFaceTVVert(faceIndex,k);//TVMaps.f[faceIndex]->t[k];
							ld->SetTVVertSelected(vertexIndex,TRUE);//vsel.Set(vertexIndex);
						}
					}
				}

				//now weld the verts
				if (normalize)
				{
					NormalizeCluster();
				}


				ld->WeldSelectedVerts(0.001f,this);

			}
	
			FreeClusterList();
		}
	}

	if (bContinue)
	{  
		theHold.Accept(GetString(IDS_PW_PLANARMAP));		

		theHold.Suspend();
		fnSyncTVSelection();
		theHold.Resume();
	}
	else
	{
		theHold.Cancel();
		
	}

	
	for (int ldID = 0; ldID < mMeshTopoData.Count(); ldID++)
	{			
		mMeshTopoData[ldID]->BuildTVEdges();
		mMeshTopoData[ldID]->RestoreFaceSel();
	}

	theHold.Suspend();
	fnSyncGeomSelection();
	theHold.Resume();

	if (matid != -1) // if we have a matID fileter set we need to rebuild since topology has changed
		SetMatFilters();

	NotifyDependents(FOREVER,PART_SELECT,REFMSG_CHANGE);
	InvalidateView();

}
Esempio n. 14
0
INT_PTR CALLBACK NewLinkDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
   SlaveControl *slv = DLGetWindowLongPtr<SlaveControl*>(hWnd);

   static Tab<int> sid,bid;

   switch (msg) {
   case WM_INITDIALOG:
      {
      sid.ZeroCount();
      bid.ZeroCount();
      slv = (SlaveControl*)lParam;
      DLSetWindowLongPtr(hWnd, lParam);

//goto master look at all sub block
      int count = slv->master->Blocks.Count();
			for (int i = 0; i < count;i++)
         {
         TSTR blockName = slv->master->SubAnimName(i+1);
         for (int j = 0;j < slv->master->Blocks[i]->controls.Count();j++)
            {
            TSTR subName = slv->master->Blocks[i]->SubAnimName(j);
            TSTR finalName = blockName + _T(" ") + subName;
//check if control is the same as ours
            if (slv->sub == NULL)
               {
               if (slv->master->Blocks[i]->controls[j]->SuperClassID() == slv->SuperClassID())  
                  {
//add to list box
                  sid.Append(1,&j,1);
                  bid.Append(1,&i,1);
							SendMessage(GetDlgItem(hWnd,IDC_LIST1), LB_ADDSTRING,0,(LPARAM)(const TCHAR*)finalName);
                  }
               }
            else if (slv->master->Blocks[i]->controls[j]->ClassID() == slv->sub->ClassID() )  
               {
//add to list box
               sid.Append(1,&j,1);
               bid.Append(1,&i,1);
               SendMessage(GetDlgItem(hWnd,IDC_LIST1),
                  LB_ADDSTRING,0,(LPARAM)(const TCHAR*)finalName);
               }
            }
         }  

			SendMessage(GetDlgItem(hWnd,IDC_LIST1), LB_SETCURSEL,0,0);
      CenterWindow(hWnd,GetParent(hWnd));
      break;
      }
      


   case WM_COMMAND:
      switch (LOWORD(wParam)) {
      case IDOK:
         {
         int sel = SendMessage(GetDlgItem(hWnd,IDC_LIST1),
                  LB_GETCURSEL,0,0);
         if (sel >=0)
            {
            slv->propBlockID = bid[sel];
            slv->propSubID = sid[sel];
					slv->NotifyDependents(FOREVER, (PartID)PART_ALL, REFMSG_CHANGE);
            }

         EndDialog(hWnd,1);
         break;
         }
      case IDCANCEL:
         EndDialog(hWnd,0);
         break;
      }
      break;

   default:
      return FALSE;
   }
   return TRUE;
}