void luAnimDlg::playAnim(const wxString& name) { if (!m_obj) return; if (!(m_scene->getUpdateFlags() & gkScene::UF_ANIMATIONS)) m_scene->setUpdateFlags(gkScene::UF_ANIMATIONS); gkString animName(WX2GK(name)); gkAnimationPlayer* player = m_obj->getAnimationPlayer(animName); if (!player) player = m_obj->addAnimation(animName); GK_ASSERT(player); m_curAnimPlayer = player; m_curAnimName = animName; m_curAnimLength = player->getLength(); m_length = GK2STR(m_curAnimLength); m_curPos = "0"; m_curPosEdit->GetValidator()->TransferToWindow(); m_lengthEdit->GetValidator()->TransferToWindow(); m_timeSlider->SetRange(0, 100); m_timeSlider->SetValue(0); m_obj->playAnimation(animName, 1); //gkAppData::gkGlobalActionBlend); m_playBtn->SetLabelText(wxT("Stop")); gkPrintf("play anim: %s", (const char*)name); }
void ActorAnimationSettingEditor::init() { wxGraphDialog* pGraphDialog = m_Frame->GetGraphDialog(); if(pGraphDialog) pGraphDialog->SetLoop(mDObject->getAnimationLoop()); this->SetTitle(Fairy::VariantCast<Ogre::String>(mObject->getProperty("actor name"))); //重新设置动画列表框 mListBoxAnimation->Clear(); for ( unsigned short i = 0; i < mDObject->getSkeletonAnimationCount(); ++i ) { Ogre::Animation *anim = mDObject->getSkeletonAnimation(i); if ( anim ) { wxString nameStr(anim->getName().c_str()); mListBoxAnimation->InsertItems( 1, &nameStr, 0 ); } } // 加入obj中定义的动作名称 Fairy::LogicModelManager::AnimationSkeletonLinksIterator asmIt = Fairy::LogicModelManager::getSingleton().getAnimationSkeletonLinksIterator(mDObject->getName()); while ( asmIt.hasMoreElements() ) { wxString animName(asmIt.peekNextKey().c_str()); if ( wxNOT_FOUND == mListBoxAnimation->FindString(animName) ) { wxString nameStr(animName.c_str()); mListBoxAnimation->InsertItems( 1, &nameStr, 0 ); } asmIt.moveNext(); } //重新设置声音 if ( NULL == Fairy::LogicModel::GetPlaySoundFuncton() ) { Fairy::LogicModel::SetPlaySoundFuncton(wxGetApp().funcPlay); } if ( NULL == Fairy::LogicModel::GetStopSoundFunction() ) Fairy::LogicModel::SetStopSoundFunction(wxGetApp().funcStop); }
void UCreatureAnimationAsset::GatherAnimationData() { // ensure the filenames are synced creature_filename = GetCreatureFilename(); // load the JSON data into creature so we can extract the animation names and generate the point caches for the anims CreatureCore creature_core; creature_core.pJsonData = &GetJsonString(); creature_core.creature_filename = creature_filename; creature_core.InitCreatureRender(); auto all_animation_names = creature_core.GetCreatureManager()->GetCreature()->GetAnimationNames(); int32 arraySize = creature_core.GetCreatureManager()->GetCreature()->GetTotalNumPoints() * 3; m_pointsCache.Reset(all_animation_names.size()); m_clipNames.Reset(all_animation_names.size()); for (auto& cur_name : all_animation_names) { FString animName(cur_name.c_str()); m_clipNames.Add(animName); if (m_pointsCacheApproximationLevel >= 0) { creature_core.GetCreatureManager()->ClearPointCache(cur_name); creature_core.GetCreatureManager()->MakePointCache(cur_name, m_pointsCacheApproximationLevel); CreatureModule::CreatureAnimation *anim = creature_core.GetCreatureManager()->GetAnimation(cur_name); if (ensure(anim) && anim->hasCachePts()) { auto &pts = anim->getCachePts(); FCreatureAnimationPointsCache &animPtsCache = m_pointsCache[m_pointsCache.AddZeroed(1)]; animPtsCache.m_animationName = animName; animPtsCache.m_numArrays = pts.size(); animPtsCache.m_points.Reserve(animPtsCache.m_numArrays * arraySize); for (float *pt : pts) { for (int32 i = 0; i < arraySize; i++) { animPtsCache.m_points.Add(pt[i]); } } } } } }
void AddSkillDialog::OnInitDialog(wxInitDialogEvent &e) { wxDialog::OnInitDialog(e); wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL ); wxFlexGridSizer *item1 = new wxFlexGridSizer( 2, 0, 0 ); wxStaticText *item2 = new wxStaticText( this, ID_TEXT, /*_("Animation")*/ wxT("动作"), wxDefaultPosition, wxDefaultSize, 0 ); item1->Add( item2, 0, wxALIGN_CENTER|wxALL, 5 ); wxString *strs3 = (wxString*) NULL; wxComboBox *item3 = new wxComboBox( this, ID_COMBO_ANIMATION, wxT(""), wxDefaultPosition, wxSize(200,-1), 0, strs3, wxCB_DROPDOWN ); item1->Add( item3, 0, wxALIGN_CENTER|wxALL, 5 ); wxStaticText *item4 = new wxStaticText( this, ID_TEXT, /*_("Skill Name")*/wxT("技能名称"), wxDefaultPosition, wxDefaultSize, 0 ); item1->Add( item4, 0, wxALIGN_CENTER|wxALL, 5 ); wxTextCtrl *item5 = new wxTextCtrl( this, ID_TEXTCTRL_SKILL, wxT(""), wxDefaultPosition, wxSize(200,-1), 0 ); item1->Add( item5, 0, wxALIGN_CENTER|wxALL, 5 ); wxButton *item6 = new wxButton( this, wxID_OK, /*_("OK")*/wxT("确认[&O]"), wxDefaultPosition, wxDefaultSize, 0 ); item1->Add( item6, 0, wxALIGN_CENTER|wxALL, 5 ); wxButton *item7 = new wxButton( this, wxID_CANCEL, /*_("Cancel")*/wxT("取消[&C]"), wxDefaultPosition, wxDefaultSize, 0 ); item1->Add( item7, 0, wxALIGN_CENTER|wxALL, 5 ); item0->Add( item1, 0, wxALIGN_CENTER|wxALL, 5 ); this->SetSizer( item0 ); item0->SetSizeHints( this ); ActorAnimationSettingDialog *parentDialog = static_cast<ActorAnimationSettingDialog *>(this->GetParent()); assert (parentDialog); WX::LogicModel *object = parentDialog->GetCurrentObject(); for ( unsigned short i = 0; i < object->getSkeletonAnimationCount(); ++i ) { Ogre::Animation *anim = object->getSkeletonAnimation(i); if ( anim ) { wxString nameStr(anim->getName().c_str()); item3->AppendString(nameStr); } } // 加入obj中定义的动作名称 WX::LogicModelManager::AnimationSkeletonLinksIterator asmIt = WX::LogicModelManager::getSingleton().getAnimationSkeletonLinksIterator(object->getName()); while ( asmIt.hasMoreElements() ) { wxString animName(asmIt.peekNextKey().c_str()); if ( wxNOT_FOUND == item3->FindString(animName) ) { wxString nameStr(animName.c_str()); item3->AppendString(nameStr); } asmIt.moveNext(); } item3->SetSelection(0); mAnimComboBox = item3; mSkillNameTextCtrl = item5; }
void ActorAnimationSettingDialog::OnInitDialog(wxInitDialogEvent &e) { wxDialog::OnInitDialog(e); wxSizer* sizer = ActorAnimationSetting(this, true, true); // 获取各控件的引用 mListBoxAnimation = wxDynamicCast(this->FindWindow(ID_LISTBOX_ANIMATION),wxListBox); mSliderAnimTimePos = wxDynamicCast(this->FindWindow(ID_SLIDER_TIME),wxSlider); mSliderAnimRate = wxDynamicCast(this->FindWindow(ID_SLIDER_GLOBAL_ANIM_RATE),wxSlider); mSliderAnimFadeOutTime = wxDynamicCast(this->FindWindow(ID_SLIDER_FADE_OUT_TIME),wxSlider); mListBoxAllSkill = wxDynamicCast(this->FindWindow(ID_LISTBOX_ALL_SKILL),wxListBox); mCheckBoxLoop = wxDynamicCast(this->FindWindow(ID_CHECKBOX_LOOP),wxCheckBox); mHairTextCtrl = wxDynamicCast(this->FindWindow(ID_TEXTCTRL_HAIR), wxTextCtrl); mCapTextCtrl = wxDynamicCast(this->FindWindow(ID_TEXTCTRL_CAP), wxTextCtrl); mBodyTextCtrl = wxDynamicCast(this->FindWindow(ID_TEXTCTRL_BODY), wxTextCtrl); mHandTextCtrl = wxDynamicCast(this->FindWindow(ID_TEXTCTRL_HAND), wxTextCtrl); mFootTextCtrl = wxDynamicCast(this->FindWindow(ID_TEXTCTRL_FOOT), wxTextCtrl); mHairTextMatCtrl = wxDynamicCast(this->FindWindow(ID_TEXTCTRL_HAIR_MAT), wxTextCtrl); mCapTextMatCtrl = wxDynamicCast(this->FindWindow(ID_TEXTCTRL_CAP_MAT), wxTextCtrl); mBodyTextMatCtrl = wxDynamicCast(this->FindWindow(ID_TEXTCTRL_BODY_MAT), wxTextCtrl); mHandTextMatCtrl = wxDynamicCast(this->FindWindow(ID_TEXTCTRL_HAND_MAT), wxTextCtrl); mFootTextMatCtrl = wxDynamicCast(this->FindWindow(ID_TEXTCTRL_FOOT_MAT), wxTextCtrl); mColourButton = wxDynamicCast(this->FindWindow(ID_BUTTON_COLOUR), wxButton); mCheckBoxLoop->SetValue(mDObject->getAnimationLoop()); for ( unsigned short i = 0; i < mDObject->getSkeletonAnimationCount(); ++i ) { Ogre::Animation *anim = mDObject->getSkeletonAnimation(i); if ( anim ) { wxString nameStr(anim->getName().c_str()); mListBoxAnimation->InsertItems( 1, &nameStr, 0 ); } } // 加入obj中定义的动作名称 WX::LogicModelManager::AnimationSkeletonLinksIterator asmIt = WX::LogicModelManager::getSingleton().getAnimationSkeletonLinksIterator(mDObject->getName()); while ( asmIt.hasMoreElements() ) { wxString animName(asmIt.peekNextKey().c_str()); if ( wxNOT_FOUND == mListBoxAnimation->FindString(animName) ) { wxString nameStr(animName.c_str()); mListBoxAnimation->InsertItems( 1, &nameStr, 0 ); } asmIt.moveNext(); } if ( NULL == WX::LogicModel::GetPlaySoundFuncton() ) { WX::LogicModel::SetPlaySoundFuncton(wxGetApp().funcPlay); } if ( NULL == WX::LogicModel::GetStopSoundFunction() ) WX::LogicModel::SetStopSoundFunction(wxGetApp().funcStop); FillAllSkillListBox(); }