当前位置: 首页>>代码示例>>C++>>正文


C++ ParticleEmitter::start方法代码示例

本文整理汇总了C++中ParticleEmitter::start方法的典型用法代码示例。如果您正苦于以下问题:C++ ParticleEmitter::start方法的具体用法?C++ ParticleEmitter::start怎么用?C++ ParticleEmitter::start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ParticleEmitter的用法示例。


在下文中一共展示了ParticleEmitter::start方法的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());
//.........这里部分代码省略.........
开发者ID:Divoo,项目名称:GamePlay,代码行数:101,代码来源:ParticlesGame.cpp

示例2: emitterChanged

void ParticlesGame::emitterChanged()
{
    ParticleEmitter* emitter = _particleEmitter;

    // Set the new emitter on the node.
    _particleEmitterNode->setParticleEmitter(_particleEmitter);
    _particleEmitter->release();

    // Reset camera view and zoom.
    _scene->getActiveCamera()->getNode()->setTranslation(0.0f, 0.0f, 40.0f);
    _cameraParent->setIdentity();
    _particleEmitterNode->setIdentity();

    // Parse editor section of particle properties
    Properties* p = Properties::create(_url.c_str());
    Properties* ns = p->getNamespace("editor", true);
    if (ns)
    {
        Vector3 v3;
        if (ns->getVector3("cameraTranslation", &v3))
        {
            _cameraParent->setTranslation(v3);
        }
        if (ns->getVector3("cameraZoom", &v3))
        {
            _scene->getActiveCamera()->getNode()->setTranslation(v3);
        }
        Quaternion q;
        if (ns->getQuaternionFromAxisAngle("cameraRotation", &q))
        {
            _cameraParent->setRotation(q);
        }
        float f;
        if ((f = ns->getFloat("sizeMax")) != 0.0f)
        {
            _startMin->setMax(f);
            _startMax->setMax(f);
            _endMin->setMax(f);
            _endMax->setMax(f);
        }
        if ((f = ns->getFloat("energyMax")) != 0.0f)
        {
            _energyMin->setMax(f);
            _energyMax->setMax(f);
        }
    }
    SAFE_DELETE(p);

    // Set the values of UI controls to display the new emitter's settings.
    _startRed->setValue(emitter->getColorStart().x);
    _startGreen->setValue(emitter->getColorStart().y);
    _startBlue->setValue(emitter->getColorStart().z);
    _startAlpha->setValue(emitter->getColorStart().w);    

    _endRed->setValue(emitter->getColorEnd().x);
    _endGreen->setValue(emitter->getColorEnd().y);
    _endBlue->setValue(emitter->getColorEnd().z);
    _endAlpha->setValue(emitter->getColorEnd().w);

    _startMin->setValue(emitter->getSizeStartMin());
    _startMax->setValue(emitter->getSizeStartMax());
    _endMin->setValue(emitter->getSizeEndMin());
    _endMax->setValue(emitter->getSizeEndMax());

    _energyMin->setValue(emitter->getEnergyMin());
    _energyMax->setValue(emitter->getEnergyMax());

    _emissionRate->setValue(emitter->getEmissionRate());

    const Vector3& posVar = emitter->getPositionVariance();
    _posVarX->setValue(posVar.x);
    _posVarY->setValue(posVar.y);
    _posVarZ->setValue(posVar.z);

    const Vector3& vel = emitter->getVelocity();
    _velX->setValue(vel.x);    
    _velY->setValue(vel.y);
    _velZ->setValue(vel.z);

    const Vector3& velVar = emitter->getVelocityVariance();
    _velVarX->setValue(velVar.x);
    _velVarY->setValue(velVar.y);
    _velVarZ->setValue(velVar.z);

    const Vector3& accel = emitter->getAcceleration();
    _accelX->setValue(accel.x);
    _accelY->setValue(accel.y);
    _accelZ->setValue(accel.z);

    const Vector3& accelVar = emitter->getAccelerationVariance();
    _accelVarX->setValue(accelVar.x);
    _accelVarY->setValue(accelVar.y);
    _accelVarZ->setValue(accelVar.z);

    _spinSpeedMin->setValue(emitter->getRotationPerParticleSpeedMin());
    _spinSpeedMax->setValue(emitter->getRotationPerParticleSpeedMax());

    const Vector3& axis = emitter->getRotationAxis();
    _axisX->setValue(axis.x);
    _axisY->setValue(axis.y);    
//.........这里部分代码省略.........
开发者ID:Divoo,项目名称:GamePlay,代码行数:101,代码来源:ParticlesGame.cpp


注:本文中的ParticleEmitter::start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。