void	UnwrapMod::fnPasteInstance()
	{
		//make sure mods are the same
		theHold.Begin();
		HoldPointsAndFaces();

		for (int ldID = 0; ldID < mMeshTopoData.Count(); ldID++)
		{
			MeshTopoData *ld = mMeshTopoData[ldID];
			if ((this == copyPasteBuffer.mod) && (ld == copyPasteBuffer.lmd))
			{

				BitArray faceSel = ld->GetFaceSelection();

				//loop through selected faces
				int copyIndex = 0;
				for (int i =0; i < faceSel.GetSize(); i++)
				{
					if (faceSel[i])
					{
						//make sure selected faces count = buffer face
						if (( i < ld->GetNumberFaces()/*TVMaps.f.Count()*/) && (copyIndex < copyPasteBuffer.faceData.Count()))
						{
							int degree = ld->GetFaceDegree(i);
							if (degree == copyPasteBuffer.faceData[copyIndex]->count)
							{
								//if so set the face data indices as the same
								for (int j = 0; j < degree; j++)
								{
									//index into the texture vertlist
									ld->SetFaceTVVert(i,j,copyPasteBuffer.faceData[copyIndex]->t[j]);//TVMaps.f[i]->t[j] = copyPasteBuffer.faceData[copyIndex]->t[j];
									//index into the geometric vertlist
									if ((ld->GetFaceHasVectors(i)/*TVMaps.f[i]->vecs*/) && (j < 4))
									{
										ld->SetFaceTVInterior(i,j,copyPasteBuffer.faceData[copyIndex]->vecs->interiors[j]);//TVMaps.f[i]->vecs->interiors[j] = copyPasteBuffer.faceData[copyIndex]->vecs->interiors[j];

										ld->SetFaceTVHandle(i,j*2,copyPasteBuffer.faceData[copyIndex]->vecs->handles[j*2]);//TVMaps.f[i]->vecs->handles[j*2] = copyPasteBuffer.faceData[copyIndex]->vecs->handles[j*2];
										ld->SetFaceTVHandle(i,j*2+1,copyPasteBuffer.faceData[copyIndex]->vecs->handles[j*2+1]);//TVMaps.f[i]->vecs->handles[j*2+1] = copyPasteBuffer.faceData[copyIndex]->vecs->handles[j*2+1];

									}
								}
								copyIndex++;
							}
						}
					}
				}				
				ld->SetTVEdgeInvalid();

			}

		}
		CleanUpDeadVertices();
		theHold.Accept(GetString(IDS_PW_PASTE));
		NotifyDependents(FOREVER,PART_ALL,REFMSG_CHANGE);
		InvalidateView();
		GetCOREInterface()->RedrawViews(GetCOREInterface()->GetTime());

	}
Beispiel #2
0
void	UnwrapMod::RebuildEdges()
	{
	if (mode == ID_SKETCHMODE)
		SetMode(ID_MOVE);


	for (int ldID = 0; ldID < mMeshTopoData.Count(); ldID++)
	{
		MeshTopoData *ld = mMeshTopoData[ldID];
		ld->SetTVEdgeInvalid();
		ld->SetGeoEdgeInvalid();
		ld->BuildTVEdges();
		ld->BuildVertexClusterList();

	}

/*
BitArray holdVSel(vsel);


	BOOL holdSyncMode = fnGetSyncSelectionMode();
	fnSetSyncSelectionMode(FALSE);


	TVMaps.BuildEdges(  );
	//PELT
	TVMaps.BuildGeomEdges(  );

	if (esel.GetSize() != TVMaps.ePtrList.Count())
		{
		esel.SetSize(TVMaps.ePtrList.Count());
		esel.ClearAll();
		}

	if (gesel.GetSize() != TVMaps.gePtrList.Count())
		{
		gesel.SetSize(TVMaps.gePtrList.Count());
		gesel.ClearAll();
		}

	//FP 05/26/06 : PELT Mapping - CER Bucket #370291
	//When the topology of the object changes, the seams bits array need to be updated.  
	//By clearing it there, the update will be done each time the topology changes
	if (peltData.seamEdges.GetSize() != TVMaps.gePtrList.Count())
		{
		peltData.seamEdges.SetSize(TVMaps.gePtrList.Count());
		peltData.seamEdges.ClearAll();
		}




	vsel = holdVSel;

	fnSetSyncSelectionMode(holdSyncMode);

	usedVertices.SetSize(TVMaps.v.Count());
	usedVertices.ClearAll();

	for (int i = 0; i < TVMaps.f.Count(); i++)
		{
		int faceIndex = i;
		for (int k = 0; k < TVMaps.f[faceIndex]->count; k++)
			{
			if (!(TVMaps.f[faceIndex]->flags & FLAG_DEAD))
				{
				int vertIndex = TVMaps.f[faceIndex]->t[k];
				usedVertices.Set(vertIndex);
				if (objType == IS_PATCH)
					{
					if ((TVMaps.f[faceIndex]->flags & FLAG_CURVEDMAPPING) && (TVMaps.f[faceIndex]->vecs))
						{
						if (TVMaps.f[faceIndex]->flags & FLAG_INTERIOR)
							{
							vertIndex = TVMaps.f[faceIndex]->vecs->interiors[k];
							if ((vertIndex >=0) && (vertIndex < usedVertices.GetSize()))
								usedVertices.Set(vertIndex);
							}
						vertIndex = TVMaps.f[faceIndex]->vecs->handles[k*2];
						if ((vertIndex >=0) && (vertIndex < usedVertices.GetSize()))
							usedVertices.Set(vertIndex);
						vertIndex = TVMaps.f[faceIndex]->vecs->handles[k*2+1];
						if ((vertIndex >=0) && (vertIndex < usedVertices.GetSize()))
							usedVertices.Set(vertIndex);
						}
					}
				}
			}
		}

	//PELT
	for (int i = 0; i < peltData.springEdges.Count(); i++)
	{
		int vertIndex = peltData.springEdges[i].v1;
		if (vertIndex != -1)
			usedVertices.Set(vertIndex);
		vertIndex = peltData.springEdges[i].v2;
		if (vertIndex != -1)
			usedVertices.Set(vertIndex);

		vertIndex = peltData.springEdges[i].vec1;
		if ( (vertIndex != -1) && (vertIndex < usedVertices.GetSize()))
			usedVertices.Set(vertIndex);
		vertIndex = peltData.springEdges[i].vec2;
		if ( (vertIndex != -1) && (vertIndex < usedVertices.GetSize()))
			usedVertices.Set(vertIndex);

	}
	BuildEdgeDistortionData();
*/
}
Beispiel #3
0
void UnwrapMod::ApplyGizmoPrivate(Matrix3 *defaultTM)
{
	BOOL wasHolding = FALSE;
 	if (theHold.Holding())
		wasHolding = TRUE;


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


	//add vertices to our internal vertex list filling in dead spots where appropriate

	//get align normal
	//get fit data


	Matrix3 gtm(1);
	TimeValue t = 0;
	if (ip) t = ip->GetTime();
	if (defaultTM)
		gtm = *defaultTM;
	else
	{
		if (tmControl)
		{
			
			gtm = GetMapGizmoMatrix(t);

			if (!fnGetNormalizeMap())
			{
				for (int i = 0; i < 3; i++)
				{
					Point3 vec = gtm.GetRow(i);
					vec = Normalize(vec);
					gtm.SetRow(i,vec);
				}
			}

		}

	}

	for (int ldID = 0; ldID < mMeshTopoData.Count(); ldID++)
	{
		MeshTopoData *ld = mMeshTopoData[ldID];
		Matrix3 tm(1);
		tm = mMeshTopoData.GetNodeTM(t,ldID)* Inverse(gtm);
		ld->ApplyMap(fnGetMapMode(), fnGetNormalizeMap(), tm, this);
		ld->SetTVEdgeInvalid();
		ld->BuildTVEdges();
		ld->BuildVertexClusterList();
		
	}


	if (!wasHolding)
	{
		theHold.Accept(GetString(IDS_PW_PLANARMAP));
	}

	RebuildEdges();
	theHold.Suspend();
	fnFaceToEdgeSelect();
	theHold.Resume();

//	ConvertFaceToEdgeSel();
//	TVMaps.edgesValid= FALSE;
	//update our views to show new faces

	InvalidateView();

}
void	UnwrapMod::fnPaste(BOOL rotate)
	{
	//check for type

	TimeValue t = GetCOREInterface()->GetTime();
	theHold.Begin();
	HoldPointsAndFaces();

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


//check faces if just one selected normal paste with rotates
//or if all faces where selected
//or if first paste

//hold the points and faces


		BitArray holdFaceSel(ld->GetFaceSelection());

		BitArray subFaceSel;
		if ( ip && (ip->GetSubObjectLevel() == 0) )
			{
//convert our current selection into faces			
			if (fnGetTVSubMode() == TVVERTMODE)
				ld->GetFaceSelFromVert(subFaceSel,FALSE);
			else if (fnGetTVSubMode() == TVEDGEMODE)
				{
				BitArray tempVSel;
				ld->GetVertSelFromEdge(tempVSel);
				BitArray vsel = ld->GetTVVertSelection();
				BitArray holdVSel(vsel);
				ld->SetTVVertSelection(tempVSel);//vsel = tempVSel;
				ld->GetFaceSelFromVert(subFaceSel,FALSE);
				ld->SetTVVertSelection(holdVSel);//vsel = holdVSel;

				}
			else if (fnGetTVSubMode() == TVFACEMODE)
				{
				subFaceSel = ld->GetFaceSelection();//.SetSize(fsel.GetSize());
				//subFaceSel = fsel;
				}
			}
		else
			{
			if (fnGetTVSubMode() == TVFACEMODE)
				{
				subFaceSel = ld->GetFaceSelection();//.SetSize(fsel.GetSize());
				//subFaceSel = fsel;
				}

			}

		if ( (copyPasteBuffer.copyType == 0) || (copyPasteBuffer.copyType == 1) || (copyPasteBuffer.iRotate==0))
			{
			int copyIndex = 0;
			Tab<int> vertexLookUpList;

			vertexLookUpList.SetCount(copyPasteBuffer.tVertData.Count());

			BitArray faceSel = ld->GetFaceSelection();

			for (int i =0; i < vertexLookUpList.Count(); i++)
				vertexLookUpList[i] = -1;
			if (copyPasteBuffer.copyType == 1)
				copyPasteBuffer.iRotate = 0;
			else 
				{
				if (copyPasteBuffer.lastSel.GetSize() == faceSel.GetSize())
					{
					if (copyPasteBuffer.lastSel == faceSel) 
						{

						if (rotate)
							{
							copyPasteBuffer.iRotate++;
							}
						else copyPasteBuffer.iRotate = 0;

						
						}
					}
				}
			if (copyPasteBuffer.copyType == 2) copyPasteBuffer.iRotate = 0;
			copyPasteBuffer.lastSel = faceSel;

//loop through selected faces
			for (int i =0; i < faceSel.GetSize(); i++)
				{
				if (faceSel[i])
					{
//make sure selected faces count = buffer face
					if (( i < ld->GetNumberFaces()/*TVMaps.f.Count()*/) && (copyIndex < copyPasteBuffer.faceData.Count()))
						{
						int degree = ld->GetFaceDegree(i);
						if (/*TVMaps.f[i]->count*/ degree == copyPasteBuffer.faceData[copyIndex]->count)
							{
//if so	set the face data indices as the same
							for (int j = 0; j < degree/*TVMaps.f[i]->count*/; j++)
								{
							//index into the texture vertlist
							
								int vid = (j + copyPasteBuffer.iRotate)%degree;//TVMaps.f[i]->count;
								int vertexIndex = copyPasteBuffer.faceData[copyIndex]->t[vid];

								if (vertexLookUpList[vertexIndex] == -1)
									{
									Point3 p = copyPasteBuffer.tVertData[vertexIndex];
									ld->AddTVVert(t, p, i, j, this,FALSE);//ld->AddPoint(p, i, j,FALSE);
									vertexLookUpList[vertexIndex] = ld->GetFaceTVVert(i,j);//TVMaps.f[i]->t[j];
									}
								else 
									 ld->SetFaceTVVert(i,j,vertexLookUpList[vertexIndex]);//TVMaps.f[i]->t[j] = vertexLookUpList[vertexIndex];

								if ((ld->GetFaceHasVectors(i)/*TVMaps.f[i]->vecs*/) && (copyPasteBuffer.faceData[copyIndex]->vecs) && (j < 4))
									{
									int hid = (j*2 + (copyPasteBuffer.iRotate*2))%(/*TVMaps.f[i]->count*/degree*2);
									int handleIndex = copyPasteBuffer.faceData[copyIndex]->vecs->handles[hid];
									if ((handleIndex >= 0) && (vertexLookUpList[handleIndex] == -1))
										{
										Point3 p = copyPasteBuffer.tVertData[handleIndex];
										ld->AddTVHandle(t,p, i, j*2,this,FALSE);
										vertexLookUpList[handleIndex] = ld->GetFaceTVHandle(i,j*2);// TVMaps.f[i]->vecs->handles[j*2];
										}
									else 
										ld->SetFaceTVHandle(i,j*2,vertexLookUpList[handleIndex]);//TVMaps.f[i]->vecs->handles[j*2] = vertexLookUpList[handleIndex];
	
									hid = (j*2 + (copyPasteBuffer.iRotate*2))%(degree/*TVMaps.f[i]->count*/*2)+1;
									handleIndex = copyPasteBuffer.faceData[copyIndex]->vecs->handles[hid];
									if ((handleIndex >= 0) && (vertexLookUpList[handleIndex] == -1))
										{
										Point3 p = copyPasteBuffer.tVertData[handleIndex];
										ld->AddTVHandle(t,p, i, j*2+1,this,FALSE);
										vertexLookUpList[handleIndex] = ld->GetFaceTVHandle(i,j*2+1);//TVMaps.f[i]->vecs->handles[j*2+1];
										}
									else 
										ld->SetFaceTVHandle(i,j*2+1,vertexLookUpList[handleIndex]);//TVMaps.f[i]->vecs->handles[j*2+1] = vertexLookUpList[handleIndex];
	
									int iid = (j + (copyPasteBuffer.iRotate))%degree;//(TVMaps.f[i]->count);
									int interiorIndex = copyPasteBuffer.faceData[copyIndex]->vecs->interiors[iid];
									if ((interiorIndex >= 0) && (vertexLookUpList[interiorIndex] == -1))
										{
										Point3 p = copyPasteBuffer.tVertData[interiorIndex];
										ld->AddTVInterior(t,p, i, j,this,FALSE);
										vertexLookUpList[interiorIndex] = ld->GetFaceTVInterior(i,j);//TVMaps.f[i]->vecs->handles[j];
										}
									else 
										ld->SetFaceTVInterior(i,j,vertexLookUpList[interiorIndex]);//TVMaps.f[i]->vecs->interiors[j] = vertexLookUpList[interiorIndex];
									}
								}
							copyIndex++;
							if (copyIndex >= copyPasteBuffer.faceData.Count()) copyIndex = 0;
							}
						}	
					}

				}

			}
		
		ld->SetTVEdgeInvalid();//RebuildEdges();

		if ( ip && (ip->GetSubObjectLevel() == 0) )
			{
			if (fnGetTVSubMode() == TVVERTMODE)
				{
				BitArray fsel = ld->GetFaceSelection();
				BitArray vsel = ld->GetTVVertSelection();
				BitArray holdFSel(fsel);
				fsel = subFaceSel;
				ld->GetVertSelFromFace(vsel);
				ld->SetTVVertSelection(vsel);
				ld->SetFaceSelection(holdFSel);//fsel = holdFSel;
				}
			else if (fnGetTVSubMode() == TVEDGEMODE)
				{
				BitArray fsel = ld->GetFaceSelection();
				BitArray esel = ld->GetTVEdgeSelection();
				BitArray holdFSel(fsel);
				fsel = subFaceSel;
				ld->GetVertSelFromFace(fsel);
				ld->SetFaceSelection(fsel);//
				ld->GetEdgeSelFromVert(esel,FALSE);
				ld->SetTVEdgeSelection(esel);
				ld->SetFaceSelection(holdFSel);//fsel = holdFSel;
				}
			else if (fnGetTVSubMode() == TVFACEMODE)
				{				
				ld->SetFaceSelection(subFaceSel);//fsel = subFaceSel;
				}

			}
		else
			{
//			md->faceSel = holdFaceSel;
			ld->SetFaceSelection(subFaceSel);
/*
			if (fnGetTVSubMode() == TVFACEMODE)
				{
				ld->SetFaceSelection(subFaceSel);//fsel = subFaceSel;
				}
*/
			}

		}
		CleanUpDeadVertices();
		theHold.Accept(GetString(IDS_PW_PASTE));

		NotifyDependents(FOREVER,PART_ALL,REFMSG_CHANGE);
		InvalidateView();
		GetCOREInterface()->RedrawViews(GetCOREInterface()->GetTime());		

	}