本文整理汇总了C++中ParticleSystemRefPtr::getAge方法的典型用法代码示例。如果您正苦于以下问题:C++ ParticleSystemRefPtr::getAge方法的具体用法?C++ ParticleSystemRefPtr::getAge怎么用?C++ ParticleSystemRefPtr::getAge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParticleSystemRefPtr
的用法示例。
在下文中一共展示了ParticleSystemRefPtr::getAge方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: affect
bool AgeFadeParticleAffector::affect(ParticleSystemRefPtr System, Int32 ParticleIndex, const Time& elps)
{
Real32 Alpha(0.0f);
if(System->getAge(ParticleIndex)<getFadeInTime())
{
lerp<Real32>(getStartAlpha(), getFadeToAlpha(),1.0f-((getFadeInTime() - System->getAge(ParticleIndex))/getFadeInTime()), Alpha);
}
else if(System->getLifespan(ParticleIndex) < 0 || (System->getAge(ParticleIndex)< System->getLifespan(ParticleIndex)-getFadeOutTime()))
{
Alpha = getFadeToAlpha();
}
else
{
//lerp
lerp<Real32>(getFadeToAlpha(), getEndAlpha(), ((System->getAge(ParticleIndex)-System->getLifespan(ParticleIndex)+getFadeOutTime())/(getFadeOutTime())), Alpha);
}
Color4f Color = System->getColor(ParticleIndex);
Color[3] = Alpha;
System->setColor(Color, ParticleIndex);
return false;
}
示例2: affect
bool RandomMovementParticleAffector::affect(ParticleSystemRefPtr System, Int32 ParticleIndex, const Time& elps)
{
//System->setUpdateSecAttribs(false);
Real32 x,
y,
z,
age(System->getAge(ParticleIndex));
if(getAttributeAffected() == VELOCITY_ATTRIBUTE)
{
Vec3f vel = System->getSecVelocity(ParticleIndex);
// grab each value independently , and adjust the phase for each
// axis, since we have a 3D phase and the 1D distribution only takes
// one value
Real32 velSum = vel.x() + vel.y() + vel.z();
getPerlinDistribution()->setPhase(getPhase().x() + velSum);
x = getPerlinDistribution()->generate(vel.x() + age);
getPerlinDistribution()->setPhase(getPhase().y() + velSum);
y = getPerlinDistribution()->generate(vel.y() + age);
getPerlinDistribution()->setPhase(getPhase().z() + velSum);
z = getPerlinDistribution()->generate(vel.z() + age);
System->setVelocity(Vec3f(x,y,z) + vel,ParticleIndex);
}else // affecting position
{
Pnt3f pos = System->getSecPosition(ParticleIndex);
Real32 posSum = pos.x() + pos.y() + pos.z();
getPerlinDistribution()->setPhase(getPhase().x() + posSum);
x = getPerlinDistribution()->generate(pos.x() + age);
getPerlinDistribution()->setPhase(getPhase().y() + posSum);
y = getPerlinDistribution()->generate(pos.y() + age);
getPerlinDistribution()->setPhase(getPhase().z() + posSum);
z = getPerlinDistribution()->generate(pos.z() + age);
System->setPosition(Pnt3f(x,y,z) + pos.subZero(),ParticleIndex);
}
return false;
}
示例3: affect
bool AgeSizeParticleAffector::affect(ParticleSystemRefPtr System, Int32 ParticleIndex, const Time& elps)
{
if(getMFAges()->size()!=getMFSizes()->size())
{
return false;
}
else
{
Real32 time;
UInt32 i(0);
Real32 Age(System->getAge(ParticleIndex)),Lifespan(System->getLifespan(ParticleIndex));
if(Lifespan < 0.0)
{
return false;
}
time = (Age)/(Lifespan);
for( ;i<getMFAges()->size() && time>getAges(i);++i)
{
}
if(i == getMFSizes()->size())
{
System->setSize(getMFSizes()->back(),ParticleIndex);
}
else if(i == 0.0)
{
System->setSize(getMFSizes()->front(),ParticleIndex);
}
else
{
Vec3f size;
time = (time - getAges(i-1))/(getAges(i)-getAges(i-1));
lerp(getSizes(i-1),getSizes(i),time,size);
System->setSize(size,ParticleIndex);
}
}
return false;
}