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


C++ ParticleEmitter类代码示例

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


在下文中一共展示了ParticleEmitter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: isDead

bool ParticleSystem::isDead() const
{
	for(EmitterSet::const_iterator i=emitters.begin();
		i!=emitters.end(); ++i)
	{
		ParticleEmitter *emitter = *i;

		if(!emitter->isDead())
		{
			return false;
		}
	}

	for(ParticleBuckets::const_iterator j=buckets.begin();
		j!=buckets.end(); ++j)
	{
		const ParticleBatch &bucket = j->second;
		const ParticleSet &set = bucket.elements;

		for(ParticleSet::const_iterator i=set.begin(); i!=set.end(); ++i)
		{
			if(!i->isDead())
			{
				return false;
			}
		}
	}

	return true;
}
开发者ID:foxostro,项目名称:heroman,代码行数:30,代码来源:ParticleSystem.cpp

示例2: RemoveParticleLayerNode

void ParticlesEditorController::RemoveParticleLayerNode(LayerParticleEditorNode* layerToRemove)
{
    if (!layerToRemove)
    {
        return;
    }
    
    EmitterParticleEditorNode* emitterNode = layerToRemove->GetEmitterEditorNode();
    if (!emitterNode)
    {
        return;
    }

    ParticleEmitter* emitter = emitterNode->GetParticleEmitter();
    if (!emitter)
    {
        return;
    }
    
    // Lookup for the layer to be removed.
    int32 layerIndex = layerToRemove->GetLayerIndex();
    if (layerIndex == -1)
    {
        return;
    }

	// Reset the selected node in case it is one to be removed.
	CleanupSelectedNodeIfDeleting(layerToRemove);

    // Remove the node from the layers list and also from the emitter.
    emitter->RemoveLayer(layerIndex);
    
    emitterNode->RemoveChildNode(layerToRemove);
}
开发者ID:,项目名称:,代码行数:34,代码来源:

示例3: PerformMoveBetweenEmitters

bool ParticlesEditorController::PerformMoveBetweenEmitters(EmitterParticleEditorNode* oldEmitterNode,
														   EmitterParticleEditorNode* newEmitterNode,
														   LayerParticleEditorNode* layerNodeToMove,
														   LayerParticleEditorNode* layerNodeToInsertAbove)
{
	ParticleEmitter* oldParentEmitter = oldEmitterNode->GetParticleEmitter();
	ParticleEmitter* newParentEmitter = newEmitterNode->GetParticleEmitter();
	if (!oldParentEmitter || !newParentEmitter)
	{
		return false;
	}

	// Move the Editor node. layerNodeToInsertAbove is allowed to be NULL.
	newEmitterNode->AddChildNodeAbove(layerNodeToMove, layerNodeToInsertAbove);
	oldEmitterNode->RemoveChildNode(layerNodeToMove, false);
	
	// Move the Particle Layers themselves.
	ParticleLayer* layerToMove = layerNodeToMove->GetLayer();
	ParticleLayer* layerToInsertAbove = NULL;
	if (layerNodeToInsertAbove)
	{
		layerToInsertAbove = layerNodeToInsertAbove->GetLayer();
	}

	SafeRetain(layerToMove);
	oldParentEmitter->RemoveLayer(layerToMove);
	
	newParentEmitter->AddLayer(layerToMove, layerToInsertAbove);
	SafeRelease(layerToMove);
	
	// Update the emitter.
	layerNodeToMove->UpdateEmitterEditorNode(newEmitterNode);

	return true;
}
开发者ID:,项目名称:,代码行数:35,代码来源:

示例4: GetSelectedNode

void ParticlesEditorController::AddParticleEmitterNodeToScene(Entity* emitterSceneNode)
{
    // We are adding new Emitter to the Particle Effect node just selected.
    Entity* effectNode = NULL;
    BaseParticleEditorNode* selectedNode = GetSelectedNode();
    if (selectedNode)
    {
        effectNode = selectedNode->GetRootNode();
    }
    
    EffectParticleEditorNode* effectEditorNode = GetRootForParticleEffectNode(effectNode);
    if (effectNode && effectEditorNode)
    {
        EmitterParticleEditorNode* emitterEditorNode = new EmitterParticleEditorNode(effectNode, emitterSceneNode,
                                                                                     QString::fromStdString(emitterSceneNode->GetName()));
		
		ParticleEmitter * emitter = GetEmitter(emitterSceneNode);
		if (!emitter)
		{
		    return;
		}
		emitter->SetLifeTime(LIFETIME_FOR_NEW_PARTICLE_EMITTER);

        effectNode->AddNode(emitterSceneNode);
        effectEditorNode->AddChildNode(emitterEditorNode);
    }
}
开发者ID:,项目名称:,代码行数:27,代码来源:

示例5: CloneParticleLayerNode

LayerParticleEditorNode* ParticlesEditorController::CloneParticleLayerNode(LayerParticleEditorNode* layerToClone)
{
    if (!layerToClone || !layerToClone->GetLayer())
    {
        return NULL;
    }
    
    EmitterParticleEditorNode* emitterNode = layerToClone->GetEmitterEditorNode();
    if (!emitterNode)
    {
        return NULL;
    }

    ParticleEmitter* emitter = emitterNode->GetParticleEmitter();
    if (!emitter)
    {
        return NULL;
    }

    ParticleLayer* clonedLayer = layerToClone->GetLayer()->Clone();
    emitter->AddLayer(clonedLayer);
    
    LayerParticleEditorNode* clonedEditorNode = new LayerParticleEditorNode(emitterNode, clonedLayer);
    emitterNode->AddChildNode(clonedEditorNode);

    return clonedEditorNode;
}
开发者ID:,项目名称:,代码行数:27,代码来源:

示例6: Update

void ParticleEmitterSystem::Update(float32 timeElapsed)
{
	uint32 size = emitters.size();
	Vector<ParticleEmitter*> emittersToBeDeleted;

	for(uint32 i = 0; i < size; ++i)
	{
		// Yuri Coder, 2013/05/15. Visible emitters are always updated, "deferred" update
		// is called for invisible ones. See pls issue #DF-1140.
		uint32 flags = emitters[i]->GetFlags();
        if ((flags & RenderObject::VISIBILITY_CRITERIA) == RenderObject::VISIBILITY_CRITERIA)
        {
            emitters[i]->Update(timeElapsed);
        }
		else
		{
			emitters[i]->DeferredUpdate(timeElapsed);
		}

		if (emitters[i]->IsToBeDeleted())
		{
			emittersToBeDeleted.push_back(emitters[i]);
		}
	}

	for(Vector<ParticleEmitter*>::iterator it = emittersToBeDeleted.begin(); it != emittersToBeDeleted.end(); ++it)
	{
		ParticleEmitter* partEmitter = (*it);
		RenderSystem* renderSystem = partEmitter->GetRenderSystem();
	
		renderSystem->RemoveFromRender(partEmitter);
		SafeRelease(partEmitter);
	}
}
开发者ID:,项目名称:,代码行数:34,代码来源:

示例7: SynchronizeEmitterParticleEditorNode

void ParticlesEditorSceneModelHelper::SynchronizeEmitterParticleEditorNode(EmitterParticleEditorNode* node)
{
    if (!node)
    {
        return;
    }

    ParticleEmitter* emitter = node->GetParticleEmitter();
    if (!emitter)
    {
        return;
    }

    int layersCountInEmitter = emitter->GetLayers().size();
    int layersCountInEmitterNode = node->GetLayersCount();

    if (layersCountInEmitter > 0 && layersCountInEmitterNode == 0)
    {
        // Emitter Node has no layers - need to add them.
        for (int32 i = 0; i < layersCountInEmitter; i ++)
        {
            // Create the new node and add it to the tree.
            LayerParticleEditorNode* layerNode = new LayerParticleEditorNode(node, emitter->GetLayers()[i]);
            node->AddNode(layerNode);
        }
     }
}
开发者ID:droidenko,项目名称:dava.framework,代码行数:27,代码来源:ParticlesEditorSceneModelHelper.cpp

示例8: assert

void ParticleGroup::Clone( ParticleGroup *p )
{
	assert(p);

	p->m_pDevice = m_pDevice;
	//p->m_b2DParticle = m_b2DParticle;
	p->m_CoordinateSystem = m_CoordinateSystem;
	p->m_bRotationTexture = m_bRotationTexture;
	//p->m_SceneBlendType = m_SceneBlendType;
	p->m_fDefaultHeight = m_fDefaultHeight;
	p->m_fDefaultWidth = m_fDefaultWidth;
	p->m_CommonDirection = m_CommonDirection;
	p->m_CommonUp = m_CommonUp;
	p->SetPoolSize( m_uiPoolSize );


	p->m_TextureName = m_TextureName;
	p->m_pTexture = m_pTexture;
	if(m_pTexture)
	{
		m_pTexture->AddRef();
		p->m_bAnimationTexture = m_bAnimationTexture;	
		p->m_iSide = m_iSide;
		p->m_iNumFrame = m_iNumFrame;
		p->m_fTexAnimDuration = m_fTexAnimDuration;
		p->m_fTexDelta = m_fTexDelta;
	}

	p->m_BillboardType = m_BillboardType;
	p->m_CommonUp = m_CommonUp;

	ParticleEmitter *pSrcEmitter = NULL;
	ParticleEmitter *pDestEmitter = NULL;
	ParticleEmitterVector::iterator iEmit = m_Emitters.begin();
	for( ; iEmit != m_Emitters.end(); ++iEmit )
	{
		pSrcEmitter = (*iEmit);
		// 调用p的CreateEmitter,因为内部要为每个Emitter设置父
		pDestEmitter = p->CreateEmitter( pSrcEmitter->m_Type );
		if(pDestEmitter)
		{
			pSrcEmitter->Clone( pDestEmitter );
			p->AddEmitter(pDestEmitter);
		}
	}

	//ParticleAffector *pSrcAffector = NULL;
	//ParticleAffector *pDestAffector = NULL;
	//ParticleAffectorVector::iterator iAffect = m_Affectors.begin();
	/*for( ; iAffect != m_Affectors.end(); ++iAffect )
	{
		pSrcAffector = (*iAffect);
		pDestAffector = p->CreateAffector( pSrcAffector->m_Type );
		if(pDestAffector)
		{
			pSrcAffector->Clone(pDestAffector);
			p->AddAffector(pDestAffector);
		}
	}*/
}
开发者ID:ly772696417,项目名称:XianXiaLegend,代码行数:60,代码来源:ParticleSystem.cpp

示例9: GP_ERROR

ParticleEmitter* ParticleEmitter::create(const char* textureFile, TextureBlending textureBlending, unsigned int particleCountMax)
{
    Texture* texture = NULL;
    texture = Texture::create(textureFile, false);

    if (!texture)
    {
        GP_ERROR("Failed to create texture for particle emitter.");
        return NULL;
    }
    GP_ASSERT(texture->getWidth());
    GP_ASSERT(texture->getHeight());

    // Use default SpriteBatch material.
    SpriteBatch* batch =  SpriteBatch::create(texture, NULL, particleCountMax);
    texture->release(); // batch owns the texture.
    GP_ASSERT(batch);

    ParticleEmitter* emitter = new ParticleEmitter(batch, particleCountMax);
    GP_ASSERT(emitter);

    // By default assume only one frame which uses the entire texture.
    emitter->setTextureBlending(textureBlending);
    emitter->_spriteTextureWidth = texture->getWidth();
    emitter->_spriteTextureHeight = texture->getHeight();
    emitter->_spriteTextureWidthRatio = 1.0f / (float)texture->getWidth();
    emitter->_spriteTextureHeightRatio = 1.0f / (float)texture->getHeight();

    Rectangle texCoord((float)texture->getWidth(), (float)texture->getHeight());
    emitter->setSpriteFrameCoords(1, &texCoord);

    return emitter;
}
开发者ID:AllenPestaluky,项目名称:GamePlay,代码行数:33,代码来源:ParticleEmitter.cpp

示例10: updateTerrain

/** If necessary defines a new particle type for the terrain emitter. Then 
 *  adjusts the location of the terrain emitter to be in synch with the 
 *  current wheel position, and defines the emission rate depending on speed,
 *  steering, and skidding.
 *  \param pk Particle type to use.
 */
void KartGFX::updateTerrain(const ParticleKind *pk)
{
   ParticleEmitter *pe = m_all_emitters[KGFX_TERRAIN];
    if(!pe) return;

    pe->setParticleType(pk);
 
    const btWheelInfo &wi = m_kart->getVehicle()
                                  ->getWheelInfo(2+m_wheel_toggle);
    Vec3 xyz = wi.m_raycastInfo.m_contactPointWS;
    // FIXME: the X and Z position is not always accurate.
    xyz.setX(xyz.getX()+ 0.06f * (m_wheel_toggle ? +1 : -1));
    xyz.setZ(xyz.getZ()+0.06f);
    pe->setPosition(xyz);

    // Now compute the particle creation rate:
    float rate           = 0;
    const float speed    = fabsf(m_kart->getSpeed());
    const float skidding = m_kart->getSkidding()->getSkidFactor();
    // Only create particles when the kart is actually on ground
    bool on_ground       = m_kart->isOnGround() &&
                           m_kart->getSkidding()->getGraphicalJumpOffset()==0;
    if (skidding > 1.0f && on_ground)
        rate = fabsf(m_kart->getControls().m_steer) > 0.8 ? skidding - 1 : 0;
    else if (speed >= 0.5f && on_ground)
        rate = speed/m_kart->getKartProperties()->getMaxSpeed();
    else
    {
        pe->setCreationRateAbsolute(0);
        return;
    }
    // m_skidding can be > 2, and speed > maxSpeed (if powerups are used).
    if(rate>1.0f) rate = 1.0f;
    pe->setCreationRateRelative(rate);
}   // updateTerrain
开发者ID:kiennguyen1994,项目名称:game-programming-cse-hcmut-2012,代码行数:41,代码来源:kart_gfx.cpp

示例11: setMaskBits

void ParticleEmitterNode::setEmitterDataBlock(ParticleEmitterData* data)
{
   if ( isServerObject() )
   {
      setMaskBits( EmitterDBMask );
   }
   else
   {
      ParticleEmitter* pEmitter = NULL;
      if ( data )
      {
         // Create emitter with new datablock
         pEmitter = new ParticleEmitter;
         pEmitter->onNewDataBlock( data, false );
         if( pEmitter->registerObject() == false )
         {
            Con::warnf(ConsoleLogEntry::General, "Could not register base emitter for particle of class: %s", data->getName() ? data->getName() : data->getIdString() );
            delete pEmitter;
            return;
         }
      }

      // Replace emitter
      if ( mEmitter )
         mEmitter->deleteWhenEmpty();

      mEmitter = pEmitter;
   }

   mEmitterDatablock = data;
}
开发者ID:Adhdcrazzy,项目名称:Torque3D,代码行数:31,代码来源:particleEmitterNode.cpp

示例12: QString

void CommandLoadInnerEmitterFromYaml::Execute()
{
    BaseParticleEditorNode* selectedNode = ParticlesEditorController::Instance()->GetSelectedNode();
    InnerEmitterParticleEditorNode* innerEmitterNode = dynamic_cast<InnerEmitterParticleEditorNode*>(selectedNode);
    if (!innerEmitterNode || !innerEmitterNode->GetInnerEmitter() ||!innerEmitterNode->GetParticleLayer())
    {
        return;
    }
    
    QString projectPath = QString(EditorSettings::Instance()->GetParticlesConfigsPath().GetAbsolutePathname().c_str());
	QString filePath = QFileDialog::getOpenFileName(NULL, QString("Open Particle Emitter Yaml file"),
                                                    projectPath, QString("YAML File (*.yaml)"));
	if (filePath.isEmpty())
    {
		return;
    }

    ParticleEmitter* innerEmitter = innerEmitterNode->GetInnerEmitter();
    innerEmitter->LoadFromYaml(filePath.toStdString());

	// No additional NULL check is needed here - already performed at the beginning.
	QFileInfo fileInfo(filePath);
	ParticleLayer* innerEmitterLayer = innerEmitterNode->GetParticleLayer();
	innerEmitterLayer->innerEmitterPath = FilePath(fileInfo.path().toStdString(), fileInfo.fileName().toStdString());

	// Perform the validation of the Yaml file loaded.
	String validationMessage;
	if (ParticlesEditorSceneDataHelper::ValidateParticleEmitter(innerEmitter, validationMessage) == false)
	{
		ShowErrorDialog(validationMessage);
	}

    QtMainWindowHandler::Instance()->RefreshSceneGraph();
}
开发者ID:,项目名称:,代码行数:34,代码来源:

示例13: ParticleEmitter

//----------------------------------------------------------------------------
PX2::Movable *EditMap::CreateParticlesToEffect (PX2::Node *node)
{
	ParticleEmitter *emitter = new0 ParticleEmitter();
	emitter->SetName("NewParticleEmitter");
	node->AttachChild(emitter);
	return emitter;
}
开发者ID:manyxu,项目名称:Phoenix3D_2.0,代码行数:8,代码来源:PX2EditMap.cpp

示例14: GetEmitter

void SpritePackerHelper::ReloadParticleSprites(SceneData* sceneData)
{
	List<Entity*> particleEffects;
	sceneData->GetAllParticleEffects(particleEffects);

	for (auto it = particleEffects.begin(); it != particleEffects.end(); ++it)
	{
		Entity* curNode = (*it);
	    ParticleEffectComponent * effectComponent = cast_if_equal<ParticleEffectComponent*>(curNode->GetComponent(Component::PARTICLE_EFFECT_COMPONENT));
		
		if (!effectComponent)
		{
			continue;
		}

		effectComponent->Stop();

		// All the children of this Scene Node must have Emitter components.
		int32 emittersCount = curNode->GetChildrenCount();
		for (int32 i = 0; i < emittersCount; i ++)
		{
			Entity* childNode = curNode->GetChild(i);
			ParticleEmitter * emitter = GetEmitter(childNode);

			if (!emitter)
			{
				continue;
			}
			
			emitter->ReloadLayerSprites();
		}

		effectComponent->Start();
	}
}
开发者ID:vilonosec,项目名称:dava.framework,代码行数:35,代码来源:SpritePackerHelper.cpp

示例15: compileEmitter

	void ParticleScriptCompiler::compileEmitter(const ScriptNodePtr &node)
	{
		if(node->children.empty() || node->children.front()->type != SNT_WORD)
			return;

		// Create the emitter based on the first child
		ParticleEmitter *emitter = 0;
		String type = node->children.front()->token;
		try{
			emitter = mSystem->addEmitter(type);
		}catch(...){
			addError(CE_OBJECTALLOCATIONERROR, node->children.front()->file, 
				node->children.front()->line, node->children.front()->column);
			return;
		}

		// Jump ahead now to the '{' as the emitter does not support other parameters in the header
		ScriptNodeList::iterator i = findNode(node->children.begin(), node->children.end(), SNT_LBRACE);
		if(i == node->children.end())
			return;

		ScriptNodeList::iterator j = (*i)->children.begin();
		while(j != (*i)->children.end())
		{
			if(!processNode(j, (*i)->children.end()))
			{
				String name = (*j)->token, 
					value = getParameterValue((*j)->children.begin(), (*j)->children.end());
				if(!emitter->setParameter(name, value))
					addError(CE_INVALIDPROPERTY, (*j)->file, (*j)->line, (*j)->column);
				++j;
			}
		}
	}
开发者ID:Anti-Mage,项目名称:ogre,代码行数:34,代码来源:OgreParticleScriptCompiler.cpp


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