예제 #1
0
void
WXEffectEditDialog::OnPropertyChanged(wxPropertyGridEvent& e)
{
	// Skip parent properties
    if (e.GetPropertyPtr()->GetParentingType() != 0)
        return;
        
	wxPGId id = e.GetPropertyPtr()->GetId();
	wxPGId parentId = mPropertiesViewer->GetPropertyParent(id);

	const wxString &parentLabel = mPropertiesViewer->GetPropertyLabel(parentId);

	unsigned short index = mPropertiesViewer->GetPropertyIndex(parentId);

	Fairy::String propertyName = e.GetPropertyName().c_str();
	Fairy::String propertyValue = e.GetPropertyValueAsString().c_str();

	Fairy::Scene::ObjectsByTypeRange effects =
		mSceneManipulator->getSceneInfo()->findObjectsByType(Fairy::EffectObject::msType);

	for (Fairy::Scene::ObjectsByTypeIterator it = effects.first; it != effects.second; ++it)
	{
		const Fairy::ObjectPtr& object = *it;
		const Fairy::EffectObject* effectObject = static_cast<Fairy::EffectObject *>(object.get());

		Fairy::Effect *effect = effectObject->getEffect();

		assert (effect);

		// 现在做的是直接对模板的修改,所以要修改全部的同个模板的特效
		if ( effect->getTemplateName() == mEffect->getTemplateName() )
		{
			if (index < effect->getNumElements())
			{
				Fairy::EffectElement *element = effect->getElement(index);
				assert (element);

				element->setParameter(propertyName, propertyValue);
			}
			else
			{
				effect->setParameter(propertyName, propertyValue);
			}
		}
	}

    // 更新当前的skill
    if (gEffectSettingGlobalData.mCurrentSkill)
    {
        for ( unsigned short i = 0; i < gEffectSettingGlobalData.mCurrentSkill->getNumAnimationEffectInfos(); ++i )
        {
            Fairy::AnimationEffectInfo *effectInfo = gEffectSettingGlobalData.mCurrentSkill->getAnimationEffectInfo(i);
            assert (effectInfo);

            Fairy::Effect *effect = effectInfo->getEffect();

            assert (effect);

            // 现在做的是直接对模板的修改,所以要修改全部的同个模板的特效
            if ( effect->getTemplateName() == mEffect->getTemplateName() )
            {
                if (index < effect->getNumElements())
                {
                    Fairy::EffectElement *element = effect->getElement(index);
                    assert (element);

                    element->setParameter(propertyName, propertyValue);
                }
                else
                {
                    effect->setParameter(propertyName, propertyValue);
                }
            }
        }
    }
}
예제 #2
0
void MaterialEditorDialog::setMeshMaterial(void)
{
	Fairy::Scene::ObjectsByTypeRange particles =
		mSceneManipulator->getSceneInfo()->findObjectsByType(Fairy::ParticleSystemObject::msType);

	for (Fairy::Scene::ObjectsByTypeIterator it = particles.first; it != particles.second; ++it)
	{
		const Fairy::ObjectPtr& object = *it;
		Fairy::ParticleSystemObject* particleObject = static_cast<Fairy::ParticleSystemObject *>(object.get());

		Ogre::ParticleSystem *system = particleObject->getParticleSystem();
		Ogre::String templateName = particleObject->getPropertyAsString("particle system name");

		// 现在做的是直接对模板的修改,所以要修改全部的同个模板的特效
		if ( system && templateName == gEffectSettingGlobalData.mCurrentParticleTemplateName )
		{
			Ogre::MeshParticleRenderer *renderer = static_cast<Ogre::MeshParticleRenderer *>
				(system->getRenderer());

			assert (renderer->getType() == "mesh");

			renderer->setMaterialName(mCurrentMaterial->getName());
		}
	}

	// 已经创建的effect中的粒子也要相应修改
	Fairy::Scene::ObjectsByTypeRange effects =
		mSceneManipulator->getSceneInfo()->findObjectsByType(Fairy::EffectObject::msType);

	for (Fairy::Scene::ObjectsByTypeIterator it = effects.first; it != effects.second; ++it)
	{
		const Fairy::ObjectPtr& object = *it;
		const Fairy::EffectObject* effectObject = static_cast<Fairy::EffectObject *>(object.get());

		Fairy::Effect *effect = effectObject->getEffect();

		assert (effect);

		for ( size_t i=0; i<effect->getNumElements(); ++i )
		{
			Fairy::EffectElement *element = effect->getElement(i);

			if ( element->getType() == "Particle" )
			{
				Ogre::String name = static_cast<Fairy::ParticleElement *>(element)->getParticleSystemName();
				if (name == gEffectSettingGlobalData.mCurrentParticleTemplateName)
				{
					Ogre::ParticleSystem *system = static_cast<Fairy::ParticleElement *>(element)->getParticleSystem();

					Ogre::MeshParticleRenderer *renderer = static_cast<Ogre::MeshParticleRenderer *>
						(system->getRenderer());

					assert (renderer->getType() == "mesh");

					renderer->setMaterialName(mCurrentMaterial->getName());
				}
			}
		}		
	}

	if (gEffectSettingGlobalData.mCurrentSkill)
	{
		for ( unsigned short i = 0; i < gEffectSettingGlobalData.mCurrentSkill->getNumAnimationEffectInfos(); ++i )
		{
			Fairy::AnimationEffectInfo *effectInfo = gEffectSettingGlobalData.mCurrentSkill->getAnimationEffectInfo(i);
			assert (effectInfo);

			Fairy::Effect *effect = effectInfo->getEffect();

			assert (effect);

			for ( size_t i=0; i<effect->getNumElements(); ++i )
			{
				Fairy::EffectElement *element = effect->getElement(i);

				if ( element->getType() == "Particle" )
				{
					Ogre::String name = static_cast<Fairy::ParticleElement *>(element)->getParticleSystemName();
					if (name == gEffectSettingGlobalData.mCurrentParticleTemplateName)
					{
						Ogre::ParticleSystem *system = static_cast<Fairy::ParticleElement *>(element)->getParticleSystem();

						Ogre::MeshParticleRenderer *renderer = static_cast<Ogre::MeshParticleRenderer *>
							(system->getRenderer());

						assert (renderer->getType() == "mesh");

						renderer->setMaterialName(mCurrentMaterial->getName());
					}
				}
			}		
		}
	}

	Ogre::MeshParticleRenderer *renderer = static_cast<Ogre::MeshParticleRenderer *>
		(gEffectSettingGlobalData.mCurrentParticleSystem->getRenderer());

	assert (renderer->getType() == "mesh");

	renderer->setMaterialName(mCurrentMaterial->getName());
}