当前位置: 首页>>代码示例>>C++>>正文


C++ MNMesh类代码示例

本文整理汇总了C++中MNMesh的典型用法代码示例。如果您正苦于以下问题:C++ MNMesh类的具体用法?C++ MNMesh怎么用?C++ MNMesh使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MNMesh类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Convert

void ConvertToPoly::Convert (PolyObject *obj, TimeValue t, MNMesh & mm, Interval & ivalid) {
	int keepConvex;
	int limitSize;
	int maxdeg=0;
	int keepPlanar, elimCollin;
	float planarThresh = 0.0f;

	pblock->GetValue (turn_keep_convex, t, keepConvex, ivalid);
	pblock->GetValue (turn_limit_size, t, limitSize, ivalid);
	if (limitSize) pblock->GetValue (turn_max_size, t, maxdeg, ivalid);
	pblock->GetValue (turn_planar, t, keepPlanar, ivalid);
	if (keepPlanar) {
		pblock->GetValue (turn_thresh, t, planarThresh, ivalid);
		planarThresh = cosf (planarThresh);
	}
	pblock->GetValue (turn_eliminate_collinear, t, elimCollin, ivalid);

	mm = obj->mm;

	// Luna task 747
	// We cannot support specified normals in Convert to Poly at this time.
	mm.ClearSpecifiedNormals();

	if (!mm.GetFlag (MN_MESH_FILLED_IN)) mm.FillInMesh ();
	if (!mm.GetFlag (MN_MESH_NO_BAD_VERTS)) mm.EliminateBadVerts ();

	if (maxdeg) mm.RestrictPolySize (maxdeg);
	if (keepConvex) mm.MakeConvex ();
	if (maxdeg || keepConvex) mm.ClearEFlags (MN_EDGE_INVIS);
	if (keepPlanar) mm.MakePlanar (planarThresh);
	if (elimCollin) mm.EliminateCollinearVerts ();
	mm.selLevel = obj->mm.selLevel;
}
开发者ID:artemeliy,项目名称:inf4715,代码行数:33,代码来源:topoly.cpp

示例2: DebugPrint

void EditFaceDataModData::ApplyChanges (MNMesh & mesh) {
	// Make sure we're sized correctly for this mesh.
	// (NOTE: If the user reduces, then increases input number of faces, we lose data.)
	if (mesh.numf != mFaceSel.GetSize()) SynchSize (mesh.numf);

	// Set the selection:
	mesh.FaceSelect (mFaceSel);

	// Get the face data manager from the mesh:
	DebugPrint ("EditFaceDataMod: Getting manager from MNMesh (0x%08x)\n", &mesh);
	IFaceDataMgr *pFDMgr = static_cast<IFaceDataMgr*>(mesh.GetInterface (FACEDATAMGR_INTERFACE));
	if (pFDMgr == NULL) return;

	SampleFaceData* fdc = dynamic_cast<SampleFaceData*>(pFDMgr->GetFaceDataChan( FACE_MAXSAMPLEUSE_CLSID ));
	if ( fdc == NULL ) {
		// The mesh does not have our sample face-data channel so we will add it here
		fdc = new SampleFaceData();
		fdc->FacesCreated (0, mFaceSel.GetSize());
		pFDMgr->AddFaceDataChan( fdc );
	}

	if (!mFacesAffected.NumberSet ()) return;

	for (int i=0; i<mFacesAffected.GetSize(); i++) {
		if (!mFacesAffected[i]) continue;
		fdc->SetValue (i, mtNewFaceValues[i]);
	}
}
开发者ID:2asoft,项目名称:xray,代码行数:28,代码来源:EditFaceData.cpp

示例3: Do

void PolyOpExtrudeEdge::Do (MNMesh & mesh) {
	MNChamferData chamData;
	chamData.InitToMesh(mesh);
	Tab<Point3> tUpDir;
	tUpDir.SetCount (mesh.numv);

	// Topology change:
	if (!mesh.ExtrudeEdges (MN_USER, &chamData, tUpDir)) return;

	// Apply map changes based on base width:
	int i;
	Tab<UVVert> tMapDelta;
	for (int mapChannel=-NUM_HIDDENMAPS; mapChannel<mesh.numm; mapChannel++) {
		if (mesh.M(mapChannel)->GetFlag (MN_DEAD)) continue;
		chamData.GetMapDelta (mesh, mapChannel, mWidth, tMapDelta);
		UVVert *pMapVerts = mesh.M(mapChannel)->v;
		if (!pMapVerts) continue;
		for (i=0; i<mesh.M(mapChannel)->numv; i++) pMapVerts[i] += tMapDelta[i];
	}

	// Apply geom changes based on base width:
	Tab<Point3> tDelta;
	chamData.GetDelta (mWidth, tDelta);
	for (i=0; i<mesh.numv; i++) mesh.v[i].p += tDelta[i];

	// Move the points up:
	for (i=0; i<tUpDir.Count(); i++) mesh.v[i].p += tUpDir[i]*mHeight;
}
开发者ID:2asoft,项目名称:xray,代码行数:28,代码来源:PolyOps.cpp

示例4: MakeHitRegion

int EditFaceDataMod::HitTest (TimeValue t, INode* inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt, ModContext* mc) {
	Interval valid;
	int savedLimits, res = 0;
	GraphicsWindow *gw = vpt->getGW();
	HitRegion hr;
	
	// Setup GW
	MakeHitRegion(hr,type, crossing,4,p);
	gw->setHitRegion(&hr);
	Matrix3 mat = inode->GetObjectTM(t);
	gw->setTransform(mat);	
	gw->setRndLimits(((savedLimits = gw->getRndLimits()) | GW_PICK) & ~GW_ILLUM);
	gw->clearHitCode();

	if (!mc->localData) return 0;
	EditFaceDataModData *md = (EditFaceDataModData*)mc->localData;
	Mesh *mesh = md->GetCacheMesh ();
	MNMesh *mnmesh = md->GetCacheMNMesh ();

	SubObjHitList hitList;
	if (mesh) {
		res = mesh->SubObjectHitTest(gw, gw->getMaterial(), &hr, flags|hitLevel[selLevel], hitList);
	} else if (mnmesh) {
		res = mnmesh->SubObjectHitTest (gw, gw->getMaterial(), &hr, flags|mnhitLevel[selLevel], hitList);
	}

	MeshSubHitRec *rec = hitList.First();
	while (rec) {
		vpt->LogHit(inode,mc,rec->dist,rec->index,NULL);
		rec = rec->Next();
	}

	gw->setRndLimits(savedLimits);	
	return res;	
}
开发者ID:2asoft,项目名称:xray,代码行数:35,代码来源:EditFaceData.cpp

示例5: GetSubObjectTMs

void EditFaceDataMod::GetSubObjectTMs (SubObjAxisCallback *cb,TimeValue t,INode *node,ModContext *mc) {
	if (!mc->localData) return;
	if (selLevel == SEL_OBJECT) return;	// shouldn't happen.
	EditFaceDataModData *modData = (EditFaceDataModData *) mc->localData;

	Mesh *mesh = modData->GetCacheMesh();
	MNMesh *mnmesh = modData->GetCacheMNMesh();
	if (!mesh && !mnmesh) return;

	Matrix3 tm = node->GetObjectTM(t);
	Box3 box;
	if (mesh) {
		BitArray sel = mesh->VertexTempSel ();
		if (!sel.NumberSet()) return;
		for (int i=0; i<mesh->numVerts; i++) if (sel[i]) box += mesh->verts[i] * tm;
	} else {
		int numSel, which;
		float value;
		bool valueDetermined;
		modData->DescribeSelection (numSel, which, value, valueDetermined);
		if (!numSel) return;
		if (numSel==1) {
			for (int j=0; j<mnmesh->f[which].deg; j++) box += mnmesh->P(mnmesh->f[which].vtx[j]) * tm;
		} else {
			for (int i=0; i<mnmesh->numf; i++) {
				if (mnmesh->f[i].GetFlag (MN_DEAD)) continue;
				if (!modData->GetFaceSel()[i]) continue;
				for (int j=0; j<mnmesh->f[i].deg; j++) box += mnmesh->P(mnmesh->f[i].vtx[j]) * tm;
			}
		}
	}
	Matrix3 ctm(1);
	ctm.SetTrans (box.Center());
	cb->TM (ctm,0);
}
开发者ID:2asoft,项目名称:xray,代码行数:35,代码来源:EditFaceData.cpp

示例6: SetPolyFlags

void VWeldMod::SetPolyFlags (MNMesh & mesh, DWORD flag) {
	// Convert existing selection (at whatever level) to vertex selection:
	mesh.ClearVFlags (flag);
	if (mesh.selLevel == MNM_SL_OBJECT) {
		for (int i=0; i<mesh.numv; i++) mesh.v[i].SetFlag (flag);
	} else {
		mesh.PropegateComponentFlags (MNM_SL_VERTEX, flag, mesh.selLevel, MN_SEL);
	}
}
开发者ID:innovatelogic,项目名称:ilogic-vm,代码行数:9,代码来源:vweld.cpp

示例7: get_convex_hull

void get_convex_hull(Mesh& mesh, Mesh& outmesh)
{  
	MNMesh mn;
	map<int, int> ptmap;
	vector<Vector3> vertmap;
	for (int i = 0; i < mesh.getNumVerts(); ++i)
	{
		Vector3 temp(mesh.getVert(i).x, mesh.getVert(i).y, mesh.getVert(i).z);
		vertmap.push_back(temp);
	}
	vector<Triangle> outshape = NifQHull::compute_convex_hull(vertmap);
	vector<Triangle>::size_type sz = outshape.size();
	for (int i = 0; i < mesh.getNumVerts(); ++i)
	{
		mn.NewVert(Point3(mesh.getVert(i).x, mesh.getVert(i).y, mesh.getVert(i).z));
	}
	for (unsigned i = 0; i < sz; i++)
	{
		mn.NewTri(outshape[i].v1, outshape[i].v2, outshape[i].v3);
	}
	mn.EliminateIsoMapVerts();
	mn.MakeConvex();
	mn.FillInMesh();
	mn.EliminateBadVerts(0);
	mn.Triangulate();
	mn.OutToTri(outmesh);
}
开发者ID:blabbatheorange,项目名称:Nif-Plugin,代码行数:27,代码来源:CollisionHull.cpp

示例8: WeldPolyObject

void SymmetryMod::WeldPolyObject (MNMesh & mesh, Point3 & N, float offset, float threshold) {
	// Mark the vertices within the welding threshold of the plane:
	mesh.ClearVFlags (MN_USER);
	for (int i=0; i<mesh.numv; i++) {
		if (mesh.v[i].GetFlag (MN_DEAD)) continue;
		float dist = DotProd (N, mesh.P(i)) - offset;
		if (fabsf(dist) > threshold) continue;
		mesh.v[i].SetFlag (MN_USER);
	}

	// Do the welding:
	if (mesh.WeldBorderVerts (threshold, MN_USER)) {
		// If result was true, we have some MN_DEAD components:
		mesh.CollapseDeadStructs ();
	}
}
开发者ID:innovatelogic,项目名称:ilogic-vm,代码行数:16,代码来源:Symmetry.cpp

示例9: MNMeshCollapseEdges

bool PolyOpWeldVertex::WeldShortPolyEdges (MNMesh & mesh, DWORD vertFlag) {
	// In order to collapse vertices, we turn them into edge selections,
	// where the edges are shorter than the weld threshold.
	bool canWeld = false;
	mesh.ClearEFlags (MN_USER);
	float threshSq = mThreshold*mThreshold;
	for (int i=0; i<mesh.nume; i++) {
		if (mesh.e[i].GetFlag (MN_DEAD)) continue;
		if (!mesh.v[mesh.e[i].v1].GetFlag (vertFlag)) continue;
		if (!mesh.v[mesh.e[i].v2].GetFlag (vertFlag)) continue;
		if (LengthSquared (mesh.P(mesh.e[i].v1) - mesh.P(mesh.e[i].v2)) > threshSq) continue;
		mesh.e[i].SetFlag (MN_USER);
		canWeld = true;
	}
	if (!canWeld) return false;

	return MNMeshCollapseEdges (mesh, MN_USER);
}
开发者ID:2asoft,项目名称:xray,代码行数:18,代码来源:PolyOps.cpp

示例10: SMHit_getSOid

void SMBrushSculpt::Proc(ViewExp *vpt, const SMHit &hit, IPoint2 &m, IPoint2 &lastm)
{
  if (!m_stroking || SMHit_hasNoFaceHit(hit))
    return;

  int startid = SMHit_getSOid(hit,m_subobj);
  Point3 startpos = hit.face.pos;

  MNMeshConVertBuffer *mcon = m_SM->GetMConVert();

  // compute affected + distances
  mcon->SeedSingle(m_subobj,startid,m_SM->m_brushsize,startpos,TRUE,m_SM->m_ip->SelectionFrozen());
  mcon->BuildAffectedSoft(m_SM->m_brushsize,startpos);
  mcon->AffectedDistWeights(hit.brushinner,hit.brush);

  // run sculpt
  MNMesh* mesh = m_SM->m_mesh;

  Point3  extrudedir = (m_SM->m_workplane.IsLocal()) ? mcon->GetAffectedNormal(TRUE) : m_SM->m_workplane.GetNormal();

  extrudedir *= m_dirsign * hit.pressure * m_speed;

  IMNMeshUtilities8* mesh8 = static_cast<IMNMeshUtilities8*>(mesh->GetInterface( IMNMESHUTILITIES8_INTERFACE_ID ));
  MNMeshConVertIter it;
  MNMeshConVertIter itend;
  mcon->GetIterators(it,itend);

  MESHCONVERT_IT_MASK(mcon->GetMasked())
    mesh->v[it->vid].p += extrudedir*it->dist;

  #if MAX_RELEASE >= 9000
    mesh8->InvalidateVertexCache(it->vid);
  #endif
  MESHCONVERT_IT_NORM
    mesh->v[it->vid].p += extrudedir*it->dist;
  #if MAX_RELEASE >= 9000
    mesh8->InvalidateVertexCache(it->vid);
  #endif
  MESHCONVERT_IT_END;

  // update draw geo
  MNMesh_updateDrawGeo(mesh,m_SM->m_polyobj);

}
开发者ID:pixeljetstream,项目名称:allesimfluss_maxplugin,代码行数:44,代码来源:brush_sculpt.cpp

示例11: mmu

// (This code was copied from EditPolyObj::EpfnCollapse.)
bool VWeldMod::WeldShortPolyEdges (MNMesh & mesh, float thresh, DWORD flag) {
	// In order to collapse vertices, we turn them into edge selections,
	// where the edges are shorter than the weld threshold.
	bool canWeld = false;
	mesh.ClearEFlags (flag);
	float threshSq = thresh*thresh;
	for (int i=0; i<mesh.nume; i++) {
		if (mesh.e[i].GetFlag (MN_DEAD)) continue;
		if (!mesh.v[mesh.e[i].v1].GetFlag (flag)) continue;
		if (!mesh.v[mesh.e[i].v2].GetFlag (flag)) continue;
		if (LengthSquared (mesh.P(mesh.e[i].v1) - mesh.P(mesh.e[i].v2)) > threshSq) continue;
		mesh.e[i].SetFlag (flag);
		canWeld = true;
	}
	if (!canWeld) return false;

	MNMeshUtilities mmu(&mesh);
	return mmu.CollapseEdges (MN_USER);
}
开发者ID:innovatelogic,项目名称:ilogic-vm,代码行数:20,代码来源:vweld.cpp

示例12: MirrorPolyObject

void SymmetryMod::MirrorPolyObject (MNMesh & mesh, int axis, Matrix3 & tm, Matrix3 & itm) {
	// Create scaling matrix for mirroring on selected axis:
	Point3 scale(1,1,1);
	scale[axis] = -1.0f;
	itm.Scale(scale,TRUE);

	// Make the mirror copy of the entire mesh:
	int oldnumv = mesh.numv;
	for (int i=0; i<mesh.numf; i++) mesh.f[i].SetFlag (MN_USER);
	mesh.CloneFaces (MN_USER, true);

	// Transform the vertices to their mirror images:
	for (int i=oldnumv; i<mesh.numv; i++) mesh.v[i].p = (itm*mesh.v[i].p)*tm;

	// Flip over faces, edges:
	mesh.FlipElementNormals (MN_USER);	// flag should now be set only on clones.

	DbgAssert (mesh.CheckAllData ());
}
开发者ID:innovatelogic,项目名称:ilogic-vm,代码行数:19,代码来源:Symmetry.cpp

示例13: RemovePolySpurs

void SymmetryMod::RemovePolySpurs (MNMesh & mesh) {
	// Make sure we don't have any "spurs".
	for (int i=0; i<mesh.numv; i++) {
		if (mesh.v[i].GetFlag (MN_DEAD)) continue;
		if (mesh.vedg[i].Count() != 1) continue;
		int vid = i;
		while ((!mesh.v[vid].GetFlag (MN_DEAD)) && (mesh.vedg[vid].Count() == 1)) {
			int edge = mesh.vedg[vid][0];
			int otherEnd = mesh.e[edge].OtherVert (vid);
			mesh.RemoveSpur (edge);
			// The other end might be a tip of a spur now:
			vid = otherEnd;
			if (vid == i) {	// shouldn't happen - extra check to prevent loops.
				DbgAssert (0);
				break;
			}
		}
	}
}
开发者ID:innovatelogic,项目名称:ilogic-vm,代码行数:19,代码来源:Symmetry.cpp

示例14: FaceValue

float EditFaceDataModData::FaceValue (int faceID) {
	if (faceID<0) return 0.0f;
	if (faceID>mFacesAffected.GetSize()) return 0.0f;
	if (mFacesAffected[faceID]) return mtNewFaceValues[faceID];
	IFaceDataMgr *pFDMgr = NULL;
	if (mpCacheMesh && (faceID < mpCacheMesh->numFaces)) {
		// Get the face data manager from the mesh:
		pFDMgr = static_cast<IFaceDataMgr*>(mpCacheMesh->GetInterface (FACEDATAMGR_INTERFACE));
	}
	if (mpCacheMNMesh && (faceID < mpCacheMNMesh->numf)) {
		// Get the face data manager from the mesh:
		pFDMgr = static_cast<IFaceDataMgr*>(mpCacheMNMesh->GetInterface (FACEDATAMGR_INTERFACE));
	}
	if (pFDMgr == NULL) return 0.0f;
	SampleFaceData* fdc = dynamic_cast<SampleFaceData*>(pFDMgr->GetFaceDataChan( FACE_MAXSAMPLEUSE_CLSID ));
	if (!fdc) return 0.0f;
	float val;
	if (!fdc->GetValue (faceID, val)) return 0.0f;
	return val;
}
开发者ID:2asoft,项目名称:xray,代码行数:20,代码来源:EditFaceData.cpp

示例15: ApplyAllOperations

void EditPolyData::ApplyAllOperations (MNMesh & mesh)
{
#ifdef __DEBUG_PRINT_EDIT_POLY
	DebugPrint (_T("EditPolyData::ApplyAllOperations\n"));
#endif

	if (mpOpList) {
		// Preallocate if possible.  (Upon first application, this will do nothing.)
		PolyOperationRecord* pOpRec = NULL;
		int newFaces(0), newVertices(0), newEdges(0);
		Tab<int> newMapVertices;
		newMapVertices.SetCount (mesh.numm + NUM_HIDDENMAPS);
		for (int mp=-NUM_HIDDENMAPS; mp<mesh.numm; mp++) newMapVertices[mp+NUM_HIDDENMAPS] = 0;
		for (pOpRec=mpOpList; pOpRec != NULL; pOpRec=pOpRec->Next()) {
			newFaces += pOpRec->Operation()->NewFaceCount();
			newVertices += pOpRec->Operation()->NewVertexCount();
			newEdges += pOpRec->Operation()->NewEdgeCount ();

			for (int mp=-NUM_HIDDENMAPS; mp<mesh.numm; mp++) {
				if (mesh.M(mp)->GetFlag (MN_DEAD)) continue;
				newMapVertices[mp+NUM_HIDDENMAPS] += pOpRec->Operation()->NewMapVertexCount(mp);
			}
		}

		mesh.VAlloc (mesh.numv + newVertices);
		mesh.EAlloc (mesh.nume + newEdges);
		mesh.FAlloc (mesh.numf + newFaces);
		for (int mp=-NUM_HIDDENMAPS; mp<mesh.numm; mp++) {
			MNMap *map = mesh.M(mp);
			if (map->GetFlag (MN_DEAD)) continue;
			map->VAlloc (map->numv + newMapVertices[mp+NUM_HIDDENMAPS]);
			map->FAlloc (map->numf + newFaces);
		}

		for (pOpRec=mpOpList; pOpRec != NULL; pOpRec=pOpRec->Next())
		{
#ifdef __DEBUG_PRINT_EDIT_POLY
			DebugPrint (_T("EditPolyData::Applying %s\n"), pOpRec->Operation()->Name());
#endif
			pOpRec->Operation()->SetUserFlags (mesh);
			bool ret = pOpRec->Operation()->Apply (mesh, pOpRec->LocalData());
			if (ret && pOpRec->Operation()->CanDelete()) mesh.CollapseDeadStructs ();
		}
	}
}
开发者ID:innovatelogic,项目名称:ilogic-vm,代码行数:45,代码来源:EditPolyData.cpp


注:本文中的MNMesh类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。