AnimAVI.cpp
资源名称:gloop.zip [点击查看]
上传用户:shxiangxiu
上传日期:2007-01-03
资源大小:1101k
文件大小:4k
源码类别:
OpenGL
开发平台:
Visual C++
- /////////////////////////////////////////////////////////////////////////////
- // AnimAVI.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 "AnimationDialog.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CAnimAVI
- IMPLEMENT_DYNAMIC(CAnimAVI, CAnimation)
- /////////////////////////////////////////////////////////////////////////////
- // CAnimAVI construction
- CAnimAVI::CAnimAVI()
- {
- // Reset our pointers
- m_pAviMovie = NULL;
- // Set the attributes to default values..
- m_szName = SZ_ANIMATE_AVI;
- m_bFirst = TRUE;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CAnimAVI Destructor
- CAnimAVI::~CAnimAVI()
- {
- }
- /////////////////////////////////////////////////////////////////////////////
- // CAnimAVI Methods or virtual function implimentation
- void CAnimAVI::AddAnimationPage(LPVOID pSht, C3dObject* pObject, C3dCamera* pCamera, C3dWorld* pWorld)
- {
- CAnimPropSheet* pSheet = (CAnimPropSheet*)pSht;
- ASSERT(pSheet);
- // Add the page to the property sheet
- pSheet->AddPage(&pSheet->m_TextureMapPage);
- // Save the address of this animation procedure in the page
- pSheet->m_TextureMapPage.m_pAnimation = this;
- }
- void CAnimAVI::AnimateObject(C3dObject* pObject, double dTime)
- {
- // Ensure that we have a vaild pointer..
- if(!pObject)
- return;
- // First pass through, just save the objects original
- // parameters
- if(m_bFirst)
- {
- m_bFirst = FALSE;
- SaveObjectAttributes(pObject);
- return;
- }
- // Play the AVI movie
- m_pAviMovie->Play(dTime);
- // Save the time of the last iteration
- m_dTimePrevious = dTime;
- }
- void CAnimAVI::AnimateWorld(C3dWorld* pWorld, double dTime)
- {
- // Ensure that we have a vaild pointer..
- if(!pWorld)
- return;
- // First pass through, just save the objects original
- // parameters
- if(m_bFirst)
- {
- m_bFirst = FALSE;
- return;
- }
- // Play the AVI movie
- m_pAviMovie->Play(dTime);
- // Save the time of the last iteration
- m_dTimePrevious = dTime;
- }
- void CAnimAVI::Serialize(CArchive& ar, int iVersion)
- {
- CString szBuffer;
- CString szName;
- szBuffer.GetBuffer(256);
- szName.GetBuffer(128);
- if (ar.IsStoring())
- {
- // Save the CAnimation derived class header...
- szBuffer.Format("%sCAnimAVI {n", szIndent);
- ar.WriteString(szBuffer);
- // Save the this animation procedures' specific data...
- // szBuffer.Format("%stSpinX < %f >n", szIndent, m_fSpinX);
- // ar.WriteString(szBuffer);
- // Save the base class data...
- CAnimation::Serialize(ar, iVersion);
- szBuffer.Format("%s}n", szIndent); // end of animation def
- ar.WriteString(szBuffer);
- }
- else
- {
- // Read the derived class data..
- ar.ReadString(szBuffer); // Read the class header
- // ar.ReadString(szBuffer);
- // szBuffer.TrimLeft(); // Remove leading white spaces
- // sscanf(szBuffer, "SpinX < %f >n", &m_fSpinX);
- // Read the base class data...
- CAnimation::Serialize(ar, iVersion);
- }
- }
- void CAnimAVI::Reset()
- {
- // Stop our movie..
- if(m_pAviMovie)
- m_pAviMovie->Stop();
- }
- /////////////////////////////////////////////////////////////////////////////
- // CAnimAVI function implimentation