Ejemplo n.º 1
0
void WeaponSelectorDialog::addEffect(void)
{
    if (false == mCurrentEffectName.empty())
    {
        /*if (mLeftHand)
        {
            if (mLeftHandWeapon && mLeftHandWeapon->isLocatorExist("武器特效点"))
            {
                mLeftHandWeapon->delAllEffect();
                mCurrentEffectHandle = mLeftHandWeapon->addEffect(mCurrentEffectName, "武器特效点");
            }
        }
        else
        {
            if (mRightHandWeapon && mRightHandWeapon->isLocatorExist("武器特效点"))
            {
                mRightHandWeapon->delAllEffect();
                mCurrentEffectHandle = mRightHandWeapon->addEffect(mCurrentEffectName, "武器特效点");
            }
        }*/

        if ( mCurrentWeapon && mCurrentWeapon->isLocatorExist("武器特效点") )
        {
            mCurrentWeapon->delAllEffect();
            mCurrentEffectHandle = mCurrentWeapon->addEffect(mCurrentEffectName, "武器特效点", 
                Fairy::LogicModel::GTIT_ALL);
        }

    } 

    Fairy::Effect* effect = getCurrentEffect();

    if (effect)
        effect->setColour(mCurrentColour * mCurrentAlpha);
}
Ejemplo n.º 2
0
void WXEffectEditDialog::OnDelElementButtonDown(wxCommandEvent &e)
{
	wxPGId id = mPropertiesViewer->GetSelectedProperty();

	if ( true == id.IsOk() && false == mPropertiesViewer->IsPropertyEnabled(id) )
	{
		unsigned short index = mPropertiesViewer->GetPropertyIndex(id);
		
		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 (index < effect->getNumElements())
			{
				// 现在做的是直接对模板的修改,所以要修改全部的同个模板的特效
				if ( effect->getTemplateName() == mEffect->getTemplateName() )
				{
					effect->destroyElement(index);
				}

				mPropertiesViewer->Delete(id);
			}
		}
	}
}
Ejemplo n.º 3
0
void WeaponSelectorDialog::OnAlphaTextChanged(wxCommandEvent &e)
{
    mCurrentAlpha = Ogre::StringConverter::parseReal(mAlphaTextCtrl->GetValue().c_str());

    Fairy::Effect* effect = getCurrentEffect();

    if (effect)
        effect->setColour(mCurrentColour * mCurrentAlpha);
}
Ejemplo n.º 4
0
HANDLE CEffectObject::AddEffect(INT idEffect, BOOL bLoop, LPCTSTR /*szLocatorName*/)
{
	//创建特效实例
	Fairy::Effect* pEffectIml = Fairy::EffectManager::getSingleton().createEffect("g01_jingangquan_01");
	if(!pEffectIml) return NULL;

	//创建场景节点
	Ogre::SceneNode* pSceneNode = pEffectIml->createSceneNode();

	//保存
	m_listEffectImpl.push_back(std::make_pair(pEffectIml, pSceneNode));

	return pEffectIml;

#if 0
	//-------------------------------------------------------------
	//得到数据库系统模块
	static const tDataBaseSystem* s_pDataBase = NULL;
	if(!s_pDataBase) s_pDataBase = (tDataBaseSystem*)g_pKernel->GetNode("bin\\dbc");
	TDAssert(s_pDataBase);

	//-------------------------------------------------------------
	//从DBC_EFFECT_DEFINE查找具体特效
	static const tDataBase* s_pDBCEffect = NULL;
	if(!s_pDBCEffect) s_pDBCEffect = s_pDataBase->GetDataBase(DBC_EFFECT_DEFINE);
	TDAssert(s_pDBCEffect);

	//查找具体特效
	const _DBC_EFFECT_DEFINE* pEffect = (const _DBC_EFFECT_DEFINE*)s_pDBCEffect->Search_Index_EQU(idEffect);
	//没有找到
	if(!pEffect) return NULL;
	
	//生成Effect对象
	Ogre::Effect* pEffectIml = Ogre::EffectManager::getSingleton().createEffect(pEffect->pEffectType, pEffect->pParam1);
	if(!pEffectIml) return NULL;

	//保存
	m_listEffectImpl.push_back(pEffectIml);

	return (HANDLE)pEffectIml;
#endif
}
Ejemplo n.º 5
0
void WXEffectEditDialog::OnAddElementButtonDown(wxCommandEvent &e)
{
	AddEffectElementDialog *dlg = new AddEffectElementDialog(this, wxID_ANY,
		_("特效元素类型"));

	bool ok = (dlg->ShowModal() == wxID_OK);
	if(ok)
	{
		Ogre::String type = wxDynamicCast(dlg->FindWindow(feID_COMBOCTRL_ELEMENT_TYPE),wxComboBox)->GetValue().c_str();

		if ( false == type.empty() )
		{
			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() )
				{
					effect->addElement(type);
				}
			}

			InitEffectDialog(mEffect, mSceneManipulator);
		}		
	}

	dlg->Destroy();
}
Ejemplo n.º 6
0
void WeaponSelectorDialog::OnColourButtonDown(wxCommandEvent &e)
{
    wxColourDialog dialog(this);
    if (dialog.ShowModal() == wxID_OK)
    {
        wxColour colour;

        wxColourData retData = dialog.GetColourData();
        colour = retData.GetColour();

        IColourToFColour(colour.Red(), colour.Green(), colour.Blue(),
            mCurrentColour.r, mCurrentColour.g, mCurrentColour.b);

        Fairy::Effect* effect = getCurrentEffect();
        
        if (effect)
            effect->setColour(mCurrentColour * mCurrentAlpha);

        // 设置按钮颜色,颜色数字文本
        mColourButton->SetBackgroundColour(colour);

        setColourText();
    }
}
Ejemplo n.º 7
0
void WXEffectEditDialog::OnSaveAsButtonDown(wxCommandEvent &e)
{
	SaveAsEffectDialog *dlg = new SaveAsEffectDialog(this, wxID_ANY,
		_("保存特效"), mEffect);

	bool ok = (dlg->ShowModal() == wxID_OK);
	if(ok)
	{
	//	bool append = true;
		// 如果模板名称不一样了,说明是要存成一个新的模板
		/*if ( dlg->mTextCtrl->GetValue().c_str() == mEffect->getTemplateName() )
		{
			append = false;
		}*/
		Ogre::StringVector templates;

		const Ogre::String fileName = dlg->mComboBox->GetValue().c_str();
		const Ogre::String templateName = dlg->mTextCtrl->GetValue().c_str();

		Ogre::StringVector strings = Ogre::StringUtil::split( fileName, "." );
		if ( (strings.size() != 2) || (strings[1] != "effect") )
		{
			wxMessageBox ( _("The Script File Name Is Wrong!") );
			return;
		}

		Fairy::EffectManager::getSingleton().getTemplatesFromScriptFile(fileName, templates);

		std::ofstream outFile;

		Ogre::String pathFileName = EFFECT_PATH+fileName;
		outFile.open ( pathFileName.c_str(), std::ios::out | std::ios::trunc ); // append to file

		if (!outFile.is_open())
		{
			return;
		}
		
		bool newTemplate = true;

		// 把所有的模板都写入该文件中
		for ( size_t i=0; i<templates.size(); ++i )
		{
		//	if (templates[i] != mEffect->getTemplateName())
			///{
				Fairy::Effect *effect = Fairy::EffectManager::getSingleton().getTemplate(templates[i]);
				assert (effect);

				if (effect->getTemplateName() == dlg->mTextCtrl->GetValue().c_str())
				{
					saveEffect(mEffect, dlg->mTextCtrl->GetValue().c_str(), outFile );

					*effect = *mEffect;

					newTemplate = false;
				}
				else
					saveEffect(effect, effect->getTemplateName(), outFile);
		
		}


		if (newTemplate)
		{
			saveEffect(mEffect, templateName, outFile );
			mEffect->setTemplateName(templateName);

			// 刷新EffectManager中的模板内容
			Fairy::Effect *effect = Fairy::EffectManager::getSingleton().createEffectTemplate(mEffect->getTemplateName());

			*effect = *mEffect;

			Fairy::EffectManager::getSingleton().addToEffectTemplateScriptFileMap(templateName, fileName);
		}

		outFile.close();
	}

	dlg->Destroy();
}
Ejemplo n.º 8
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);
                }
            }
        }
    }
}
Ejemplo n.º 9
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());
}
Ejemplo n.º 10
0
void MaterialEditorDialog::InitDialog( Fairy::SceneManipulator *manipulator )
{
	assert (manipulator);
	mSceneManipulator = manipulator;

	//InitMaterialCombo();

	// 根据当前所编辑的东西自动地选择或创建材质

	// 如果当前选择了粒子系统,就编辑该粒子系统的材质
	CurrentEditEffectType currentEditItem = gEffectSettingGlobalData.mCurrentEditEffectType;

	switch (currentEditItem)
	{
	case CEFT_PARTICLE:
		{
			Ogre::ParticleSystem *currentSystem = gEffectSettingGlobalData.mCurrentParticleSystem;
			Ogre::String currentTemplateName = gEffectSettingGlobalData.mCurrentParticleTemplateName;

			assert (currentSystem);

			if (currentSystem->getMaterialName() != currentSystem->getName())
			{
				mCurrentMaterial = Ogre::MaterialManager::getSingleton().getByName(currentSystem->getName());

				if (mCurrentMaterial.isNull())
				{
					mCurrentMaterial = Ogre::MaterialManager::getSingleton().create(currentSystem->getName(),"General");
				}

				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 == currentTemplateName )
					{
						system->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 == currentTemplateName)
							{
								Ogre::ParticleSystem *system = static_cast<Fairy::ParticleElement *>(element)->getParticleSystem();

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

				currentSystem->setMaterialName(mCurrentMaterial->getName());	
			}
			else
			{
				mCurrentMaterial = Ogre::MaterialManager::getSingleton().getByName(currentSystem->getName());

				assert ( false == mCurrentMaterial.isNull() );
			}
			InitMaterialInfo( Ogre::String(mCurrentMaterial->getName()) );

			break;
		}

	case CEFT_RIBBON:
		{
			unsigned short currentRibbonIndex = gEffectSettingGlobalData.mCurrentRibbonIndex;

			Fairy::AnimationRibbon *ribbon = gEffectSettingGlobalData.mCurrentSkill->getAnimationRibbon(currentRibbonIndex);

			assert (ribbon);

			Ogre::String currRibbonMatName = ribbon->getMaterialName();

			// ribbon该有的名称
			Ogre::String ribbonMatName = gEffectSettingGlobalData.mCurrentSkill->getSkillName() +
				"ribbon" + Ogre::StringConverter::toString(currentRibbonIndex);

			if ( currRibbonMatName != ribbonMatName )
			{
				mCurrentMaterial = Ogre::MaterialManager::getSingleton().getByName(ribbonMatName);

				if (mCurrentMaterial.isNull())
				{
					mCurrentMaterial = Ogre::MaterialManager::getSingleton().create(ribbonMatName,"General");
				}

				ribbon->setMaterial(ribbonMatName);
			}
			else
			{
				mCurrentMaterial = Ogre::MaterialManager::getSingleton().getByName(ribbonMatName);

				assert ( false == mCurrentMaterial.isNull() );
			}

			InitMaterialInfo( Ogre::String(mCurrentMaterial->getName()) );

			break;
		}

	case CEFT_EFFECT_BEAM:
		{
			Fairy::BeamElement *beam = static_cast<Fairy::BeamElement *>
				( gEffectSettingGlobalData.mCurrentEffect->getElement(gEffectSettingGlobalData.mCurrentEffectElementIndex) );

			assert (beam);

			Ogre::String currBeamMatName = beam->getMaterialName();

			// ribbon该有的名称
			Ogre::String beamMatName = gEffectSettingGlobalData.mCurrentEffect->getTemplateName() +
				"beam" + Ogre::StringConverter::toString(gEffectSettingGlobalData.mCurrentEffectElementIndex);

			if ( currBeamMatName != beamMatName )
			{
				mCurrentMaterial = Ogre::MaterialManager::getSingleton().getByName(beamMatName);

				if (mCurrentMaterial.isNull())
				{
					mCurrentMaterial = Ogre::MaterialManager::getSingleton().create(beamMatName,"General");
				}

				beam->setMaterialName(beamMatName);
			}
			else
			{
				mCurrentMaterial = Ogre::MaterialManager::getSingleton().getByName(beamMatName);

				assert ( false == mCurrentMaterial.isNull() );
			}

			InitMaterialInfo( Ogre::String(mCurrentMaterial->getName()) );

			break;
		}

	case CEFT_EFFECT_PROJECTOR:
		{
			Fairy::ProjectorElement *projectorElement = static_cast<Fairy::ProjectorElement *>
				( gEffectSettingGlobalData.mCurrentEffect->getElement(gEffectSettingGlobalData.mCurrentEffectElementIndex) );

			assert (projectorElement);

			gEffectSettingGlobalData.mOriginProjectorMaterial = projectorElement->getMaterialName();

			mCurrentMaterial = projectorElement->getProjector()->_getPatchMaterial();

			if ( false == mCurrentMaterial.isNull() )
				InitMaterialInfo( Ogre::String(mCurrentMaterial->getName()) );
			else
			{
				wxMessageBox(_("Please select the material in effect editor first!"));
			}
		}

    case CEFT_EFFECT_BILLBOARDSET:
        {
            Fairy::BillboardSetElement *billboardSet = static_cast<Fairy::BillboardSetElement *>
                ( gEffectSettingGlobalData.mCurrentEffect->getElement(gEffectSettingGlobalData.mCurrentEffectElementIndex) );

            assert (billboardSet);

            Ogre::String currBillboardMatName = billboardSet->getBillboardMaterial();

            // ribbon该有的名称
            Ogre::String billboardMatName = gEffectSettingGlobalData.mCurrentEffect->getTemplateName() +
                "billboardset" + Ogre::StringConverter::toString(gEffectSettingGlobalData.mCurrentEffectElementIndex);

            if ( currBillboardMatName != billboardMatName )
            {
                mCurrentMaterial = Ogre::MaterialManager::getSingleton().getByName(billboardMatName);

                if (mCurrentMaterial.isNull())
                {
                    mCurrentMaterial = Ogre::MaterialManager::getSingleton().create(billboardMatName,"General");
                }

                billboardSet->setBillboardMaterial(billboardMatName);
            }
            else
            {
                mCurrentMaterial = Ogre::MaterialManager::getSingleton().getByName(billboardMatName);

                assert ( false == mCurrentMaterial.isNull() );
            }

            InitMaterialInfo( Ogre::String(mCurrentMaterial->getName()) );

            break;
        }

	}
}