📄 3dsimpleobserverdlg.cpp
字号:
pInfo->dwTimeInterval = nData;
sprintf(szSubTitle, "Name");
MYASSERT(::IniStrGet(szIniFile, szTitle, szSubTitle, pInfo->szActionName));
sprintf(szInfo, "%03u (%s)", pInfo->nActionIndex, pInfo->szActionName);
this->m_ctrlAction.InsertString(i, szInfo);
//this->m_ctrlAction.AddString(pInfo->szActionName);
m_setActionInfo.push_back(pInfo);
}
}
//--------------------------------------------------------------------------------
MyActionInfo* CMy3DSimpleObserverDlg::GetActionInfo(int nAction)
{
int nAmount = m_setActionInfo.size();
for(int i = 0; i < nAmount; i ++)
{
MyActionInfo* pInfo = m_setActionInfo[i];
if(pInfo)
{
if(pInfo->nActionIndex == nAction)
return pInfo;
}
}
return NULL;
}
//--------------------------------------------------------------------------------
MyActionInfo* CMy3DSimpleObserverDlg::GetActionInfoByIndex(int nIndex)
{
if((nIndex >= 0) && (nIndex < m_setActionInfo.size()))
{
return m_setActionInfo[nIndex];
}
return NULL;
}
//--------------------------------------------------------------------------------
void CMy3DSimpleObserverDlg::DestroyActionInfo()
{
int nAmount = m_setActionInfo.size();
for(int i = 0; i < nAmount; i ++)
{
MyActionInfo* pInfo = m_setActionInfo[i];
SAFE_DELETE(pInfo);
}
m_setActionInfo.clear();
}
//--------------------------------------------------------------------------------
int CMy3DSimpleObserverDlg::GetNextAction(int nAction)
{
int nIndex = this->m_ctrlAction.GetCurSel();
nIndex ++;
if(nIndex >= m_setActionInfo.size())
nIndex = 0;
MyActionInfo* pInfo = this->GetActionInfoByIndex(nIndex);
if(pInfo)
{
this->m_ctrlAction.SetCurSel(nIndex);
return pInfo->nActionIndex;
strcpy(m_szCurrentAction, pInfo->szActionName);
}
this->m_ctrlAction.SetCurSel(0);
strcpy(m_szCurrentAction, "ERROR");
return 100;
}
//--------------------------------------------------------------------------------
void CMy3DSimpleObserverDlg::OnCheckHair()
{
// TODO: Add your control notification handler code here
this->UpdateData(true);
if(this->m_bHair)
m_obj3DRole.SetArmet(2119310);
else
SAFE_DELETE(m_obj3DRole.m_pArmet);
}
//--------------------------------------------------------------------------------
void CMy3DSimpleObserverDlg::OnCheckRw()
{
// TODO: Add your control notification handler code here
this->UpdateData(true);
// if(this->m_bRW)
// m_obj3DRole.SetRWeapon(50000);
// else
// m_obj3DRole.SetRWeapon(0);
}
//--------------------------------------------------------------------------------
void CMy3DSimpleObserverDlg::OnCheckLw()
{
// TODO: Add your control notification handler code here
this->UpdateData(true);
// if(this->m_bLW)
// m_obj3DRole.SetLWeapon(500000);
// else
// m_obj3DRole.SetLWeapon(0);
}
//--------------------------------------------------------------------------------
BOOL CMy3DSimpleObserverDlg::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
{
// TODO: Add your message handler code here and/or call default
if(zDelta > 0)
m_nDir ++;
if(zDelta < 0)
m_nDir --;
if(m_nDir < 0)
m_nDir = 7;
m_nDir = m_nDir % 8;
return CDialog::OnMouseWheel(nFlags, zDelta, pt);
}
//--------------------------------------------------------------------------------
void CMy3DSimpleObserverDlg::OnSetfocusComboAction()
{
// TODO: Add your control notification handler code here
this->SetFocus();
}
//--------------------------------------------------------------------------------
void CMy3DSimpleObserverDlg::ProcessAction()
{
DWORD dwTimePass = ::TimeGet() - m_dwTimeBegin;
DWORD dwFI = 1;
MyActionInfo* pInfo = this->GetActionInfo(m_nCurrentAction);
if(pInfo)
{
dwFI = pInfo->dwTimeInterval;
}
if(m_bSingleAction && m_p3DMotion)
{
dwFI = atoi(m_strFI);
}
m_dwCurrentFI = dwFI;
if(dwFI == 0)
dwFI = 1;
if(m_bSlowPlay)
dwFI *= 3;
if(::TimeGet() - m_dwFrameTime > dwFI && m_bPlay)
{
m_dwFrameIndex ++;
m_dwFrameTime = ::TimeGet();
}
int nFrameIndex = dwTimePass/dwFI;
if(nFrameIndex >= m_nFrameAmount)
{
if(m_bSingleAction && m_p3DMotion)
{
m_obj3DRole.m_pArmor->SetMotion(m_p3DMotion);
m_nFrameAmount = m_p3DMotion->GetFrameAmount();
}
else
{
if(m_bLoop)
{
// updata ..
m_nCurrentAction = this->GetNextAction(m_nCurrentAction);
{
int nAmount = m_setActionInfo.size();
for(int i = 0; i < nAmount; i++)
{
MyActionInfo* pInfo = m_setActionInfo[i];
if(pInfo && pInfo->nActionIndex == m_nCurrentAction)
{
//this->m_ctrlAction.SetCurSel(i);
strcpy(m_szCurrentAction, pInfo->szActionName);
break;
}
}
}
m_nFrameAmount = m_obj3DRole.SetAction(m_nCurrentAction);
m_dwTimeBegin = ::TimeGet();
nFrameIndex = 1;
}
else
{
m_nFrameAmount = m_obj3DRole.SetAction(m_nCurrentAction);
m_dwTimeBegin = ::TimeGet();
nFrameIndex = 1;
}
}
}
m_nCurrentFrameIndex = nFrameIndex;
m_obj3DRole.SetFrame(m_dwFrameIndex);
}
//--------------------------------------------------------------------------------
void CMy3DSimpleObserverDlg::OnSelchangeComboAction()
{
// TODO: Add your control notification handler code here
int nIndex = this->m_ctrlAction.GetCurSel();
if(nIndex >= 0)
{
MyActionInfo* pInfo = this->GetActionInfoByIndex(nIndex);
if(pInfo)
{
m_dwTimeBegin = ::TimeGet();
m_nCurrentAction = pInfo->nActionIndex;
strcpy(m_szCurrentAction, pInfo->szActionName);
m_nFrameAmount = m_obj3DRole.SetAction(m_nCurrentAction);
}
}
}
//--------------------------------------------------------------------------------
void CMy3DSimpleObserverDlg::ShowInfo()
{
static char szMsg[1024] = "";
CMyBitmap::ShowBlock(0, 0, _SCR_WIDTH, 60, 0xff0000ff);
float fFI = m_dwCurrentFI*1.0/1000;
float fCost = m_nFrameAmount*m_dwCurrentFI*1.0/1000;
sprintf(szMsg, "当前动作:名称%s 编号%04d 总祯数%04d 当前祯%04d 祯间隔%04f秒 总耗时%04f秒",
m_szCurrentAction, m_nCurrentAction, m_nFrameAmount,
m_nCurrentFrameIndex, fFI, fCost);
CMyBitmap::ShowString(10, 10, 0xffff00, szMsg);
sprintf(szMsg, "当前方向:%d (请使用鼠标滚轮来改变角色的朝向)", m_nDir);
CMyBitmap::ShowString(10, 30, 0xffff00, szMsg);
}
//--------------------------------------------------------------------------------
void CMy3DSimpleObserverDlg::OnCheckSingleAction()
{
// TODO: Add your control notification handler code here
if(m_bSingleAction && m_p3DMotion)
{
m_dwTimeBegin = ::TimeGet();
m_obj3DRole.m_pArmor->SetMotion(m_p3DMotion);
m_nFrameAmount = m_p3DMotion->GetFrameAmount();
}
else
{
m_nFrameAmount = m_obj3DRole.SetAction(m_nCurrentAction);
m_dwTimeBegin = ::TimeGet();
}
}
//--------------------------------------------------------------------------------
void CMy3DSimpleObserverDlg::OnButtonReloadAction()
{
// TODO: Add your control notification handler code here
SAFE_DELETE(m_p3DMotion);
m_p3DMotion = new C3DMotion;
MYASSERT(m_p3DMotion);
m_p3DMotion->Create("动作/1.c3");
if(m_bSingleAction && m_p3DMotion)
{
m_dwTimeBegin = ::TimeGet();
m_obj3DRole.m_pArmor->SetMotion(m_p3DMotion);
m_nFrameAmount = m_p3DMotion->GetFrameAmount();
}
}
//--------------------------------------------------------------------------------
void CMy3DSimpleObserverDlg::OnButtonSetlook()
{
// TODO: Add your control notification handler code here
int nLook = atoi(m_strLook);
// m_obj3DRole.SetLook(nLook);
}
//--------------------------------------------------------------------------------
void CMy3DSimpleObserverDlg::OnRadio1()
{
// TODO: Add your control notification handler code here
m_obj3DRole.SetLook(1);
}
//--------------------------------------------------------------------------------
void CMy3DSimpleObserverDlg::OnRadio2()
{
// TODO: Add your control notification handler code here
m_obj3DRole.SetLook(2);
}
//--------------------------------------------------------------------------------
void CMy3DSimpleObserverDlg::OnRadio3()
{
// TODO: Add your control notification handler code here
m_obj3DRole.SetLook(3);
}
//--------------------------------------------------------------------------------
void CMy3DSimpleObserverDlg::OnRadio4()
{
// TODO: Add your control notification handler code here
m_obj3DRole.SetLook(4);
}
//--------------------------------------------------------------------------------
void CMy3DSimpleObserverDlg::OnButton1()
{
// TODO: Add your control notification handler code here
m_bPlay = true;
}
void CMy3DSimpleObserverDlg::OnButton2()
{
// TODO: Add your control notification handler code here
m_bPlay = false;
}
void CMy3DSimpleObserverDlg::OnButton3()
{
// TODO: Add your control notification handler code here
m_dwFrameIndex ++;
}
void CMy3DSimpleObserverDlg::OnButton4()
{
// TODO: Add your control notification handler code here
m_dwFrameIndex --;
}
void CMy3DSimpleObserverDlg::OnButton5()
{
// TODO: Add your control notification handler code here
m_bSlowPlay = !m_bSlowPlay;
}
void CMy3DSimpleObserverDlg::OnButtonIn()
{
// TODO: Add your control notification handler code here
if(m_nZoom < 300)
m_nZoom += 10;
}
void CMy3DSimpleObserverDlg::OnButtonOut()
{
// TODO: Add your control notification handler code here
if(m_nZoom > 50)
m_nZoom -= 10;
}
void CMy3DSimpleObserverDlg::OnButtonOut2()
{
// TODO: Add your control notification handler code here
m_nZoom = 100;
}
void CMy3DSimpleObserverDlg::OnCheckmantel()
{
// TODO: Add your control notification handler code here
this->UpdateData(true);
if(this->m_bMantel)
m_obj3DRole.SetMantle(1);
else
SAFE_DELETE(m_obj3DRole.m_pMantle);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -