本文整理汇总了C++中ParticleEmitter::getPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ ParticleEmitter::getPosition方法的具体用法?C++ ParticleEmitter::getPosition怎么用?C++ ParticleEmitter::getPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParticleEmitter
的用法示例。
在下文中一共展示了ParticleEmitter::getPosition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: controlEvent
void ParticlesGame::controlEvent(Control* control, EventType evt)
{
std::string id = control->getId();
// Handle UI events.
ParticleEmitter* emitter = _particleEmitterNode->getParticleEmitter();
switch(evt)
{
case Listener::VALUE_CHANGED:
if (control == _startRed)
{
Vector4 startColor = emitter->getColorStart();
startColor.x = _startRed->getValue();
emitter->setColor(startColor, emitter->getColorStartVariance(), emitter->getColorEnd(), emitter->getColorEndVariance());
}
else if (control == _startGreen)
{
Vector4 startColor = emitter->getColorStart();
startColor.y = _startGreen->getValue();
emitter->setColor(startColor, emitter->getColorStartVariance(), emitter->getColorEnd(), emitter->getColorEndVariance());
}
else if (control == _startBlue)
{
Vector4 startColor = emitter->getColorStart();
startColor.z = _startBlue->getValue();
emitter->setColor(startColor, emitter->getColorStartVariance(), emitter->getColorEnd(), emitter->getColorEndVariance());
}
else if (control == _startAlpha)
{
Vector4 startColor = emitter->getColorStart();
startColor.w = _startAlpha->getValue();
emitter->setColor(startColor, emitter->getColorStartVariance(), emitter->getColorEnd(), emitter->getColorEndVariance());
}
else if (control == _endRed)
{
Vector4 endColor = emitter->getColorEnd();
endColor.x = _endRed->getValue();
emitter->setColor(emitter->getColorStart(), emitter->getColorStartVariance(), endColor, emitter->getColorEndVariance());
}
else if (control == _endGreen)
{
Vector4 endColor = emitter->getColorEnd();
endColor.y = _endGreen->getValue();
emitter->setColor(emitter->getColorStart(), emitter->getColorStartVariance(), endColor, emitter->getColorEndVariance());
}
else if (control == _endBlue)
{
Vector4 endColor = emitter->getColorEnd();
endColor.z = _endBlue->getValue();
emitter->setColor(emitter->getColorStart(), emitter->getColorStartVariance(), endColor, emitter->getColorEndVariance());
}
else if (control == _endAlpha)
{
Vector4 endColor = emitter->getColorEnd();
endColor.w = _endAlpha->getValue();
emitter->setColor(emitter->getColorStart(), emitter->getColorStartVariance(), endColor, emitter->getColorEndVariance());
}
else if (control == _startMin)
{
emitter->setSize(_startMin->getValue(), emitter->getSizeStartMax(), emitter->getSizeEndMin(), emitter->getSizeEndMax());
}
else if (control == _startMax)
{
emitter->setSize(emitter->getSizeStartMin(), _startMax->getValue(), emitter->getSizeEndMin(), emitter->getSizeEndMax());
}
else if (control == _endMin)
{
emitter->setSize(emitter->getSizeStartMin(), emitter->getSizeStartMax(), _endMin->getValue(), emitter->getSizeEndMax());
}
else if (control == _endMax)
{
emitter->setSize(emitter->getSizeStartMin(), emitter->getSizeStartMax(), emitter->getSizeEndMin(), _endMax->getValue());
}
else if (control == _energyMin)
{
emitter->setEnergy(_energyMin->getValue(), emitter->getEnergyMax());
}
else if (control == _energyMax)
{
emitter->setEnergy(emitter->getEnergyMin(), _energyMax->getValue());
}
else if (control == _emissionRate)
{
emitter->setEmissionRate(_emissionRate->getValue());
}
else if (id == "posX")
{
Vector3 pos(emitter->getPosition());
pos.x = ((Slider*)control)->getValue();
emitter->setPosition(pos, emitter->getPositionVariance());
}
else if (id == "posY")
{
Vector3 pos(emitter->getPosition());
pos.y = ((Slider*)control)->getValue();
emitter->setPosition(pos, emitter->getPositionVariance());
}
else if (id == "posZ")
{
Vector3 pos(emitter->getPosition());
//.........这里部分代码省略.........
示例2: saveFile
void ParticlesGame::saveFile()
{
std::string filename;
filename = FileSystem::displayFileDialog(FileSystem::SAVE, "Save Particle File", "Particle Files", "particle", "res");
if (filename.length() == 0)
return;
ParticleEmitter* e = _particleEmitter;
// Extract just the particle name from the filename
std::string dir = FileSystem::getDirectoryName(filename.c_str());
std::string ext = FileSystem::getExtension(filename.c_str());
std::string name = filename.substr(dir.length(), filename.length() - dir.length() - ext.length());
Texture* texture = e->getTexture();
std::string texturePath = texture->getPath();
std::string textureDir = FileSystem::getDirectoryName(texturePath.c_str());
texturePath = texturePath.substr(textureDir.length());
// Get camera rotation as axis-angle
Vector3 cameraAxis;
float cameraAngle = MATH_RAD_TO_DEG(_cameraParent->getRotation().toAxisAngle(&cameraAxis));
// Write out a properties file
std::ostringstream s;
s <<
"particle " << name << "\n" <<
"{\n" <<
" sprite\n" <<
" {\n" <<
" path = " << texturePath << "\n" <<
" width = " << e->getSpriteWidth() << "\n" <<
" height = " << e->getSpriteHeight() << "\n" <<
" blending = " << toString(e->getTextureBlending()) << "\n" <<
" animated = " << toString(e->isSpriteAnimated()) << "\n" <<
" looped = " << toString(e->isSpriteLooped()) << "\n" <<
" frameCount = " << e->getSpriteFrameCount() << "\n" <<
" frameRandomOffset = " << e->getSpriteFrameRandomOffset() << "\n" <<
" frameDuration = " << e->getSpriteFrameDuration() << "\n" <<
" }\n" <<
"\n" <<
" particleCountMax = " << e->getParticleCountMax() << "\n" <<
" emissionRate = " << e->getEmissionRate() << "\n" <<
" ellipsoid = " << toString(e->isEllipsoid()) << "\n" <<
" orbitPosition = " << toString(e->getOrbitPosition()) << "\n" <<
" orbitVelocity = " << toString(e->getOrbitVelocity()) << "\n" <<
" orbitAcceleration = " << toString(e->getOrbitAcceleration()) << "\n" <<
" sizeStartMin = " << e->getSizeStartMin() << "\n" <<
" sizeStartMax = " << e->getSizeStartMax() << "\n" <<
" sizeEndMin = " << e->getSizeEndMin() << "\n" <<
" sizeEndMax = " << e->getSizeEndMax() << "\n" <<
" energyMin = " << e->getEnergyMin() << "\n" <<
" energyMax = " << e->getEnergyMax() << "\n" <<
" colorStart = " << toString(e->getColorStart()) << "\n" <<
" colorStartVar = " << toString(e->getColorStartVariance()) << "\n" <<
" colorEnd = " << toString(e->getColorEnd()) << "\n" <<
" colorEndVar = " << toString(e->getColorEndVariance()) << "\n" <<
" position = " << toString(e->getPosition()) << "\n" <<
" positionVar = " << toString(e->getPositionVariance()) << "\n" <<
" velocity = " << toString(e->getVelocity()) << "\n" <<
" velocityVar = " << toString(e->getVelocityVariance()) << "\n" <<
" acceleration = " << toString(e->getAcceleration()) << "\n" <<
" accelerationVar = " << toString(e->getAccelerationVariance()) << "\n" <<
" rotationPerParticleSpeedMin = " << e->getRotationPerParticleSpeedMin() << "\n" <<
" rotationPerParticleSpeedMax = " << e->getRotationPerParticleSpeedMax() << "\n" <<
"\n" <<
" editor\n" <<
" {\n" <<
" cameraTranslation = " << toString(_cameraParent->getTranslation()) << "\n" <<
" cameraZoom = " << toString(_scene->getActiveCamera()->getNode()->getTranslation()) << "\n" <<
" cameraRotation = " << toString(cameraAxis) << ", " << cameraAngle << "\n" <<
" sizeMax = " << _startMax->getMax() << "\n" <<
" energyMax = " << _energyMax->getMax() << "\n" <<
" }\n"
"}\n";
std::string text = s.str();
Stream* stream = FileSystem::open(filename.c_str(), FileSystem::WRITE);
stream->write(text.c_str(), 1, text.length());
stream->close();
SAFE_DELETE(stream);
}