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);
        }
     }
}
Example #2
0
void SpritePackerHelper::EnumerateSpritesForReloading(SceneData* sceneData, Map<String, Sprite *> &sprites)
{
    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;
			}
			
            Vector<ParticleLayer*> & layers = emitter->GetLayers();
            int32 layersCount = layers.size();
            for (int il = 0; il < layersCount; ++il)
            {
                Sprite *sprite = layers[il]->GetSprite();
                sprites[sprite->GetRelativePathname()] = sprite;
            }
		}
        
		effectComponent->Start();
	}
}
Example #3
0
int32 LayerParticleEditorNode::GetLayerIndex() const
{
    ParticleEmitter* emitter = GetParticleEmitter();
    if (!emitter)
    {
        return -1;
    }
    
    const Vector<ParticleLayer*>& layers = emitter->GetLayers();
    int32 layersCount = layers.size();
    
    for (int32 i = 0; i < layersCount; i ++)
    {
        if (layers[i] == this->layer)
        {
            return i;
        }
    }
    
    return -1;
}