本文整理汇总了C++中PatchObject::GetPatchMesh方法的典型用法代码示例。如果您正苦于以下问题:C++ PatchObject::GetPatchMesh方法的具体用法?C++ PatchObject::GetPatchMesh怎么用?C++ PatchObject::GetPatchMesh使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PatchObject
的用法示例。
在下文中一共展示了PatchObject::GetPatchMesh方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ModifyObject
void MatMod::ModifyObject(TimeValue t, ModContext &mc, ObjectState *os, INode *node)
{
Interval valid = FOREVER;
int id;
pblock->GetValue(PB_MATID,t,id,valid);
id--;
if (id<0) id = 0;
if (id>0xffff) id = 0xffff;
// For version 4 and later, we process patch meshes as they are and pass them on. Earlier
// versions converted to TriMeshes (done below). For adding other new types of objects, add
// them here!
#ifndef NO_PATCHES
if(version >= MATMOD_VER4 && os->obj->IsSubClassOf(patchObjectClassID)) {
PatchObject *patchOb = (PatchObject *)os->obj;
PatchMesh &pmesh = patchOb->GetPatchMesh(t);
BOOL useSel = pmesh.selLevel >= PO_PATCH;
for (int i=0; i<pmesh.getNumPatches(); i++) {
if (!useSel || pmesh.patchSel[i]) {
pmesh.setPatchMtlIndex(i,(MtlID)id);
}
}
pmesh.InvalidateGeomCache(); // Do this because there isn't a topo cache in PatchMesh
patchOb->UpdateValidity(TOPO_CHAN_NUM,valid);
}
else
#endif // NO_PATCHES
// Process PolyObjects
if(os->obj->IsSubClassOf(polyObjectClassID)) {
PolyObject *polyOb = (PolyObject *)os->obj;
MNMesh &mesh = polyOb->GetMesh();
BOOL useSel = mesh.selLevel == MNM_SL_FACE;
for (int i=0; i<mesh.numf; i++) {
if (!useSel || mesh.f[i].GetFlag(MN_SEL)) {
mesh.f[i].material = (MtlID)id;
}
}
polyOb->UpdateValidity(TOPO_CHAN_NUM,valid);
}
else // If it's a TriObject, process it
if(os->obj->IsSubClassOf(triObjectClassID)) {
TriObject *triOb = (TriObject *)os->obj;
DoMaterialSet(triOb, id);
triOb->UpdateValidity(TOPO_CHAN_NUM,valid);
}
else // Fallback position: If it can convert to a TriObject, do it!
if(os->obj->CanConvertToType(triObjectClassID)) {
TriObject *triOb = (TriObject *)os->obj->ConvertToType(t, triObjectClassID);
// Now stuff this into the pipeline!
os->obj = triOb;
DoMaterialSet(triOb, id);
triOb->UpdateValidity(TOPO_CHAN_NUM,valid);
}
else
return; // Do nothing if it can't convert to triObject
}
示例2: ModifyObject
void RelaxMod::ModifyObject(TimeValue t, ModContext &mc, ObjectState * os, INode *node) {
// Get our personal validity interval...
Interval valid = GetValidity(t);
// and intersect it with the channels we use as input (see ChannelsUsed)
valid &= os->obj->ChannelValidity (t, GEOM_CHAN_NUM);
valid &= os->obj->ChannelValidity (t, TOPO_CHAN_NUM);
valid &= os->obj->ChannelValidity (t, SUBSEL_TYPE_CHAN_NUM);
valid &= os->obj->ChannelValidity (t, SELECT_CHAN_NUM);
Matrix3 modmat,minv;
if (mc.localData == NULL) mc.localData = new RelaxModData;
RelaxModData *rd = (RelaxModData *) mc.localData;
TriObject *triObj = NULL;
PatchObject *patchObj = NULL;
PolyObject *polyObj = NULL;
BOOL converted = FALSE;
// For version 4 and later, we process patch or poly meshes as they are and pass them on.
// Earlier versions converted to TriMeshes (done below).
// For adding other new types of objects, add them here!
#ifndef NO_PATCHES
if(version >= RELAXMOD_VER4 && os->obj->IsSubClassOf(patchObjectClassID)) {
patchObj = (PatchObject *)os->obj;
}
else // If it's a TriObject, process it
#endif // NO_PATCHES
if(os->obj->IsSubClassOf(triObjectClassID)) {
triObj = (TriObject *)os->obj;
}
else if (os->obj->IsSubClassOf (polyObjectClassID)) {
polyObj = (PolyObject *) os->obj;
}
else // If it can convert to a TriObject, do it
if(os->obj->CanConvertToType(triObjectClassID)) {
triObj = (TriObject *)os->obj->ConvertToType(t, triObjectClassID);
converted = TRUE;
}
else
return; // We can't deal with it!
Mesh *mesh = triObj ? &(triObj->GetMesh()) : NULL;
#ifndef NO_PATCHES
PatchMesh &pmesh = patchObj ? patchObj->GetPatchMesh(t) : *((PatchMesh *)NULL);
#else
PatchMesh &pmesh = *((PatchMesh *)NULL);
#endif // NO_PATCHES
float relax, wtdRelax; // mjm - 4.8.99
int iter;
BOOL boundary, saddle;
pblock->GetValue (PB_RELAX, t, relax, FOREVER);
pblock->GetValue (PB_ITER, t, iter, FOREVER);
pblock->GetValue (PB_BOUNDARY, t, boundary, FOREVER);
pblock->GetValue (PB_SADDLE, t, saddle, FOREVER);
LimitValue (relax, MIN_RELAX, MAX_RELAX);
LimitValue (iter, MIN_ITER, MAX_ITER);
if(triObj) {
int i, j, max;
DWORD selLevel = mesh->selLevel;
// mjm - 4.8.99 - add support for soft selection
// sca - 4.29.99 - extended soft selection support to cover EDGE and FACE selection levels.
float *vsw = (selLevel!=MESH_OBJECT) ? mesh->getVSelectionWeights() : NULL;
if (rd->ivalid.InInterval(t) && (mesh->numVerts != rd->vnum)) {
// Shouldn't happen, but does with Loft bug and may with other bugs.
rd->ivalid.SetEmpty ();
}
if (!rd->ivalid.InInterval(t)) {
rd->SetVNum (mesh->numVerts);
for (i=0; i<rd->vnum; i++) {
rd->fnum[i]=0;
rd->nbor[i].ZeroCount();
}
rd->sel.ClearAll ();
DWORD *v;
int k1, k2, origmax;
for (i=0; i<mesh->numFaces; i++) {
v = mesh->faces[i].v;
for (j=0; j<3; j++) {
if ((selLevel==MESH_FACE) && mesh->faceSel[i]) rd->sel.Set(v[j]);
if ((selLevel==MESH_EDGE) && mesh->edgeSel[i*3+j]) rd->sel.Set(v[j]);
if ((selLevel==MESH_EDGE) && mesh->edgeSel[i*3+(j+2)%3]) rd->sel.Set(v[j]);
origmax = max = rd->nbor[v[j]].Count();
rd->fnum[v[j]]++;
for (k1=0; k1<max; k1++) if (rd->nbor[v[j]][k1] == v[(j+1)%3]) break;
if (k1==max) { rd->nbor[v[j]].Append (1, v+(j+1)%3, 1); max++; }
for (k2=0; k2<max; k2++) if (rd->nbor[v[j]][k2] == v[(j+2)%3]) break;
if (k2==max) { rd->nbor[v[j]].Append (1, v+(j+2)%3, 1); max++; }
if (max>origmax) rd->vis[v[j]].SetSize (max, TRUE);
if (mesh->faces[i].getEdgeVis (j)) rd->vis[v[j]].Set (k1);
else if (k1>=origmax) rd->vis[v[j]].Clear (k1);
if (mesh->faces[i].getEdgeVis ((j+2)%3)) rd->vis[v[j]].Set (k2);
else if (k2>= origmax) rd->vis[v[j]].Clear (k2);
}
}
//.........这里部分代码省略.........
示例3: ModifyObject
void MirrorMod::ModifyObject(
TimeValue t, ModContext &mc, ObjectState *os, INode *node)
{
Matrix3 itm = CompMatrix(t,NULL,&mc);
Matrix3 tm = Inverse(itm);
Interval iv = FOREVER;
int axis, copy;
float offset;
pblock->GetValue(PB_AXIS,t,axis,iv);
pblock->GetValue(PB_COPY,t,copy,iv);
pblock->GetValue(PB_OFFSET,t,offset,iv);
DWORD oldLevel;
BOOL convertedShape = FALSE;
BitArray oldFaceSelections;
// support for TriObjects
if (os->obj->IsSubClassOf(triObjectClassID)) {
TriObject *tobj = (TriObject*)os->obj;
Mesh &mesh = tobj->GetMesh();
switch (mesh.selLevel) {
case MESH_OBJECT: mesh.faceSel.SetAll(); break;
case MESH_VERTEX: {
for (int i=0; i<mesh.getNumFaces(); i++) {
for (int j=0; j<3; j++) {
if (mesh.vertSel[mesh.faces[i].v[j]]) {
mesh.faceSel.Set(i);
}
}
}
break;
}
case MESH_EDGE: {
for (int i=0; i<mesh.getNumFaces(); i++) {
for (int j=0; j<3; j++) {
if (mesh.edgeSel[i*3+j]) {
mesh.faceSel.Set(i);
}
}
}
break;
}
}
oldLevel = mesh.selLevel;
mesh.selLevel = MESH_FACE;
if (copy) {
mesh.CloneFaces(mesh.faceSel);
mesh.ClearVSelectionWeights ();
}
if (axis<3) {
for (int i=0; i<mesh.getNumFaces(); i++) {
if (mesh.faceSel[i]) mesh.FlipNormal(i);
}
}
}
#ifndef NO_PATCHES
// support for PatchObjects
if (os->obj->IsSubClassOf(patchObjectClassID)) {
PatchObject *pobj = (PatchObject*)os->obj;
PatchMesh &pmesh = pobj->GetPatchMesh(t);
switch (pmesh.selLevel) {
case PATCH_OBJECT: pmesh.patchSel.SetAll(); break;
case PATCH_VERTEX: {
for (int i=0; i<pmesh.getNumPatches(); i++) {
Patch &p = pmesh.patches[i];
for (int j=0; j<p.type; j++) {
if (pmesh.vertSel[p.v[j]]) {
pmesh.patchSel.Set(i);
break;
}
}
}
break;
}
case PATCH_EDGE: {
for (int i=0; i<pmesh.getNumPatches(); i++) {
Patch &p = pmesh.patches[i];
for (int j=0; j<p.type; j++) {
if (pmesh.edgeSel[p.edge[j]]) {
pmesh.patchSel.Set(i);
break;
}
}
}
break;
}
}
oldLevel = pmesh.selLevel;
pmesh.selLevel = PATCH_PATCH;
if (copy)
pmesh.ClonePatchParts(); // Copy the selected patches
if (axis<3)
pmesh.FlipPatchNormal(-1); // Flip selected normals
}
#endif // NO_PATCHES
// support for PolyObjects
else if (os->obj->IsSubClassOf(polyObjectClassID)) {
//.........这里部分代码省略.........