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;
}
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);
}
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;
}
Exemple #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) );
}
Exemple #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;
}
Exemple #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);
}
Exemple #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);
}
Exemple #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;
}
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);
	}
}
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;
}
Exemple #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;
	}
}
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;
}
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);   
	}
}
MNMesh *EditPolyMod::EpModGetOutputMesh (INode *pNode) {
	EditPolyData *pData = GetEditPolyDataForNode (pNode);
	if (!pData) return NULL;
	return pData->GetMeshOutput();
}
Exemple #15
0
MNMesh* EditPolyMod::GetPaintObject( MeshPaintHost* host )
{
	EditPolyData* modData = static_cast<EditPolyData*>(host);
	return modData->GetPaintMesh();
}
	void Redo () { mpData->SetPolyOpData (mOpID); }
	void Restore (int isUndo) { mpData->ClearPolyOpData (); }