void BombObject::UpdateUI(TimeValue t) { if (hParam && !waitPostLoad) { if (this == DLGetWindowLongPtr<BombObject *>(hParam)) { strengthSpin->SetValue(GetStrength(t),FALSE); gravSpin->SetValue(GetGravity(t),FALSE); chaosSpin->SetValue(GetChaos(t),FALSE); falloffSpin->SetValue(GetFalloff(t),FALSE); spinSpin->SetValue(GetSpin(t),FALSE); if (pblock->KeyFrameAtTime(PB_STRENGTH,t)) strengthSpin->SetKeyBrackets(TRUE); else strengthSpin->SetKeyBrackets(FALSE); if (pblock->KeyFrameAtTime(PB_GRAVITY,t)) gravSpin->SetKeyBrackets(TRUE); else gravSpin->SetKeyBrackets(FALSE); if (pblock->KeyFrameAtTime(PB_CHAOS,t)) chaosSpin->SetKeyBrackets(TRUE); else chaosSpin->SetKeyBrackets(FALSE); if (pblock->KeyFrameAtTime(PB_SPIN,t)) spinSpin->SetKeyBrackets(TRUE); else spinSpin->SetKeyBrackets(FALSE); if (pblock->KeyFrameAtTime(PB_FALLOFF,t)) falloffSpin->SetKeyBrackets(TRUE); else falloffSpin->SetKeyBrackets(FALSE); } } }
void ExtrudeMod::EndEditParams( IObjParam *ip, ULONG flags,Animatable *next) { this->ip = NULL; editMod = NULL; TimeValue t = ip->GetTime(); ClearAFlag(A_MOD_BEING_EDITED); NotifyDependents(Interval(t,t), PART_ALL, REFMSG_END_EDIT); NotifyDependents(Interval(t,t), PART_ALL, REFMSG_MOD_DISPLAY_OFF); DestroyCPParamMap(pmapParam); // Save these values in class variables so the next object created will inherit them. pblock->GetValue(PB_AMOUNT,ip->GetTime(),dlgAmount,FOREVER); pblock->GetValue(PB_SEGS,ip->GetTime(),dlgSegs,FOREVER); if (dlgSegs<1) dlgSegs = 1; pblock->GetValue(PB_CAPSTART,ip->GetTime(),dlgCapStart,FOREVER); pblock->GetValue(PB_CAPEND,ip->GetTime(),dlgCapEnd,FOREVER); pblock->GetValue(PB_CAPTYPE,ip->GetTime(),dlgCapType,FOREVER); pblock->GetValue(PB_OUTPUT,ip->GetTime(),dlgOutput,FOREVER); pblock->GetValue(PB_MAPPING,ip->GetTime(),dlgMapping,FOREVER); pblock->GetValue(PB_GEN_MATIDS,ip->GetTime(),dlgGenMatIDs,FOREVER); pblock->GetValue(PB_USE_SHAPEIDS,ip->GetTime(),dlgUseShapeIDs,FOREVER); pblock->GetValue(PB_SMOOTH,ip->GetTime(),dlgSmooth,FOREVER); }
Interval RelaxMod::GetValidity(TimeValue t) { int i; float f; // Only have to worry about animated parameters. Interval valid = FOREVER; pblock->GetValue (PB_RELAX, t, f, valid); pblock->GetValue (PB_ITER, t, i, valid); return valid; }
BillboardObject::BillboardObject() : HelperObject() { pblock = NULL; IParamBlock* pb = CreateParameterBlock(descVer0, PB_BB_LENGTH, CURRENT_VERSION); pb->SetValue(PB_BB_SCREEN_ALIGN, 0, FALSE); ReplaceReference( 0, pb); assert(pblock); }
void BombObject::RescaleWorldUnits(float f) { if (TestAFlag(A_WORK1)) return; SetAFlag(A_WORK1); WSMObject::RescaleWorldUnits(f); pblock->RescaleParam(PB_STRENGTH,f*f); pblock->RescaleParam(PB_GRAVITY,f); }
// property accessor functions for a new property 'aspect' Value* get_caps_aspect(ReferenceTarget* obj, Value* prop, TimeValue t, Interval& valid) { // compute & return capsule aspect IParamBlock *pb = ((Object*)obj)->GetParamBlock()->GetParamBlock(); float h, r; pb->GetValue(CAPS_HEIGHT, t, h, valid); pb->GetValue(CAPS_RADIUS, t, r, valid); return Float::intern(r * 2.0f / h); }
void M3Mat::Reset() { // char s[25]; DeleteReference(101); for(int i=0;i<100;i++) { DeleteReference(i); mTex[i] = NULL; // ReplaceReference(i,NewDefaultStdMat()); // sprintf(s,GetString(IDS_MTL_CNAME),i+1); // mTex[i]->SetName(s); } ReplaceReference(100,NewDefaultStdMat()); mTex[100]->SetName(GetString(IDS_MTL_BASE)); ParamBlockDescID *descVer = new ParamBlockDescID[101]; for(int x=0;x<100;x++){ ParamBlockDescID add; add.type=TYPE_FLOAT; add.user=NULL; add.animatable=TRUE; add.id=x; descVer[x] = add; } ParamBlockDescID add; add.type=TYPE_INT; add.user=NULL; add.animatable=FALSE; add.id=x; descVer[x] = add; // x == 100 we guess? IParamBlock *pblockMat = (IParamBlock*)CreateParameterBlock(descVer,101,1); ReplaceReference(101,pblockMat); //ReplaceReference(102,NULL); delete [] descVer; pblockMat->SetValue(100,0,0); // set param [100], the mystery param }
Interval ExtrudeMod::GetValidity(TimeValue t) { float f; int i; Interval valid = FOREVER; pblock->GetValue(PB_AMOUNT,t,f,valid); pblock->GetValue(PB_SEGS,t,i,valid); pblock->GetValue(PB_CAPSTART,t,i,valid); pblock->GetValue(PB_CAPEND,t,i,valid); pblock->GetValue(PB_CAPTYPE,t,i,valid); return valid; }
FogObject::FogObject() : HelperObject() { pblock = NULL; IParamBlock* pb = CreateParameterBlock(descVer0, PB_FOG_LENGTH, CURRENT_VERSION); pb->SetValue(PB_TYPE, 0, 0); pb->SetValue(PB_COLOR, 0, Point3(1,1,1)); pb->SetValue(PB_VIS_RANGE, 0, 0.0f); pb->SetValue(PB_FOG_SIZE, 1, 1.0f); ReplaceReference( 0, pb); assert(pblock); }
TouchSensorObject::TouchSensorObject() : HelperObject() { IParamBlock* pb = CreateParameterBlock(descVer0, PB_TS_LENGTH, CURRENT_VERSION); pb->SetValue(PB_TS_SIZE, 0, 0.0f); pb->SetValue(PB_TS_ENABLED, 0, TRUE); pb->SetValue(PB_TS_NUMOBJS, 0, 0); MakeRefByID(FOREVER, 0, pb); assert(pblock); previousMode = NULL; triggerObject = NULL; objects.SetCount(0); BuildObjectList(this); }
int OptMod::RenderEnd(TimeValue t) { int views, render; pblock->GetValue(PB_VIEWS,0,views,FOREVER); #ifndef NO_OUTPUTRENDERER pblock->GetValue(PB_RENDER,0,render,FOREVER); #else render = views; #endif ClearAFlag(A_RENDER); if (views!=render) { NotifyDependents(FOREVER,PART_ALL,REFMSG_CHANGE); } return 0; }
Interval FExtrudeMod::LocalValidity(TimeValue t) { // aszabo|feb.05.02 If we are being edited, return NEVER // to forces a cache to be built after previous modifier. if (TestAFlag(A_MOD_BEING_EDITED)) return NEVER; Interval iv = FOREVER; float v; Point3 pt; pblock->GetValue(PB_AMOUNT,t,v,iv); pblock->GetValue(PB_SCALE,t,v,iv); base->GetValue(t,&pt,iv,CTRL_ABSOLUTE); return iv; }
void AFRMod::ModifyObject (TimeValue t, ModContext &mc, ObjectState *os, INode *node) { Interval iv = FOREVER; float f, p, b; int backface; Point3 pt1, pt2; pblock->GetValue(PB_FALLOFF,t,f,iv); pblock->GetValue(PB_PINCH,t,p,iv); pblock->GetValue(PB_BUBBLE,t,b,iv); pblock->GetValue(PB_BACKFACE,t,backface,iv); p1->GetValue(t,&pt1,iv,CTRL_ABSOLUTE); p2->GetValue(t,&pt2,iv,CTRL_ABSOLUTE); if (f==0.0) { os->obj->UpdateValidity(GEOM_CHAN_NUM,iv); return; } Tab<Point3> normals; if (backface) { // Need to get vertex normals. if (os->obj->IsSubClassOf(triObjectClassID)) { TriObject *tobj = (TriObject*)os->obj; AverageVertexNormals (tobj->GetMesh(), normals); } else if (os->obj->IsSubClassOf (polyObjectClassID)) { PolyObject *pobj = (PolyObject *) os->obj; MNMesh &mesh = pobj->GetMesh(); normals.SetCount (mesh.numv); Point3 *vn = normals.Addr(0); for (int i=0; i<mesh.numv; i++) { if (mesh.v[i].GetFlag (MN_DEAD)) vn[i]=Point3(0,0,0); else vn[i] = mesh.GetVertexNormal (i); } #ifndef NO_PATCHES } else if (os->obj->IsSubClassOf (patchObjectClassID)) { PatchObject *pobj = (PatchObject *) os->obj; normals.SetCount (pobj->NumPoints ()); Point3 *vn = normals.Addr(0); for (int i=0; i<pobj->NumPoints(); i++) vn[i] = pobj->VertexNormal (i); #endif } } if (normals.Count()) { AFRDeformer deformer(mc,f,p,b,pt1,pt2,&normals); os->obj->Deform(&deformer, TRUE); } else { AFRDeformer deformer(mc,f,p,b,pt1,pt2); os->obj->Deform(&deformer, TRUE); } os->obj->UpdateValidity(GEOM_CHAN_NUM,iv); }
Interval MatMod::LocalValidity(TimeValue t) { int i; Interval valid = FOREVER; pblock->GetValue(PB_MATID,t,i,valid); return valid; }
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 }
int OptMod::RenderBegin(TimeValue t, ULONG flags) { int views, render, man; pblock->GetValue(PB_VIEWS,0,views,FOREVER); #ifndef NO_OUTPUTRENDERER pblock->GetValue(PB_RENDER,0,render,FOREVER); #else render = views; #endif pblock->GetValue(PB_MANUPDATE,0,man,FOREVER); SetAFlag(A_RENDER); if (views!=render || man) { NotifyDependents(FOREVER,PART_ALL,REFMSG_CHANGE); } return 0; }
RefTargetHandle OptMod::Clone(RemapDir& remap) { OptMod* newmod = new OptMod(); newmod->ReplaceReference(0,pblock->Clone(remap)); BaseClone(this, newmod, remap); return newmod; }
RefTargetHandle TriPatchObject::Clone(RemapDir& remap) { TriPatchObject* newob = new TriPatchObject(); newob->ReplaceReference(0,pblock->Clone(remap)); newob->ivalid.SetEmpty(); BaseClone(this, newob, remap); return(newob); }
Interval AFRMod::LocalValidity(TimeValue t) { // aszabo|feb.05.02 If we are being edited, return NEVER // to forces a cache to be built after previous modifier. if (TestAFlag(A_MOD_BEING_EDITED)) return NEVER; Interval iv = FOREVER; float v; Point3 pt; pblock->GetValue(PB_FALLOFF,t,v,iv); pblock->GetValue(PB_PINCH,t,v,iv); pblock->GetValue(PB_BUBBLE,t,v,iv); p1->GetValue(t,&pt,iv,CTRL_ABSOLUTE); p2->GetValue(t,&pt,iv,CTRL_ABSOLUTE); return iv; }
//aszabo|feb.06.02 - When LocalValidity is called by ModifyObject, // it returns NEVER and thus the object channels are marked non valid // As a result, the mod stack enters and infinite evaluation of the modifier // ModifyObject now calls GetValidity and CORE calls LocalValidity to // allow for building a cache on the input of this modifier when it's // being edited Interval MirrorMod::GetValidity(TimeValue t) { Interval iv = FOREVER; Matrix3 mat(1); tmControl->GetValue(t,&mat,iv,CTRL_RELATIVE); float o; pblock->GetValue(PB_OFFSET,t,o,iv); return iv; }
RefTargetHandle AFRMod::Clone(RemapDir& remap) { AFRMod *mod = new AFRMod(); mod->ReplaceReference(PBLOCK_REF,pblock->Clone(remap)); mod->ReplaceReference(POINT1_REF,p1->Clone(remap)); mod->ReplaceReference(POINT2_REF,p2->Clone(remap)); BaseClone(this, mod, remap); return mod; }
RefTargetHandle MirrorMod::Clone(RemapDir& remap) { MirrorMod *mod = new MirrorMod(); mod->ReplaceReference(PBLOCK_REF,pblock->Clone(remap)); mod->ReplaceReference(TM_REF,remap.CloneRef(tmControl)); mod->splineMethod = splineMethod; BaseClone(this, mod, remap); return mod; }
void BombObject::EnableControls() { if (falloffSpin) { BOOL fallOffOn; pblock->GetValue(PB_FALLOFFON, 0, fallOffOn, FOREVER); falloffSpin->Enable(fallOffOn); } }
Cal3DObject::Cal3DObject() : HelperObject() { scale = 1.0f; coreHelper = NULL; cal3d_cfg = _T(""); if (cores == NULL) cores = new Cal3DCoreHelpers(); pblock = NULL; IParamBlock *pb = CreateParameterBlock(descVer0, PB_CAL_LENGTH, CURRENT_VERSION); pb->SetValue(PB_CAL_SIZE, 0, 1.0f); pb->SetValue(PB_CAL_ANIM, 0, 0); pb->SetValue(PB_CAL_ACTION, 0, 1); #if MAX_PRODUCT_VERSION_MAJOR > 8 ReplaceReference(0, pb); #else MakeRefByID(FOREVER, 0, pb); #endif assert(pblock); previousMode = NULL; }
void ExtrudeMod::SetUsePhysicalScaleUVs(BOOL flag) { BOOL curState = GetUsePhysicalScaleUVs(); if (curState == flag) return; if (theHold.Holding()) theHold.Put(new RealWorldScaleRecord<ExtrudeMod>(this, curState)); ::SetUsePhysicalScaleUVs(this, flag); if (pblock != NULL) pblock->NotifyDependents(FOREVER, PART_GEOM, REFMSG_CHANGE); UpdateUI(); macroRec->SetProperty(this, _T("realWorldMapSize"), mr_bool, flag); }
BackgroundObject::BackgroundObject() : HelperObject() { IParamBlock* pb = CreateParameterBlock(descVer0, PB_BG_LENGTH, CURRENT_VERSION); pb->SetValue(PB_SKY_NUM_COLORS, 0, 0); pb->SetValue(PB_SKY_COLOR1 , 0, Point3(0.0f, 0.0f, 1.0f)); pb->SetValue(PB_SKY_COLOR2 , 0, Point3(1.0f, 0.0f, 0.0f)); pb->SetValue(PB_SKY_COLOR3 , 0, Point3(0.0f, 1.0f, 0.0f)); pb->SetValue(PB_SKY_COLOR2_ANGLE, 0, float(PI/4.0)); pb->SetValue(PB_SKY_COLOR3_ANGLE, 0, float(PI/2.0)); pb->SetValue(PB_GROUND_NUM_COLORS, 0, 0); pb->SetValue(PB_GROUND_COLOR1 , 0, Point3(0.7f, 0.4f, 0.3f)); pb->SetValue(PB_GROUND_COLOR2 , 0, Point3(1.0f, 0.0f, 0.0f)); pb->SetValue(PB_GROUND_COLOR3 , 0, Point3(0.0f, 1.0f, 0.0f)); pb->SetValue(PB_GROUND_COLOR2_ANGLE, 0, float(PI/4.0)); pb->SetValue(PB_GROUND_COLOR3_ANGLE, 0, float(PI/2.0)); MakeRefByID(FOREVER, 0, pb); assert(pblock); }
SwitchObject::SwitchObject() : HelperObject() { pblock = NULL; IParamBlock *pb = CreateParameterBlock(descVer0, PB_S_LENGTH, CURRENT_VERSION); pb->SetValue(PB_S_SIZE, 0, 0.0f); pb->SetValue(PB_S_NUMOBJS, 0, 0); pb->SetValue(PB_S_DEFAULT, 0, -1); pb->SetValue(PB_S_ALLOW_NONE, 0, TRUE); #if MAX_PRODUCT_VERSION_MAJOR > 8 ReplaceReference(0, pb); #else MakeRefByID(FOREVER, 0, pb); #endif assert(pblock); previousMode = NULL; // triggerObject = NULL; objects.SetCount(0); BuildObjectList(this); needsScript = true; }
NavInfoObject::NavInfoObject() : HelperObject() { pblock = NULL; IParamBlock* pb = CreateParameterBlock(descVer1, PB_NA_LENGTH, CURRENT_VERSION); pb->SetValue(PB_TYPE, 0, 0); pb->SetValue(PB_HEADLIGHT, 0, FALSE); pb->SetValue(PB_VIS_LIMIT, 0, 0.0f); pb->SetValue(PB_SPEED, 0, 1.0f); pb->SetValue(PB_COLLISION, 0, 0.25f); pb->SetValue(PB_TERRAIN, 0, 1.6f); pb->SetValue(PB_STEP, 0, 0.75f); ReplaceReference( 0, pb); assert(pblock); }
RefResult OptMod::NotifyRefChanged( Interval changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message) { switch (message) { case REFMSG_CHANGE: { if (pmapParam && pmapParam->GetParamBlock()==pblock) { pmapParam->Invalidate(); } int man = FALSE; if (pblock) pblock->GetValue(PB_MANUPDATE,0,man,FOREVER); if (man) return REF_STOP; break; } case REFMSG_GET_PARAM_DIM: { GetParamDim *gpd = (GetParamDim*)partID; switch (gpd->index) { case PB_FACETHRESH1: case PB_FACETHRESH2: case PB_EDGETHRESH1: case PB_EDGETHRESH2: gpd->dim = stdAngleDim; break; case PB_MAXEDGE1: case PB_MAXEDGE2: gpd->dim = stdWorldDim; break; default: gpd->dim = defaultDim; break; } return REF_STOP; } case REFMSG_GET_PARAM_NAME: { GetParamName *gpn = (GetParamName*)partID; switch (gpn->index) { case PB_FACETHRESH1: gpn->name = GetString(IDS_RB_FACETHRESHL1); break; case PB_FACETHRESH2: gpn->name = GetString(IDS_RB_FACETHRESHL2); break; case PB_EDGETHRESH1: gpn->name = GetString(IDS_RB_EDGETHRESHL1); break; case PB_EDGETHRESH2: gpn->name = GetString(IDS_RB_EDGETHRESHL2); break; case PB_BIAS1: gpn->name = GetString(IDS_RB_BIASL1); break; case PB_BIAS2: gpn->name = GetString(IDS_RB_BIASL2); break; case PB_MAXEDGE1: gpn->name = GetString(IDS_RB_MAXEDGE1); break; case PB_MAXEDGE2: gpn->name = GetString(IDS_RB_MAXEDGE2); break; default: gpn->name = TSTR(_T("")); break; } return REF_STOP; } } return REF_SUCCEED; }
void MirrorMod::DrawGizmo(float size,PolyLineProc& lp) { Point3 v0(0,0,0), pv0(0,0,0), v1(0,0,0), pv1(0,0,0); int ct=0; int axis; pblock->GetValue(PB_AXIS,0,axis,FOREVER); switch (axis) { case 0: case 1: case 2: v0[axis] = -1.0f; pv0[(axis+1)%3] = 1.0f; pv0[(axis+2)%3] = 1.0f; ct=1; break; case 3: case 4: case 5: v0[(axis)%3] = -1.0f; pv0[(axis+1)%3] = 1.0f; pv0[(axis+2)%3] = 1.0f; v1[(axis+1)%3] = -1.0f; pv1[(axis+2)%3] = 1.0f; pv1[(axis+3)%3] = 1.0f; ct=2; break; } Point3 pts[20]; SetupAxisPoints(v0, pv0, size, pts); lp.proc(pts,5); lp.proc(pts+5,2); lp.proc(pts+7,3); lp.proc(pts+10,3); lp.proc(pts+13,3); lp.proc(pts+16,3); if (ct==2) { SetupAxisPoints(v1, pv1, size, pts); lp.proc(pts,5); lp.proc(pts+5,2); lp.proc(pts+7,3); lp.proc(pts+10,3); lp.proc(pts+13,3); lp.proc(pts+16,3); } }