本文整理汇总了C++中Noise::sampleFloat方法的典型用法代码示例。如果您正苦于以下问题:C++ Noise::sampleFloat方法的具体用法?C++ Noise::sampleFloat怎么用?C++ Noise::sampleFloat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Noise
的用法示例。
在下文中一共展示了Noise::sampleFloat方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setFogModel
void ParticleSystem::setFogModel(const Color4& color, int materialIndex) {
const Color4unorm8 c(Color4(color.r, color.g, color.b, pow(color.a, 1.0f / SmokeVolumeSet::PARTICLE_GAMMA)));
Random rnd;
Noise noise;
m_particle.resize(5000);
m_physicsData.resize(m_particle.size());
for (int i = 0; i < m_particle.size(); ++i) {
SmokeVolumeSet::Particle& particle = m_particle[i];
PhysicsData& physicsData = m_physicsData[i];
// Fill sponza
particle.position = Point3(rnd.uniform(-16, 14), pow(rnd.uniform(0, 1), 4.0f) * 4 + 0.5f, rnd.uniform(-6.5, 6.5));
/*
if (rnd.uniform() < 0.3f) {
// Arena bridge
particle.position = Point3(rnd.uniform(-14, 14) - 2.0f, pow(rnd.uniform(0, 1), 5.0f) * 16.0f + 7.2f, rnd.uniform(-8, 8) - 28.0f);
} else {
// Arena everywhere
particle.position = Point3(rnd.uniform(-20, 20), pow(rnd.uniform(0, 1), 5.0f) * 12.0f + 7.2f, rnd.uniform(-20, 20));
}
*/
particle.angle = rnd.uniform(0.0f, 2.0f) * pif();
particle.materialIndex = materialIndex;
particle.radius = 1.0f;
particle.emissive = 0.0f;
particle.color = c;
int r = rnd.integer(0, 15);
particle.color.r = unorm8::fromBits(r + particle.color.r.bits());
particle.color.g = unorm8::fromBits(r + particle.color.g.bits());
particle.color.b = unorm8::fromBits(r + particle.color.b.bits());
physicsData.angularVelocity = 0;//rnd.uniform(-1.0f, 1.0f) * (360.0f * units::degrees()) / (5.0f * units::seconds());
// Unique values every 5m for the lowest frequencies
const Vector3int32 intPos(particle.position * ((1 << 16) / (5 * units::meters())));
const float acceptProbability = pow(max(0.0f, noise.sampleFloat(intPos.x, intPos.y, intPos.z, 5)), 2.0f);
if (rnd.uniform() > acceptProbability) {
// Reject this puff
--i;
}
}
// Ensure that this matches
m_physicsData.resize(m_particle.size());
}