本文整理汇总了C++中TriObject::UpdateValidity方法的典型用法代码示例。如果您正苦于以下问题:C++ TriObject::UpdateValidity方法的具体用法?C++ TriObject::UpdateValidity怎么用?C++ TriObject::UpdateValidity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TriObject
的用法示例。
在下文中一共展示了TriObject::UpdateValidity方法的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 OptMod::ModifyObject(TimeValue t, ModContext &mc, ObjectState *os, INode *node)
{
float faceThresh, edgeThresh, bias, maxEdge;
int preserveMat, preserveSmooth, which, render=0, autoEdge;
DWORD flags = 0;
Interval valid = FOREVER;
int nv,nf;
int man;
pblock->GetValue(PB_MANUPDATE,t,man,valid);
if (man && !forceUpdate && !TestAFlag(A_RENDER)) return;
forceUpdate = FALSE;
if (TestAFlag(A_RENDER)) {
pblock->GetValue(PB_RENDER,t,which,valid);
} else {
pblock->GetValue(PB_VIEWS,t,which,valid);
}
pblock->GetValue(PB_AUTOEDGE,t,autoEdge,valid);
if (which==0) {
pblock->GetValue(PB_FACETHRESH1,t,faceThresh,valid);
pblock->GetValue(PB_EDGETHRESH1,t,edgeThresh,valid);
pblock->GetValue(PB_BIAS1,t,bias,valid);
pblock->GetValue(PB_PRESERVEMAT1,t,preserveMat,valid);
pblock->GetValue(PB_PRESERVESMOOTH1,t,preserveSmooth,valid);
pblock->GetValue(PB_MAXEDGE1,t,maxEdge,valid);
} else {
pblock->GetValue(PB_FACETHRESH2,t,faceThresh,valid);
pblock->GetValue(PB_EDGETHRESH2,t,edgeThresh,valid);
pblock->GetValue(PB_BIAS2,t,bias,valid);
pblock->GetValue(PB_PRESERVEMAT2,t,preserveMat,valid);
pblock->GetValue(PB_PRESERVESMOOTH2,t,preserveSmooth,valid);
pblock->GetValue(PB_MAXEDGE2,t,maxEdge,valid);
}
assert(os->obj->IsSubClassOf(triObjectClassID));
TriObject *triOb = (TriObject *)os->obj;
nv = triOb->GetMesh().getNumVerts();
nf = triOb->GetMesh().getNumFaces();
if (preserveMat) flags |= OPTIMIZE_SAVEMATBOUNDRIES;
if (preserveSmooth) flags |= OPTIMIZE_SAVESMOOTHBOUNDRIES;
if (autoEdge) flags |= OPTIMIZE_AUTOEDGE;
if (faceThresh!=0.0f) {
GetAsyncKeyState(VK_ESCAPE); // clear the state
HCURSOR hCur;
if (nf > 2000) hCur = SetCursor(LoadCursor(NULL,IDC_WAIT));
triOb->GetMesh().Optimize(
faceThresh,edgeThresh, bias*0.5f, maxEdge, flags,this);
if (nf > 200) SetCursor(hCur);
}
triOb->GetMesh().InvalidateTopologyCache ();
triOb->PointsWereChanged();
triOb->UpdateValidity(GEOM_CHAN_NUM,valid);
triOb->UpdateValidity(TOPO_CHAN_NUM,valid);
triOb->UpdateValidity (TEXMAP_CHAN_NUM, valid);
triOb->UpdateValidity (VERT_COLOR_CHAN_NUM, valid);
if (pmapParam && pmapParam->GetParamBlock()==pblock && !TestAFlag(A_RENDER)) {
TSTR buf;
buf.printf("%d / %d",nv,triOb->GetMesh().getNumVerts());
SetWindowText(GetDlgItem(pmapParam->GetHWnd(),IDC_OPT_VERTCOUNT),buf);
buf.printf("%d / %d",nf,triOb->GetMesh().getNumFaces());
SetWindowText(GetDlgItem(pmapParam->GetHWnd(),IDC_OPT_FACECOUNT),buf);
}
}
示例3: ModifyObject
void BombMod::ModifyObject(
TimeValue t, ModContext &mc, ObjectState *os, INode *node)
{
BombObject *bobj = GetWSMObject(t);
if (bobj && nodeRef && (bobj->ClassID() == Class_ID(BOMB_OBJECT_CLASS_ID,0))) {
assert(os->obj->IsSubClassOf(triObjectClassID));
TriObject *triOb = (TriObject *)os->obj;
Interval valid = FOREVER;
if (os->GetTM()) {
Matrix3 tm = *(os->GetTM());
for (int i=0; i<triOb->GetMesh().getNumVerts(); i++) {
triOb->GetMesh().verts[i] = triOb->GetMesh().verts[i] * tm;
}
os->obj->UpdateValidity(GEOM_CHAN_NUM,os->tmValid());
os->SetTM(NULL,FOREVER);
}
if (waitPostLoad) {
valid.SetInstant(t);
triOb->UpdateValidity(GEOM_CHAN_NUM,valid);
triOb->UpdateValidity(TOPO_CHAN_NUM,valid);
return;
}
Matrix3 tm;
TimeValue det = bobj->GetDetonation(t,valid);
float strength = bobj->GetStrength(t,valid) * STRENGTH_CONSTANT;
float grav = bobj->GetGravity(t,valid);
float chaos = bobj->GetChaos(t,valid);
float chaosBase = (float(1)-chaos/2);
float rotSpeed = bobj->GetSpin(t,valid) * TWOPI/float(TIME_TICKSPERSEC);
int minClust = bobj->GetMinFrag(t,valid), maxClust = bobj->GetMaxFrag(t,valid);
if (minClust<1) minClust = 1;
if (maxClust<1) maxClust = 1;
int clustVar = maxClust-minClust+1;
float falloff = bobj->GetFalloff(t,valid);
int useFalloff = bobj->GetFalloffOn(t,valid);
int seed = bobj->GetSeed(t,valid);
//tm = nodeRef->GetNodeTM(t,&valid);
tm = nodeRef->GetObjectTM(t,&valid);
if (t<det) {
valid.Set(TIME_NegInfinity,det-1);
triOb->UpdateValidity(GEOM_CHAN_NUM,valid);
triOb->UpdateValidity(TOPO_CHAN_NUM,valid);
triOb->PointsWereChanged();
return;
}
float dt = float(t-det);
valid.SetInstant(t);
int n0=0,n1=1,n2=2,nv;
Point3 v, p0, p1, g(0.0f,0.0f,grav*GRAVITY_CONSTANT);
Tab<Point3> l_newVerts ;
Face *f = triOb->GetMesh().faces;
float dot;
Mesh &mesh = triOb->GetMesh();
// First, segment the faces.
srand((unsigned int)seed);
Tab<DWORD> vclust;
Tab<DWORD> vmap;
Tab<Point3> nverts;
vclust.SetCount(mesh.getNumVerts());
vmap.SetCount(mesh.getNumVerts());
int numClust = 0;
if (minClust==1 && maxClust==1) {
// Simple case... 1 face per cluster
nv = triOb->GetMesh().getNumFaces() * 3;
l_newVerts.SetCount(nv);
vclust.SetCount(nv);
for (int i=0; i<nv; i++) {
vclust[i] = i/3;
}
for (int i=0,j=0; i<mesh.getNumFaces(); i++) {
l_newVerts[j] = mesh.verts[mesh.faces[i].v[0]];
l_newVerts[j+1] = mesh.verts[mesh.faces[i].v[1]];
l_newVerts[j+2] = mesh.verts[mesh.faces[i].v[2]];
mesh.faces[i].v[0] = j;
mesh.faces[i].v[1] = j+1;
mesh.faces[i].v[2] = j+2;
j += 3;
}
numClust = triOb->GetMesh().getNumFaces();
} else {
// More complex case... clusters are randomely sized
for (int i=0; i<mesh.getNumVerts(); i++) {
vclust[i] = UNDEFINED;
vmap[i] = i;
}
int cnum = 0;
for (int i=0; i<mesh.getNumFaces(); ) {
int csize = int(Rand1()*float(clustVar)+float(minClust));
//.........这里部分代码省略.........