本文整理匯總了C++中Interval::Set方法的典型用法代碼示例。如果您正苦於以下問題:C++ Interval::Set方法的具體用法?C++ Interval::Set怎麽用?C++ Interval::Set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Interval
的用法示例。
在下文中一共展示了Interval::Set方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: GetValue
void SampleProCtrl::GetValue(TimeValue t, void *ptr, Interval &valid, GetSetMethod method)
{
Point3 p3OurAbsValue(0, 0, 0);
p3OurAbsValue.x = 15*sin((float)t/960);
p3OurAbsValue.y = (float)t/192;
valid.Set(t,t+1);
if (method == CTRL_ABSOLUTE)
{
Point3* p3InVal = (Point3*)ptr;
*p3InVal = p3OurAbsValue;
}
else // CTRL_RELATIVE
{
Matrix3* m3InVal = (Matrix3*)ptr;
m3InVal->PreTranslate(p3OurAbsValue);
}
}
示例2: Extrapolate
void AudioBaseControl::Extrapolate(Interval range,TimeValue t,void *val,Interval &valid,int etype)
{
if(type == AUDIO_FLOAT_CONTROL_CLASS_ID1) {
float fval0, fval1, fval2, res = 0.0f;
switch (etype) {
case ORT_LINEAR:
if (t<range.Start()) {
GetValueLocalTime(range.Start(),&fval0,valid);
GetValueLocalTime(range.Start()+1,&fval1,valid);
res = LinearExtrapolate(range.Start(),t,fval0,fval1,fval0);
}
else {
GetValueLocalTime(range.End()-1,&fval0,valid);
GetValueLocalTime(range.End(),&fval1,valid);
res = LinearExtrapolate(range.End(),t,fval0,fval1,fval1);
}
break;
case ORT_IDENTITY:
if (t<range.Start()) {
GetValueLocalTime(range.Start(),&fval0,valid);
res = IdentityExtrapolate(range.Start(),t,fval0);
}
else {
GetValueLocalTime(range.End(),&fval0,valid);
res = IdentityExtrapolate(range.End(),t,fval0);
}
break;
case ORT_RELATIVE_REPEAT:
GetValueLocalTime(range.Start(),&fval0,valid);
GetValueLocalTime(range.End(),&fval1,valid);
GetValueLocalTime(CycleTime(range,t),&fval2,valid);
res = RepeatExtrapolate(range,t,fval0,fval1,fval2);
break;
}
valid.Set(t,t);
*((float*)val) = res;
}
else if(type == AUDIO_SCALE_CONTROL_CLASS_ID1) {
ScaleValue val0, val1, val2, res;
switch (etype) {
case ORT_LINEAR:
if (t<range.Start()) {
GetValueLocalTime(range.Start(),&val0,valid);
GetValueLocalTime(range.Start()+1,&val1,valid);
res = LinearExtrapolate(range.Start(),t,val0,val1,val0);
}
else {
GetValueLocalTime(range.End()-1,&val0,valid);
GetValueLocalTime(range.End(),&val1,valid);
res = LinearExtrapolate(range.End(),t,val0,val1,val1);
}
break;
case ORT_IDENTITY:
if (t<range.Start()) {
GetValueLocalTime(range.Start(),&val0,valid);
res = IdentityExtrapolate(range.Start(),t,val0);
}
else {
GetValueLocalTime(range.End(),&val0,valid);
res = IdentityExtrapolate(range.End(),t,val0);
}
break;
case ORT_RELATIVE_REPEAT:
GetValueLocalTime(range.Start(),&val0,valid);
GetValueLocalTime(range.End(),&val1,valid);
GetValueLocalTime(CycleTime(range,t),&val2,valid);
res = RepeatExtrapolate(range,t,val0,val1,val2);
break;
}
valid.Set(t,t);
*((ScaleValue *)val) = res;
}
else {
Point3 val0, val1, val2, res;
switch (etype) {
case ORT_LINEAR:
if (t<range.Start()) {
GetValueLocalTime(range.Start(),&val0,valid);
GetValueLocalTime(range.Start()+1,&val1,valid);
res = LinearExtrapolate(range.Start(),t,val0,val1,val0);
}
else {
GetValueLocalTime(range.End()-1,&val0,valid);
GetValueLocalTime(range.End(),&val1,valid);
res = LinearExtrapolate(range.End(),t,val0,val1,val1);
}
break;
case ORT_IDENTITY:
if (t<range.Start()) {
GetValueLocalTime(range.Start(),&val0,valid);
res = IdentityExtrapolate(range.Start(),t,val0);
}
else {
GetValueLocalTime(range.End(),&val0,valid);
res = IdentityExtrapolate(range.End(),t,val0);
//.........這裏部分代碼省略.........
示例3: EvalExpAndCounts
int EvalExpAndCounts(PilParams ¶ms, double tmin, double tmax, int &countscalc, double &expcalc)
{
int timestep = 1;
Intervals intervals;
if (!eval::LoadTimeList(params["timelist"], intervals, tmin, tmax)) {
cerr << "Error loading timelist file '" << params["timelist"].GetStr() << "'" << endl;
return EXIT_FAILURE;
}
cout << endl << "INPUT PARAMETERS:" << endl;
params.Print();
double radius = params["radius"]; //mres
double mdim = radius*sqrt(2);
cout << "radius for evt: " << radius << " - mdim for exp: " << mdim << endl;
double binstep = 1.0;
const char *projection = "ARC";
cout << "Binstep: " << binstep << endl;
cout << "Projection: " << projection << endl;
cout << "INTERVALS N=" << intervals.Count() << ":" << endl;
for (int i=0; i<intervals.Count(); i++)
cout << " " << intervals[i].String() << endl;
cout << "Selecting the events.." << endl;
char selectionLogFilename[FLEN_FILENAME];
char templateLogFilename[FLEN_FILENAME];
tmpnam(selectionLogFilename);
tmpnam(templateLogFilename);
char *logfile = (char*) params["logfile"].GetStr();
if (logfile && logfile[0]=='@')
logfile++;
string logExpr = selection::LogExprString(intervals, params["phasecode"], timestep);
cout << logExpr << endl;
int status = selection::MakeSelection(logfile, intervals, logExpr, selectionLogFilename, templateLogFilename);
if (status==-118) {
cout << endl << "AG_lm5......................no matching events found" << endl;
cout << endString << endl;
return 0;
}
else if (status != 0) {
cout << endl << "AG_lm5......................selection failed" << endl;
cout << endString << endl;
return 0;
}
cout << "Selecting the events.." << endl;
char selectionEvtFilename[FLEN_FILENAME];
char templateEvtFilename[FLEN_FILENAME];
tmpnam(selectionEvtFilename);
tmpnam(templateEvtFilename);
char *evtfile = (char*) params["evtfile"].GetStr();
if (evtfile && evtfile[0]=='@')
evtfile++;
string evtExpr = selection::EvtExprString(intervals, params["emin"], params["emax"],
params["albrad"], params["fovradmax"], params["fovradmin"],
params["phasecode"], params["filtercode"]);
status = selection::MakeSelection(evtfile, intervals, evtExpr, selectionEvtFilename, templateEvtFilename);
if (status==-118) {
cout << endl << "AG_lm5......................no matching events found" << endl;
cout << endString << endl;
return 0;
}
else if (status != 0) {
cout << endl << "AG_lm5......................selection failed" << endl;
cout << endString << endl;
return 0;
}
double beginTime = tmin;
double endTime = tmax;
cout.setf(ios::fixed);
cout << std::setprecision(2);
cout << "***** " << beginTime << " " << endTime << " " << endl << endl;
Interval timeSlot;
timeSlot.Set(beginTime, endTime);
#ifdef DEBUG
cout << "Time slot beginTime: " << beginTime << " endTime: " << endTime << endl;
#endif
Intervals intervalSlots = Intersection(intervals, timeSlot);
if (intervalSlots.Count()) {
cout << "Selected slots:" << endl;
for (int i=0; i<intervalSlots.Count(); i++)
cout << " " << intervalSlots[i].Start() << " " << intervalSlots[i].Stop() << endl;
vector< vector<double> > exposures;
status = eval::EvalExposure("None", params["sarFileName"], params["edpFileName"],
"None", projection, mdim, mdim, params["la"], params["ba"],
params["lonpole"], params["albrad"], params["y_tol"], params["roll_tol"],
params["earth_tol"], params["phasecode"], binstep, params["timestep"],
params["index"], tmin, tmax, params["emin"],
params["emax"], params["fovradmin"], params["fovradmax"],
selectionLogFilename, templateLogFilename, intervalSlots, exposures, false);
vector<int> counts;
status = eval::EvalCountsInRadius("None", tmin, tmax, radius,
params["la"], params["ba"], params["lonpole"],
//.........這裏部分代碼省略.........
示例4: 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));
//.........這裏部分代碼省略.........