本文整理汇总了C++中ParticleSystem::addEmitter方法的典型用法代码示例。如果您正苦于以下问题:C++ ParticleSystem::addEmitter方法的具体用法?C++ ParticleSystem::addEmitter怎么用?C++ ParticleSystem::addEmitter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParticleSystem
的用法示例。
在下文中一共展示了ParticleSystem::addEmitter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: makeSprinkler
void makeSprinkler () {
particleSystem.removeAllEmitters();
double startOffset;
double sideOffset;
double sideOffsetRange = 0;
double angle = 90;
double angleDiff = 360.0 / emitterCount;
double sideBetweenEmitters = sideOffsetRange / emitterCount;
if (emitterCount % 2 == 0) {
startOffset = ((emitterCount / 2) - 0.5) * emitterSpacing;
sideOffset = ((emitterCount / 2) - 0.5) * sideBetweenEmitters;
} else {
startOffset = ((emitterCount - 1) / 2) * emitterSpacing;
sideOffset = ((emitterCount / 2) - 0.5) * sideBetweenEmitters;
}
Vector3 emitterLocation = Vector3(-startOffset, -20.0, 0);
Vector3 betweenEmitters = Vector3(emitterSpacing, 0, 0);
sideOffset = -sideOffset;
for (int i = 0; i < emitterCount; i++) {
emitterLocation.y = -20 + sin(angle * (M_PI / 180)) * sprinkerHeight;
particleSystem.addEmitter(ParticleEmitter(emitterLocation, Vector3(0.0, -20.0, sideOffset)));
emitterLocation.addSelf(betweenEmitters);
sideOffset += sideBetweenEmitters;
angle += angleDiff;
}
}
示例2: makeFountain
void makeFountain () {
emitterSpacing = 0;
particleSystem.removeAllEmitters();
Vector3 emitterLocation = Vector3(0, 0, 0);
double sideOffsetRange = 50;
for (int i = 0; i < emitterCount; i++) {
particleSystem.addEmitter(ParticleEmitter(emitterLocation, Vector3(0.0, -30.0, -sideOffsetRange * std::cos(((360 / emitterCount) * i) * (M_PI / 180)))));
}
}
示例3: loadConfiguredSystem
ParticleSystem* ParticleIO::loadConfiguredSystem(string ref, const Color& mask) {
TiXmlDocument m_xmldocument(ref.c_str());
bool loadOkay = m_xmldocument.LoadFile();
if (!loadOkay) {
ErrorDialog::createAndShow(StringUtil::append("Could not load Particle System: ", ref));
exit(0);
}
ParticleSystem* sys = new ParticleSystem(new Image("data/particle.png", mask));
TiXmlElement* rootelement = m_xmldocument.FirstChildElement("system");
if (rootelement == NULL) {
ErrorDialog::createAndShow(string("Invalid particle system file. Root node must be <system>."));
}
if (strcmp(rootelement->Attribute("additive"), "true") == 0) {
sys->setBlendingMode(ParticleSystem::BLEND_ADDITIVE);
} else {
sys->setBlendingMode(ParticleSystem::BLEND_COMBINE);
}
const char* points = rootelement->Attribute("points");
if (points != NULL) {
sys->setUsePoints(strcmp(points, "true") == 0);
}
TiXmlElement* emitter = 0;
for (emitter = rootelement->FirstChildElement("emitter");
emitter;
emitter = emitter->NextSiblingElement("emitter")) {
ConfigurableEmitter* e = new ConfigurableEmitter("new");
elementToEmitter(e, emitter);
sys->addEmitter(e);
}
sys->setRemoveCompletedEmitters(false);
return sys;
}