本文整理汇总了C++中TimeSamplingPtr::getFloorIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ TimeSamplingPtr::getFloorIndex方法的具体用法?C++ TimeSamplingPtr::getFloorIndex怎么用?C++ TimeSamplingPtr::getFloorIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeSamplingPtr
的用法示例。
在下文中一共展示了TimeSamplingPtr::getFloorIndex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetRelevantSampleTimes
//-*****************************************************************************
void GetRelevantSampleTimes( ProcArgs &args, TimeSamplingPtr timeSampling,
size_t numSamples, SampleTimeSet &output )
{
if ( numSamples < 2 )
{
output.insert( 0.0 );
return;
}
chrono_t frameTime = args.frame / args.fps;
chrono_t shutterOpenTime = ( args.frame + args.shutterOpen ) / args.fps;
chrono_t shutterCloseTime = ( args.frame + args.shutterClose ) / args.fps;
std::pair<index_t, chrono_t> shutterOpenFloor =
timeSampling->getFloorIndex( shutterOpenTime, numSamples );
std::pair<index_t, chrono_t> shutterCloseCeil =
timeSampling->getCeilIndex( shutterCloseTime, numSamples );
//TODO, what's a reasonable episilon?
static const chrono_t epsilon = 1.0 / 10000.0;
//check to see if our second sample is really the
//floor that we want due to floating point slop
//first make sure that we have at least two samples to work with
if ( shutterOpenFloor.first < shutterCloseCeil.first )
{
//if our open sample is less than open time,
//look at the next index time
if ( shutterOpenFloor.second < shutterOpenTime )
{
chrono_t nextSampleTime =
timeSampling->getSampleTime( shutterOpenFloor.first + 1 );
if ( fabs( nextSampleTime - shutterOpenTime ) < epsilon )
{
shutterOpenFloor.first += 1;
shutterOpenFloor.second = nextSampleTime;
}
}
}
for ( index_t i = shutterOpenFloor.first; i < shutterCloseCeil.first; ++i )
{
output.insert( timeSampling->getSampleTime( i ) );
}
//no samples above? put frame time in there and get out
if ( output.size() == 0 )
{
output.insert( frameTime );
return;
}
chrono_t lastSample = *(output.rbegin() );
//determine whether we need the extra sample at the end
if ( ( fabs( lastSample - shutterCloseTime ) > epsilon )
&& lastSample < shutterCloseTime )
{
output.insert( shutterCloseCeil.second );
}
}
示例2: frameSelector
AtNode * ProcessPointsBase(
IPoints & prim, ProcArgs & args,
SampleTimeSet & sampleTimes,
std::vector<AtPoint> & vidxs,
std::vector<float> & radius,
MatrixSampleMap * xformSamples )
{
if ( !prim.valid() )
{
return NULL;
}
Alembic::AbcGeom::IPointsSchema &ps = prim.getSchema();
TimeSamplingPtr ts = ps.getTimeSampling();
sampleTimes.insert( ts->getFloorIndex(args.frame / args.fps, ps.getNumSamples()).second );
std::string name = args.nameprefix + prim.getFullName();
AtNode * instanceNode = NULL;
std::string cacheId;
SampleTimeSet singleSampleTimes;
singleSampleTimes.insert( ts->getFloorIndex(args.frame / args.fps, ps.getNumSamples()).second );
ICompoundProperty arbGeomParams = ps.getArbGeomParams();
ISampleSelector frameSelector( *singleSampleTimes.begin() );
std::vector<std::string> tags;
//get tags
if ( arbGeomParams != NULL && arbGeomParams.valid() )
{
if (arbGeomParams.getPropertyHeader("mtoa_constant_tags") != NULL)
{
const PropertyHeader * tagsHeader = arbGeomParams.getPropertyHeader("mtoa_constant_tags");
if (IStringGeomParam::matches( *tagsHeader ))
{
IStringGeomParam param( arbGeomParams, "mtoa_constant_tags" );
if ( param.valid() )
{
IStringGeomParam::prop_type::sample_ptr_type valueSample =
param.getExpandedValue( frameSelector ).getVals();
if ( param.getScope() == kConstantScope || param.getScope() == kUnknownScope)
{
Json::Value jtags;
Json::Reader reader;
if(reader.parse(valueSample->get()[0], jtags))
for( Json::ValueIterator itr = jtags.begin() ; itr != jtags.end() ; itr++ )
{
tags.push_back(jtags[itr.key().asUInt()].asString());
}
}
}
}
}
}
if ( args.makeInstance )
{
std::ostringstream buffer;
AbcA::ArraySampleKey sampleKey;
for ( SampleTimeSet::iterator I = sampleTimes.begin();
I != sampleTimes.end(); ++I )
{
ISampleSelector sampleSelector( *I );
ps.getPositionsProperty().getKey(sampleKey, sampleSelector);
buffer << GetRelativeSampleTime( args, (*I) ) << ":";
sampleKey.digest.print(buffer);
buffer << ":";
}
cacheId = buffer.str();
instanceNode = AiNode( "ginstance" );
AiNodeSetStr( instanceNode, "name", name.c_str() );
args.createdNodes.push_back(instanceNode);
if ( args.proceduralNode )
{
AiNodeSetByte( instanceNode, "visibility",
AiNodeGetByte( args.proceduralNode, "visibility" ) );
}
else
{
AiNodeSetByte( instanceNode, "visibility", AI_RAY_ALL );
}
ApplyTransformation( instanceNode, xformSamples, args );
NodeCache::iterator I = g_meshCache.find(cacheId);
// parameters overrides
if(args.linkOverride)
ApplyOverrides(name, instanceNode, tags, args);
//.........这里部分代码省略.........