3dObjectHSpline.cpp
资源名称:gloop.zip [点击查看]
上传用户:shxiangxiu
上传日期:2007-01-03
资源大小:1101k
文件大小:6k
源码类别:
OpenGL
开发平台:
Visual C++
- /////////////////////////////////////////////////////////////////////////////
- // 3dObjectHSpline.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.
- //
- // HSplines by Joe Dart, 1999
- //
- // ???? this ok? ** Modify as necessary **
- //
- /////////////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "glOOP.h"
- #include "3dObjectDialog.h"
- #include <math.h>
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- //////////////////////////////////////////////////////////////////
- // C3dObjectHSpline
- IMPLEMENT_DYNAMIC(C3dObjectHSpline, C3dObject)
- /////////////////////////////////////////////////////////////////////////////
- // C3dShape construction
- C3dObjectHSpline::C3dObjectHSpline()
- {
- // Set the attributes to default values..
- m_iType = SHAPE_OBJECT;
- m_szName.Format("hSpline %u", nHSplineObjects++);
- //*****************************************************************
- // Add your member variable initializations here
- //*****************************************************************
- // Create our C3dPointArray object
- m_pPointArray = new C3dPointArray;
- ASSERT(m_pPointArray);
- }
- /////////////////////////////////////////////////////////////////////////////
- // C3DWorld Destructor
- C3dObjectHSpline::~C3dObjectHSpline()
- {
- // Delete our point array
- if(m_pPointArray)
- delete m_pPointArray;
- }
- /////////////////////////////////////////////////////////////////////////////
- // C3dObjectHSpline virtual function overrides
- void C3dObjectHSpline::AddAttributePage(C3dWorld* pWorld, LPVOID pSht)
- {
- C3dObjectPropSheet* pSheet = (C3dObjectPropSheet*)pSht;
- ASSERT(pSheet);
- // Add the page to the property sheet
- pSheet->AddPage(&pSheet->m_HSplinePage);
- // Save the address of this object in the page
- pSheet->m_HSplinePage.m_pObject = this;
- }
- void C3dObjectHSpline::GetShapeBounds(C3dBoundingBox* pBox)
- {
- //*****************************************************************
- // Add your code to calculate the bounds of the shape
- //*****************************************************************
- }
- int C3dObjectHSpline::LoadBitMapImage(CImageList* pList)
- {
- CBitmap bitmap;
- // If the image index has been stored in this object,
- // return the index.
- if(m_iBMImage > -1)
- return m_iBMImage;
- // If the image index for this object type has been
- // created, store the index for this object and
- // return the index.
- if( iObjectHSplineBMImage > -1) {
- m_iBMImage = iObjectHSplineBMImage;
- return m_iBMImage;
- }
- // The image index for this object type has not been
- // loaded and the object image index has not been
- // stored.
- //
- // Load the bitmap for the non-selected object
- bitmap.LoadBitmap(IDB_OBJECT_HSPLINE);
- m_iBMImage = pList->Add(&bitmap, (COLORREF)0xFFFFFF);
- bitmap.DeleteObject();
- // Load the bitmap for the non-selected object
- bitmap.LoadBitmap(IDB_OBJECT_HSPLINE_SELECTED);
- pList->Add(&bitmap, (COLORREF)0xFFFFFF);
- bitmap.DeleteObject();
- iObjectHSplineBMImage = m_iBMImage;
- return m_iBMImage;
- }
- void C3dObjectHSpline::Serialize(CArchive& ar, int iVersion)
- {
- CString szBuffer;
- if (ar.IsStoring())
- {
- // Save the Object Class header...
- szBuffer.Format("n%sC3dObjectHSpline {n", szIndent);
- ar.WriteString(szBuffer);
- // Save the this objects' specific data...
- //***************************************************
- //******* Add your object specific date here *******
- //***************************************************
- // Save the base class object data...
- C3dObject::Serialize(ar, iVersion);
- szBuffer.Format("%s}n", szIndent); // end of object def
- ar.WriteString(szBuffer);
- }
- else
- {
- if(iVersion < 102)
- // Read the base class object data...
- C3dObject::Serialize(ar, iVersion);
- // Read the derived class data..
- //***************************************************
- //******* Add your object specific date here *******
- //***************************************************
- // Create the array of points
- if(!m_pPointArray->Create(m_pPointArray->m_iNumPoints))
- {
- // Now that the points array has been created,
- // read the point data.
- for(int i=0; i<m_pPointArray->m_iNumPoints; i++)
- {
- ar.ReadString(szBuffer);
- szBuffer.TrimLeft();
- sscanf(szBuffer, "< %f, %f, %f >n", &m_pPointArray->m_pPoints[i].m_fOrigin[0],
- &m_pPointArray->m_pPoints[i].m_fOrigin[1],
- &m_pPointArray->m_pPoints[i].m_fOrigin[2]);
- }
- }
- if(iVersion < 102)
- // Read all child objects...
- LoadChildObjects(ar, iVersion);
- else
- // Read the base class object data...
- C3dObject::Serialize(ar, iVersion);
- }
- }
- void C3dObjectHSpline::Build(C3dWorld* pWorld, C3dCamera* pCamera)
- {
- glNewList(m_iDisplayLists, GL_COMPILE_AND_EXECUTE);
- //*****************************************************************
- // Add your code to 'build' the object, in object coordinates, here
- //*****************************************************************
- glEndList();
- }
- /////////////////////////////////////////////////////////////////////////////
- // C3dObjectHSpline function implimentation