예제 #1
0
void SkillObjectEditor::OnNewAnimEffect(wxCommandEvent &e)
{
	if (mSkill)
	{
		AddEffectInfoDialog *dlg = new AddEffectInfoDialog(this, wxID_ANY,
			_("Animation Effect Info"));

		bool ok = (dlg->ShowModal() == wxID_OK);
		if(ok)
		{
			Ogre::String effect = wxDynamicCast(dlg->FindWindow(feID_COMBOCTRL_EFFECT),wxComboBox)->GetValue().c_str();
			Ogre::String locator1 = wxDynamicCast(dlg->FindWindow(feID_COMBOCTRL_LOCATOR),wxComboBox)->GetValue().c_str();

			Fairy::AnimationEffectInfo *effectInfo = mSkill->addAnimationEffectInfo();
			assert (effectInfo);

			effectInfo->setEffectTemplateName(effect);
			effectInfo->setAttachPoint(locator1);

			ResetSkillObject();
			RefreshSkillTree();
			m_Frame->GetGraphDialog()->InitSkillEditor(mSkill,mSkillTemplateName);
			SelectElementItem(effectInfo);
		}

		dlg->Destroy();
	}
}
예제 #2
0
void SkillObjectTree::AddSkillToTree(Fairy::Skill *pSkill)
{
	// 更新模板
	Fairy::Skill *skill = Fairy::EffectManager::getSingleton().getSkill(pSkill->getSkillName());
    skill = pSkill;

	int iSkillImage = SkillObjectTree::TreeCtrlIcon_Skill;
	wxTreeItemId SkillRootId = AddRoot(skill->getSkillName(),
		iSkillImage, iSkillImage,
		new SkillTreeItemData(wxT("Skill root item"),skill->getSkillName(),skill));

	int iPorpertyImage = SkillObjectTree::TreeCtrlIcon_SkilltProperty;

	wxTreeItemId BasicSettingId= AppendItem(SkillRootId,wxT("BasicSetting"),
		iPorpertyImage, iPorpertyImage,
		new SkillTreeItemData(wxT("Skill BasicSetting"),wxT("Skill BasicSetting"),pSkill));

	if ( BasicSettingId.IsOk() )
	{
		const Ogre::ParameterList &paraList = pSkill->getParameters();

		for ( size_t paraCount=0; paraCount < paraList.size(); ++paraCount )
		{
			Ogre::String name = paraList[paraCount].name;
			Ogre::String value = pSkill->getParameter(paraList[paraCount].name);

			wxTreeItemId itemId =AppendItem( BasicSettingId,(name + ":" + value).c_str(),iPorpertyImage,iPorpertyImage,
				new SkillTreeItemData(wxT("Skill property item"),name,skill));
		}
	}

	int iAnimEfectImage = SkillObjectTree::TreeCtrlIcon_AnimEffect;
	int iCameraShakeImage = SkillObjectTree::TreeCtrlIcon_CameraShake;
	int iRibbinImage = SkillObjectTree::TreeCtrlIcon_Ribbon;
	int iSoundImage = SkillObjectTree::TreeCtrlIcon_Sound;
	int iSceneLightImage = SkillObjectTree::TreeCtrlIcon_SceneLight;
	int iBulletFlowImage = SkillObjectTree::TreeCtrlIcon_BulletFlow;


	// 设置effect属性
	for ( unsigned short i=0; i < skill->getNumAnimationEffectInfos(); ++i )
	{
		Fairy::AnimationEffectInfo *effectInfo = skill->getAnimationEffectInfo(i);
		assert (effectInfo);

		Ogre::String effectIndexStr = "Effect Info " + Ogre::StringConverter::toString(i);
		wxTreeItemId AnimEffectId= AppendItem(SkillRootId,effectIndexStr.c_str(),
			iAnimEfectImage, iAnimEfectImage,
			new SkillTreeItemData(wxT("Skill Element"),wxT("AnimEffect"),effectInfo));

		if ( AnimEffectId.IsOk() )
		{

			const Ogre::ParameterList &paraList = effectInfo->getParameters();

			for ( size_t paraCount=0; paraCount < paraList.size(); ++paraCount )
			{
				Ogre::String name = paraList[paraCount].name;
				Ogre::String value = effectInfo->getParameter(paraList[paraCount].name);

				wxTreeItemId itemId =AppendItem( AnimEffectId,(name + ":" + value).c_str(),iPorpertyImage,iPorpertyImage,
					new SkillTreeItemData(wxT("Skill Element item"),name,effectInfo));

			}
		}
	}

	for ( unsigned short i=0; i < skill->getNumAnimationCameraShake(); ++i )
	{
		Fairy::AnimationCameraShake *cameraShake = skill->getAnimationCameraShake(i);

		assert (cameraShake);

		Ogre::String cameraShakeIndexStr = "CameraShake " + Ogre::StringConverter::toString(i);

		wxTreeItemId CameraShakeId= AppendItem(SkillRootId,cameraShakeIndexStr.c_str(),
			iCameraShakeImage, iCameraShakeImage,
			new SkillTreeItemData(wxT("Skill Element"),wxT("CameraShake"),cameraShake));

		if ( CameraShakeId.IsOk() )
		{

			const Ogre::ParameterList &paraList = cameraShake->getParameters();

			for ( size_t paraCount=0; paraCount < paraList.size(); ++paraCount )
			{
				Ogre::String name = paraList[paraCount].name;
				Ogre::String value = cameraShake->getParameter(paraList[paraCount].name);

				wxTreeItemId itemId =AppendItem( CameraShakeId,(name + ":" + value).c_str(),iPorpertyImage,iPorpertyImage,
					new SkillTreeItemData(wxT("Skill Element item"),name,cameraShake));

			}
		}		
	}

	for ( unsigned short i=0; i < skill->getNumAnimationRibbons(); ++i )
	{
		Fairy::AnimationRibbon *ribbon = skill->getAnimationRibbon(i);

		assert (ribbon);

		Ogre::String ribbonIndexStr = "Ribbon " + Ogre::StringConverter::toString(i);

		wxTreeItemId RibbonId= AppendItem(SkillRootId,ribbonIndexStr.c_str(),
			iRibbinImage, iRibbinImage,
			new SkillTreeItemData(wxT("Skill Element"),wxT("Ribbon"),ribbon));

		if ( RibbonId.IsOk() )
		{

			const Ogre::ParameterList &paraList = ribbon->getParameters();

			for ( size_t paraCount=0; paraCount < paraList.size(); ++paraCount )
			{
				Ogre::String name = paraList[paraCount].name;
				Ogre::String value = ribbon->getParameter(paraList[paraCount].name);

				wxTreeItemId itemId =AppendItem( RibbonId,(name + ":" + value).c_str(),iPorpertyImage,iPorpertyImage,
					new SkillTreeItemData(wxT("Skill Element item"),name,ribbon));

			}
		}		
	}

	for ( unsigned short i=0; i < skill->getNumAnimationSounds(); ++i )
	{
		Fairy::AnimationSound *sound = skill->getAnimationSound(i);

		assert (sound);

		Ogre::String soundIndexStr = "Sound " + Ogre::StringConverter::toString(i);

		wxTreeItemId SoundId= AppendItem(SkillRootId,soundIndexStr.c_str(),
			iSoundImage, iSoundImage,
			new SkillTreeItemData(wxT("Skill Element"),wxT("Sound"),sound));

		if ( SoundId.IsOk() )
		{

			const Ogre::ParameterList &paraList = sound->getParameters();

			for ( size_t paraCount=0; paraCount < paraList.size(); ++paraCount )
			{
				Ogre::String name = paraList[paraCount].name;
				Ogre::String value = sound->getParameter(paraList[paraCount].name);

				wxTreeItemId itemId =AppendItem( SoundId,(name + ":" + value).c_str(),iPorpertyImage,iPorpertyImage,
					new SkillTreeItemData(wxT("Skill Element item"),name,sound));

			}
		}	
	}

	for ( unsigned short i=0; i < skill->getNumAnimationSceneLightInfos(); ++i )
	{
		Fairy::AnimationSceneLightInfo *light = skill->getAnimationSceneLightInfo(i);

		assert (light);

		Ogre::String lightIndexStr = "SceneLight " + Ogre::StringConverter::toString(i);

		wxTreeItemId LightId= AppendItem(SkillRootId,lightIndexStr.c_str(),
			iSceneLightImage, iSceneLightImage,
			new SkillTreeItemData(wxT("Skill Element"),wxT("SceneLight"),light));

		if ( LightId.IsOk() )
		{

			const Ogre::ParameterList &paraList = light->getParameters();

			for ( size_t paraCount=0; paraCount < paraList.size(); ++paraCount )
			{
				Ogre::String name = paraList[paraCount].name;
				Ogre::String value = light->getParameter(paraList[paraCount].name);

				wxTreeItemId itemId =AppendItem( LightId,(name + ":" + value).c_str(),iPorpertyImage,iPorpertyImage,
					new SkillTreeItemData(wxT("Skill Element item"),name,light));

			}
		}		
	}

	for ( unsigned short i=0; i < skill->getNumAnimationBulletFlows(); ++i )
	{
		Fairy::AnimationBulletFlow *bulletFlow = skill->getAnimationBulletFlow(i);

		assert (bulletFlow);

		Ogre::String bulletFlowIndexStr = "BulletFlow " + Ogre::StringConverter::toString(i);

		wxTreeItemId BulletFlowId= AppendItem(SkillRootId,bulletFlowIndexStr.c_str(),
			iBulletFlowImage, iBulletFlowImage,
			new SkillTreeItemData(wxT("Skill Element"),wxT("BulletFlow"),bulletFlow));

		if ( BulletFlowId.IsOk() )
		{

			const Ogre::ParameterList &paraList = bulletFlow->getParameters();

			for ( size_t paraCount=0; paraCount < paraList.size(); ++paraCount )
			{
				Ogre::String name = paraList[paraCount].name;
				Ogre::String value = bulletFlow->getParameter(paraList[paraCount].name);

				wxTreeItemId itemId =AppendItem( BulletFlowId,(name + ":" + value).c_str(),iPorpertyImage,iPorpertyImage,
					new SkillTreeItemData(wxT("Skill Element item"),name,bulletFlow));

			}
		}		
	}

	Expand(SkillRootId);

}
예제 #3
0
void BulletTree::AddBulletSystemToTree(Fairy::BulletSystem *pBulletSystem,const Ogre::String &templateName)
{
	int iBulletSystemImage = BulletTree::TreeCtrlIcon_BulletSystem;

	wxTreeItemId rootId = this->GetRootItem();
	if(!rootId.IsOk())
		return;
	wxTreeItemId BulletSystemRootId = AppendItem(rootId,templateName,
		iBulletSystemImage, iBulletSystemImage,
		new BulletTreeItemData(wxT("BulletSystem item"),templateName,pBulletSystem));

	int iAnimEfectImage = BulletTree::TreeCtrlIcon_AnimEffect;
	int iRibbinImage = BulletTree::TreeCtrlIcon_Ribbon;
	int iCameraShakeImage = BulletTree::TreeCtrlIcon_CameraShake;
	int iSoundImage = BulletTree::TreeCtrlIcon_Sound;
	int iSceneLightImage = BulletTree::TreeCtrlIcon_SceneLight;
	int iLineImage = BulletTree::TreeCtrlIcon_Line;
	int iPorpertyImage = BulletTree::TreeCtrlIcon_BulletProperty;


	// ÉèÖÃeffectÊôÐÔ
	for ( unsigned short i=0; i < pBulletSystem->getNumAnimationEffectInfos(); ++i )
	{
		Fairy::AnimationEffectInfo *effectInfo = pBulletSystem->getAnimationEffectInfo(i);
		assert (effectInfo);

		Ogre::String effectIndexStr = "Effect Info " + Ogre::StringConverter::toString(i);
		wxTreeItemId AnimEffectId= AppendItem(BulletSystemRootId,effectIndexStr.c_str(),
			iAnimEfectImage, iAnimEfectImage,
			new BulletTreeItemData(wxT("BulletSystem Element"),wxT("AnimEffect"),effectInfo));

		if ( AnimEffectId.IsOk() )
		{

			const Ogre::ParameterList &paraList = effectInfo->getParameters();

			for ( size_t paraCount=0; paraCount < paraList.size(); ++paraCount )
			{
				Ogre::String name = paraList[paraCount].name;
				Ogre::String value = effectInfo->getParameter(paraList[paraCount].name);

				wxTreeItemId itemId =AppendItem( AnimEffectId,(name + ":" + value).c_str(),iPorpertyImage,iPorpertyImage,
					new BulletTreeItemData(wxT("BulletSystem Element item"),name,effectInfo));

			}
		}
	}

	for ( unsigned short i=0; i < pBulletSystem->getNumAnimationRibbons(); ++i )
	{
		Fairy::AnimationRibbon *ribbon = pBulletSystem->getAnimationRibbon(i);

		assert (ribbon);

		Ogre::String ribbonIndexStr = "Ribbon " + Ogre::StringConverter::toString(i);

		wxTreeItemId RibbonId= AppendItem(BulletSystemRootId,ribbonIndexStr.c_str(),
			iRibbinImage, iRibbinImage,
			new BulletTreeItemData(wxT("BulletSystem Element"),wxT("Ribbon"),ribbon));

		if ( RibbonId.IsOk() )
		{

			const Ogre::ParameterList &paraList = ribbon->getParameters();

			for ( size_t paraCount=0; paraCount < paraList.size(); ++paraCount )
			{
				Ogre::String name = paraList[paraCount].name;
				Ogre::String value = ribbon->getParameter(paraList[paraCount].name);

				wxTreeItemId itemId =AppendItem( RibbonId,(name + ":" + value).c_str(),iPorpertyImage,iPorpertyImage,
					new BulletTreeItemData(wxT("BulletSystem Element item"),name,ribbon));

			}
		}		
	}
	for ( unsigned short i=0; i < pBulletSystem->getNumAnimationCameraShake(); ++i )
	{
		Fairy::AnimationCameraShake *cameraShake = pBulletSystem->getAnimationCameraShake(i);

		assert (cameraShake);

		Ogre::String soundIndexStr = "CameraShake " + Ogre::StringConverter::toString(i);

		wxTreeItemId CamaerShakeId= AppendItem(BulletSystemRootId,soundIndexStr.c_str(),
			iCameraShakeImage, iCameraShakeImage,
			new BulletTreeItemData(wxT("BulletSystem Element"),wxT("CameraShake"),cameraShake));

		if ( CamaerShakeId.IsOk() )
		{

			const Ogre::ParameterList &paraList = cameraShake->getParameters();

			for ( size_t paraCount=0; paraCount < paraList.size(); ++paraCount )
			{
				Ogre::String name = paraList[paraCount].name;
				Ogre::String value = cameraShake->getParameter(paraList[paraCount].name);

				wxTreeItemId itemId =AppendItem( CamaerShakeId,(name + ":" + value).c_str(),iPorpertyImage,iPorpertyImage,
					new BulletTreeItemData(wxT("BulletSystem Element item"),name,cameraShake));

			}
		}	
	}

	for ( unsigned short i=0; i < pBulletSystem->getNumAnimationSounds(); ++i )
	{
		Fairy::AnimationSound *sound = pBulletSystem->getAnimationSound(i);

		assert (sound);

		Ogre::String soundIndexStr = "Sound " + Ogre::StringConverter::toString(i);

		wxTreeItemId SoundId= AppendItem(BulletSystemRootId,soundIndexStr.c_str(),
			iSoundImage, iSoundImage,
			new BulletTreeItemData(wxT("BulletSystem Element"),wxT("Sound"),sound));

		if ( SoundId.IsOk() )
		{

			const Ogre::ParameterList &paraList = sound->getParameters();

			for ( size_t paraCount=0; paraCount < paraList.size(); ++paraCount )
			{
				Ogre::String name = paraList[paraCount].name;
				Ogre::String value = sound->getParameter(paraList[paraCount].name);

				wxTreeItemId itemId =AppendItem( SoundId,(name + ":" + value).c_str(),iPorpertyImage,iPorpertyImage,
					new BulletTreeItemData(wxT("BulletSystem Element item"),name,sound));

			}
		}	
	}

	for ( unsigned short i=0; i < pBulletSystem->getNumAnimationSceneLightInfos(); ++i )
	{
		Fairy::AnimationSceneLightInfo *light = pBulletSystem->getAnimationSceneLightInfo(i);

		assert (light);

		Ogre::String lightIndexStr = "SceneLight " + Ogre::StringConverter::toString(i);

		wxTreeItemId LightId= AppendItem(BulletSystemRootId,lightIndexStr.c_str(),
			iSceneLightImage, iSceneLightImage,
			new BulletTreeItemData(wxT("BulletSystem Element"),wxT("SceneLight"),light));

		if ( LightId.IsOk() )
		{

			const Ogre::ParameterList &paraList = light->getParameters();

			for ( size_t paraCount=0; paraCount < paraList.size(); ++paraCount )
			{
				Ogre::String name = paraList[paraCount].name;
				Ogre::String value = light->getParameter(paraList[paraCount].name);

				wxTreeItemId itemId =AppendItem( LightId,(name + ":" + value).c_str(),iPorpertyImage,iPorpertyImage,
					new BulletTreeItemData(wxT("BulletSystem Element item"),name,light));

			}
		}		
	}

	for ( unsigned short i=0; i < pBulletSystem->getNumAnimationLines(); ++i )
	{
		Fairy::AnimationLine *line = pBulletSystem->getAnimationLine(i);

		assert (line);

		Ogre::String lineIndexStr = "Line " + Ogre::StringConverter::toString(i);

		wxTreeItemId LineId= AppendItem(BulletSystemRootId,lineIndexStr.c_str(),
			iLineImage, iLineImage,
			new BulletTreeItemData(wxT("BulletSystem Element"),wxT("Line"),line));

		if ( LineId.IsOk() )
		{

			const Ogre::ParameterList &paraList = line->getParameters();

			for ( size_t paraCount=0; paraCount < paraList.size(); ++paraCount )
			{
				Ogre::String name = paraList[paraCount].name;
				Ogre::String value = line->getParameter(paraList[paraCount].name);

				wxTreeItemId itemId =AppendItem( LineId,(name + ":" + value).c_str(),iPorpertyImage,iPorpertyImage,
					new BulletTreeItemData(wxT("BulletSystem Element item"),name,line));

			}
		}		
	}

	Expand(BulletSystemRootId);
}
예제 #4
0
void SkillObjectEditor::saveSkill(Fairy::Skill *skill, const Ogre::String &templateName, std::ofstream &of)
{
	assert (skill);

	of << "\n";
	of << "skill " << templateName << "\n";
	of << "{\n";

	const Ogre::ParameterList &paraList = skill->getParameters();

	for ( size_t paraCount=0; paraCount < paraList.size(); ++paraCount )
	{
		of << "\t" << paraList[paraCount].name << " " << skill->getParameter(paraList[paraCount].name) << "\n";
	}

	for (unsigned short i=0; i<skill->getNumAnimationEffectInfos(); ++i)
	{
		of << "\tAnimEffect\n" << "\t{\n";

		Fairy::AnimationEffectInfo *effectInfo = skill->getAnimationEffectInfo(i);
		assert (effectInfo);

		const Ogre::ParameterList &effectInfoList = effectInfo->getParameters();

		for ( size_t paraCount = 0; paraCount < effectInfoList.size(); ++paraCount )
		{
			of << "\t\t" << effectInfoList[paraCount].name.c_str() 
				<< " " << effectInfo->getParameter( effectInfoList[paraCount].name.c_str() ) << "\n";
		}

		of << "\t}\n";
	}

	for (unsigned short i=0; i<skill->getNumAnimationRibbons(); ++i)
	{
		of << "\tRibbon\n" << "\t{\n";

		Fairy::AnimationRibbon *ribbon = skill->getAnimationRibbon(i);
		assert (ribbon);

		const Ogre::ParameterList &ribbonList = ribbon->getParameters();

		for ( size_t paraCount = 0; paraCount < ribbonList.size(); ++paraCount )
		{
			of << "\t\t" << ribbonList[paraCount].name.c_str() 
				<< " " << ribbon->getParameter( ribbonList[paraCount].name.c_str() ) << "\n";
		}

		of << "\t}\n";
	}

	for (unsigned short i=0; i<skill->getNumAnimationCameraShake(); ++i)
	{
		of << "\tCameraShake\n" << "\t{\n";

			Fairy::AnimationCameraShake *cameraShake = skill->getAnimationCameraShake(i);
		assert (cameraShake);

		const Ogre::ParameterList &cameraShakeList = cameraShake->getParameters();

		for ( size_t paraCount = 0; paraCount < cameraShakeList.size(); ++paraCount )
		{
			of << "\t\t" << cameraShakeList[paraCount].name.c_str() 
				<< " " << cameraShake->getParameter( cameraShakeList[paraCount].name.c_str() ) << "\n";
		}

		of << "\t}\n";
	}

	for (unsigned short i=0; i<skill->getNumAnimationSounds(); ++i)
	{
		of << "\tSound\n" << "\t{\n";

		Fairy::AnimationSound *sound = skill->getAnimationSound(i);
		assert (sound);

		const Ogre::ParameterList &soundList = sound->getParameters();

		for ( size_t paraCount = 0; paraCount < soundList.size(); ++paraCount )
		{
			of << "\t\t" << soundList[paraCount].name.c_str() 
				<< " " << sound->getParameter( soundList[paraCount].name.c_str() ) << "\n";
		}

		of << "\t}\n";
	}

	for (unsigned short i=0; i<skill->getNumAnimationSceneLightInfos(); ++i)
	{
		of << "\tSceneLight\n" << "\t{\n";

		Fairy::AnimationSceneLightInfo *light = skill->getAnimationSceneLightInfo(i);
		assert (light);

		const Ogre::ParameterList &lightList = light->getParameters();

		for ( size_t paraCount = 0; paraCount < lightList.size(); ++paraCount )
		{
			of << "\t\t" << lightList[paraCount].name.c_str() 
				<< " " << light->getParameter( lightList[paraCount].name.c_str() ) << "\n";
		}

		of << "\t}\n";
	}

	for (unsigned short i=0; i<skill->getNumAnimationBulletFlows(); ++i)
	{
		of << "\tAnimBulletFlow\n" << "\t{\n";

		Fairy::AnimationBulletFlow *bulletFlow = skill->getAnimationBulletFlow(i);
		assert (light);

		const Ogre::ParameterList &bulletFlowList = bulletFlow->getParameters();

		for ( size_t paraCount = 0; paraCount < bulletFlowList.size(); ++paraCount )
		{
			of << "\t\t" << bulletFlowList[paraCount].name.c_str() 
				<< " " << bulletFlow->getParameter( bulletFlowList[paraCount].name.c_str() ) << "\n";
		}

		of << "\t}\n";
	}
	of << "}\n";

}
예제 #5
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);
                }
            }
        }
    }
}
예제 #6
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());
}