3dPageAnimation.cpp
资源名称:gloop.zip [点击查看]
上传用户:shxiangxiu
上传日期:2007-01-03
资源大小:1101k
文件大小:10k
源码类别:
OpenGL
开发平台:
Visual C++
- /////////////////////////////////////////////////////////////////////////////
- // 3dPageAnimation.cpp : implementation file
- //
- // glOOP (OpenGL Object Oriented Programming library)
- // Copyright (c) Craig Fahrnbach 1997, 1998
- //
- // OpenGL is a registered trademark of Silicon Graphics
- //
- //
- // This program is provided for educational and personal use only and
- // is provided without guarantee or warrantee expressed or implied.
- //
- // Commercial use is strickly prohibited without written permission
- // from ImageWare Development.
- //
- // This program is -not- in the public domain.
- //
- /////////////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "glOOP.h"
- #include "3dObjectDialog.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char BASED_CODE THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // C3dPageAnimation
- IMPLEMENT_DYNCREATE(C3dPageAnimation, CPropertyPage)
- /////////////////////////////////////////////////////////////////////////////
- // C3dPageAnimation dialog construction
- C3dPageAnimation::C3dPageAnimation()
- : CPropertyPage(C3dPageAnimation::IDD)
- {
- m_szSelectedProcedure = _T("");
- m_pObject = NULL;
- m_pCamera = NULL;
- m_pWorld = NULL;
- m_pAnimation = NULL;
- //{{AFX_DATA_INIT(C3dPageAnimation)
- //}}AFX_DATA_INIT
- }
- /////////////////////////////////////////////////////////////////////////////
- // C3dPageAnimation Destructor
- C3dPageAnimation::~C3dPageAnimation()
- {
- }
- void C3dPageAnimation::DoDataExchange(CDataExchange* pDX)
- {
- CPropertyPage::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(C3dPageAnimation)
- DDX_Control(pDX, IDC_SELECTED_LIST, m_AnimationList);
- DDX_Control(pDX, IDC_PROCEDURE_LIST, m_ProcedureList);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(C3dPageAnimation, CPropertyPage)
- //{{AFX_MSG_MAP(C3dPageAnimation)
- ON_BN_CLICKED(IDC_BUTTON_ADD, OnButtonAdd)
- ON_BN_CLICKED(IDC_BUTTON_CONFIGURE, OnButtonConfigure)
- ON_BN_CLICKED(IDC_BUTTON_DELETE, OnButtonDelete)
- ON_LBN_SELCHANGE(IDC_PROCEDURE_LIST, OnSelchangeProcedureList)
- ON_LBN_SELCHANGE(IDC_SELECTED_LIST, OnSelchangeSelectedList)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // C3dPageAnimation functions
- void C3dPageAnimation::AddObjectProcedures()
- {
- // Available list of animation procedures for Objects
- m_ProcedureList.AddString(SZ_ANIMATE_SPIN);
- m_ProcedureList.AddString(SZ_ANIMATE_WOBBLE);
- m_ProcedureList.AddString(SZ_ANIMATE_KEYFRAME);
- // if(m_pObject->m_pTextureMap)
- // {
- // if(m_pObject->m_pTextureMap->IsKindOf( RUNTIME_CLASS (CMyAviVideo)))
- // m_ProcedureList.AddString(SZ_ANIMATE_AVI);
- // }
- }
- void C3dPageAnimation::AddCameraProcedures()
- {
- // Available list of animation procedures for our Camera
- m_ProcedureList.AddString(SZ_ANIMATE_SPIN);
- m_ProcedureList.AddString(SZ_ANIMATE_WOBBLE);
- m_ProcedureList.AddString(SZ_ANIMATE_KEYFRAME);
- }
- void C3dPageAnimation::AddWorldProcedures()
- {
- // if(m_pWorld->m_pBkgndTextureMap)
- // {
- // if(m_pWorld->m_pBkgndTextureMap->IsKindOf( RUNTIME_CLASS (CMyAviVideo)))
- // m_ProcedureList.AddString(SZ_ANIMATE_AVI);
- // }
- }
- void C3dPageAnimation::DisplaySelectedProcedures()
- {
- if(m_pObject)
- {
- // Reset or clear the contents of the list box
- m_AnimationList.ResetContent();
- // Fill the List box with all animation procedures attached to this
- // object
- CAnimation* pAnimation = NULL;
- // walk the list
- POSITION Pos = m_pObject->m_AnimList.GetHeadPosition();
- while (Pos)
- {
- pAnimation = m_pObject->m_AnimList.GetAt(Pos);
- m_AnimationList.AddString(pAnimation->m_szName);
- int count = m_AnimationList.GetCount() - 1; // zero based
- m_AnimationList.SetItemData(count, (unsigned long)pAnimation);
- pAnimation = m_pObject->m_AnimList.GetNext(Pos);
- }
- }
- if(m_pCamera)
- {
- // Reset or clear the contents of the list box
- m_AnimationList.ResetContent();
- // Fill the List box with all animation procedures attached to this
- // camera
- CAnimation* pAnimation = NULL;
- // walk the list
- POSITION Pos = m_pCamera->m_AnimList.GetHeadPosition();
- while (Pos)
- {
- pAnimation = m_pCamera->m_AnimList.GetAt(Pos);
- m_AnimationList.AddString(pAnimation->m_szName);
- int count = m_AnimationList.GetCount() - 1; // zero based
- m_AnimationList.SetItemData(count, (unsigned long)pAnimation);
- pAnimation = m_pCamera->m_AnimList.GetNext(Pos);
- }
- }
- if(m_pWorld)
- {
- // Reset or clear the contents of the list box
- m_AnimationList.ResetContent();
- // Fill the List box with all animation procedures attached to this
- // World
- CAnimation* pAnimation = NULL;
- // walk the list
- POSITION Pos = m_pWorld->m_AnimList.GetHeadPosition();
- while (Pos)
- {
- pAnimation = m_pWorld->m_AnimList.GetAt(Pos);
- m_AnimationList.AddString(pAnimation->m_szName);
- int count = m_AnimationList.GetCount() - 1; // zero based
- m_AnimationList.SetItemData(count, (unsigned long)pAnimation);
- pAnimation = m_pWorld->m_AnimList.GetNext(Pos);
- }
- }
- }
- /////////////////////////////////////////////////////////////////////////////
- // C3dPageAnimation message handlers
- BOOL C3dPageAnimation::OnInitDialog()
- {
- // let the base class do the default work
- CPropertyPage::OnInitDialog();
- // Reset or clear the contents of the list box
- m_ProcedureList.ResetContent();
- // Display the list of available animation procedures
- if(m_pObject)
- AddObjectProcedures();
- if(m_pCamera)
- AddCameraProcedures();
- if(m_pWorld)
- AddWorldProcedures();
- // Display the objects current animation procedures
- DisplaySelectedProcedures();
- // Dialog box is being initialized (FALSE)
- // or data is being retrieved (TRUE).
- UpdateData(FALSE);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void C3dPageAnimation::OnOK()
- {
- // TODO: Add your specialized code here and/or call the base class
- CPropertyPage::OnOK();
- }
- void C3dPageAnimation::OnButtonAdd()
- {
- if(m_szSelectedProcedure == _T("") )
- AfxMessageBox("Please select a procedure from the 'Available Procedures' list.", MB_OK);
- else
- {
- if(m_pObject) // Which object animation procedure do we add?
- {
- if(m_szSelectedProcedure.Compare(SZ_ANIMATE_SPIN) == 0)
- {
- if(!m_pObject->m_AnimList.Find(SZ_ANIMATE_SPIN))
- {
- CAnimSpin* pAnimSpin = new CAnimSpin;
- m_pObject->m_AnimList.Append(pAnimSpin);
- }
- else
- AfxMessageBox("Can only have one 'Spin' animation!", MB_OK);
- }
- if(m_szSelectedProcedure.Compare(SZ_ANIMATE_WOBBLE) == 0)
- {
- if(!m_pObject->m_AnimList.Find(SZ_ANIMATE_WOBBLE))
- {
- CAnimWobble* pAnimWobble = new CAnimWobble;
- m_pObject->m_AnimList.Append(pAnimWobble);
- }
- else
- AfxMessageBox("Can only have one 'Wobble' animation!", MB_OK);
- }
- if(m_szSelectedProcedure.Compare(SZ_ANIMATE_AVI) == 0)
- {
- if(!m_pObject->m_AnimList.Find(SZ_ANIMATE_AVI))
- {
- CAnimAVI* pAnimAVI = new CAnimAVI;
- m_pObject->m_AnimList.Append(pAnimAVI);
- }
- else
- AfxMessageBox("This Object can only have one animation procedure!", MB_OK);
- }
- if(m_szSelectedProcedure.Compare(SZ_ANIMATE_KEYFRAME) == 0)
- {
- CAnimKeyFrame* pAnimKey = new CAnimKeyFrame;
- m_pObject->m_AnimList.Append(pAnimKey);
- }
- }
- if(m_pCamera) // Which camera animation procedure do we add?
- {
- if(m_szSelectedProcedure.Compare(SZ_ANIMATE_SPIN) == 0)
- {
- if(!m_pCamera->m_AnimList.Find(SZ_ANIMATE_SPIN))
- {
- CAnimSpin* pAnimSpin = new CAnimSpin;
- m_pCamera->m_AnimList.Append(pAnimSpin);
- }
- else
- AfxMessageBox("Can only have one 'Spin' animation!", MB_OK);
- }
- if(m_szSelectedProcedure.Compare(SZ_ANIMATE_WOBBLE) == 0)
- {
- if(!m_pObject->m_AnimList.Find(SZ_ANIMATE_WOBBLE))
- {
- CAnimWobble* pAnimWobble = new CAnimWobble;
- m_pCamera->m_AnimList.Append(pAnimWobble);
- }
- else
- AfxMessageBox("Can only have one 'Wobble' animation!", MB_OK);
- }
- if(m_szSelectedProcedure.Compare(SZ_ANIMATE_KEYFRAME) == 0)
- {
- CAnimKeyFrame* pAnimKey = new CAnimKeyFrame;
- m_pCamera->m_AnimList.Append(pAnimKey);
- }
- }
- if(m_pWorld) // Which World animation procedure do we add?
- {
- if(m_szSelectedProcedure.Compare(SZ_ANIMATE_AVI) == 0)
- {
- if(!m_pWorld->m_AnimList.Find(SZ_ANIMATE_AVI))
- {
- CAnimAVI* pAnimAVI = new CAnimAVI;
- m_pWorld->m_AnimList.Append(pAnimAVI);
- }
- else
- AfxMessageBox("This TextureMap can only have one animation procedure!", MB_OK);
- }
- }
- }
- // Update the selected animation procedures
- DisplaySelectedProcedures();
- }
- void C3dPageAnimation::OnButtonConfigure()
- {
- if(m_pObject)
- {
- m_pObject->EditAnimation(this, NULL);
- return;
- }
- if(m_pCamera)
- {
- m_pCamera->EditAnimation(this, NULL);
- return;
- }
- if(m_pWorld)
- {
- m_pWorld->EditAnimation(this, NULL);
- return;
- }
- }
- void C3dPageAnimation::OnButtonDelete()
- {
- if(m_pAnimation == NULL)
- AfxMessageBox("Please select a procedure from the 'Selected Procedures' list to delete.", MB_OK);
- else
- {
- if(m_pObject)
- {
- m_pObject->m_AnimList.Delete(m_pAnimation);
- m_pAnimation = NULL;
- DisplaySelectedProcedures();
- return;
- }
- if(m_pCamera)
- {
- m_pCamera->m_AnimList.Delete(m_pAnimation);
- m_pAnimation = NULL;
- DisplaySelectedProcedures();
- return;
- }
- if(m_pWorld)
- {
- m_pWorld->m_AnimList.Delete(m_pAnimation);
- m_pAnimation = NULL;
- DisplaySelectedProcedures();
- return;
- }
- }
- }
- void C3dPageAnimation::OnSelchangeProcedureList()
- {
- // Get the zero-based index of the item selected
- int index = m_ProcedureList.GetCurSel();
- if(index != LB_ERR)
- {
- // Get the user selected procedure from the list
- // a C3dColor pointer..
- m_ProcedureList.GetText(index, m_szSelectedProcedure);
- }
- else
- m_szSelectedProcedure = _T("");
- }
- void C3dPageAnimation::OnSelchangeSelectedList()
- {
- // User selected an Animation procedure from the "Selected List"
- // Get the zero-based index of the item selected
- int index = m_AnimationList.GetCurSel();
- if(index != LB_ERR)
- {
- // Cast the user selected list box items' lParam to
- // a CAnimation pointer..
- m_pAnimation = (CAnimation*)m_AnimationList.GetItemData(index);
- }
- else
- m_pAnimation = NULL;
- }