3dpagecloud.cpp
资源名称:gloop.zip [点击查看]
上传用户:shxiangxiu
上传日期:2007-01-03
资源大小:1101k
文件大小:6k
源码类别:
OpenGL
开发平台:
Visual C++
- /////////////////////////////////////////////////////////////////////////////
- // 3dPageCloud.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
- //////////////////////////////////////////////////////////////////
- // C3dPageCloud
- IMPLEMENT_DYNCREATE(C3dPageCloud, CPropertyPage)
- /////////////////////////////////////////////////////////////////////////////
- // C3dPageCloud dialog construction
- C3dPageCloud::C3dPageCloud()
- : CPropertyPage(C3dPageCloud::IDD)
- {
- m_bInitVertices = FALSE;
- //{{AFX_DATA_INIT(C3dPageCloud)
- m_szName = _T("");
- m_bRandomSeed = FALSE;
- m_iHeightSeed = 0;
- m_fDepth = 0.0f;
- m_fWidth = 0.0f;
- m_iTile = 0;
- //}}AFX_DATA_INIT
- }
- /////////////////////////////////////////////////////////////////////////////
- // C3dPageCloud Destructor
- C3dPageCloud::~C3dPageCloud()
- {
- }
- void C3dPageCloud::DoDataExchange(CDataExchange* pDX)
- {
- CPropertyPage::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(C3dPageCloud)
- DDX_Control(pDX, IDC_SLIDER_HEIGHT, m_SliderHeight);
- DDX_Control(pDX, IDC_SLIDER_DENSITY, m_SliderDensity);
- DDX_Text(pDX, IDC_NAME, m_szName);
- DDV_MaxChars(pDX, m_szName, 40);
- DDX_Text(pDX, IDC_DEPTH, m_fDepth);
- DDX_Text(pDX, IDC_HEIGHT_SEED, m_iHeightSeed);
- DDX_Text(pDX, IDC_TILE, m_iTile);
- DDX_Text(pDX, IDC_WIDTH, m_fWidth);
- DDX_Check(pDX, IDC_RANDOM_SEED, m_bRandomSeed);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(C3dPageCloud, CPropertyPage)
- //{{AFX_MSG_MAP(C3dPageCloud)
- ON_WM_VSCROLL()
- ON_EN_CHANGE(IDC_HEIGHT_SEED, OnChangeHeightSeed)
- ON_EN_CHANGE(IDC_DEPTH, OnChangeDepth)
- ON_EN_CHANGE(IDC_WIDTH, OnChangeWidth)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // C3dPageCloud message handlers
- BOOL C3dPageCloud::OnInitDialog()
- {
- // Let the base class do the default work
- CPropertyPage::OnInitDialog();
- // Set our local values to the Objects' values
- m_szName = m_pObject->m_szName;
- m_fDepth = m_pObject->m_fDepth;
- m_fWidth = m_pObject->m_fWidth;
- m_iHeightSeed = m_pObject->m_iHeightSeed;
- m_iTile = m_pObject->m_iTile;
- // Set our Cloud bump height, or smoothness, slider. Scaled by 100.
- m_SliderHeight.SetRange(0, 100, TRUE);
- m_SliderHeight.SetPos((int)(m_pObject->m_fBumpHeight*100));
- // Set our Cloud density slider. Range 0 to .5, scaled by 100
- m_SliderDensity.SetRange(0, 50, TRUE);
- m_SliderDensity.SetPos((int)(m_pObject->m_fDensity*100));
- // 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 C3dPageCloud::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
- {
- // The property page settings have been modified, so
- // Enable (TRUE) or disable (FALSE) the Apply Now button
- SetModified(TRUE);
- // User has modified the planes depth, so set our vertice
- // initialization flag
- m_bInitVertices = TRUE;
- int posn;
- C3dObjectCloud* pCloud = m_pObject;
- if(pScrollBar == (CScrollBar*)&m_SliderHeight)
- {
- // Get the position of our slider control.
- posn = m_SliderHeight.GetPos();
- pCloud->m_fBumpHeight = (float)posn/100.f;
- }
- else if(pScrollBar == (CScrollBar*)&m_SliderDensity)
- {
- posn = m_SliderDensity.GetPos();
- pCloud->m_fDensity = (float)posn/100.f;
- }
- CPropertyPage::OnVScroll(nSBCode, nPos, pScrollBar);
- }
- void C3dPageCloud::OnChangeHeightSeed()
- {
- // The property page settings have been modified, so
- // Enable (TRUE) or disable (FALSE) the Apply Now button
- SetModified(TRUE);
- // User has modified the clouds random seed height, so set our vertice
- // initialization flag
- m_bInitVertices = TRUE;
- }
- void C3dPageCloud::OnChangeDepth()
- {
- // The property page settings have been modified, so
- // Enable (TRUE) or disable (FALSE) the Apply Now button
- SetModified(TRUE);
- // User has modified the clouds' depth, so set our vertice
- // initialization flag
- m_bInitVertices = TRUE;
- }
- void C3dPageCloud::OnChangeWidth()
- {
- // The property page settings have been modified, so
- // Enable (TRUE) or disable (FALSE) the Apply Now button
- SetModified(TRUE);
- // User has modified the clouds' width, so set our vertice
- // initialization flag
- m_bInitVertices = TRUE;
- }
- void C3dPageCloud::OnOK()
- {
- CPropertyPage::OnOK();
- }
- BOOL C3dPageCloud::OnApply()
- {
- // The property page settings have been modified, so
- // Enable (TRUE) or disable (FALSE) the Apply Now button
- SetModified(FALSE);
- // Dialog box is being initialized (FALSE)
- // or data is being retrieved (TRUE).
- UpdateData(TRUE);
- // Set the Objects Origin..
- m_pObject->m_szName = m_szName;
- m_pObject->m_fDepth = m_fDepth;
- m_pObject->m_fWidth = m_fWidth;
- m_pObject->m_iTile = m_iTile;
- if(m_bRandomSeed)
- m_pObject->m_iHeightSeed = -1;
- else
- m_pObject->m_iHeightSeed = m_iHeightSeed;
- // Force the object to rebuild its' display list
- m_pObject->m_bBuildLists = TRUE;
- // Rebuild our objects vertices?
- if(m_bInitVertices)
- m_pObject->InitVertices();
- return CPropertyPage::OnApply();
- }