00001
00002
00003
00004 #include "stdafx.h"
00005 #include "Viewer.h"
00006 #include "ViewerDoc.h"
00007 #include "BottomView.h"
00008 #include "Model/Model.h"
00009
00010
00011
00012 IMPLEMENT_DYNCREATE(CBottomView, CView)
00013
00014 CBottomView::CBottomView()
00015 {
00016 m_bShowSelection = false;
00017 }
00018
00019 CBottomView::~CBottomView()
00020 {
00021 }
00022
00023 BEGIN_MESSAGE_MAP(CBottomView, CView)
00024 ON_WM_SIZE()
00025 ON_WM_CREATE()
00026 END_MESSAGE_MAP()
00027
00028
00029
00030
00031 void CBottomView::OnDraw(CDC* pDC)
00032 {
00033 CDocument* pDoc = GetDocument();
00034
00035 }
00036
00037
00038
00039
00040 #ifdef _DEBUG
00041 void CBottomView::AssertValid() const
00042 {
00043 CView::AssertValid();
00044 }
00045
00046 void CBottomView::Dump(CDumpContext& dc) const
00047 {
00048 CView::Dump(dc);
00049 }
00050
00051 CViewerDoc* CBottomView::GetDocument() const
00052 {
00053 ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CViewerDoc)));
00054 return (CViewerDoc*)m_pDocument;
00055 }
00056 #endif //_DEBUG
00057
00058
00059
00060
00061 int CBottomView::OnCreate(LPCREATESTRUCT lpCreateStruct)
00062 {
00063 if (CView::OnCreate(lpCreateStruct) == -1)
00064 return -1;
00065
00066 if( !m_BottomDlg.Create( IDD_BOTTOMDIALOG, this ) )
00067 return -1;
00068
00069 GetDocument()->SetBottomView( this );
00070 GetDocument()->SetBottomDialog( &m_BottomDlg );
00071 m_BottomDlg.SetDocument( GetDocument() );
00072
00073 m_BottomDlg.InitValue();
00074
00075 m_ImageList.Create( IDB_BITMAP_IMAGELIST, 16, 1, RGB( 255, 0, 255) );
00076 m_hIconMesh = m_ImageList.ExtractIcon( 0 );
00077 m_hIconAnim = m_ImageList.ExtractIcon( 1 );
00078 m_hIconMeshAnim = m_ImageList.ExtractIcon( 2 );
00079
00080 return 0;
00081 }
00082
00083 void CBottomView::OnSize(UINT nType, int cx, int cy)
00084 {
00085 CView::OnSize(nType, cx, cy);
00086
00087 m_BottomDlg.MoveWindow( 0, 0, cx, cy );
00088 }
00089
00090 void CBottomView::InitViewer()
00091 {
00092 m_BottomDlg.InitValue();
00093 ResetRenderEffect();
00094 }
00095
00096 void CBottomView::ResetRenderEffect()
00097 {
00098 KModel* pModel = GetDocument()->GetpCurrentModel();
00099
00100 if( !pModel )
00101 return;
00102
00103 for( u32 i = 0; i < pModel->GetnMeshes(); i ++ )
00104 pModel->GetpMesh( i )->m_RenderEffect = KMMRE_NORMAL;
00105 }
00106
00107 void CBottomView::Refresh()
00108 {
00109 KModel* pModel = GetDocument()->GetpCurrentModel();
00110
00111 s32 StartFrame = 0;
00112 s32 EndFrame = pModel ? pModel->GetEndFrame() : 0;
00113
00114 if( GetDocument()->IsMeshSelected() )
00115 {
00116 ResetRenderEffect();
00117
00118 KMdlMesh* pMesh = (KMdlMesh*)GetDocument()->GetpObjectSelected();
00119 KASSERT( pMesh );
00120
00121 GetDocument()->GetBottomDialog()->m_ButtonAnim.ShowWindow( SW_HIDE );
00122 GetDocument()->GetBottomDialog()->m_ButtonMesh.ShowWindow( SW_HIDE );
00123 GetDocument()->GetBottomDialog()->SetValue( pMesh->m_CurrentFrame,
00124 StartFrame,
00125 EndFrame,
00126 0,
00127 pMesh->m_MaxFrame,
00128 20,
00129 true,
00130 pMesh->m_Name.GetpString(),
00131 m_hIconMesh,
00132 false,
00133 true,
00134 true );
00135
00136 if( m_bShowSelection )
00137 pMesh->m_RenderEffect = KMMRE_NORMALWIREFRAME;
00138 }
00139 else if( GetDocument()->IsAnimSelected() )
00140 {
00141 ResetRenderEffect();
00142
00143 KMdlAnim* pAnim = (KMdlAnim*)GetDocument()->GetpObjectSelected();
00144 KASSERT( pAnim );
00145
00146 GetDocument()->GetBottomDialog()->m_ButtonAnim.ShowWindow( SW_HIDE );
00147 GetDocument()->GetBottomDialog()->m_ButtonMesh.ShowWindow( SW_HIDE );
00148 GetDocument()->GetBottomDialog()->SetValue( pAnim->GetCurrentFrame(),
00149 0,
00150 pAnim->GetMaxFrame(),
00151 0,
00152 pAnim->GetMaxFrame(),
00153 pAnim->GetFPS(),
00154 false,
00155 pAnim->GetName().GetpString(),
00156 m_hIconAnim,
00157 true,
00158 false,
00159 true );
00160
00161 if( m_bShowSelection )
00162 for( u32 i = 0; i < pAnim->GetnMeshAnims(); i ++ )
00163 pAnim->GetpMeshAnims(i)->GetpMesh()->m_RenderEffect = KMMRE_NORMALWIREFRAME;
00164 }
00165 else if( GetDocument()->IsMeshAnimSelected() )
00166 {
00167 ResetRenderEffect();
00168
00169 KMdlMeshAnim* pMeshAnim = (KMdlMeshAnim*)GetDocument()->GetpObjectSelected();
00170 KASSERT( pMeshAnim );
00171
00172 GetDocument()->GetBottomDialog()->m_ButtonAnim.ShowWindow( SW_SHOW );
00173 GetDocument()->GetBottomDialog()->m_ButtonMesh.ShowWindow( SW_SHOW );
00174
00175 if( GetDocument()->GetBottomDialog()->m_ButtonAnim.GetCheck() )
00176 {
00177
00178 GetDocument()->GetBottomDialog()->SetValue( pMeshAnim->GetCurrentFrame(),
00179 0,
00180 pMeshAnim->GetpAnim()->GetMaxFrame(),
00181 pMeshAnim->GetFrameStart(),
00182 pMeshAnim->GetFrameEnd(),
00183 pMeshAnim->GetpAnim()->GetFPS(),
00184 pMeshAnim->IsInheritFrame(),
00185 pMeshAnim->GetpMesh()->m_Name.GetpString(),
00186 m_hIconMeshAnim,
00187 false,
00188 true,
00189 false );
00190 }
00191 else
00192 {
00193
00194 GetDocument()->GetBottomDialog()->SetValue( pMeshAnim->GetCurrentFrame(),
00195 StartFrame,
00196 EndFrame,
00197 pMeshAnim->GetMeshFrameStart(),
00198 pMeshAnim->GetMeshFrameEnd(),
00199 20,
00200 pMeshAnim->IsInheritFrame(),
00201 pMeshAnim->GetpMesh()->m_Name.GetpString(),
00202 m_hIconMeshAnim,
00203 false,
00204 true,
00205 true );
00206 }
00207
00208 if( m_bShowSelection )
00209 pMeshAnim->GetpMesh()->m_RenderEffect = KMMRE_NORMALWIREFRAME;
00210 }
00211 else
00212 {
00213 InitViewer();
00214 }
00215 }