本文整理汇总了C++中ParticleSystemRefPtr::getVelocity方法的典型用法代码示例。如果您正苦于以下问题:C++ ParticleSystemRefPtr::getVelocity方法的具体用法?C++ ParticleSystemRefPtr::getVelocity怎么用?C++ ParticleSystemRefPtr::getVelocity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParticleSystemRefPtr
的用法示例。
在下文中一共展示了ParticleSystemRefPtr::getVelocity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: affect
bool VortexParticleAffector::affect(ParticleSystemRefPtr System, Int32 ParticleIndex, const Time& elps)
{
if(getBeacon() != NULL)
{
Matrix BeaconToWorld(getBeacon()->getToWorld());
Vec3f translation, tmp;
Quaternion tmp2;
BeaconToWorld.getTransform(translation,tmp2,tmp,tmp2);
Pnt3f particlePos = System->getPosition(ParticleIndex);
Real32 distanceFromAffector = particlePos.dist(Pnt3f(translation.x(),translation.y(),translation.z()));
if((getMaxDistance() < 0.0) || (distanceFromAffector <= getMaxDistance())) //only affect the particle if it is in range
{
Vec3f particleDirectionFromVortex(particlePos.x() - translation.x(), particlePos.y() - translation.y(), particlePos.z() - translation.z());
particleDirectionFromVortex = particleDirectionFromVortex.cross(getVortexAxis());
particleDirectionFromVortex.normalize();
particleDirectionFromVortex = particleDirectionFromVortex *
((-getMagnitude() *
elps)/OSG::osgClamp<Real32>(1.0f,std::pow(distanceFromAffector,getAttenuation()),TypeTraits<Real32>::getMax()));
System->setVelocity(particleDirectionFromVortex + System->getVelocity(ParticleIndex),ParticleIndex);
}
}
return false;
}
示例2: affect
bool TurbulenceParticleAffector::affect(ParticleSystemRefPtr System, Int32 ParticleIndex, const Time& elps)
{
if(getBeacon() != NULL)
{
Matrix BeaconToWorld(getBeacon()->getToWorld());
Vec3f translation, tmp;
Quaternion tmp2;
BeaconToWorld.getTransform(translation,tmp2,tmp,tmp2);
Pnt3f particlePos = System->getPosition(ParticleIndex);
Real32 distanceFromAffector = particlePos.dist(Pnt3f(translation.x(),translation.y(),translation.z()));
if((getMaxDistance() < 0.0) || (distanceFromAffector <= getMaxDistance())) //only affect the particle if it is in range
{
Real32 Xparam, Yparam, Zparam;
Pnt3f pos(System->getPosition(ParticleIndex));
getPerlinDistribution()->setPhase(getPhase()[0]);
Xparam = getPerlinDistribution()->generate(pos[0]);
getPerlinDistribution()->setPhase(getPhase()[1]);
Yparam = getPerlinDistribution()->generate(pos[1]);
getPerlinDistribution()->setPhase(getPhase()[2]);
Zparam = getPerlinDistribution()->generate(pos[2]);
Vec3f fieldAffect(Vec3f(Xparam, Yparam, Zparam));
fieldAffect = fieldAffect * (getAmplitude()*
(elps/(OSG::osgClamp<Real32>(1.0f,std::pow(distanceFromAffector,getAttenuation()),TypeTraits<Real32>::getMax()))));
System->setVelocity(System->getVelocity(ParticleIndex) + fieldAffect, ParticleIndex);
} // end distance conditional
} // end null beacon conditional
return false;
}