3dCameraPage.cpp
资源名称:gloop.zip [点击查看]
上传用户:shxiangxiu
上传日期:2007-01-03
资源大小:1101k
文件大小:5k
源码类别:
OpenGL
开发平台:
Visual C++
- /////////////////////////////////////////////////////////////////////////////
- // 3dCameraPage.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"
- #include "3dCameraDialog.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char BASED_CODE THIS_FILE[] = __FILE__;
- #endif
- //////////////////////////////////////////////////////////////////
- // C3dCameraPage
- IMPLEMENT_DYNCREATE(C3dCameraPage, CPropertyPage)
- /////////////////////////////////////////////////////////////////////////////
- // C3dCameraPage dialog construction
- C3dCameraPage::C3dCameraPage()
- : CPropertyPage(C3dCameraPage::IDD)
- {
- //{{AFX_DATA_INIT(C3dCameraPage)
- m_fClipBottom = 0.0f;
- m_fClipFar = 0.0f;
- m_fClipLeft = 0.0f;
- m_fClipNear = 0.0f;
- m_fClipRight = 0.0f;
- m_fClipTop = 0.0f;
- m_fFieldOfView = 0.0f;
- m_iPerspective = -1;
- //}}AFX_DATA_INIT
- }
- /////////////////////////////////////////////////////////////////////////////
- // C3dCameraPage Destructor
- C3dCameraPage::~C3dCameraPage()
- {
- }
- void C3dCameraPage::DoDataExchange(CDataExchange* pDX)
- {
- CPropertyPage::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(C3dCameraPage)
- DDX_Text(pDX, IDC_CLIP_BOTTOM, m_fClipBottom);
- DDX_Text(pDX, IDC_CLIP_FAR, m_fClipFar);
- DDX_Text(pDX, IDC_CLIP_LEFT, m_fClipLeft);
- DDX_Text(pDX, IDC_CLIP_NEAR, m_fClipNear);
- DDX_Text(pDX, IDC_CLIP_RIGHT, m_fClipRight);
- DDX_Text(pDX, IDC_CLIP_TOP, m_fClipTop);
- DDX_Text(pDX, IDC_FIELD_OF_VIEW, m_fFieldOfView);
- DDV_MinMaxFloat(pDX, m_fFieldOfView, 1.f, 180.f);
- DDX_Radio(pDX, IDC_RADIO_PERSPECTIVE, m_iPerspective);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(C3dCameraPage, CPropertyPage)
- //{{AFX_MSG_MAP(C3dCameraPage)
- ON_BN_CLICKED(IDC_RADIO_ORTHOGRAPHIC, OnRadioOrthographic)
- ON_BN_CLICKED(IDC_RADIO_PERSPECTIVE, OnRadioPerspective)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // C3dCameraPage function implimentation
- void C3dCameraPage::GetDialogData()
- {
- // Dialog box is being initialized (FALSE)
- // or data is being retrieved (TRUE).
- UpdateData(TRUE);
- //Set the camera attributes..
- m_pCamera->m_fBottom = m_fClipBottom;
- m_pCamera->m_fFar = m_fClipFar;
- m_pCamera->m_fLeft = m_fClipLeft;
- m_pCamera->m_fNear = m_fClipNear;
- m_pCamera->m_fRight = m_fClipRight;
- m_pCamera->m_fTop = m_fClipTop;
- m_pCamera->m_fFovY = m_fFieldOfView;
- }
- void C3dCameraPage::SetDialogData()
- {
- // Set dialog values
- m_fClipBottom = m_pCamera->m_fBottom;
- m_fClipFar = m_pCamera->m_fFar;
- m_fClipLeft = m_pCamera->m_fLeft;
- m_fClipNear = m_pCamera->m_fNear;
- m_fClipRight = m_pCamera->m_fRight;
- m_fClipTop = m_pCamera->m_fTop;
- m_fFieldOfView = m_pCamera->m_fFovY;
- if(m_pCamera->m_bPerspective)
- m_iPerspective = 0;
- else
- m_iPerspective = 1;
- // Dialog box is being initialized (FALSE)
- // or data is being retrieved (TRUE).
- UpdateData(FALSE);
- }
- /////////////////////////////////////////////////////////////////////////////
- // C3dCameraPage message handlers
- BOOL C3dCameraPage::OnInitDialog()
- {
- CPropertyPage::OnInitDialog(); // let the base class do the default work
- // Set our local values to the Cameras' values
- SetDialogData();
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void C3dCameraPage::OnOK()
- {
- // Get the dialog data and store to our cameras'
- // member variables
- GetDialogData();
- // Force the camera to rebuild its' display list
- m_pCamera->m_bBuildLists = TRUE;
- CPropertyPage::OnOK();
- }
- void C3dCameraPage::OnRadioPerspective()
- {
- // Get the dialog data and store to our cameras'
- // member variables
- GetDialogData();
- m_pCamera->m_bPerspective = TRUE;
- m_iPerspective = 0;
- // Set our local values to the Cameras' values
- SetDialogData();
- }
- void C3dCameraPage::OnRadioOrthographic()
- {
- // Get the dialog data and store to our cameras'
- // member variables
- GetDialogData();
- m_pCamera->m_bPerspective = FALSE;
- m_iPerspective = 1;
- // Set our local values to the Cameras' values
- SetDialogData();
- }