AnimationList.cpp
资源名称:gloop.zip [点击查看]
上传用户:shxiangxiu
上传日期:2007-01-03
资源大小:1101k
文件大小:4k
源码类别:
OpenGL
开发平台:
Visual C++
- /////////////////////////////////////////////////////////////////////////////
- // AnimationList.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"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- //////////////////////////////////////////////////////////////////
- // CAnimationList
- //IMPLEMENT_DYNAMIC(CAnimationList, CObList)
- /////////////////////////////////////////////////////////////////////////////
- // CAnimationList construction
- CAnimationList::CAnimationList()
- {
- // TODO: add construction code here,
- // Place all significant initialization in InitInstance
- }
- /////////////////////////////////////////////////////////////////////////////
- // CAnimationList Destructor
- CAnimationList::~CAnimationList()
- {
- DeleteAll();
- }
- /////////////////////////////////////////////////////////////////////////////
- // CAnimationList function implimentation
- void CAnimationList::Append(CAnimation* pAnimation)
- {
- if (!pAnimation) return;
- CObList::AddTail(pAnimation);
- }
- void CAnimationList::Remove(CAnimation* pAnimation)
- {
- if (!pAnimation) return;
- POSITION pos = CObList::Find(pAnimation);
- if (pos) {
- RemoveAt(pos);
- }
- }
- void CAnimationList::Delete(CAnimation* pAnimation)
- {
- if (!pAnimation) return;
- Remove(pAnimation);
- delete pAnimation;
- }
- void CAnimationList::DeleteAll()
- {
- while (!IsEmpty()) {
- CAnimation* pAnimation = (CAnimation*) RemoveHead();
- delete pAnimation;
- }
- }
- CAnimation* CAnimationList::Find(CString szName)
- {
- // Find the animation "Name" in the list
- // Create an animation pointer
- CAnimation* pAnimation = NULL;
- // walk the list
- POSITION Pos = GetHeadPosition();
- while (Pos) {
- pAnimation = GetAt(Pos);
- if(pAnimation->m_szName.Compare(szName) == 0)
- return pAnimation;
- pAnimation = GetNext(Pos);
- }
- // Did not find in current list
- return NULL;
- }
- void CAnimationList::Serialize(CArchive& ar, int iVersion)
- {
- CString szIndentSave;
- CString szBuffer;
- if (ar.IsStoring())
- {
- // Save the Objects' CAnimation procedures
- szBuffer.Format("%stCAnimation Procedures {n", szIndent);
- ar.WriteString(szBuffer);
- // Save the current indention and indent
- // all CAnimation class procedures
- szIndentSave = szIndent;
- szIndent += _T("tt"); // Add tabs
- CAnimation* pAnimation = NULL;
- // walk the list
- POSITION Pos = GetHeadPosition();
- while (Pos) {
- pAnimation = GetAt(Pos);
- // Since we save the AVI video animation procedure with the
- // CMyAviVideo (C3dTextureMap derived class), dont save it here!
- if(!pAnimation->IsKindOf(RUNTIME_CLASS(CAnimAVI)))
- pAnimation->Serialize(ar, iVersion);
- pAnimation = GetNext(Pos);
- }
- // Restore indent position
- szIndent = szIndentSave; // restore indent
- szBuffer.Format("%st}n", szIndent); // end of CAnimation procedures
- ar.WriteString(szBuffer);
- }
- else
- {
- // Search for the beginning of the CAnimation procedures
- while(ar.ReadString(szBuffer)) {
- szBuffer.TrimLeft(); // Remove leading white spaces
- if(szBuffer.Compare("CAnimation Procedures {") == 0)
- break;
- }
- // Found the marker!
- // Load all CAnimation procedures
- while(ar.ReadString(szBuffer)) {
- CAnimation* pAnimation = NULL;
- szBuffer.TrimLeft(); // Remove leading white spaces
- if(szBuffer.Compare("}") == 0) // end of CAnimation procedures
- break;
- pAnimation = CAnimation::IsAnimationClass(&szBuffer);
- if(pAnimation) {
- pAnimation->Serialize(ar, iVersion);
- Append(pAnimation);
- }
- }
- }
- }