예제 #1
0
LocalModData *EditPolyMod::GetPrimaryLocalModData ()
{
	if (!ip) return NULL;

	ModContextList list;
	INodeTab nodes;	
	ip->GetModContexts(list,nodes);

	for (int i=0; i<list.Count(); i++)
	{
		if (list[i]->localData == NULL) continue;
		EditPolyData *pData = (EditPolyData *) list[i]->localData;
		if (pData->GetFlag (kEPDataPrimary)) return pData;
	}
	// No primary? Ok, return first mesh we get to (and make it primary).
	for (int i=0; i<list.Count(); i++)
	{
		if (list[i]->localData == NULL) continue;
		EditPolyData *pData = (EditPolyData *) list[i]->localData;
		pData->SetFlag (kEPDataPrimary);
		return pData;
	}

	return NULL;
}
예제 #2
0
Matrix3 EditPolyMod::EpModGetNodeTM (TimeValue t, INode *node)
{
	if (node) return node->GetObjectTM (t);

	if (!ip) return Matrix3(true);

	ModContextList list;
	INodeTab nodes;	
	ip->GetModContexts(list,nodes);

	for (int i=0; i<list.Count(); i++)
	{
		if (list[i]->localData == NULL) continue;
		EditPolyData *pData = (EditPolyData *) list[i]->localData;
		if (pData->GetFlag (kEPDataPrimary)) return nodes[i]->GetObjectTM (t);
	}

	// No primary? Ok, return first node we get to (and set it to primary):
	for (int i=0; i<list.Count(); i++)
	{
		if (list[i]->localData == NULL) continue;
		EditPolyData *pData = (EditPolyData *) list[i]->localData;
		pData->SetFlag (kEPDataPrimary);
		return nodes[i]->GetObjectTM (t);
	}

	return Matrix3(true);
}
예제 #3
0
LocalModData *EditPolyData::Clone() {
	EditPolyData *d = new EditPolyData;
	d->mVertSel = mVertSel;
	d->mFaceSel = mFaceSel;
	d->mEdgeSel = mEdgeSel;
	d->mVertHide = mVertHide;
	d->mFaceHide = mFaceHide;

	// Copy the Operation linked list:
	PolyOperationRecord *clone=NULL;
	for (PolyOperationRecord *pop = mpOpList; pop != NULL; pop = pop->Next())
	{
		if (clone == NULL) {
			clone = pop->Clone ();
			d->mpOpList = clone;
		} else {
			clone->SetNext (pop->Clone ());
			clone = clone->Next ();
		}
	}

	// Copy any current operation data:
	if (mpPolyOpData != NULL) {
		d->SetPolyOpData (mpPolyOpData->Clone());
	}

	return d;
}
예제 #4
0
void EditPolyMod::GetPaintMask( MeshPaintHost* host, BitArray& sel, FloatTab& softSel ) {
	EditPolyData* modData = static_cast<EditPolyData*>(host);
	if (!modData->GetMesh()) return;
	MNMesh& mesh = *(modData->GetMesh());
	sel = mesh.VertexTempSel ();
	float* weights = mesh.getVSelectionWeights ();
	int count = (weights==NULL? 0:mesh.VNum());
	softSel.SetCount(count);
	if( count>0 ) memcpy( softSel.Addr(0), weights, count*sizeof(float) );
}
예제 #5
0
void EditPolyMod::GetPaintInputVertPos( MeshPaintHost* host, Point3Tab& vertPos ) {
	EditPolyData* modData = static_cast<EditPolyData*>(host);
	MNMesh *pMesh = modData->GetMesh();
	DbgAssert (pMesh);
	if (!pMesh) return;	// avoid crashing.
	MNMesh& mesh = *(pMesh);
	int count = mesh.VNum();
	vertPos.SetCount( count );
	for( int i=0; i<count; i++ ) vertPos[i] = mesh.v[i].p;
}
예제 #6
0
void EditPolyMod::ApplyPaintDeform( MeshPaintHost* host ,BitArray *invalidVerts) {
	EditPolyData* modData = static_cast<EditPolyData*>(host);

	// Make sure we're set to the right operation:
	EpModSetOperation (ep_op_paint_deform);
	modData->SetPolyOpData (ep_op_paint_deform);

	LocalPaintDeformData *pDeform = (LocalPaintDeformData *) modData->GetPolyOpData();
	pDeform->SetOffsets (host->GetPaintDeformCount(), host->GetPaintDeformOffsets(), modData->GetMesh());

	EpModLocalDataChanged (PART_DISPLAY);
}
예제 #7
0
void EditPolyMod::RevertPaintDeform( MeshPaintHost* host,BitArray *invalidVerts ) {
	EditPolyData* modData = static_cast<EditPolyData*>(host);

	// Make sure we're set to the right operation:
	//EpModSetOperation (ep_op_paint_deform);
	//modData->SetPolyOpData (ep_op_paint_deform);

	if (modData->GetPolyOpData() == NULL) return;
	if (modData->GetPolyOpData()->OpID() != ep_op_paint_deform) return;
	LocalPaintDeformData *pDeform = (LocalPaintDeformData *) modData->GetPolyOpData();
	pDeform->ClearVertices ();

	EpModLocalDataChanged (PART_DISPLAY);
}
예제 #8
0
void EditPolyMod::GetPaintInputSel( MeshPaintHost* host, FloatTab& selValues ) {
	EditPolyData* modData = static_cast<EditPolyData*>(host);

	GenSoftSelData softSelData;
	GetSoftSelData( softSelData, ip->GetTime() );
	FloatTab* weights = modData->TempData()->VSWeight(
		softSelData.useEdgeDist, softSelData.edgeIts, softSelData.ignoreBack,
		softSelData.falloff, softSelData.pinch, softSelData.bubble );

	if (!weights) {
		// can happen if num vertices == 0.
		selValues.ZeroCount();
		return;
	}
	selValues = *weights;
}
예제 #9
0
void EditPolyMod::EpModSetPrimaryNode (INode *inode)
{
	if (!ip) return;

	ModContextList list;
	INodeTab nodes;	
	ip->GetModContexts(list,nodes);

	for (int i=0; i<list.Count(); i++)
	{
		if (list[i]->localData == NULL) continue;
		EditPolyData *pdat = (EditPolyData *) list[i]->localData;
		if (!inode) inode = nodes[i]->GetActualINode();	// Pick the first one, if we're called with NULL.
		if (nodes[i]->GetActualINode() == inode) pdat->SetFlag (kEPDataPrimary);
		else pdat->ClearFlag (kEPDataPrimary);
	}
}
예제 #10
0
bool SmoothingGroupUIHandler::GetSmoothingGroups (EPolyMod *pMod, DWORD *anyFaces, DWORD *allFaces, bool useSel) {
	bool ret = true;
	// Initialization:
	*anyFaces = 0;
	if (allFaces) *allFaces = ~0;

	bool useStackSelection = pMod->getParamBlock()->GetInt (epm_stack_selection) != 0;

	ModContextList list;
	INodeTab nodes;
	pMod->EpModGetIP()->GetModContexts (list, nodes);
	for (int i=0; i<list.Count(); i++)
	{
		EditPolyData *pData = (EditPolyData *) list[i]->localData;
		if (!pData) continue;
		MNMesh *pMesh = pData->GetMeshOutput();
		if (!pMesh) {
			ret = false;
			continue;
		}

		DWORD l_selFlag = useStackSelection ? MN_EDITPOLY_STACK_SELECT:MN_SEL;

		for (int j=0; j<pMesh->numf; j++)
		{
			if (useSel && !pMesh->f[j].GetFlag (l_selFlag)) 
				continue;
			if (pMesh->f[j].GetFlag (MN_DEAD)) 
				continue;

			*anyFaces |= pMesh->f[j].smGroup;
			if (allFaces) *allFaces &= pMesh->f[j].smGroup;
		}
	}
	nodes.DisposeTemporary ();

	if (allFaces) *allFaces &= *anyFaces;
	return ret;
}
예제 #11
0
void EditPolyMod::ApplyPaintSel( MeshPaintHost* host ) {
	EditPolyData* modData = static_cast<EditPolyData*>(host);
	if (!modData->GetMesh()) return;
	MNMesh& mesh = *(modData->GetMesh());

	//arValid = NEVER;
	// TODO: Where do we keep this soft selection?
	float* destWeights = mesh.getVSelectionWeights();
	float* srcWeights = modData->GetPaintSelValues();
	int count = modData->GetPaintSelCount();

	if (mesh.numv < count) {
		DbgAssert (false);
		count = mesh.numv;
	}

	memcpy( destWeights, srcWeights, count * sizeof(float) );

	if (mesh.numv > count) {
		DbgAssert (false);
		for (int i=count; i<mesh.numv; i++) destWeights[i] = 0.0f;
	}
}
예제 #12
0
INode *EditPolyMod::EpModGetPrimaryNode ()
{
	if (!ip) return NULL;

	ModContextList list;
	INodeTab nodes;	
	ip->GetModContexts(list,nodes);

	INode *ret = NULL;
	for (int i=0; i<list.Count(); i++)
	{
		if (list[i]->localData == NULL) continue;
		EditPolyData *pData = (EditPolyData *) list[i]->localData;
		if (pData->GetFlag (kEPDataPrimary))
		{
			ret = nodes[i];
			break;
		}
	}

	if (!ret) {
		// No primary? Ok, return first one we get to (and make it primary).
		for (int i=0; i<list.Count(); i++)
		{
			if (list[i]->localData == NULL) continue;
			EditPolyData *pData = (EditPolyData *) list[i]->localData;
			pData->SetFlag (kEPDataPrimary);
			ret = nodes[i];
			break;
		}
	}

	if (ret) ret = ret->GetActualINode ();
	nodes.DisposeTemporary();

	return ret;
}
예제 #13
0
void MaterialUIHandler::UpdateCurrentMaterial (HWND hWnd, EPolyMod *pMod, TimeValue t, Interval & validity)
{
	MtlID mat = 0;
	bool determined = false;

	if (pMod->GetPolyOperationID() == ep_op_set_material)
	{
		int materialHolder;
		pMod->getParamBlock()->GetValue (epm_material, t, materialHolder, validity);
		mat = materialHolder;
		determined = true;
	}
	else
	{
		bool useStackSelection = pMod->getParamBlock()->GetInt (epm_stack_selection) != 0;

		bool init = false;
		ModContextList list;
		INodeTab nodes;
		pMod->EpModGetIP()->GetModContexts (list, nodes);
      int i;
		for (i=0; i<list.Count(); i++)
		{
			EditPolyData *pData = (EditPolyData *) list[i]->localData;
			if (!pData) continue;
			MNMesh *pMesh = pData->GetMesh();
			if (!pMesh) {
				validity = NEVER;
				continue;
			}

			DWORD l_selFlag = useStackSelection ? MN_EDITPOLY_STACK_SELECT:MN_SEL;

         int j;
			for (j=0; j<pMesh->numf; j++)
			{
				if (!pMesh->f[j].GetFlag (l_selFlag)) 
					continue;
				if (pMesh->f[j].GetFlag (MN_DEAD))
					continue;

				if (!init)
				{
					mat = pMesh->f[j].material;
					init = true;
				}
				else if (mat != pMesh->f[j].material) break;
			}

			if (j<pMesh->numf) break;
		}
		nodes.DisposeTemporary ();

		determined = (i>=list.Count()) && init;
	}

	ISpinnerControl *spin = GetISpinner(GetDlgItem(hWnd,IDC_MAT_IDSPIN));
	spin->SetIndeterminate(!determined);
	if (determined) spin->SetValue (int(mat+1), FALSE);
	ReleaseISpinner(spin);

	spin = GetISpinner(GetDlgItem(hWnd,IDC_MAT_IDSPIN_SEL)); 
	spin->SetIndeterminate(!determined);
	if (determined) spin->SetValue (int(mat+1), FALSE);
	ReleaseISpinner(spin);

	if (GetDlgItem (hWnd, IDC_MTLID_NAMES_COMBO)) { 
		ValidateUINameCombo(hWnd, pMod);   
	}
}
예제 #14
0
MNMesh *EditPolyMod::EpModGetOutputMesh (INode *pNode) {
	EditPolyData *pData = GetEditPolyDataForNode (pNode);
	if (!pData) return NULL;
	return pData->GetMeshOutput();
}
예제 #15
0
MNMesh* EditPolyMod::GetPaintObject( MeshPaintHost* host )
{
	EditPolyData* modData = static_cast<EditPolyData*>(host);
	return modData->GetPaintMesh();
}
예제 #16
0
	void Redo () { mpData->SetPolyOpData (mOpID); }
예제 #17
0
	void Restore (int isUndo) { mpData->ClearPolyOpData (); }