Initial full mirror of c:\VWE (source + assets + toolchain + outputs) via Git LFS

Complete disaster-recovery snapshot: engine/game source, game data assets,
VC6 toolchain + DX SDKs, build outputs, deployed game, and _UNUSED archive.
Large binaries in Git LFS; text preserved byte-for-byte (core.autocrlf=false,
no eol attributes). See RECOVERY.md for the one-clone rebuild procedure.
This commit is contained in:
Cyd
2026-06-24 21:28:16 -05:00
commit 2b8ca921cb
66341 changed files with 7923174 additions and 0 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+396
View File
@@ -0,0 +1,396 @@
// CamInfoDlg.cpp : implementation file
//
#include "stdafx.h"
#include "TCTb.h"
#include "CamInfoDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define VALIDATE_TIMER 1234
#define VALIDATE_TIME 1000
/////////////////////////////////////////////////////////////////////////////
// CCamInfoDlg dialog
CCamInfoDlg::CCamInfoDlg(CWnd* pParent /*=NULL*/)
: CDialog(CCamInfoDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CCamInfoDlg)
m_CamLocX = 0.0;
m_CamLocZ = 0.0;
m_CamLocY = 0.0;
m_CamTrkAlt = 0.0;
m_TarLocX = 0.0;
m_TarLocY = 0.0;
m_TarLocZ = 0.0;
m_TarTAlt = 0.0;
m_TmeSli = 0;
m_VelSli = 0;
m_FOVSli = 0;
m_FarClip = 0.0;
m_NearClip = 0.0;
m_FOVText = 0;
//}}AFX_DATA_INIT
CamInfo=NULL;
FCon=0;
NoUpdate=false;
}
void CCamInfoDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCamInfoDlg)
DDX_Control(pDX, IDC_NEARCLIP, m_NearClipCtrl);
DDX_Control(pDX, IDC_FARCLIP, m_FarClipCtrl);
DDX_Control(pDX, IDC_FOVTEXT, m_FOVTextCtrl);
DDX_Control(pDX, IDC_FOVSLI, m_FOVSliCtrl);
DDX_Control(pDX, IDC_VELTEXT, m_VelText);
DDX_Control(pDX, IDC_VELSLI, m_VelSliCtrl);
DDX_Control(pDX, IDC_CAMLOCZ, m_CLOCZCtrl);
DDX_Control(pDX, IDC_CAMLOCY, m_CLOCYCtrl);
DDX_Control(pDX, IDC_CAMLOCX, m_CLOCXCtrl);
DDX_Control(pDX, IDC_SPOSSLI, m_TSliCtrl);
DDX_Control(pDX, IDC_POSTEXT, m_PosText);
DDX_Control(pDX, IDC_CAMTALT, m_CTAlt);
DDX_Control(pDX, IDC_TLOCTT, m_TTT);
DDX_Control(pDX, IDC_TARTALT, m_TTACtrl);
DDX_Control(pDX, IDC_TARLOCZ, m_TLZCtrl);
DDX_Control(pDX, IDC_TARLOCY, m_TLYCtrl);
DDX_Control(pDX, IDC_TARLOCX, m_TLXCtrl);
DDX_Text(pDX, IDC_CAMLOCX, m_CamLocX);
DDX_Text(pDX, IDC_CAMLOCZ, m_CamLocZ);
DDX_Text(pDX, IDC_CAMLOCY, m_CamLocY);
DDX_Text(pDX, IDC_CAMTALT, m_CamTrkAlt);
DDX_Text(pDX, IDC_TARLOCX, m_TarLocX);
DDX_Text(pDX, IDC_TARLOCY, m_TarLocY);
DDX_Text(pDX, IDC_TARLOCZ, m_TarLocZ);
DDX_Text(pDX, IDC_TARTALT, m_TarTAlt);
DDX_Slider(pDX, IDC_SPOSSLI, m_TmeSli);
DDX_Slider(pDX, IDC_VELSLI, m_VelSli);
DDX_Slider(pDX, IDC_FOVSLI, m_FOVSli);
DDX_Text(pDX, IDC_FARCLIP, m_FarClip);
DDV_MinMaxDouble(pDX, m_FarClip, 1.e-003, 99999999.);
DDX_Text(pDX, IDC_NEARCLIP, m_NearClip);
DDV_MinMaxDouble(pDX, m_NearClip, 1.e-003, 9999999.);
DDX_Text(pDX, IDC_FOVTEXT, m_FOVText);
DDV_MinMaxInt(pDX, m_FOVText, 1, 180);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCamInfoDlg, CDialog)
//{{AFX_MSG_MAP(CCamInfoDlg)
ON_WM_CLOSE()
ON_BN_CLICKED(IDC_CLOCTT, OnCloctt)
ON_BN_CLICKED(IDC_USETARGET, OnUsetarget)
ON_BN_CLICKED(IDC_TLOCTT, OnTloctt)
ON_BN_CLICKED(IDC_TRACK, OnTrack)
ON_BN_CLICKED(IDC_FREE, OnFree)
ON_WM_CREATE()
ON_BN_CLICKED(IDC_ANIMATE, OnAnimate)
ON_WM_HSCROLL()
ON_WM_RBUTTONUP()
ON_WM_RBUTTONDOWN()
ON_EN_CHANGE(IDC_CAMLOCX, OnChangeCamlocx)
ON_EN_CHANGE(IDC_CAMLOCY, OnChangeCamlocy)
ON_EN_CHANGE(IDC_CAMLOCZ, OnChangeCamlocz)
ON_EN_CHANGE(IDC_TARLOCX, OnChangeTarlocx)
ON_EN_CHANGE(IDC_TARLOCY, OnChangeTarlocy)
ON_EN_CHANGE(IDC_TARLOCZ, OnChangeTarlocz)
ON_BN_CLICKED(IDC_RESETCURVE, OnResetcurve)
ON_EN_CHANGE(IDC_FARCLIP, OnChangeFarclip)
ON_EN_CHANGE(IDC_NEARCLIP, OnChangeNearclip)
ON_WM_TIMER()
ON_EN_CHANGE(IDC_TARTALT, OnChangeTartalt)
ON_EN_CHANGE(IDC_FOVTEXT, OnChangeFovtext)
ON_EN_CHANGE(IDC_CAMTALT, OnChangeCamtalt)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCamInfoDlg message handlers
void CCamInfoDlg::UpdateInfo()
{
if(!CamInfo) return;
if(NoUpdate) return;
m_CamLocX=CamInfo->Loc.x;
m_CamLocY=CamInfo->Loc.y;
m_CamLocZ=CamInfo->Loc.z;
m_TarLocX=CamInfo->TargetLoc.x;
m_TarLocY=CamInfo->TargetLoc.y;
m_TarLocZ=CamInfo->TargetLoc.z;
m_TarTAlt=CamInfo->TarTrackAlt;
m_CamTrkAlt=CamInfo->CamTrackAlt;
m_NearClip=CamInfo->NearClip;
m_FarClip=CamInfo->FarClip;
m_FOVSli=m_FOVText=(int)(CamInfo->FOV*Degrees_Per_Radian);
m_TmeSli=((int)(CamInfo->GetTime()*100));
m_VelSli=((int)(CamInfo->GetVel()*100));
CheckDlgButton(IDC_USETARGET,CamInfo->UseTarget);
CheckDlgButton(IDC_ANIMATE,CamInfo->Animate);
CheckDlgButton(IDC_CLOCTT,CamInfo->CamATrkFlg);
CheckDlgButton(IDC_TLOCTT,CamInfo->TarATrkFlg);
CheckRadioButton(IDC_FREE,IDC_TRACK,CamInfo->GetMode()==CameraInfo::CM_TRACK?IDC_TRACK:IDC_FREE);
UpdateData(FALSE);
UpdateControlStates();
}
void CCamInfoDlg::OnCancel()
{
// TODO: Add extra cleanup here
// CDialog::OnCancel();
}
void CCamInfoDlg::OnOK()
{
// TODO: Add extra validation here
// CDialog::OnOK();
}
void CCamInfoDlg::OnClose()
{
// TODO: Add your message handler code here and/or call default
// ShowWindow(SW_MINIMIZE);
ShowWindow(SW_HIDE);
// CDialog::OnClose();
}
void CCamInfoDlg::UpdateControlStates()
{
m_TLXCtrl.EnableWindow(IsDlgButtonChecked(IDC_USETARGET));
m_TLYCtrl.EnableWindow(IsDlgButtonChecked(IDC_USETARGET));
m_TLZCtrl.EnableWindow(IsDlgButtonChecked(IDC_USETARGET));
m_TTACtrl.EnableWindow(IsDlgButtonChecked(IDC_USETARGET));
m_TTT.EnableWindow(IsDlgButtonChecked(IDC_USETARGET));
if(IsDlgButtonChecked(IDC_USETARGET))
m_TTACtrl.EnableWindow(IsDlgButtonChecked(IDC_TLOCTT));
m_CTAlt.EnableWindow(IsDlgButtonChecked(IDC_CLOCTT));
//m_TSliCtrl.EnableWindow(!IsDlgButtonChecked(IDC_ANIMATE));
CheckDlgButton(IDC_ANIMATE,CamInfo->Animate);
CString tstr;
tstr.Format("%i%%",m_TmeSli);
m_PosText.SetWindowText(tstr);
tstr.Format("%i%%",m_VelSli);
m_VelText.SetWindowText(tstr);
}
void CCamInfoDlg::OnCloctt()
{
UpdateControlStates();
CamInfo->CamATrkFlg=IsDlgButtonChecked(IDC_CLOCTT)?true:false;
}
void CCamInfoDlg::OnTloctt()
{
UpdateControlStates();
CamInfo->TarATrkFlg=IsDlgButtonChecked(IDC_TLOCTT)?true:false;
}
void CCamInfoDlg::OnUsetarget()
{
CamInfo->UseTarget=IsDlgButtonChecked(IDC_USETARGET)?true:false;
}
void CCamInfoDlg::SetCamInfo(CameraInfo *CIn)
{
CamInfo=CIn;
}
void CCamInfoDlg::OnTrack()
{
CamInfo->SetMode(CameraInfo::CM_TRACK);
}
void CCamInfoDlg::OnFree()
{
CamInfo->SetMode(CameraInfo::CM_FREE);
}
int CCamInfoDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
return 0;
}
BOOL CCamInfoDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_TSliCtrl.SetRange(0,100);
m_VelSliCtrl.SetRange(-100,100);
m_FOVSliCtrl.SetRange(1,180);
m_TSliCtrl.SetFocus();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CCamInfoDlg::OnAnimate()
{
CamInfo->Animate=IsDlgButtonChecked(IDC_ANIMATE)?true:false;
UpdateControlStates();
}
void CCamInfoDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
CString tstr;
if(pScrollBar==(CScrollBar* )&m_TSliCtrl || pScrollBar==(CScrollBar* )&m_VelSliCtrl)
CamInfo->SetMode(CameraInfo::CM_TRACK);
if(pScrollBar==(CScrollBar* )&m_TSliCtrl)
{
CamInfo->Animate=false;
CheckDlgButton(IDC_ANIMATE,CamInfo->Animate);
tstr.Format("%i%%",m_TSliCtrl.GetPos());
m_PosText.SetWindowText(tstr);
CamInfo->SetTime(m_TSliCtrl.GetPos()/100.0f);
}
if(pScrollBar==(CScrollBar* )&m_VelSliCtrl)
{
tstr.Format("%i%%",m_VelSliCtrl.GetPos());
m_VelText.SetWindowText(tstr);
CamInfo->SetVel(m_VelSliCtrl.GetPos()/100.0f);
CheckDlgButton(IDC_ANIMATE,TRUE);
CamInfo->Animate=true;
}
if(pScrollBar==(CScrollBar* )&m_FOVSliCtrl)
{
tstr.Format("%i",m_FOVSliCtrl.GetPos());
m_FOVTextCtrl.SetWindowText(tstr);
CamInfo->FOV=m_FOVSliCtrl.GetPos()*Radians_Per_Degree;
}
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}
void CCamInfoDlg::OnRButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CDialog::OnRButtonUp(nFlags, point);
}
void CCamInfoDlg::OnRButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CDialog::OnRButtonDown(nFlags, point);
}
void CCamInfoDlg::OnResetcurve()
{
if(!CamInfo || !CamInfo->ViewLoop) return;
CamInfo->ViewLoop->ResetCurve();
}
void CCamInfoDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
Validate();
CDialog::OnTimer(nIDEvent);
}
void CCamInfoDlg::Validate()
{
KillTimer(VALIDATE_TIMER);
if(!CamInfo) return;
UpdateData(TRUE);
if(m_FarClip<m_NearClip) m_FarClip=m_NearClip;
CamInfo->NearClip=(float)m_NearClip;
CamInfo->FarClip=(float)m_FarClip;
CamInfo->Loc.x=(float)m_CamLocX;
CamInfo->Loc.y=(float)m_CamLocY;
CamInfo->Loc.z=(float)m_CamLocZ;
CamInfo->TargetLoc.x=(float)m_TarLocX;
CamInfo->TargetLoc.y=(float)m_TarLocY;
CamInfo->TargetLoc.z=(float)m_TarLocZ;
CamInfo->FOV=(float)m_FOVText*Radians_Per_Degree;
CamInfo->CamTrackAlt=(float)m_CamTrkAlt;
CamInfo->TarTrackAlt=(float)m_TarTAlt;
NoUpdate=false;
}
void CCamInfoDlg::DelayedValidate(int tme)
{
NoUpdate=true;
KillTimer(VALIDATE_TIMER);
SetTimer(VALIDATE_TIMER,tme,NULL);
}
void CCamInfoDlg::OnChangeTartalt() { DelayedValidate(VALIDATE_TIME); }
void CCamInfoDlg::OnChangeFovtext() { DelayedValidate(VALIDATE_TIME); }
void CCamInfoDlg::OnChangeCamtalt() { DelayedValidate(VALIDATE_TIME); }
void CCamInfoDlg::OnChangeFarclip() { DelayedValidate(VALIDATE_TIME); }
void CCamInfoDlg::OnChangeNearclip() { DelayedValidate(VALIDATE_TIME); }
void CCamInfoDlg::OnChangeTarlocx() { DelayedValidate(VALIDATE_TIME); }
void CCamInfoDlg::OnChangeTarlocz() { DelayedValidate(VALIDATE_TIME);}
void CCamInfoDlg::OnChangeTarlocy()
{
DelayedValidate(VALIDATE_TIME);
CheckDlgButton(IDC_TLOCTT,false);
CamInfo->TarATrkFlg=false;
}
void CCamInfoDlg::OnChangeCamlocx()
{
if(!CamInfo) return;
CamInfo->SetMode(CameraInfo::CM_FREE);
DelayedValidate(VALIDATE_TIME);
}
void CCamInfoDlg::OnChangeCamlocy()
{
if(!CamInfo) return;
DelayedValidate(VALIDATE_TIME);
CheckDlgButton(IDC_CLOCTT,false);
CamInfo->CamATrkFlg=false;
}
void CCamInfoDlg::OnChangeCamlocz()
{
if(!CamInfo) return;
CamInfo->SetMode(CameraInfo::CM_FREE);
DelayedValidate(VALIDATE_TIME);
}
+112
View File
@@ -0,0 +1,112 @@
#if !defined(AFX_CAMINFODLG_H__4A5F2F61_6CB8_11D2_8409_00A0C933BCAC__INCLUDED_)
#define AFX_CAMINFODLG_H__4A5F2F61_6CB8_11D2_8409_00A0C933BCAC__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// CamInfoDlg.h : header file
//
#include "CameraInfo.h"
/////////////////////////////////////////////////////////////////////////////
// CCamInfoDlg dialog
class CCamInfoDlg : public CDialog
{
// Construction
public:
void DelayedValidate(int tme);
bool NoUpdate;
void Validate();
void SetCamInfo(CameraInfo *CIn);
void UpdateControlStates();
void UpdateInfo();
CCamInfoDlg(CWnd* pParent = NULL); // standard constructor
CameraInfo *CamInfo;
// Dialog Data
//{{AFX_DATA(CCamInfoDlg)
enum { IDD = IDD_CAMINFO };
CEdit m_NearClipCtrl;
CEdit m_FarClipCtrl;
CEdit m_FOVTextCtrl;
CSliderCtrl m_FOVSliCtrl;
CStatic m_VelText;
CSliderCtrl m_VelSliCtrl;
CEdit m_CLOCZCtrl;
CEdit m_CLOCYCtrl;
CEdit m_CLOCXCtrl;
CSliderCtrl m_TSliCtrl;
CStatic m_PosText;
CEdit m_CTAlt;
CButton m_TTT;
CEdit m_TTACtrl;
CEdit m_TLZCtrl;
CEdit m_TLYCtrl;
CEdit m_TLXCtrl;
double m_CamLocX;
double m_CamLocZ;
double m_CamLocY;
double m_CamTrkAlt;
double m_TarLocX;
double m_TarLocY;
double m_TarLocZ;
double m_TarTAlt;
int m_TmeSli;
int m_VelSli;
int m_FOVSli;
double m_FarClip;
double m_NearClip;
int m_FOVText;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CCamInfoDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
DWORD FCon;
// Generated message map functions
//{{AFX_MSG(CCamInfoDlg)
virtual void OnCancel();
virtual void OnOK();
afx_msg void OnClose();
afx_msg void OnCloctt();
afx_msg void OnUsetarget();
afx_msg void OnTloctt();
afx_msg void OnTrack();
afx_msg void OnFree();
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
virtual BOOL OnInitDialog();
afx_msg void OnAnimate();
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
afx_msg void OnChangeCamlocx();
afx_msg void OnChangeCamlocy();
afx_msg void OnChangeCamlocz();
afx_msg void OnChangeTarlocx();
afx_msg void OnChangeTarlocy();
afx_msg void OnChangeTarlocz();
afx_msg void OnResetcurve();
afx_msg void OnChangeFarclip();
afx_msg void OnChangeNearclip();
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnChangeTartalt();
afx_msg void OnChangeFovtext();
afx_msg void OnChangeCamtalt();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_CAMINFODLG_H__4A5F2F61_6CB8_11D2_8409_00A0C933BCAC__INCLUDED_)
@@ -0,0 +1,57 @@
#include"StdAfx.h"
#include"CamInfoPage.h"
#define VALIDATE_TIME 1000
BEGIN_MESSAGE_MAP(CCamInfoPage, CPropertyPage)
//{{AFX_MSG_MAP(CCamInfoPage)
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
CCamInfoPage::CCamInfoPage( UINT nIDTemplate, UINT nIDCaption)
:CPropertyPage( nIDTemplate, nIDCaption)
{
VTimerID=nIDTemplate;
//+0x1000;
VTime=VALIDATE_TIME;
CamInfo=NULL;
NoUpdate=false;
}
void CCamInfoPage::Validate()
{
KillTimer(VTimerID);
if(!CamInfo) return;
UpdateData(TRUE);
DataOut();
NoUpdate=false;
}
void CCamInfoPage::DelayedValidate()
{
NoUpdate=true;
KillTimer(VTimerID);
SetTimer(VTimerID,VTime,NULL);
}
void CCamInfoPage::Refresh()
{
if(!CamInfo || NoUpdate) return;
DataIn();
UpdateData(FALSE);
UpdateControlStates();
}
void CCamInfoPage::OnTimer(UINT nIDEvent)
{
Validate();
CPropertyPage::OnTimer(nIDEvent);
}
@@ -0,0 +1,36 @@
#ifndef CAMERAPAGE_H_
#define CAMERAPAGE_H_
#include "CameraInfo.h"
class CCamInfoPage:public CPropertyPage
{
private:
void Validate();
bool NoUpdate;
DWORD VTimerID,VTime;
protected:
void DelayedValidate();
CameraInfo *CamInfo;
void SetValidateTime(int tme) {VTime=tme;}
virtual void UpdateControlStates()=0;
virtual void DataOut()=0;
virtual void DataIn()=0;
public:
void SetCamInfo(CameraInfo *CIn) {CamInfo=CIn;}
void Refresh();
void SetUpdate(bool flg) {NoUpdate=!flg;}
CCamInfoPage( UINT nIDTemplate, UINT nIDCaption = 0 );
// Generated message map functions
//{{AFX_MSG(CCamInfoDlg)
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnEditChange(UINT nIDEvent);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#endif
+123
View File
@@ -0,0 +1,123 @@
// CamInfoTab.cpp : implementation file
//
#include "stdafx.h"
#include "TCTb.h"
#include "CamInfoTab.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCamInfoTab property page
IMPLEMENT_DYNCREATE(CCamInfoTab, CPropertyPage)
CCamInfoTab::CCamInfoTab() : CCamInfoPage(CCamInfoTab::IDD)
{
//{{AFX_DATA_INIT(CCamInfoTab)
m_CamLocX = 0.0f;
m_CamLocY = 0.0f;
m_CamLocZ = 0.0f;
m_CamTrkAlt = 0.0f;
//}}AFX_DATA_INIT
}
CCamInfoTab::~CCamInfoTab()
{
}
void CCamInfoTab::DoDataExchange(CDataExchange* pDX)
{
CCamInfoPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCamInfoTab)
DDX_Control(pDX, IDC_CAMTALT, m_CTAlt);
DDX_Text(pDX, IDC_CAMLOCX, m_CamLocX);
DDX_Text(pDX, IDC_CAMLOCY, m_CamLocY);
DDX_Text(pDX, IDC_CAMLOCZ, m_CamLocZ);
DDX_Text(pDX, IDC_CAMTALT, m_CamTrkAlt);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCamInfoTab, CCamInfoPage)
//{{AFX_MSG_MAP(CCamInfoTab)
ON_EN_CHANGE(IDC_CAMLOCX, OnChangeCamlocx)
ON_EN_CHANGE(IDC_CAMLOCY, OnChangeCamlocy)
ON_EN_CHANGE(IDC_CAMLOCZ, OnChangeCamlocz)
ON_BN_CLICKED(IDC_CLOCTT, OnCloctt)
ON_BN_CLICKED(IDC_FREE, OnFree)
ON_BN_CLICKED(IDC_TRACK, OnTrack)
ON_EN_CHANGE(IDC_CAMTALT, OnChangeCamtalt)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCamInfoTab message handlers
void CCamInfoTab::DataIn()
{
m_CamLocX=CamInfo->Loc.x;
m_CamLocY=CamInfo->Loc.y;
m_CamLocZ=CamInfo->Loc.z;
m_CamTrkAlt=CamInfo->CamTrackAlt;
CheckDlgButton(IDC_CLOCTT,CamInfo->CamATrkFlg);
}
void CCamInfoTab::DataOut()
{
CamInfo->Loc.x=m_CamLocX;
CamInfo->Loc.y=m_CamLocY;
CamInfo->Loc.z=m_CamLocZ;
CamInfo->CamTrackAlt=m_CamTrkAlt;
}
void CCamInfoTab::UpdateControlStates()
{
m_CTAlt.EnableWindow(IsDlgButtonChecked(IDC_CLOCTT));
CheckRadioButton(IDC_FREE,IDC_TRACK,CamInfo->GetMode()==CameraInfo::CM_TRACK?IDC_TRACK:IDC_FREE);
}
void CCamInfoTab::OnChangeCamlocx()
{
DelayedValidate();
CamInfo->SetMode(CameraInfo::CM_FREE);
}
void CCamInfoTab::OnChangeCamlocy()
{
DelayedValidate();
CamInfo->CamATrkFlg=false;
CheckDlgButton(IDC_CLOCTT,FALSE);
UpdateControlStates();
}
void CCamInfoTab::OnChangeCamlocz()
{
DelayedValidate();
CamInfo->SetMode(CameraInfo::CM_FREE);
}
void CCamInfoTab::OnCloctt()
{
UpdateControlStates();
CamInfo->CamATrkFlg=IsDlgButtonChecked(IDC_CLOCTT)?true:false;
}
void CCamInfoTab::OnFree()
{
CamInfo->SetMode(CameraInfo::CM_FREE);
}
void CCamInfoTab::OnTrack()
{
CamInfo->SetMode(CameraInfo::CM_TRACK);
}
void CCamInfoTab::OnChangeCamtalt()
{
DelayedValidate();
}
+63
View File
@@ -0,0 +1,63 @@
#if !defined(AFX_CAMINFOTAB_H__DB172FD6_6E4E_11D2_8409_00A0C933BCAC__INCLUDED_)
#define AFX_CAMINFOTAB_H__DB172FD6_6E4E_11D2_8409_00A0C933BCAC__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// CamInfoTab.h : header file
//
#include"CamInfoPage.h"
/////////////////////////////////////////////////////////////////////////////
// CCamInfoTab dialog
class CCamInfoTab : public CCamInfoPage
{
DECLARE_DYNCREATE(CCamInfoTab)
// Construction
public:
CCamInfoTab();
~CCamInfoTab();
// Dialog Data
//{{AFX_DATA(CCamInfoTab)
enum { IDD = IDD_CAMINFOTAB };
CEdit m_CTAlt;
float m_CamLocX;
float m_CamLocY;
float m_CamLocZ;
float m_CamTrkAlt;
//}}AFX_DATA
// Overrides
// ClassWizard generate virtual function overrides
//{{AFX_VIRTUAL(CCamInfoTab)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CCamInfoTab)
afx_msg void OnChangeCamlocx();
afx_msg void OnChangeCamlocy();
afx_msg void OnChangeCamlocz();
afx_msg void OnCloctt();
afx_msg void OnFree();
afx_msg void OnTrack();
afx_msg void OnChangeCamtalt();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
virtual void UpdateControlStates();
virtual void DataOut();
virtual void DataIn();
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_CAMINFOTAB_H__DB172FD6_6E4E_11D2_8409_00A0C933BCAC__INCLUDED_)
@@ -0,0 +1,79 @@
// CamInfoTabDlg.cpp : implementation file
//
#include "stdafx.h"
#include "TCTb.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCamInfoTabDlg
IMPLEMENT_DYNAMIC(CCamInfoTabDlg, CPropertySheet)
CCamInfoTabDlg::CCamInfoTabDlg(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
:CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
{
NumTabs=0;
}
CCamInfoTabDlg::CCamInfoTabDlg(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
:CPropertySheet(pszCaption, pParentWnd, iSelectPage)
{
NumTabs=0;
}
CCamInfoTabDlg::~CCamInfoTabDlg()
{
int i;
for(i=0;i<NumTabs;i++) delete Tab[i];
NumTabs=0;
}
BEGIN_MESSAGE_MAP(CCamInfoTabDlg, CPropertySheet)
//{{AFX_MSG_MAP(CCamInfoTabDlg)
ON_WM_CLOSE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCamInfoTabDlg message handlers
void CCamInfoTabDlg::SetCameraInfo(CameraInfo *CIn)
{
int i;
for(i=0;i<NumTabs;i++) Tab[i]->SetCamInfo(CIn);
}
void CCamInfoTabDlg::Refresh()
{
Tab[GetActiveIndex()]->Refresh();
}
BOOL CCamInfoTabDlg::Create( CWnd* pParentWnd, DWORD dwStyle, DWORD dwExStyle )
{
return CPropertySheet::Create( pParentWnd , dwStyle , dwExStyle);
}
void CCamInfoTabDlg::AddPage( CCamInfoPage *pPage )
{
Tab[NumTabs++]=pPage;
CPropertySheet::AddPage(pPage);
}
void CCamInfoTabDlg::OnClose()
{
// TODO: Add your message handler code here and/or call default
// ShowWindow(SW_MINIMIZE);
ShowWindow(SW_HIDE);
// CPropertySheet::OnClose();
}
@@ -0,0 +1,63 @@
#if !defined(AFX_CAMINFOTABDLG_H__DB172FDF_6E4E_11D2_8409_00A0C933BCAC__INCLUDED_)
#define AFX_CAMINFOTABDLG_H__DB172FDF_6E4E_11D2_8409_00A0C933BCAC__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// CamInfoTabDlg.h : header file
//
#include"CamInfoPage.h"
#define MAXTABS 256
/////////////////////////////////////////////////////////////////////////////
// CCamInfoTabDlg
class CCamInfoTabDlg : public CPropertySheet
{
protected:
CCamInfoPage *Tab[MAXTABS];
int NumTabs;
DECLARE_DYNAMIC(CCamInfoTabDlg)
// Construction
public:
CCamInfoTabDlg(UINT nIDCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);
CCamInfoTabDlg(LPCTSTR pszCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);
BOOL Create( CWnd* pParentWnd = NULL, DWORD dwStyle = -1, DWORD dwExStyle = 0 );
void AddPage( CCamInfoPage *pPage );
void SetCameraInfo(CameraInfo *CIn);
void Refresh();
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CCamInfoTabDlg)
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CCamInfoTabDlg();
// Generated message map functions
protected:
//{{AFX_MSG(CCamInfoTabDlg)
afx_msg void OnClose();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_CAMINFOTABDLG_H__DB172FDF_6E4E_11D2_8409_00A0C933BCAC__INCLUDED_)
+217
View File
@@ -0,0 +1,217 @@
// CamState.cpp : implementation file
//
#include "stdafx.h"
#include "TCTb.h"
#include "CamState.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCamState property page
IMPLEMENT_DYNCREATE(CCamState, CPropertyPage)
CCamState::CCamState() : CCamInfoPage(CCamState::IDD)
{
//{{AFX_DATA_INIT(CCamState)
m_AMode = -1;
m_WFMode = -1;
m_FilterMode = -1;
//}}AFX_DATA_INIT
}
CCamState::~CCamState()
{
}
void CCamState::DoDataExchange(CDataExchange* pDX)
{
CCamInfoPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCamState)
DDX_CBIndex(pDX, IDC_AMODE, m_AMode);
DDX_CBIndex(pDX, IDC_WIREFRAME, m_WFMode);
DDX_CBIndex(pDX, IDC_FILTERMODE, m_FilterMode);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCamState, CCamInfoPage)
//{{AFX_MSG_MAP(CCamState)
ON_BN_CLICKED(IDC_BACKFACE, OnBackface)
ON_BN_CLICKED(IDC_DITHERING, OnDithering)
ON_BN_CLICKED(IDC_ZBCOMPARE, OnZbcompare)
ON_BN_CLICKED(IDC_ZBWRITE, OnZbwrite)
ON_BN_CLICKED(IDC_TEXTURES, OnTextures)
ON_BN_CLICKED(IDC_PCORRECT, OnPcorrect)
ON_BN_CLICKED(IDC_FOG, OnFog)
ON_CBN_DROPDOWN(IDC_AMODE, OnDropdownAmode)
ON_CBN_CLOSEUP(IDC_AMODE, OnCloseupAmode)
ON_CBN_CLOSEUP(IDC_WIREFRAME, OnCloseupWireframe)
ON_CBN_DROPDOWN(IDC_WIREFRAME, OnDropdownWireframe)
ON_CBN_CLOSEUP(IDC_FILTERMODE, OnCloseupFiltermode)
ON_CBN_DROPDOWN(IDC_FILTERMODE, OnDropdownFiltermode)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCamState message handlers
void CCamState::DataIn()
{
switch(CamInfo->State.GetAlphaMode())
{
case StateChange::OneZeroMode: m_AMode=0; break;
case StateChange::OneOneMode: m_AMode=1; break;
case StateChange::AlphaOneMode : m_AMode=2; break;
case StateChange::OneAlphaMode : m_AMode=3; break;
case StateChange::AlphaInvAlphaMode:m_AMode=4; break;
}
switch(CamInfo->State.GetFilterMode())
{
case StateChange::PointSampleMode: m_FilterMode=0; break;
case StateChange::BilinearMode: m_FilterMode=1; break;
case StateChange::TrilinearMode: m_FilterMode=2; break;
}
switch(CamInfo->State.GetWireFrameMode())
{
case StateChange::WireMode : m_WFMode=0; break;
case StateChange::SolidAndWireMode: m_WFMode=1; break;
case StateChange::SolidMode : m_WFMode=2; break;
}
CheckDlgButton(IDC_ZBCOMPARE,CamInfo->State.IsZBufferCompareEnabled()?TRUE:FALSE);
CheckDlgButton(IDC_ZBWRITE,CamInfo->State.IsZBufferWriteEnabled()?TRUE:FALSE);
CheckDlgButton(IDC_BACKFACE,CamInfo->State.IsBackfaceCullingEnabled()?TRUE:FALSE);
CheckDlgButton(IDC_DITHERING,CamInfo->State.IsDitheringEnabled()?TRUE:FALSE);
//CheckDlgButton(IDC_FOG,CamInfo->State.IsFogEnabled()?TRUE:FALSE);
CheckDlgButton(IDC_PCORRECT,CamInfo->State.IsPerspectiveCorrectionEnabled()?TRUE:FALSE);
CheckDlgButton(IDC_TEXTURES,1?TRUE:FALSE);
}
void CCamState::DataOut()
{
}
void CCamState::UpdateControlStates()
{
}
void CCamState::OnBackface()
{
if (IsDlgButtonChecked(IDC_BACKFACE))
CamInfo->State.EnableBackfaceCulling();
else
CamInfo->State.DisableBackfaceCulling();
}
void CCamState::OnDithering()
{
if (IsDlgButtonChecked(IDC_DITHERING))
CamInfo->State.EnableDithering();
else
CamInfo->State.DisableDithering();
}
void CCamState::OnZbcompare()
{
if (IsDlgButtonChecked(IDC_ZBCOMPARE))
CamInfo->State.EnableZBufferCompare();
else
CamInfo->State.DisableZBufferCompare();
}
void CCamState::OnZbwrite()
{
if (IsDlgButtonChecked(IDC_ZBWRITE))
CamInfo->State.EnableZBufferWrite();
else
CamInfo->State.DisableZBufferWrite();
}
void CCamState::OnTextures()
{
}
void CCamState::OnPcorrect()
{
if (IsDlgButtonChecked(IDC_PCORRECT))
CamInfo->State.EnablePerspectiveCorrection();
else
CamInfo->State.DisablePerspectiveCorrection();
}
void CCamState::OnFog()
{
/*
if (IsDlgButtonChecked(IDC_FOG))
CamInfo->State.EnableFog();
else
CamInfo->State.DisableFog();
*/
}
void CCamState::OnDropdownFiltermode() { SetUpdate(false); }
void CCamState::OnDropdownAmode() {SetUpdate(false);}
void CCamState::OnDropdownWireframe() { SetUpdate(false); }
void CCamState::OnCloseupAmode()
{
UpdateData(TRUE);
switch(m_AMode)
{
case 0: CamInfo->State.SetAlphaMode(StateChange::OneZeroMode); break;
case 1: CamInfo->State.SetAlphaMode(StateChange::OneOneMode); break;
case 2: CamInfo->State.SetAlphaMode(StateChange::AlphaOneMode); break;
case 3: CamInfo->State.SetAlphaMode(StateChange::OneAlphaMode); break;
case 4: CamInfo->State.SetAlphaMode(StateChange::AlphaInvAlphaMode); break;
}
SetUpdate(true);
}
void CCamState::OnCloseupWireframe()
{
UpdateData(TRUE);
switch(m_WFMode)
{
case 0: CamInfo->State.SetWireFrameMode(StateChange::WireMode); break;
case 1: CamInfo->State.SetWireFrameMode(StateChange::SolidAndWireMode); break;
case 2: CamInfo->State.SetWireFrameMode(StateChange::SolidMode); break;
}
SetUpdate(true);
}
void CCamState::OnCloseupFiltermode()
{
UpdateData(TRUE);
switch(m_FilterMode)
{
case 0: CamInfo->State.SetFilterMode(StateChange::PointSampleMode); break;
case 1: CamInfo->State.SetFilterMode(StateChange::BilinearMode); break;
case 2: CamInfo->State.SetFilterMode(StateChange::TrilinearMode); break;
}
SetUpdate(true);
}
+68
View File
@@ -0,0 +1,68 @@
#if !defined(AFX_CAMSTATE_H__D436BE42_6F2B_11D2_8409_00A0C933BCAC__INCLUDED_)
#define AFX_CAMSTATE_H__D436BE42_6F2B_11D2_8409_00A0C933BCAC__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// CamState.h : header file
//
#include"CamInfoPage.h"
/////////////////////////////////////////////////////////////////////////////
// CCamState dialog
class CCamState : public CCamInfoPage
{
DECLARE_DYNCREATE(CCamState)
// Construction
public:
CCamState();
~CCamState();
// Dialog Data
//{{AFX_DATA(CCamState)
enum { IDD = IDD_CAMSTATE };
int m_AMode;
int m_WFMode;
int m_FilterMode;
//}}AFX_DATA
// Overrides
// ClassWizard generate virtual function overrides
//{{AFX_VIRTUAL(CCamState)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CCamState)
afx_msg void OnBackface();
afx_msg void OnDithering();
afx_msg void OnZbcompare();
afx_msg void OnZbwrite();
afx_msg void OnTextures();
afx_msg void OnPcorrect();
afx_msg void OnFog();
afx_msg void OnDropdownAmode();
afx_msg void OnCloseupAmode();
afx_msg void OnCloseupWireframe();
afx_msg void OnDropdownWireframe();
afx_msg void OnCloseupFiltermode();
afx_msg void OnDropdownFiltermode();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
virtual void UpdateControlStates();
virtual void DataOut();
virtual void DataIn();
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_CAMSTATE_H__D436BE42_6F2B_11D2_8409_00A0C933BCAC__INCLUDED_)
+114
View File
@@ -0,0 +1,114 @@
#include"stdafx.h"
#include"CameraInfo.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
CameraInfo::CameraInfo()
{
ViewLoop=NULL;
CurTime=0.0f;
Mode=CM_TRACK;
Animate=true;
CamATrkFlg=true;
TarATrkFlg=true;
Vel=0.5f;
NearClip=1.0f;
FarClip=350.0f;
FOV=Stuff::Pi_Over_3;
}
CameraInfo::~CameraInfo()
{
}
void CameraInfo::ValidateTime()
{
if(CurTime<=-1.0f) CurTime=0.0f;
else
if(CurTime<0.0f) CurTime=1.0f+CurTime;
if(CurTime>=2.0f) CurTime=0.0f;
else
if(CurTime>=1.0f) CurTime-=1.0f;
}
void CameraInfo::SetTime(float tme)
{
CurTime=tme;
ValidateTime();
UpdateCPos();
}
void CameraInfo::AddTime(float tme)
{
if(!Animate || Mode==CM_FREE) return;
CurTime+=tme*Vel;
ValidateTime();
UpdateCPos();
}
void CameraInfo::ZeroTime()
{
CurTime=0.0;
UpdateCPos();
}
void CameraInfo::SetMode(CAMMODE cmd)
{
Mode=cmd;
//if(CMode==CM_FREE) CMode.Animate=false;
}
void CameraInfo::UpdateCPos()
{
if(!ViewLoop) return;
Stuff::Point3D p3d;
Stuff::Vector3D v3d;
float tme=CurTime;
if(UseTarget && TargetLoc==Loc) TargetLoc.x+=0.0001f;
if(Mode==CM_TRACK)
{
ViewLoop->Evaluate(tme,&p3d,&v3d);
Loc.x=p3d.x;
Loc.z=p3d.z;
if(UseTarget)
{
v3d.x=TargetLoc.x-Loc.x;
v3d.y=TargetLoc.y-Loc.y;
v3d.z=TargetLoc.z-Loc.z;
}
v3d.Normalize(v3d);
Dir=v3d;
}
if(Mode==CameraInfo::CM_FREE)
{
if(UseTarget)
{
v3d.x=TargetLoc.x-Loc.x;
v3d.y=TargetLoc.y-Loc.y;
v3d.z=TargetLoc.z-Loc.z;
v3d.Normalize(v3d);
Dir=v3d;
}
}
}
+44
View File
@@ -0,0 +1,44 @@
#ifndef CAMERAINFO_H_
#define CAMERAINFO_H_
#include <ElementRenderer\StateChange.hpp>
#include <Stuff\StuffHeaders.hpp>
#include"ViewSpline.h"
class CameraInfo
{
public:
enum CAMMODE {CM_TRACK,CM_FREE} ;
protected:
float CurTime,Vel;
void ValidateTime();
CAMMODE Mode;
public:
Stuff::Point3D Loc,TargetLoc;
Stuff::Vector3D Dir;
Stuff::Scalar CamTrackAlt,TarTrackAlt;
Stuff::Scalar NearClip,FarClip;
Stuff::Radian FOV;
ElementRenderer::StateChange State;
bool UseTarget,Animate,CamATrkFlg,TarATrkFlg;
SplineLoop *ViewLoop;
CameraInfo();
~CameraInfo();
float GetTime() { return CurTime;}
CAMMODE GetMode() { return Mode;}
void SetMode(CAMMODE cmd);
void SetTime(float tme);
void AddTime(float tme=0.1f);
float GetVel() {return Vel;}
void SetVel(float v) {Vel=v;}
void ZeroTime() ;
void UpdateCPos();
};
#endif
+119
View File
@@ -0,0 +1,119 @@
// ChildFrm.cpp : implementation of the CChildFrame class
//
#include "stdafx.h"
#include "TCTb.h"
#include "ChildFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CChildFrame
IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd)
BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd)
//{{AFX_MSG_MAP(CChildFrame)
ON_COMMAND(ID_FILE_CLOSE, OnFileClose)
ON_WM_SETFOCUS()
ON_WM_CREATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CChildFrame construction/destruction
CChildFrame::CChildFrame()
{
// TODO: add member initialization code here
}
CChildFrame::~CChildFrame()
{
}
BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
if( !CMDIChildWnd::PreCreateWindow(cs) )
return FALSE;
cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
cs.lpszClass = AfxRegisterWndClass(0);
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CChildFrame diagnostics
#ifdef _DEBUG
void CChildFrame::AssertValid() const
{
CMDIChildWnd::AssertValid();
}
void CChildFrame::Dump(CDumpContext& dc) const
{
CMDIChildWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CChildFrame message handlers
void CChildFrame::OnFileClose()
{
// To close the frame, just send a WM_CLOSE, which is the equivalent
// choosing close from the system menu.
SendMessage(WM_CLOSE);
}
int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1)
return -1;
// create a view to occupy the client area of the frame
if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
{
TRACE0("Failed to create view window\n");
return -1;
}
return 0;
}
void CChildFrame::OnSetFocus(CWnd* pOldWnd)
{
CMDIChildWnd::OnSetFocus(pOldWnd);
m_wndView.SetFocus();
}
BOOL CChildFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{
// let the view have first crack at the command
if (m_wndView.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
return TRUE;
// otherwise, do default handling
return CMDIChildWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}
+59
View File
@@ -0,0 +1,59 @@
// ChildFrm.h : interface of the CChildFrame class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_CHILDFRM_H__D9E64DD6_5915_11D2_8408_00A0C933BCAC__INCLUDED_)
#define AFX_CHILDFRM_H__D9E64DD6_5915_11D2_8408_00A0C933BCAC__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "ChildView.h"
class CChildFrame : public CMDIChildWnd
{
DECLARE_DYNCREATE(CChildFrame)
public:
CChildFrame();
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CChildFrame)
public:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);
//}}AFX_VIRTUAL
// Implementation
public:
// view for the client area of the frame.
CChildView m_wndView;
virtual ~CChildFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
// Generated message map functions
protected:
//{{AFX_MSG(CChildFrame)
afx_msg void OnFileClose();
afx_msg void OnSetFocus(CWnd* pOldWnd);
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_CHILDFRM_H__D9E64DD6_5915_11D2_8408_00A0C933BCAC__INCLUDED_)
@@ -0,0 +1,57 @@
// ChildView.cpp : implementation of the CChildView class
//
#include "stdafx.h"
#include "TCTb.h"
#include "ChildView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CChildView
CChildView::CChildView()
{
}
CChildView::~CChildView()
{
}
BEGIN_MESSAGE_MAP(CChildView,CWnd )
//{{AFX_MSG_MAP(CChildView)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CChildView message handlers
BOOL CChildView::PreCreateWindow(CREATESTRUCT& cs)
{
if (!CWnd::PreCreateWindow(cs))
return FALSE;
cs.dwExStyle |= WS_EX_CLIENTEDGE;
cs.style &= ~WS_BORDER;
cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS,
::LoadCursor(NULL, IDC_ARROW), HBRUSH(COLOR_WINDOW+1), NULL);
return TRUE;
}
void CChildView::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
// Do not call CWnd::OnPaint() for painting messages
}
+51
View File
@@ -0,0 +1,51 @@
// ChildView.h : interface of the CChildView class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_CHILDVIEW_H__D9E64DD8_5915_11D2_8408_00A0C933BCAC__INCLUDED_)
#define AFX_CHILDVIEW_H__D9E64DD8_5915_11D2_8408_00A0C933BCAC__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
/////////////////////////////////////////////////////////////////////////////
// CChildView window
class CChildView : public CWnd
{
// Construction
public:
CChildView();
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CChildView)
protected:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CChildView();
// Generated message map functions
protected:
//{{AFX_MSG(CChildView)
afx_msg void OnPaint();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_CHILDVIEW_H__D9E64DD8_5915_11D2_8408_00A0C933BCAC__INCLUDED_)
@@ -0,0 +1,90 @@
// ColorReduce.cpp : implementation file
//
#include "stdafx.h"
#include "TCTb.h"
#include "ColorReduce.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CColorReduce dialog
CColorReduce::CColorReduce(CWnd* pParent /*=NULL*/)
: CDialog(CColorReduce::IDD, pParent)
{
rmd=RMD_MAX;
//{{AFX_DATA_INIT(CColorReduce)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CColorReduce::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CColorReduce)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CColorReduce, CDialog)
//{{AFX_MSG_MAP(CColorReduce)
ON_BN_CLICKED(IDC_ALPHACHAN, OnAlphachan)
ON_BN_CLICKED(IDC_BLUECHAN, OnBluechan)
ON_BN_CLICKED(IDC_BRIGHTNESS, OnBrightness)
ON_BN_CLICKED(IDC_GREENCHAN, OnGreenchan)
ON_BN_CLICKED(IDC_PEAKS, OnPeaks)
ON_BN_CLICKED(IDC_REDCHAN, OnRedchan)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CColorReduce message handlers
void CColorReduce::OnAlphachan()
{
rmd=RMD_ALPHAC;
}
void CColorReduce::OnBluechan()
{
rmd=RMD_BLUEC;
}
void CColorReduce::OnBrightness()
{
rmd=RMD_BHT;
}
void CColorReduce::OnGreenchan()
{
rmd=RMD_GREENC;
}
void CColorReduce::OnPeaks()
{
rmd=RMD_MAX;
}
void CColorReduce::OnRedchan()
{
rmd=RMD_REDC;
}
BOOL CColorReduce::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CheckDlgButton( IDC_PEAKS, TRUE );
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
@@ -0,0 +1,55 @@
#if !defined(AFX_COLORREDUCE_H__10312143_59DF_11D2_8408_00A0C933BCAC__INCLUDED_)
#define AFX_COLORREDUCE_H__10312143_59DF_11D2_8408_00A0C933BCAC__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ColorReduce.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CColorReduce dialog
#include"ImageLib\image.h"
class CColorReduce : public CDialog
{
// Construction
public:
CColorReduce(CWnd* pParent = NULL); // standard constructor
RMETHOD rmd;
// Dialog Data
//{{AFX_DATA(CColorReduce)
enum { IDD = IDD_COLOREDUCE };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CColorReduce)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CColorReduce)
afx_msg void OnAlphachan();
afx_msg void OnBluechan();
afx_msg void OnBrightness();
afx_msg void OnGreenchan();
afx_msg void OnPeaks();
afx_msg void OnRedchan();
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_COLORREDUCE_H__10312143_59DF_11D2_8408_00A0C933BCAC__INCLUDED_)
+117
View File
@@ -0,0 +1,117 @@
// ExportInfo.cpp: implementation of the ExportInfo class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "TCTb.h"
#include "ExportInfo.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
ExportInfo::ExportInfo()
{
dx=5.0f;
dy=1.0f;
dz=5.0f;
xs=10.0f;
zs=10.0f;
voff=0.0f;
BType=BT_GSIZE;
Display=true;
Xpix=DEFAULTBMPSIZE;
Zpix=DEFAULTBMPSIZE;
}
void ExportInfo::SetScale_Offset(double x, double y, double z, double offset)
{
if(BType==BT_SETCON) return;
dx = (float)x;
dy = (float)y;
dz = (float)z;
voff = (float)offset;
xs=dx*Xpix;
zs=dz*Zpix;
}
void ExportInfo::GetScale_Offset(double *x, double *y, double *z, double *offset)
{
*x=dx; *y=dy; *z=dz; *offset=voff;
}
void ExportInfo::GetScale_Offset(float *x, float *y, float *z, float *offset)
{
*x=(float)dx; *y=(float)dy; *z=(float)dz; *offset=(float)voff;
}
void ExportInfo::SetSizeKM(double x,double z)
{
if(BType==BT_GSIZE) return;
xs=(float)(x*1000);
zs=(float)(z*1000);
dx=xs/(Xpix-1);
dz=zs/(Zpix-1);
}
void ExportInfo::GetSizeKM(double *x,double *z)
{
*x=xs/1000;
*z=zs/1000;
}
void ExportInfo::GetSizeKM(float *x,float *z)
{
*x=(float)xs/1000;
*z=(float)zs/1000;
}
void ExportInfo::GetSizeM(double *x,double *z)
{
*x=xs;
*z=zs;
}
void ExportInfo::GetSizeM(float *x,float *z)
{
*x=(float)xs;
*z=(float)zs;
}
void ExportInfo::SetPixels(int x,int z)
{
Xpix=x;
Zpix=z;
if(BType==BT_GSIZE)
{
xs=(Xpix-1)*dx;
zs=(Zpix-1)*dz;
}
if(BType==BT_SETCON)
{
dx=xs/(Xpix-1);
dz=zs/(Zpix-1);
}
}
ExportInfo::~ExportInfo()
{
}
+41
View File
@@ -0,0 +1,41 @@
// ExportInfo.h: interface for the ExportInfo class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_EXPORTINFO_H__4BC3D163_794E_11D2_8409_00A0C933BCAC__INCLUDED_)
#define AFX_EXPORTINFO_H__4BC3D163_794E_11D2_8409_00A0C933BCAC__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class ExportInfo
{
protected:
float dx,dz,xs,zs;
int Xpix,Zpix;
float dy;
float voff;
public:
enum BUILDTYPE {BT_SETCON,BT_GSIZE,BT_FREESTYLE};
BUILDTYPE BType;
BOOL Display;
ExportInfo();
void SetScale_Offset(double x, double y, double z, double offset);
void SetSizeKM(double x,double z);
void GetScale_Offset(double *x, double *y, double *z, double *offset);
void GetScale_Offset(float *x, float *y, float *z, float *offset);
void GetSizeKM(float *x,float *z);
void GetSizeKM(double *x,double *z);
void GetSizeM(float *x,float *z);
void GetSizeM(double *x,double *z);
void SetPixels(int x,int z);
virtual ~ExportInfo();
};
#endif // !defined(AFX_EXPORTINFO_H__4BC3D163_794E_11D2_8409_00A0C933BCAC__INCLUDED_)
@@ -0,0 +1,286 @@
// ExportOptions.cpp : implementation file
//
#include "stdafx.h"
#include "TCTb.h"
#include "ExportOptions.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CExportOptions dialog
CExportOptions::CExportOptions(CWnd* pParent /*=NULL*/)
: CDialog(CExportOptions::IDD, pParent)
{
//{{AFX_DATA_INIT(CExportOptions)
m_dxtext = 0.0f;
m_dytext = 0.0f;
m_showexport = FALSE;
m_voff = 0.0f;
m_xstext = 0.0f;
m_zstext = 0.0f;
m_dztext = 0.0f;
//}}AFX_DATA_INIT
NoUpdate=0;
}
void CExportOptions::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CExportOptions)
DDX_Control(pDX, IDC_ZSTEXT, m_zstctrl);
DDX_Control(pDX, IDC_XSTEXT, m_xstctrl);
DDX_Control(pDX, IDC_DZTEXT, m_dztctrl);
DDX_Control(pDX, IDC_DYTEXT, m_dytctrl);
DDX_Control(pDX, IDC_DXTEXT, m_dxtctrl);
DDX_Control(pDX, IDC_ZSSLI, m_zssli);
DDX_Control(pDX, IDC_XSSLI, m_xssli);
DDX_Control(pDX, IDC_DZSLI, m_dzsli);
DDX_Control(pDX, IDC_DYSLI, m_dysli);
DDX_Control(pDX, IDC_DXSLI, m_dxsli);
DDX_Text(pDX, IDC_DXTEXT, m_dxtext);
DDX_Text(pDX, IDC_DYTEXT, m_dytext);
DDX_Check(pDX, IDC_SHOWEXPORT, m_showexport);
DDX_Text(pDX, IDC_VOFFTEXT, m_voff);
DDX_Text(pDX, IDC_XSTEXT, m_xstext);
DDX_Text(pDX, IDC_ZSTEXT, m_zstext);
DDX_Text(pDX, IDC_DZTEXT, m_dztext);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CExportOptions, CDialog)
//{{AFX_MSG_MAP(CExportOptions)
ON_WM_HSCROLL()
ON_BN_CLICKED(IDC_FREESTYLE, OnFreestyle)
ON_BN_CLICKED(IDC_GRIDSIZE, OnGridsize)
ON_BN_CLICKED(IDC_SETCONVERSION, OnSetconversion)
ON_EN_CHANGE(IDC_ZSTEXT, OnChangeZstext)
ON_EN_CHANGE(IDC_XSTEXT, OnChangeXstext)
ON_EN_CHANGE(IDC_DZTEXT, OnChangeDztext)
ON_EN_CHANGE(IDC_DYTEXT, OnChangeDytext)
ON_EN_CHANGE(IDC_DXTEXT, OnChangeDxtext)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CExportOptions message handlers
BOOL CExportOptions::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_dxsli.SetRange(1,50);
m_dysli.SetRange(0,40);
m_dzsli.SetRange(1,50);
m_xssli.SetRange(1,50);
m_zssli.SetRange(1,50);
NoUpdate++;
m_dxsli.SetPos((int)m_dxtext);
m_dysli.SetPos((int)m_dxtext);
m_dzsli.SetPos((int)m_dxtext);
m_xssli.SetPos((int)m_xstext);
m_zssli.SetPos((int)m_zstext);
NoUpdate--;
UpdateControls();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CExportOptions::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
if(NoUpdate) return;
CSliderCtrl *ctrl=(CSliderCtrl *)pScrollBar;
if(ctrl==&m_dxsli)
{
m_dxtext=(float)m_dxsli.GetPos();
}
if(ctrl==&m_dysli)
{
m_dytext=((float)m_dysli.GetPos())*0.25f;
}
if(ctrl==&m_dzsli)
{
m_dztext=(float)m_dzsli.GetPos();
}
if(ctrl==&m_xssli)
{
m_xstext=(float)m_xssli.GetPos();
}
if(ctrl==&m_zssli)
{
m_zstext=(float)m_zssli.GetPos();
}
UpdateData(FALSE);
UpdateTextFields();
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}
void CExportOptions::OnFreestyle() { EInfo.BType=ExportInfo::BT_FREESTYLE; UpdateControls(); }
void CExportOptions::OnGridsize() { EInfo.BType=ExportInfo::BT_GSIZE; UpdateControls(); }
void CExportOptions::OnSetconversion() { EInfo.BType=ExportInfo::BT_SETCON; UpdateControls(); }
void CExportOptions::SetData(const ExportInfo &einf)
{
EInfo = einf;
EInfo.GetSizeKM(&m_xstext,&m_zstext);
EInfo.GetScale_Offset(&m_dxtext, &m_dytext, &m_dztext, &m_voff);
m_showexport=EInfo.Display;
}
void CExportOptions::UpdateControls()
{
m_dxsli.EnableWindow(TRUE);
m_dxtctrl.EnableWindow(TRUE);
m_dysli.EnableWindow(TRUE);
m_dytctrl.EnableWindow(TRUE);
m_dzsli.EnableWindow(TRUE);
m_dztctrl.EnableWindow(TRUE);
m_zssli.EnableWindow(TRUE);
m_xssli.EnableWindow(TRUE);
m_zstctrl.EnableWindow(TRUE);
m_xstctrl.EnableWindow(TRUE);
CheckDlgButton(IDC_SETCONVERSION,FALSE);
CheckDlgButton(IDC_GRIDSIZE,FALSE);
CheckDlgButton(IDC_FREESTYLE,FALSE);
switch(EInfo.BType)
{
case ExportInfo::BT_SETCON: CheckDlgButton(IDC_SETCONVERSION,TRUE); break;
case ExportInfo::BT_GSIZE: CheckDlgButton(IDC_GRIDSIZE,TRUE); break;
case ExportInfo::BT_FREESTYLE: CheckDlgButton(IDC_FREESTYLE,TRUE); break;
}
if(IsDlgButtonChecked(IDC_SETCONVERSION))
{
m_dxsli.EnableWindow(FALSE);
m_dzsli.EnableWindow(FALSE);
m_dxtctrl.EnableWindow(FALSE);
m_dztctrl.EnableWindow(FALSE);
}
if(IsDlgButtonChecked(IDC_GRIDSIZE))
{
m_zssli.EnableWindow(FALSE);
m_xssli.EnableWindow(FALSE);
m_zstctrl.EnableWindow(FALSE);
m_xstctrl.EnableWindow(FALSE);
}
}
void CExportOptions::GetData(ExportInfo *einf)
{
einf->BType=EInfo.BType;
einf->Display=m_showexport;
einf->SetScale_Offset(m_dxtext, m_dytext, m_dztext, m_voff);
einf->SetSizeKM(m_xstext,m_zstext);
}
void CExportOptions::OnChangeZstext()
{
if(NoUpdate) return;
NoUpdate++;
UpdateData(TRUE);
m_zssli.SetPos((int)m_zstext);
UpdateTextFields();
NoUpdate--;
}
void CExportOptions::OnChangeXstext()
{
if(NoUpdate) return;
NoUpdate++;
UpdateData(TRUE);
m_xssli.SetPos((int)m_xstext);
UpdateTextFields();
NoUpdate--;
}
void CExportOptions::OnChangeDztext()
{
if(NoUpdate) return;
NoUpdate++;
UpdateData(TRUE);
m_dzsli.SetPos((int)m_dztext);
UpdateTextFields();
NoUpdate--;
}
void CExportOptions::OnChangeDytext()
{
if(NoUpdate) return;
NoUpdate++;
UpdateData(TRUE);
m_dysli.SetPos((int)(m_dytext*4));
UpdateTextFields();
NoUpdate--;
}
void CExportOptions::OnChangeDxtext()
{
if(NoUpdate) return;
NoUpdate++;
UpdateData(TRUE);
m_dxsli.SetPos((int)(m_dxtext));
UpdateTextFields();
NoUpdate--;
}
void CExportOptions::UpdateTextFields()
{
NoUpdate++;
UpdateData(TRUE);
EInfo.SetScale_Offset(m_dxtext, m_dytext, m_dztext, m_voff);
EInfo.SetSizeKM(m_xstext,m_zstext);
EInfo.GetSizeKM(&m_xstext,&m_zstext);
EInfo.GetScale_Offset(&m_dxtext, &m_dytext, &m_dztext, &m_voff);
UpdateData(FALSE);
m_dxsli.SetPos((int)m_dxtext);
m_dysli.SetPos((int)m_dytext);
m_dzsli.SetPos((int)m_dztext);
m_xssli.SetPos((int)m_xstext);
m_zssli.SetPos((int)m_zstext);
NoUpdate--;
}
@@ -0,0 +1,78 @@
#if !defined(AFX_EXPORTOPTIONS_H__4BC3D161_794E_11D2_8409_00A0C933BCAC__INCLUDED_)
#define AFX_EXPORTOPTIONS_H__4BC3D161_794E_11D2_8409_00A0C933BCAC__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ExportOptions.h : header file
//
#include"ExportInfo.h"
/////////////////////////////////////////////////////////////////////////////
// CExportOptions dialog
class CExportOptions : public CDialog
{
// Construction
public:
void UpdateTextFields();
void GetData(ExportInfo *einf);
void SetData(const ExportInfo &einf);
CExportOptions(CWnd* pParent = NULL); // standard constructor
ExportInfo EInfo;
// Dialog Data
//{{AFX_DATA(CExportOptions)
enum { IDD = IDD_EXPORTOPTIONS };
CEdit m_zstctrl;
CEdit m_xstctrl;
CEdit m_dztctrl;
CEdit m_dytctrl;
CEdit m_dxtctrl;
CSliderCtrl m_zssli;
CSliderCtrl m_xssli;
CSliderCtrl m_dzsli;
CSliderCtrl m_dysli;
CSliderCtrl m_dxsli;
float m_dxtext;
float m_dytext;
BOOL m_showexport;
float m_voff;
float m_xstext;
float m_zstext;
float m_dztext;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CExportOptions)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
void UpdateControls();
int NoUpdate;
// Generated message map functions
//{{AFX_MSG(CExportOptions)
virtual BOOL OnInitDialog();
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg void OnFreestyle();
afx_msg void OnGridsize();
afx_msg void OnSetconversion();
afx_msg void OnChangeZstext();
afx_msg void OnChangeXstext();
afx_msg void OnChangeDztext();
afx_msg void OnChangeDytext();
afx_msg void OnChangeDxtext();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_EXPORTOPTIONS_H__4BC3D161_794E_11D2_8409_00A0C933BCAC__INCLUDED_)
+49
View File
@@ -0,0 +1,49 @@
// Feature.cpp: implementation of the Feature class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "tctb.h"
#include "Feature.h"
#include <Stuff\StuffHeaders.hpp>
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
Feature::Feature(CString &fname)
{
Load(fname);
}
Feature::Feature()
{
}
Feature::~Feature()
{
}
void Feature::Load(const char *fnme)
{
FileName=fnme;
NotationFile ini_file(fnme);
char *name;
ini_file.GetEntry("General","Name",(const char **)&name);
Name=name;
}
void Feature::Save()
{
NotationFile ini_file;
ini_file.SetEntry("General","Name",(LPCSTR)Name);
ini_file.SaveAs(FileName);
}
+27
View File
@@ -0,0 +1,27 @@
// Feature.h: interface for the Feature class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_FEATURE_H__9F52F801_8066_11D2_840A_00A0C933BCAC__INCLUDED_)
#define AFX_FEATURE_H__9F52F801_8066_11D2_840A_00A0C933BCAC__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class Feature
{
protected:
CString Name,FileName;
public:
void Save();
void Load(const char *fnme);
Feature();
Feature(CString &fname);
CString GetName() {return Name;}
void SetName(CString &nme) {Name=nme;}
virtual ~Feature();
};
#endif // !defined(AFX_FEATURE_H__9F52F801_8066_11D2_840A_00A0C933BCAC__INCLUDED_)
@@ -0,0 +1,85 @@
// FeatureDlg.cpp : implementation file
//
#include "stdafx.h"
#include "tctb.h"
#include "FeatureDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CFeatureDlg
IMPLEMENT_DYNAMIC(CFeatureDlg, CPropertySheet)
CFeatureDlg::CFeatureDlg(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
:CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
{
}
CFeatureDlg::CFeatureDlg(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
:CPropertySheet(pszCaption, pParentWnd, iSelectPage)
{
}
CFeatureDlg::~CFeatureDlg()
{
delete FTab;
delete PList;
}
BEGIN_MESSAGE_MAP(CFeatureDlg, CPropertySheet)
//{{AFX_MSG_MAP(CFeatureDlg)
ON_WM_CLOSE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFeatureDlg message handlers
BOOL CFeatureDlg::OnInitDialog()
{
BOOL bResult = CPropertySheet::OnInitDialog();
int i;
for(i=0;i<GetPageCount();i++) SetActivePage(i); //Make sure all the pages are initalized
SetActivePage(0);
return bResult;
}
BOOL CFeatureDlg::Create( CWnd* pParentWnd, DWORD dwStyle, DWORD dwExStyle )
{
FTab=new CFeaturesTab;
PList=new CPathList ;
FTab->SetPathList(PList);
AddPage(FTab);
AddPage(PList);
return CPropertySheet::Create( pParentWnd , dwStyle , dwExStyle);
}
void CFeatureDlg::OnClose()
{
// TODO: Add your message handler code here and/or call default
ShowWindow(SW_HIDE);
// CPropertySheet::OnClose();
}
void CFeatureDlg::Init()
{
FTab->UpdateList(&PList->m_PList);
}
void CFeatureDlg::Update()
{
SetActivePage(0);
}
+59
View File
@@ -0,0 +1,59 @@
#if !defined(AFX_FEATUREDLG_H__4ED6B681_7E0B_11D2_840A_00A0C933BCAC__INCLUDED_)
#define AFX_FEATUREDLG_H__4ED6B681_7E0B_11D2_840A_00A0C933BCAC__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// FeatureDlg.h : header file
//
#include"FeaturesTab.h"
#include"PathList.h"
/////////////////////////////////////////////////////////////////////////////
// CFeatureDlg
class CFeatureDlg : public CPropertySheet
{
DECLARE_DYNAMIC(CFeatureDlg)
// Construction
public:
CFeatureDlg(UINT nIDCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);
CFeatureDlg(LPCTSTR pszCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);
BOOL Create( CWnd* pParentWnd = NULL, DWORD dwStyle = -1, DWORD dwExStyle = 0 );
CFeaturesTab *FTab;
CPathList *PList;
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CFeatureDlg)
public:
virtual BOOL OnInitDialog();
//}}AFX_VIRTUAL
// Implementation
public:
void Update();
void Init();
virtual ~CFeatureDlg();
// Generated message map functions
protected:
//{{AFX_MSG(CFeatureDlg)
afx_msg void OnClose();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_FEATUREDLG_H__4ED6B681_7E0B_11D2_840A_00A0C933BCAC__INCLUDED_)
@@ -0,0 +1,54 @@
// FeatureEditDlg.cpp : implementation file
//
#include "stdafx.h"
#include "tctb.h"
#include "FeatureEditDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CFeatureEditDlg dialog
CFeatureEditDlg::CFeatureEditDlg(CWnd* pParent /*=NULL*/)
: CDialog(CFeatureEditDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CFeatureEditDlg)
m_NameEdit = _T("");
//}}AFX_DATA_INIT
}
void CFeatureEditDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CFeatureEditDlg)
DDX_Text(pDX, IDC_NAMEEDIT, m_NameEdit);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CFeatureEditDlg, CDialog)
//{{AFX_MSG_MAP(CFeatureEditDlg)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFeatureEditDlg message handlers
void CFeatureEditDlg::SetData(Feature &fet)
{
m_NameEdit=fet.GetName();
}
void CFeatureEditDlg::GetData(Feature *fet)
{
//UpdateData(TRUE);
fet->SetName(m_NameEdit);
}
@@ -0,0 +1,50 @@
#if !defined(AFX_FEATUREEDITDLG_H__4ED6B684_7E0B_11D2_840A_00A0C933BCAC__INCLUDED_)
#define AFX_FEATUREEDITDLG_H__4ED6B684_7E0B_11D2_840A_00A0C933BCAC__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// FeatureEditDlg.h : header file
//
#include "Feature.h"
/////////////////////////////////////////////////////////////////////////////
// CFeatureEditDlg dialog
class CFeatureEditDlg : public CDialog
{
// Construction
public:
void GetData(Feature *fet);
void SetData(Feature &fet);
CFeatureEditDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CFeatureEditDlg)
enum { IDD = IDD_FEATUREEDIT };
CString m_NameEdit;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CFeatureEditDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CFeatureEditDlg)
// NOTE: the ClassWizard will add member functions here
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_FEATUREEDITDLG_H__4ED6B684_7E0B_11D2_840A_00A0C933BCAC__INCLUDED_)
@@ -0,0 +1,159 @@
// FeaturesTab.cpp : implementation file
//
#include "stdafx.h"
#include "tctb.h"
#include "FeaturesTab.h"
#include "FeatureEditDlg.h"
#include "Feature.h"
#ifdef _DEBUG
//#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CFeaturesTab property page
IMPLEMENT_DYNCREATE(CFeaturesTab, CPropertyPage)
CFeaturesTab::CFeaturesTab() : CPropertyPage(CFeaturesTab::IDD)
{
//{{AFX_DATA_INIT(CFeaturesTab)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
PList=NULL;
}
CFeaturesTab::~CFeaturesTab()
{
}
void CFeaturesTab::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CFeaturesTab)
DDX_Control(pDX, IDC_FEATURELIST, m_FList);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CFeaturesTab, CPropertyPage)
//{{AFX_MSG_MAP(CFeaturesTab)
ON_NOTIFY(NM_DBLCLK, IDC_FEATURELIST, OnDblclkFeaturelist)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFeaturesTab message handlers
void CFeaturesTab::UpdateList(CListBox *paths)
{
int i;
CString cpath;
m_FList.DeleteAllItems();
for(i=0;i<paths->GetCount();i++)
{
paths->GetText(i,cpath);
FillBranch(cpath);
}
}
void CFeaturesTab::FillBranch(CString cpath)
{
WIN32_FIND_DATA fd;
HANDLE han;
CString ext;
cpath+="\\";
han=FindFirstFile(cpath+"*.*",&fd);
LVFINDINFO lvf;
lvf.flags=LVFI_STRING;
Feature fet;
if(INVALID_HANDLE_VALUE!=han)
do
{
if(fd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY
&& strcmp(fd.cFileName,".") && strcmp(fd.cFileName,".."))
{
FillBranch(cpath+fd.cFileName);
}
else
{
ext=fd.cFileName;
ext=ext.Right(ext.GetLength()-(ext.ReverseFind('.')+1));
lvf.psz=fd.cFileName;
if(ext=="tctf" && m_FList.FindItem(&lvf)==-1)
{
fet.Load(cpath+fd.cFileName);
m_FList.InsertItem(0,fd.cFileName);
m_FList.SetItemText(m_FList.FindItem(&lvf),1,fet.GetName());
m_FList.SetItemText(m_FList.FindItem(&lvf),2,cpath);
}
}
}
while(FindNextFile(han,&fd));
}
BOOL CFeaturesTab::OnInitDialog()
{
CPropertyPage::OnInitDialog();
// TODO: Add extra initialization here
m_FList.InsertColumn(0,"File",LVCFMT_LEFT,100);
m_FList.InsertColumn(1,"Name",LVCFMT_LEFT,100);
m_FList.InsertColumn(2,"Path",LVCFMT_LEFT,100);
// LayList.SetImageList(imlist,LVSIL_SMALL);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CFeaturesTab::OnSetActive()
{
if(PList && PList->Changed==TRUE)
{
UpdateList(&PList->m_PList);
PList->Changed=FALSE;
}
return CPropertyPage::OnSetActive();
}
void CFeaturesTab::OnDblclkFeaturelist(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
CFeatureEditDlg dlg;
char nme[MAX_PATH],pth[MAX_PATH];
CString str;
POSITION p;
int sel;
p=m_FList.GetFirstSelectedItemPosition();
if(p!=NULL)
{
sel=m_FList.GetNextSelectedItem(p);
m_FList.GetItemText(sel,2,pth,MAX_PATH);
m_FList.GetItemText(sel,0,nme,MAX_PATH);
str=pth;
str+=nme;
Feature fet(str);
dlg.SetData(fet);
if(dlg.DoModal()==IDOK)
{
dlg.GetData(&fet);
fet.Save();
}
UpdateList(&PList->m_PList);
}
*pResult = 0;
}
@@ -0,0 +1,55 @@
#if !defined(AFX_FEATURESTAB_H__4ED6B682_7E0B_11D2_840A_00A0C933BCAC__INCLUDED_)
#define AFX_FEATURESTAB_H__4ED6B682_7E0B_11D2_840A_00A0C933BCAC__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// FeaturesTab.h : header file
//
#include"PathList.h"
/////////////////////////////////////////////////////////////////////////////
// CFeaturesTab dialog
class CFeaturesTab : public CPropertyPage
{
DECLARE_DYNCREATE(CFeaturesTab)
// Construction
public:
void FillBranch(CString cpath);
void UpdateList(CListBox *paths);
void SetPathList(CPathList *plst) {PList=plst;}
CFeaturesTab();
~CFeaturesTab();
CPathList *PList;
// Dialog Data
//{{AFX_DATA(CFeaturesTab)
enum { IDD = IDD_FEATURES };
CListCtrl m_FList;
//}}AFX_DATA
// Overrides
// ClassWizard generate virtual function overrides
//{{AFX_VIRTUAL(CFeaturesTab)
public:
virtual BOOL OnSetActive();
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CFeaturesTab)
virtual BOOL OnInitDialog();
afx_msg void OnDblclkFeaturelist(NMHDR* pNMHDR, LRESULT* pResult);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_FEATURESTAB_H__4ED6B682_7E0B_11D2_840A_00A0C933BCAC__INCLUDED_)
@@ -0,0 +1,920 @@
// FinalBitmapWnd.cpp : implementation file
//
#include "stdafx.h"
#include "TCTb.h"
#include "FinalBitmapWnd.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CTCTbApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CFinalBitmapWnd
//IMPLEMENT_DYNCREATE(CFinalBitmapWnd, CMDIChildWnd)
CFinalBitmapWnd::CFinalBitmapWnd()
{
Adjust=1;
zfactor=(float)1.0;
hfname="none";
curpnt=-1;
}
CFinalBitmapWnd::~CFinalBitmapWnd()
{
}
BEGIN_MESSAGE_MAP(CFinalBitmapWnd, CMDIChildWnd)
//{{AFX_MSG_MAP(CFinalBitmapWnd)
ON_WM_DESTROY()
ON_WM_CLOSE()
ON_WM_CREATE()
ON_WM_PAINT()
ON_WM_SIZE()
ON_WM_DROPFILES()
ON_COMMAND(ID_EDIT_PASTE, OnEditPaste)
ON_WM_MOUSEMOVE()
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_RBUTTONDOWN()
ON_WM_RBUTTONUP()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFinalBitmapWnd message handlers
void CFinalBitmapWnd::OnDestroy()
{
WhitePen.DeleteObject();
BluePen.DeleteObject();
RedPen.DeleteObject();
RDPen.DeleteObject();
RedBrush.DeleteObject();
BlueBrush.DeleteObject();
CMDIChildWnd::OnDestroy();
// TODO: Add your message handler code here
}
void CFinalBitmapWnd::OnClose()
{
//ShowWindow(SW_MINIMIZE);
ShowWindow(SW_HIDE);
// CMDIChildWnd::OnClose();
}
void CFinalBitmapWnd::MakeDisplayedBmp(TCTTerrainData *tdat)
{
Check_Pointer(tdat);
CDC *pDC=GetDC();
switch(theApp.DMode)
{
case DM_HFIELD:
{
int imw,imh;
Image timg;
HeightFieldLayer *lay;
lay=&tdat->HFLayer;
timg=lay->Img;
hfname=lay->Img.GetFileName();
timg.MakeGrayscalePalette();
timg.MakeRGB24();
//Change this make it work with arbitary pitch possibly code a method in image class
imw=timg.GetWidth();
imh=timg.GetHeight();
DispBmp.DeleteObject();
DispBmp.CreateCompatibleBitmap(pDC,imw,imh);
CRect trct;
trct.top=trct.left=0;
trct.bottom=imh; trct.right=imw;
CalcWindowRect(&trct);
SetWindowPos(&wndTop,trct.left,trct.top,trct.Width(),trct.Height(),SWP_NOMOVE|SWP_SHOWWINDOW);
BITMAPINFOHEADER bhd;
BITMAPINFO binf;
bhd.biSize=sizeof(BITMAPINFOHEADER);
bhd.biWidth=imw; bhd.biHeight=-imh;
bhd.biPlanes=1;
bhd.biBitCount=24;
bhd.biCompression=BI_RGB;
bhd.biSizeImage=0;
bhd.biClrImportant=0;
binf.bmiHeader=bhd;
CDC memDC;
memDC.CreateCompatibleDC(pDC);
memDC.SelectObject(&DispBmp);
SetDIBitsToDevice(memDC.m_hDC,0,0,imw,
imh,0,0,0,imh,timg.Lock(),
&binf,DIB_RGB_COLORS);
timg.UnLock();
memDC.DeleteDC();
}
break;
case DM_BASETEXTURE:
{
int imw,imh;
Image timg;
TextureLayer *lay;
lay=&tdat->BaseTexture;
timg=lay->Img;
hfname=lay->Img.GetFileName();
timg.MakeRGB24();
//Change this make it work with arbitary pitch possibly code a method in image class
imw=timg.GetWidth();
imh=timg.GetHeight();
DispBmp.DeleteObject();
DispBmp.CreateCompatibleBitmap(pDC,imw,imh);
CRect trct;
trct.top=trct.left=0;
trct.bottom=imh; trct.right=imw;
CalcWindowRect(&trct);
SetWindowPos(&wndTop,trct.left,trct.top,trct.Width(),trct.Height(),SWP_NOMOVE|SWP_SHOWWINDOW);
BITMAPINFOHEADER bhd;
BITMAPINFO binf;
bhd.biSize=sizeof(BITMAPINFOHEADER);
bhd.biWidth=imw; bhd.biHeight=-imh;
bhd.biPlanes=1;
bhd.biBitCount=24;
bhd.biCompression=BI_RGB;
bhd.biSizeImage=0;
bhd.biClrImportant=0;
binf.bmiHeader=bhd;
CDC memDC;
memDC.CreateCompatibleDC(pDC);
memDC.SelectObject(&DispBmp);
SetDIBitsToDevice(memDC.m_hDC,0,0,imw,
imh,0,0,0,imh,timg.Lock(),
&binf,DIB_RGB_COLORS);
timg.UnLock();
memDC.DeleteDC();
}
break;
}
SetWindowPos(NULL,0,0,640,640,SWP_NOMOVE|SWP_SHOWWINDOW);
ReleaseDC(pDC);
ReDraw();
}
int CFinalBitmapWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
CDC *pDC=GetDC();
DispBmp.CreateCompatibleBitmap(pDC,DEFAULTBMPSIZE,DEFAULTBMPSIZE);
DispBBuffer.CreateCompatibleBitmap(pDC,DEFAULTBMPSIZE,DEFAULTBMPSIZE);
//Make a BitMap and Black it out.
CDC memDC;
memDC.CreateCompatibleDC(pDC);
memDC.SelectObject(&DispBmp);
BITMAP bmp;
DispBmp.GetBitmap(&bmp);
CRect trct;
trct.top=trct.left=0;
trct.bottom=bmp.bmHeight; trct.right=bmp.bmWidth;
LastWidth=bmp.bmWidth;
LastHeight=trct.bottom;
CalcWindowRect(&trct);
SetWindowPos(&wndTop,trct.left,trct.top,trct.Width(),trct.Height(),SWP_NOMOVE|SWP_SHOWWINDOW);
memDC.BitBlt(0,0,bmp.bmWidth,bmp.bmHeight,NULL,0,0,BLACKNESS);
memDC.DeleteDC();
WhitePen.CreatePen(PS_SOLID,1,RGB(255,255,255));
BluePen.CreatePen(PS_SOLID,1,RGB(0,0,255));
RedPen.CreatePen(PS_SOLID,3,RGB(255,0,0));
RDPen.CreatePen(PS_DASH,1,RGB(255,0,0));
RedBrush.CreateSolidBrush(RGB(255,0,0));
BlueBrush.CreateSolidBrush(RGB(0,255,0));
memDC.DeleteDC();
ReleaseDC(pDC);
return 0;
}
void CFinalBitmapWnd::OnPaint()
{
CPaintDC dc(this); // device context for painting
ReDraw();
// Do not call CMDIChildWnd::OnPaint() for painting messages
}
void CFinalBitmapWnd::ReDraw()
{
CDC *pDC,memDC,bbDC;
BITMAP bmp,bmp2;
DispBmp.GetBitmap(&bmp);
pDC=GetDC();
memDC.CreateCompatibleDC(pDC);
memDC.SelectObject(&DispBmp);
bbDC.CreateCompatibleDC(pDC);
bbDC.SelectObject(&DispBBuffer);
//Blt image to back buffer
DispBBuffer.GetBitmap(&bmp);
DispBmp.GetBitmap(&bmp2);
bbDC.StretchBlt(0,0,bmp.bmWidth,bmp.bmHeight,&memDC,
0,0,bmp2.bmWidth,bmp2.bmHeight,SRCCOPY);
UpdateDims();
SplineLoop *ViewLoop;
ViewLoop=theApp.CamInfo.ViewLoop;
//Display the ViewSpline
if(ViewLoop && theApp.CamInfo.GetMode()==CameraInfo::CM_TRACK)
{
Stuff::Scalar t=0.0f,step=1.0f/VSRES;
Stuff::Point3D np;
Stuff::Vector3D nv;
CPoint loc;
int i;
bbDC.SelectObject(WhitePen);
bbDC.SelectObject(GetStockObject(NULL_BRUSH));
ViewLoop->Evaluate(0.0f,&np,&nv);
bbDC.MoveTo(GridToMap(np));
for(t=step;t<=1.0f;t+=step)
{
ViewLoop->Evaluate(t,&np,&nv);
bbDC.LineTo(GridToMap(np));
}
for(i=0;i<EDCPOINTS;i++)
{
ViewLoop->GetCPoint(i,&np,&nv);
loc=GridToMap(np);
bbDC.Rectangle(loc.x-5,loc.y-5,loc.x+5,loc.y+5);
}
}
//Display the Camera
if(theApp.RVWnd && theApp.RVWnd->ActiveHField)
{
Stuff::Point3D np;
Stuff::Vector3D nv;
CPoint loc,tloc;
bbDC.SelectObject(RedPen);
bbDC.SelectObject(RedBrush);
if(theApp.CamInfo.GetMode()==CameraInfo::CM_TRACK)
{
//theApp.ViewLoop->Evaluate(theApp.RVWnd->CTime,&np,&nv);
np=theApp.CamInfo.Loc;
nv=theApp.CamInfo.Dir;
loc=GridToMap(np);
bbDC.Rectangle(loc.x-5,loc.y-5,loc.x+5,loc.y+5);
}
else
{
np=theApp.CamInfo.Loc;
nv=theApp.CamInfo.Dir;
loc=GridToMap(np);
bbDC.Rectangle(loc.x-5,loc.y-5,loc.x+5,loc.y+5);
}
if(theApp.CamInfo.UseTarget)
{
tloc=GridToMap(theApp.CamInfo.TargetLoc);
bbDC.SelectObject(BluePen);
bbDC.SelectObject(GetStockObject(NULL_BRUSH));
bbDC.Rectangle(tloc.x-5,tloc.y-5,tloc.x+5,tloc.y+5);
bbDC.SelectObject(RDPen);
bbDC.MoveTo(loc);
bbDC.LineTo(tloc);
}
else
{
Stuff::Scalar xs,zs;
xs=theApp.RVWnd->ActiveHField->GetXScale();
zs=theApp.RVWnd->ActiveHField->GetZScale();
bbDC.SelectObject(RedPen);
bbDC.MoveTo(loc);
nv.Normalize(nv);
np.x+=nv.x*20*xs;
np.z+=nv.z*20*zs;
bbDC.LineTo(GridToMap(np));
}
} //end of draw camera
//Display the backbuffer
CRect crct;
GetClientRect(&crct);
DispBBuffer.GetBitmap(&bmp);
pDC->BitBlt(0,0,crct.Width(),crct.Height(),&bbDC,0,0,SRCCOPY);
bbDC.DeleteDC();
memDC.DeleteDC();
ReleaseDC(pDC);
}
void CFinalBitmapWnd::OnSize(UINT nType, int cx, int cy)
{
CMDIChildWnd::OnSize(nType, cx, cy);
CRect crct;
BITMAP bmp;
GetClientRect(&crct);
DispBmp.GetBitmap(&bmp);
CDC *pDC=GetDC();
DispBBuffer.DeleteObject();
DispBBuffer.CreateCompatibleBitmap(pDC,crct.Width(),crct.Height());
ReleaseDC(pDC);
if(crct.Width()==0 || crct.Height()==0) return;
if(Adjust)
{
int nw,nh;
int xdiff,ydiff;
float bmaspect,cltaspect;
xdiff=crct.Width()-LastWidth;
ydiff=crct.Height()-LastHeight;
bmaspect=(float)bmp.bmWidth/bmp.bmHeight;
cltaspect=(float)crct.Width()/crct.Height();
if(abs(xdiff)>abs(ydiff)) //Retain X and adjust Y to maintain Aspect Ratio
{
nw=crct.Width();
nh=(int)(crct.Width()/bmaspect);
}
else //Retain Y and adjust X to maintain Aspect Ratio
{
nh=crct.Height();
nw=(int)(bmaspect*crct.Height());
}
Adjust=0;
SetWindowPos(NULL,0,0,nw,nh,SWP_NOMOVE|SWP_SHOWWINDOW|SWP_NOZORDER|SWP_NOACTIVATE);
LastWidth=crct.Width();
LastHeight=crct.Height();
Adjust=1;
}
GetClientRect(&crct);
zfactor=(float)100*crct.Width()/bmp.bmWidth;
SetTitle();
UpdateDims();
}
void CFinalBitmapWnd::SetTitle()
{
CString tstr,tstr2;
int i;
i=hfname.ReverseFind('\\');
if(i!=-1)
{
tstr2=hfname.Right(hfname.GetLength()-i-1);
}
tstr.Format("%s - %3.2f%% - file = %s",TITLEVIEW2D,zfactor,tstr2);
SetWindowText(tstr);
}
BOOL CFinalBitmapWnd::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CMDIFrameWnd* pParentWnd, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
return CMDIChildWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, pContext);
}
void CFinalBitmapWnd::OnDropFiles(HDROP hDropInfo)
{
// TODO: Add your message handler code here and/or call default
char fname[MAX_PATH];
CString tstr;
DragQueryFile(hDropInfo,0,fname,MAX_PATH);
tstr=fname;
theApp.ImportBitmap(tstr);
// CMDIChildWnd::OnDropFiles(hDropInfo);
}
void CFinalBitmapWnd::OnEditPaste()
{
// TODO: Add your command handler code here
COleDataObject DObj;
HRESULT res;
res=DObj.AttachClipboard();
if(DObj.IsDataAvailable(CF_DIB))
{
CFile *fle;
fle=DObj.GetFileData(CF_DIB);
BITMAPINFOHEADER ihdr;
fle->Read(&ihdr,sizeof(ihdr));
Image timg;
if(!(ihdr.biBitCount==8 || ihdr.biBitCount==16 || ihdr.biBitCount==24 || ihdr.biBitCount==32)) return;
if(ihdr.biBitCount==8)
{
timg.CreateSolid(ihdr.biWidth,ihdr.biHeight,ImgRGBColor(0,0,0),ITYPE_INDEXED,ihdr.biBitCount);
fle->Seek(256*sizeof(RGBQUAD),CFile::current);
}
else
timg.CreateSolid(ihdr.biWidth,ihdr.biHeight,ImgRGBColor(0,0,0),ITYPE_RGB,ihdr.biBitCount);
unsigned char *dat;
dat=timg.Lock();
fle->Read(dat,ihdr.biWidth*ihdr.biHeight*(ihdr.biBitCount>>3));
timg.UnLock();
theApp.ImportBitmap(timg);
delete fle;
}
}
void CFinalBitmapWnd::DrawViewSpline(SplineLoop *ViewLoop)
{
if(!ViewLoop) return;
Stuff::Scalar t=0.0f,step=1.0f/VSRES;
Stuff::Point3D np;
Stuff::Vector3D nv;
CPoint loc;
CDC *dc;
dc=GetDC();
int i;
UpdateDims();
dc->SelectObject(WhitePen);
dc->SelectObject(GetStockObject(NULL_BRUSH));
ViewLoop->Evaluate(0.0f,&np,&nv);
dc->MoveTo(GridToMap(np));
for(t=step;t<=1.0f;t+=step)
{
ViewLoop->Evaluate(t,&np,&nv);
dc->LineTo(GridToMap(np));
}
for(i=0;i<EDCPOINTS;i++)
{
ViewLoop->GetCPoint(i,&np,&nv);
loc=GridToMap(np);
dc->Rectangle(loc.x-5,loc.y-5,loc.x+5,loc.y+5);
}
ReleaseDC(dc);
}
void CFinalBitmapWnd::OnMouseMove(UINT nFlags, CPoint point)
{
if(nFlags&MK_LBUTTON)
{
UpdateDims();
if(nFlags&MK_CONTROL)
{
CPoint Dist;
Dist=point-LastPoint;
if(nFlags&MK_SHIFT)
{
if(theApp.CamInfo.TarATrkFlg) theApp.CamInfo.TarTrackAlt+=-Dist.y/100;
else theApp.CamInfo.TargetLoc.y+=Dist.y;
if(theApp.CamInfo.GetMode()==CameraInfo::CM_FREE)
if(theApp.CamInfo.CamATrkFlg) theApp.CamInfo.CamTrackAlt+=-Dist.y/100;
else theApp.CamInfo.Loc.y+=Dist.y;
} //end of if Lbutton && Shift
else
{
if(theApp.CamInfo.CamATrkFlg) theApp.CamInfo.CamTrackAlt+=-Dist.y/100;
else theApp.CamInfo.Loc.y+=-Dist.y/100;
}//end of if Lbutton && !Shift
}//end of if Ctrl
else
{
if(nFlags&MK_SHIFT)
{
if(theApp.CamInfo.UseTarget)
{
Stuff::Point3D tpt=MapToGrid(point);
theApp.CamInfo.TargetLoc.x=tpt.x;
theApp.CamInfo.TargetLoc.z=tpt.z;
}
else
{
if(theApp.CamInfo.GetMode()==CameraInfo::CM_FREE)
{
Stuff::Point3D tpt=MapToGrid(point),otloc=theApp.CamInfo.TargetLoc;
theApp.CamInfo.TargetLoc.x=tpt.x;
theApp.CamInfo.TargetLoc.z=tpt.z;
theApp.CamInfo.TargetLoc.y=theApp.CamInfo.Loc.y;
theApp.CamInfo.UseTarget=true;
theApp.CamInfo.UpdateCPos();
theApp.CamInfo.UseTarget=false;
theApp.CamInfo.TargetLoc=otloc;
}
}//end of if Use Target
} //end of if Lbutton && Shift
else
{
if(theApp.CamInfo.GetMode()==CameraInfo::CM_TRACK && curpnt>=0)
{
Stuff::Point3D tpt,p3d=MapToGrid(point);
Stuff::Vector3D v3d;
theApp.CamInfo.ViewLoop->GetCPoint(curpnt,&tpt,&v3d);
theApp.CamInfo.ViewLoop->SetCPoint(curpnt,p3d,v3d);
}
if(theApp.CamInfo.GetMode()==CameraInfo::CM_FREE)
{
Stuff::Point3D tpt=MapToGrid(point);
theApp.CamInfo.Loc.x=tpt.x;
theApp.CamInfo.Loc.z=tpt.z;
}
}//end of if Lbutton && !Shift
}//end of !Ctrl
theApp.CamInfo.UpdateCPos();
ReDraw();
}//end of if Lbutton
CMDIChildWnd::OnMouseMove(nFlags, point);
}
void CFinalBitmapWnd::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
UpdateDims();
LastPoint=point;
if(theApp.CamInfo.GetMode()==CameraInfo::CM_TRACK)
{
curpnt=theApp.CamInfo.ViewLoop->GetClosestCPoint(MapToGrid(point));
}
OnMouseMove(nFlags, point);
CMDIChildWnd::OnLButtonDown(nFlags, point);
}
Stuff::Point3D CFinalBitmapWnd::MapToGrid(CPoint &pnt)
{
Stuff::Point3D tpnt;
Stuff::Scalar xs,zs,xgsze,zgsze;
xs=theApp.RVWnd->ActiveHField->GetXScale();
zs=theApp.RVWnd->ActiveHField->GetZScale();
xgsze=theApp.TData.HFLayer.Img.GetWidth()*xs;
zgsze=theApp.TData.HFLayer.Img.GetHeight()*zs;
Stuff::Scalar xmapsize,ymapsize;
xmapsize=(float)crct.Width();
ymapsize=(float)crct.Height();
tpnt.x=(pnt.x/xmapsize)*xgsze;
tpnt.z=(pnt.y/ymapsize)*zgsze;
// tpnt.x=((pnt.x-crct.Width()/2)*xs)/(zfactor/100)+(DBmp.bmWidth/2)*xs;
// tpnt.z=((pnt.y-crct.Height()/2)*zs)/(zfactor/100)+(DBmp.bmHeight/2)*zs;
//tpnt.y=theApp.RVWnd->ActiveHField->GetHeight(tpnt.x,tpnt.z);
tpnt.y=0.0f;
return tpnt;
}
CPoint CFinalBitmapWnd::GridToMap(Stuff::Point3D &pnt)
{
CPoint tpnt;
Stuff::Scalar xs,zs,xgsze,zgsze;
xs=theApp.RVWnd->ActiveHField->GetXScale();
zs=theApp.RVWnd->ActiveHField->GetZScale();
xgsze=(theApp.TData.HFLayer.Img.GetWidth())*xs;
zgsze=(theApp.TData.HFLayer.Img.GetHeight())*zs;
Stuff::Scalar xmapsize,ymapsize;
xmapsize=(float)crct.Width();
ymapsize=(float)crct.Height();
tpnt.x=(int)((pnt.x/xgsze)*xmapsize);
tpnt.y=(int)((pnt.z/zgsze)*ymapsize);
/*
tpnt.x=(int)(
(pnt.x-(DBmp.bmWidth/2)*xs)*(zfactor*.01))/xs+crct.Width()/2;
tpnt.y=(int)(
(pnt.z-(DBmp.bmHeight/2)*zs)*(zfactor*.01))/zs+crct.Height()/2;
*/
return tpnt;
}
void CFinalBitmapWnd::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
curpnt=-1;
CMDIChildWnd::OnLButtonUp(nFlags, point);
}
void CFinalBitmapWnd::UpdateDims()
{
GetClientRect(&crct);
DispBmp.GetBitmap(&DBmp);
}
void CFinalBitmapWnd::DrawCamera()
{
if(!theApp.RVWnd || !theApp.RVWnd->ActiveHField) return;
CDC *dc;
dc=GetDC();
UpdateDims();
Stuff::Point3D np;
Stuff::Vector3D nv;
CPoint loc,tloc;
dc->SelectObject(RedPen);
dc->SelectObject(RedBrush);
if(theApp.CamInfo.GetMode()==CameraInfo::CM_TRACK)
{
//theApp.ViewLoop->Evaluate(theApp.RVWnd->CTime,&np,&nv);
np=theApp.CamInfo.Loc;
nv=theApp.CamInfo.Dir;
loc=GridToMap(np);
dc->Rectangle(loc.x-5,loc.y-5,loc.x+5,loc.y+5);
}
else
{
np=theApp.CamInfo.Loc;
nv=theApp.CamInfo.Dir;
loc=GridToMap(np);
dc->Rectangle(loc.x-5,loc.y-5,loc.x+5,loc.y+5);
}
if(theApp.CamInfo.UseTarget)
{
tloc=GridToMap(theApp.CamInfo.TargetLoc);
dc->SelectObject(BluePen);
dc->SelectObject(GetStockObject(NULL_BRUSH));
dc->Rectangle(tloc.x-5,tloc.y-5,tloc.x+5,tloc.y+5);
dc->SelectObject(RDPen);
dc->MoveTo(loc);
dc->LineTo(tloc);
}
else
{
Stuff::Scalar xs,zs;
xs=theApp.RVWnd->ActiveHField->GetXScale();
zs=theApp.RVWnd->ActiveHField->GetZScale();
dc->SelectObject(RedPen);
dc->MoveTo(loc);
nv.Normalize(nv);
np.x+=nv.x*20*xs;
np.z+=nv.z*20*zs;
dc->LineTo(GridToMap(np));
}
ReleaseDC(dc);
}
void CFinalBitmapWnd::OnRButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CMDIChildWnd::OnRButtonDown(nFlags, point);
}
void CFinalBitmapWnd::OnRButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CMDIChildWnd::OnRButtonUp(nFlags, point);
}
void CFinalBitmapWnd::BoundSpline(SplineLoop *ViewLoop)
{
int i;
Stuff::Point3D np;
Stuff::Vector3D nv;
CPoint loc;
UpdateDims();
for(i=0;i<EDCPOINTS;i++)
{
ViewLoop->GetCPoint(i,&np,&nv);
loc=GridToMap(np);
if(loc.x<0) loc.x=0;
if(loc.y<0) loc.y=0;
if(loc.x>theApp.TData.HFLayer.Img.GetWidth()) loc.x=theApp.TData.HFLayer.Img.GetWidth();
if(loc.y>theApp.TData.HFLayer.Img.GetHeight()) loc.y=theApp.TData.HFLayer.Img.GetHeight();
np=MapToGrid(loc);
ViewLoop->SetCPoint(i,np,nv);
}
}
void CFinalBitmapWnd::DrawGrid(ToDrawTriangle **tlist,int tnum,COLORREF col,float cx,float cy,float rad)
{
CDC *pDC,memDC,bbDC;
BITMAP bmp,bmp2;
DispBmp.GetBitmap(&bmp);
pDC=GetDC();
CPen pen(PS_SOLID,1,col);
memDC.CreateCompatibleDC(pDC);
memDC.SelectObject(&DispBmp);
bbDC.CreateCompatibleDC(pDC);
bbDC.SelectObject(&DispBBuffer);
//Blt image to back buffer
DispBBuffer.GetBitmap(&bmp);
DispBmp.GetBitmap(&bmp2);
/*
bbDC.StretchBlt(0,0,bmp.bmWidth,bmp.bmHeight,&memDC,
0,0,bmp2.bmWidth,bmp2.bmHeight,SRCCOPY);
*/
UpdateDims();
bbDC.SelectObject(pen);
bbDC.SelectObject(GetStockObject(NULL_BRUSH));
Stuff::Point3D np;
CPoint oloc,loc;
int i;
for(i=0;i<tnum;i++)
{
oloc=GridToMap(tlist[i]->GetV0());
bbDC.MoveTo(oloc);
loc=GridToMap(tlist[i]->GetV1());
bbDC.LineTo(loc);
loc=GridToMap(tlist[i]->GetV2());
bbDC.LineTo(loc);
bbDC.LineTo(oloc);
}
CRect rect;
np.x=cx+rad;
np.y=0.0f;
np.z=cy+rad;
loc=GridToMap(np);
rect.bottom=loc.y;
rect.right=loc.x;
np.x=cx-rad;
np.y=0.0f;
np.z=cy-rad;
loc=GridToMap(np);
rect.top=loc.y;
rect.left=loc.x;
bbDC.Ellipse(&rect);
//Display the backbuffer
CRect crct;
GetClientRect(&crct);
DispBBuffer.GetBitmap(&bmp);
pDC->BitBlt(0,0,crct.Width(),crct.Height(),&bbDC,0,0,SRCCOPY);
bbDC.DeleteDC();
memDC.DeleteDC();
pen.DeleteObject();
ReleaseDC(pDC);
}
void CFinalBitmapWnd::DrawGrid(ToDrawTriangle *tlist,int tnum)
{
CDC *pDC,memDC,bbDC;
BITMAP bmp,bmp2;
DispBmp.GetBitmap(&bmp);
pDC=GetDC();
memDC.CreateCompatibleDC(pDC);
memDC.SelectObject(&DispBmp);
bbDC.CreateCompatibleDC(pDC);
bbDC.SelectObject(&DispBBuffer);
//Blt image to back buffer
DispBBuffer.GetBitmap(&bmp);
DispBmp.GetBitmap(&bmp2);
bbDC.StretchBlt(0,0,bmp.bmWidth,bmp.bmHeight,&memDC,
0,0,bmp2.bmWidth,bmp2.bmHeight,SRCCOPY);
UpdateDims();
bbDC.SelectObject(WhitePen);
Stuff::Point3D np;
CPoint oloc,loc;
int i;
for(i=0;i<tnum;i++)
{
oloc=GridToMap(tlist[i].GetV0());
bbDC.MoveTo(oloc);
loc=GridToMap(tlist[i].GetV1());
bbDC.LineTo(loc);
loc=GridToMap(tlist[i].GetV2());
bbDC.LineTo(loc);
bbDC.LineTo(oloc);
}
//Display the backbuffer
CRect crct;
GetClientRect(&crct);
DispBBuffer.GetBitmap(&bmp);
pDC->BitBlt(0,0,crct.Width(),crct.Height(),&bbDC,0,0,SRCCOPY);
bbDC.DeleteDC();
memDC.DeleteDC();
ReleaseDC(pDC);
}
@@ -0,0 +1,80 @@
#if !defined(AFX_FINALBITMAPWND_H__D9E64DE1_5915_11D2_8408_00A0C933BCAC__INCLUDED_)
#define AFX_FINALBITMAPWND_H__D9E64DE1_5915_11D2_8408_00A0C933BCAC__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// FinalBitmapWnd.h : header file
//
#include"ViewSpline.h"
/////////////////////////////////////////////////////////////////////////////
// CFinalBitmapWnd frame
#include"TCTTerrainData.h"
class CFinalBitmapWnd : public CMDIChildWnd
{
// DECLARE_DYNCREATE(CFinalBitmapWnd)
protected:
CBitmap DispBmp,DispBBuffer;
int LastWidth,LastHeight,Adjust;
float zfactor;
CString hfname;
CPen WhitePen,RedPen,BluePen,RDPen;
CBrush RedBrush,BlueBrush;
int curpnt;
CPoint LastPoint;
// Attributes
public:
CRect crct;
BITMAP DBmp;
CFinalBitmapWnd(); // protected constructor used by dynamic creation
virtual ~CFinalBitmapWnd();
// Operations
public:
void DrawGrid(ToDrawTriangle *tlist,int tnum);
void DrawGrid(ToDrawTriangle **tlist,int tnum,COLORREF col,float cx,float cy,float rad);
void BoundSpline(SplineLoop *ViewLoop);
void DrawCamera();
void UpdateDims();
Stuff::Point3D MapToGrid(CPoint &pnt);
CPoint GridToMap(Stuff::Point3D &pnt);
void DrawViewSpline(SplineLoop *ViewLoop);
void SetTitle();
void ReDraw();
void MakeDisplayedBmp(TCTTerrainData *tdat);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CFinalBitmapWnd)
public:
virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_OVERLAPPEDWINDOW, const RECT& rect = rectDefault, CMDIFrameWnd* pParentWnd = NULL, CCreateContext* pContext = NULL);
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CFinalBitmapWnd)
afx_msg void OnDestroy();
afx_msg void OnClose();
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnPaint();
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnDropFiles(HDROP hDropInfo);
afx_msg void OnEditPaste();
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_FINALBITMAPWND_H__D9E64DE1_5915_11D2_8408_00A0C933BCAC__INCLUDED_)
@@ -0,0 +1,83 @@
// HFAttribDlg.cpp : implementation file
//
#include "stdafx.h"
#include "TCTb.h"
#include "HFAttribDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CTCTbApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CHFAttribDlg dialog
CHFAttribDlg::CHFAttribDlg(CWnd* pParent /*=NULL*/)
: CDialog(CHFAttribDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CHFAttribDlg)
//}}AFX_DATA_INIT
}
void CHFAttribDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CHFAttribDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CHFAttribDlg, CDialog)
//{{AFX_MSG_MAP(CHFAttribDlg)
ON_BN_CLICKED(IDC_LOADBASETEXTURE, OnLoadbasetexture)
ON_BN_CLICKED(IDC_LOADDETAILTEXTURE, OnLoaddetailtexture)
ON_BN_CLICKED(IDC_IMPORT, OnImport)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CHFAttribDlg message handlers
void CHFAttribDlg::OnLoadbasetexture()
{
theApp.LoadBTexture();
theApp.UpdateScreen();
}
void CHFAttribDlg::OnLoaddetailtexture()
{
theApp.LoadDTexture();
theApp.UpdateScreen();
}
void CHFAttribDlg::OnImport()
{
CFileDialog fdlg(TRUE,NULL,NULL,NULL,"Bitmap Images (*.tif,*.gif,*.tga)|*.tif;*.gif;*.tga||",NULL);
if(fdlg.DoModal()==IDOK)
{
theApp.ImportBitmap(fdlg.GetPathName());
theApp.SetStates();
theApp.UpdateScreen();
}
}
BOOL CHFAttribDlg::OnInitDialog()
{
CDialog::OnInitDialog();
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CHFAttribDlg::OnOK()
{
CDialog::OnOK();
}
@@ -0,0 +1,49 @@
#if !defined(AFX_HFATTRIBDLG_H__C8276C61_7315_11D2_8409_00A0C933BCAC__INCLUDED_)
#define AFX_HFATTRIBDLG_H__C8276C61_7315_11D2_8409_00A0C933BCAC__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// HFAttribDlg.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CHFAttribDlg dialog
class CHFAttribDlg : public CDialog
{
// Construction
public:
CHFAttribDlg(CWnd* pParent = NULL); // standard constructor
double oldx,oldy,oldz;
// Dialog Data
//{{AFX_DATA(CHFAttribDlg)
enum { IDD = IDD_HFATTRIBS };
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CHFAttribDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CHFAttribDlg)
afx_msg void OnLoadbasetexture();
afx_msg void OnLoaddetailtexture();
afx_msg void OnImport();
virtual BOOL OnInitDialog();
virtual void OnOK();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_HFATTRIBDLG_H__C8276C61_7315_11D2_8409_00A0C933BCAC__INCLUDED_)
File diff suppressed because it is too large Load Diff
+280
View File
@@ -0,0 +1,280 @@
#if !defined(HFSLIM_HPP)
#define HFSLIM_HPP
#include "ImageLib\image.h"
#include "terra\terra.hpp"
struct DetailLevelInfo {
unsigned short width, height;
unsigned char *array;
};
#define GRID_TEST
struct ToDrawTriangle
{
Point3D v[3];
Point3D center;
Scalar area;
void SetPoint(int idx,float x,float y,float z);
void GetSurfaceAreaAndCentroid();
Point3D &GetV0() { return v[0]; }
Point3D &GetV1() { return v[1]; }
Point3D &GetV2() { return v[2]; }
};
class HFSlim {
public:
HFSlim();
~HFSlim();
void
FillFromImage(Image &image, int smooth=3);
void
TestInstance() const
{}
void
SetScale (Stuff::Scalar xs, Stuff::Scalar ys, Stuff::Scalar zs)
{ Check_Object(this); dX = xs; dY = ys; dZ = zs; }
void
SetDetailTextureInfo(
const char *name,
Scalar xOff, Scalar zOff,
Scalar xFac, Scalar zFac,
Scalar dStart, Scalar dEnd,
MLRState::AlphaMode alphaMode
)
{
detailInfo.name = name;
detailInfo.xOff = xOff;
detailInfo.zOff = zOff;
detailInfo.xFac = xFac;
detailInfo.zFac = zFac;
detailInfo.dStart = dStart;
detailInfo.dEnd = dEnd;
detailInfo.alphaMode = alphaMode;
}
void
SetBorderPixels(int bp)
{ borderPixelFun = bp/256.0f; }
int GetFullPolyCount() {return (X-1)*(Z-1)*2; }
int GetOptPolyCount() {return OptPolyCount; }
ElementRenderer::GroupElement*
GetGroup()
{ return terrainGroup; }
Scalar
GetXinM()
{ return (X-1) * dX; }
Scalar
GetZinM()
{ return (Z-1) * dZ; }
int
GetX()
{ return X; }
int
GetZ()
{ return Z; }
Stuff::Scalar
GetXScale()
{ return dX; }
Stuff::Scalar
GetZScale()
{ return dZ; }
Stuff::Scalar
GetYScale()
{ return dY; }
Scalar
GetX(int x)
{ return xOffset + x*dX; }
Scalar
GetZ(int z)
{ return zOffset + z*dZ; }
Scalar
GetX(Scalar x)
{ return xOffset + x; }
Scalar
GetZ(Scalar z)
{ return zOffset + z; }
Scalar
GetHeight(int, int);
Stuff::ExtentBox
GetExtents();
int
GetNrOfIZs()
{ return nrOfIZs; };
void
SetOffset(Stuff::Scalar offset)
{ Offset = offset; };
bool
SetMegaTexture(
int nrOfLevels,
int bucketSize,
const char *mega_base_name,
DetailLevelInfo *dli
);
void
OptimizeHField(int depth=0, int binSize=64);
Stuff::Scalar
GetOffset()
{ return Offset; };
bool
IsFullDisplayed()
{
return (terrainGroup->FindElement(fullTerrainGroup->GetName())!=NULL);
}
bool
IsOptDisplayed()
{
return (terrainGroup->FindElement(simpleTerrainGroup->GetName())!=NULL);
}
void
DisplayFull(bool bl);
void
DisplayOpt(bool bl);
ElementRenderer::GroupElement *
GetFullTerrain() { Check_Pointer(this); return fullTerrainGroup; }
#ifdef GRID_TEST
ElementRenderer::GridElement *
#else
ElementRenderer::ListElement *
#endif
GetOptTerrain() { Check_Pointer(this); return simpleTerrainGroup; }
void
SetAllDepth(int d)
{ maxAllDepth = d; }
void
SetOffset(Stuff::Scalar xo, Stuff::Scalar zo)
{ Check_Object(this); xOffset = xo; zOffset = zo; }
protected:
void
Blur2D(int);
bool
CreateMesh(
ListElement *parent,
int index,
int levDiff,
DynamicArrayOf<ToDrawTriangle*>& tdtrilist,
Stuff::ExtentBox*,
MidLevelRenderer::MLRState *state = NULL
);
bool
BinSort(
ListElement *parent,
int index,
int levDiff,
DynamicArrayOf<ToDrawTriangle*>& tdtrilist,
int binSize,
Stuff::ExtentBox*,
MidLevelRenderer::MLRState *state = NULL
);
void
BuildTile(
ElementRenderer::ListElement *,
int index,
int depth, int maxdepth,
DynamicArrayOf<unsigned char>& onOffPoints,
int maxNumOfTrianglesPerMesh,
Scalar xOffset,
Scalar zOffset,
Scalar xGrid,
Scalar zGrid,
int tileX,
int tileZ,
const char *texRoot
);
void
DescentToUnderMountain(
int depth,
#ifdef GRID_TEST
ElementRenderer::GridElement *group,
#else
ElementRenderer::ListElement *group,
#endif
DynamicArrayOf<unsigned char>& onOffPoints,
int maxNumOfTrianglesPerMesh,
Scalar x0,
Scalar z0,
Scalar x1,
Scalar z1,
int tileX,
int tileZ,
const char *texRoot
);
DynamicArrayOf<ToDrawTriangle*> toSortTriangles;
DynamicArrayOf<ToDrawTriangle> tdtrilist;
// X, Z number of points, the length of the terrain would be (X-1)*dX
int X, Z, visHeight;
Stuff::Scalar dX, dY, dZ;
int OptPolyCount;
Stuff::DynamicArrayOf<float> field;
int side, meshX, meshZ;
ElementRenderer::GroupElement *terrainGroup;
ElementRenderer::GroupElement *fullTerrainGroup;
#ifdef GRID_TEST
ElementRenderer::GridElement *simpleTerrainGroup;
#else
ElementRenderer::ListElement *simpleTerrainGroup;
#endif
Stuff::DynamicArrayOf<MidLevelRenderer::MLRShape*> terrain;
MidLevelRenderer::MLRState state0, state1;
MidLevelRenderer::DetailTextureInfo detailInfo;
Scalar borderPixelFun;
unsigned char maxAllDepth;
Scalar xOffset, zOffset;
int
nrOfIZs;
private:
Stuff::Scalar Offset;
};
#endif
File diff suppressed because it is too large Load Diff
+540
View File
@@ -0,0 +1,540 @@
#if !defined(HFSLIMMZ_HPP)
#define HFSLIMMZ_HPP
#include "ImageLib\image.h"
#include "terra\terra.hpp"
namespace ElementRenderer {
class GridElement;
class GroupElement;
class ListElement;
}
extern bool doWater;
extern Scalar waterLevel;
extern bool doBSP;
extern bool doPrecise;
extern bool doInterest;
extern bool doTileCap;
extern bool doTileCapYovin;
extern bool doDensityMap;
extern bool silentMode;
struct TriangleAbstract
{
TriangleAbstract():
plane(
Normal3D::Down,
0.0f
)
{ center = Point3D::Identity; area = 0.0f; centerValid = false; }
bool centerValid;
Point3D center;
Scalar area;
Plane plane;
virtual Point3D &GetPoint(int) = 0;
bool GetSurfaceAreaAndCentroid();
};
// ===================== not so precise ===========================
struct ToDrawTriangle :
public TriangleAbstract
{
ToDrawTriangle() : TriangleAbstract()
{ v[0] = Point3D::Identity; v[1] = Point3D::Identity; v[2] =
Point3D::Identity; }
Point3D v[3];
void SetPoint(int idx,float x,float y,float z);
ToDrawTriangle&
operator= (const ToDrawTriangle& tdt)
{
v[0] = tdt.v[0]; v[1] = tdt.v[1]; v[2] = tdt.v[2];
center = tdt.center; area = tdt.area; plane = tdt.plane; centerValid =
tdt.centerValid;
return *this;
}
Point3D &GetPoint(int i) { return v[i]; }
};
// ========================== Precision ===========================
struct DetailLevelInfo {
unsigned short width, height;
unsigned char *array;
};
struct TriangleStruct;
struct TrianglePointAngleStruct {
TrianglePointAngleStruct() { tri = NULL; angle = 0.0f; pos = -1; }
TriangleStruct *tri;
float angle;
int pos;
};
struct PointStruct {
PointStruct() : myTri(16) { p = Point3D::Identity; connectedTo = 0; }
Point3D p;
int connectedTo;
DynamicArrayOf<TrianglePointAngleStruct> myTri;
void Add (TriangleStruct *ts, int pos);
void CalculateAngles();
bool
CheckAngles(float xmin, float zmin, float xmax, float zmax, float dX, float dZ);
bool
CheckAngles(); // checks for adjecent triangles with angle of close to 180
float
GetAngles();
float
GetExpectedAngles(float xmin, float zmin, float xmax, float zmax);
void
TestInstance() const;
};
struct TriangleStruct :
public TriangleAbstract
{
TriangleStruct() : TriangleAbstract()
{ v[0] = 0; v[1] = 0; v[2] = 0; }
static PointStruct *points;
int v[3];
bool GetSurfaceAreaAndCentroid()
{
Verify(points!=NULL);
if(v[0]==v[1] || v[0]==v[2] || v[1]==v[2])
{
center = GetPoint(0);
centerValid = true;
area = 0.0f;
return false;
}
return TriangleAbstract::GetSurfaceAreaAndCentroid();
}
Point3D &GetPoint(int i) { Verify(points!=NULL); return points[v[i]].p; }
};
//======================= Water ===================================
struct WaterEdge
{
int p[2];
Normal3D normal;
bool inside[2];
int used;
WaterEdge()
{ p[0] = -1; p[1] = -1; normal = Normal3D::Down; inside[0] = false;
inside[1] = false; used = 0; }
};
struct WaterEdgePoint
{
Stuff::Point3D p;
int toEdge[8];
int toEdgeCount;
int used;
int onEdge;
WaterEdgePoint()
{ toEdge[0] = -1; toEdge[1] = -1; used = 0; onEdge = 0; toEdgeCount = 0;}
WaterEdgePoint&
operator=(const WaterEdgePoint& wep)
{ p = wep.p; toEdge[0] = wep.toEdge[0]; toEdge[1] = wep.toEdge[1];
used = wep.used; onEdge = wep.onEdge; toEdgeCount = wep.toEdgeCount;
return *this; }
};
struct WaterPools
{
Stuff::DynamicArrayOf<WaterEdge> waterEdge;
Stuff::DynamicArrayOf<WaterEdgePoint> waterEdgePoints;
int waterEdgeCount;
int waterEdgePointCount;
Stuff::Scalar x0, x1, z0, z1, waterLevel;
WaterPools(int nr, Scalar wl) :
waterEdge(nr), waterEdgePoints(2*nr)
{ waterEdgeCount = 0; waterEdgePointCount = 0; waterLevel = wl; }
void
AddEdge(Stuff::Point3D& p0, Stuff::Point3D& p1, const Stuff::Normal3D&
n);
MidLevelRenderer::MLRPrimitiveBase*
LinkEdges();
void
SetTileEdges(Stuff::Scalar _x0, Stuff::Scalar _x1, Stuff::Scalar _z0,
Stuff::Scalar _z1)
{x0 = _x0; x1 = _x1; z0 = _z0; z1 = _z1; }
int
OnWhatEdge(WaterEdgePoint& wep);
int
OnWhatEdge(Stuff::Point3D& wep);
};
// ============================= Naturals ==========================
struct CulturalLoc {
Stuff::Point3D loc;
BYTE yaw;
BYTE nr;
};
// ======================== Height field slim ======================
class HFSlimMZ {
public:
HFSlimMZ();
~HFSlimMZ();
void
FillFromImage(Image &image, int smooth=3);
void
FillInterestDataFromImage(Image &image);
void
TestInstance() const
{}
void
SetScale (Stuff::Scalar xs, Stuff::Scalar ys, Stuff::Scalar zs)
{ Check_Object(this); dX = xs; dY = ys; dZ = zs; }
void
SetDetailTextureInfo(
const char *name,
const char *altname,
Scalar xOff, Scalar zOff,
Scalar xFac, Scalar zFac,
Scalar dStart, Scalar dEnd,
MLRState::AlphaMode alphaMode
)
{
detailInfo.name = name;
detailInfo.altname = altname;
detailInfo.xOff = xOff;
detailInfo.zOff = zOff;
detailInfo.xFac = xFac;
detailInfo.zFac = zFac;
detailInfo.dStart = dStart;
detailInfo.dEnd = dEnd;
detailInfo.alphaMode = alphaMode;
}
void
SetWaterDetailTextureInfo(
const char *name,
Scalar xOff, Scalar zOff,
Scalar xFac, Scalar zFac,
Scalar dStart, Scalar dEnd,
MLRState::AlphaMode alphaMode,
int movieFrames
)
{
waterDetailInfo.name = name;
waterDetailInfo.altname = NULL;
waterDetailInfo.xOff = xOff;
waterDetailInfo.zOff = zOff;
waterDetailInfo.xFac = xFac;
waterDetailInfo.zFac = zFac;
waterDetailInfo.dStart = dStart;
waterDetailInfo.dEnd = dEnd;
waterDetailInfo.alphaMode = alphaMode;
waterDetailInfo.movieFrames = movieFrames;
}
void
SetBorderPixels(int bp)
{ borderPixelFun = bp/256.0f; }
int GetOptPolyCount() {return OptPolyCount; }
Scalar
GetXinM()
{ return (X-1) * dX; }
Scalar
GetZinM()
{ return (Z-1) * dZ; }
int
GetX()
{ return X; }
int
GetZ()
{ return Z; }
Stuff::Scalar
GetXScale()
{ return dX; }
Stuff::Scalar
GetZScale()
{ return dZ; }
Stuff::Scalar
GetYScale()
{ return dY; }
Scalar
GetX(int x)
{ return x*dX; }
Scalar
GetZ(int z)
{ return z*dZ; }
Scalar
GetX(Scalar x)
{ return x; }
Scalar
GetZ(Scalar z)
{ return z; }
Scalar
GetHeight(int, int);
Stuff::ExtentBox
GetExtents();
void
GetZoneDimensions(int *xd, int *zd)
{ *xd = xDim; *zd = zDim; }
Stuff::DynamicArrayOf<ElementRenderer::GridElement*>*
GetTerrainArray()
{ return &simpleTerrainGroup; }
Stuff::DynamicArrayOf<ElementRenderer::GroupElement*>*
GetWaterArray()
{ return &waterGroup; }
void
SetOffset(Stuff::Scalar offset)
{ Offset = offset; };
bool
SetMegaTexture(
int nrOfLevels,
int bucketSize,
const char *megaBaseName,
const char *output
);
void
SetWaterInfo(const char *name, Scalar ratio, int movieFrames)
{ waterTextureName = name; waterTextureRatio = ratio; waterMovieFrames = movieFrames; }
void
OptimizeHField(int depth=0, int binSize=64, const char *name=NULL);
Stuff::Scalar
GetOffset()
{ return Offset; };
void
SetAllDepth(int d)
{ maxAllDepth = d; }
void
SetCenter(Stuff::Scalar xo, Stuff::Scalar zo)
{ Check_Object(this); xCenterOffset = xo; zCenterOffset = zo; }
Stuff::Scalar
GetCenterX()
{ Check_Object(this); return xCenterOffset; }
Stuff::Scalar
GetCenterZ()
{ Check_Object(this); return zCenterOffset; }
void
SetCulturals(CulturalLoc*, int);
void
SetCulturalFadeValues(Stuff::Scalar fadeIn, Stuff::Scalar fadeOut)
{ Check_Object(this); culturalFadeIn = fadeIn; culturalFadeOut =
fadeOut; }
protected:
void
Blur2D(int);
typedef Stuff::Scalar frameArray[8][4];
bool
CreateMesh(
ElementRenderer::ListElement *parent,
int index,
int levDiff,
DynamicArrayOf<TriangleAbstract*>& tdtrilist,
frameArray *frame,
MidLevelRenderer::MLRState *state = NULL
);
bool
CreateMesh2(
ElementRenderer::ListElement *parent,
int index,
int levDiff,
DynamicArrayOf<TriangleAbstract*>& tdtrilist,
frameArray *frame,
MidLevelRenderer::MLRState *state = NULL,
bool uw = false
);
MLRPrimitiveBase*
CreateWater(
Scalar x0, Scalar x1,
Scalar z0, Scalar z1,
Scalar waterLevel
);
bool
BinSort(
ElementRenderer::ListElement *parent,
int index,
int levDiff,
DynamicArrayOf<TriangleAbstract*>& tdtrilist,
int binSize,
frameArray *frame,
MidLevelRenderer::MLRState *state = NULL
);
bool
BinSort2(
ElementRenderer::ListElement *parent,
int index,
int levDiff,
DynamicArrayOf<TriangleAbstract*>& tdtrilist,
int binSize,
frameArray *frame,
MidLevelRenderer::MLRState *state = NULL,
bool uw = false
);
void
BuildTile(
ElementRenderer::ListElement *,
ElementRenderer::GroupElement *,
int index,
int depth, int maxdepth,
DynamicArrayOf<unsigned char>& onOffPoints,
int maxNumOfTrianglesPerMesh,
Scalar xOffset,
Scalar zOffset,
Scalar xGrid,
Scalar zGrid,
int tileX,
int tileZ,
const char *texRoot
);
void
BuildTile(
DynamicArrayOf<TriangleStruct*>& tempTrianglesPtr,
int index,
int depth, int maxdepth,
int numOfTriangles,
DynamicArrayOf<unsigned char>& onOffPoints,
int maxNumOfTrianglesPerMesh,
Scalar xOffset,
Scalar zOffset,
Scalar xGrid,
Scalar zGrid,
int tileX,
int tileZ
);
void
CreateTile(
ElementRenderer::ListElement *list,
ElementRenderer::GroupElement *waterList,
DynamicArrayOf<TriangleStruct*>& tempTrianglesPtr,
int index,
int depth, int maxdepth,
int maxNumOfTrianglesPerMesh,
Scalar xOffset,
Scalar zOffset,
Scalar xGrid,
Scalar zGrid,
int tileX,
int tileZ,
const char *texRoot
);
DynamicArrayOf<ToDrawTriangle*> toSortTriangles;
DynamicArrayOf<ToDrawTriangle> tdtrilist;
// X, Z number of points, the length of the terrain would be (X-1)*dX
int X, Z, Xoffset, Zoffset, visHeight;
Stuff::Scalar dX, dY, dZ;
int OptPolyCount;
Stuff::DynamicArrayOf<float> field;
int side, meshX, meshZ;
Stuff::DynamicArrayOf<ElementRenderer::GridElement*> simpleTerrainGroup;
Stuff::DynamicArrayOf<ElementRenderer::GroupElement*> waterGroup;
Stuff::DynamicArrayOf<MidLevelRenderer::MLRShape*> terrain;
MidLevelRenderer::MLRState state0, state1, state2;
MidLevelRenderer::DetailTextureInfo detailInfo, waterDetailInfo;
const char *waterTextureName;
Scalar waterTextureRatio;
int waterMovieFrames;
int waterDetailMovieFrames;
Scalar borderPixelFun;
unsigned char maxAllDepth;
Stuff::Scalar xCenterOffset, zCenterOffset;
Stuff::Scalar
culturalFadeIn, culturalFadeOut;
int
xDim, zDim;
private:
Stuff::DynamicArrayOf<BYTE> interestData;
DirectMap<real> *map;
GreedySubdivision *mesh;
Stuff::Scalar Offset;
};
#endif
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,208 @@
#if !defined(HFSLIMMZ0P3_HPP)
#define HFSLIMMZ0P3_HPP
#include "ImageLib\image.h"
#include "terra\terra.hpp"
struct ToDrawTriangle
{
Point3D v[3];
Point3D center;
Scalar area;
Plane plane;
ToDrawTriangle():
plane(
Normal3D::Down,
0.0f
)
{}
void SetPoint(int idx,float x,float y,float z);
void GetSurfaceAreaAndCentroid();
bool IntersectTriangle(ToDrawTriangle*);
Point3D &GetV0() { return v[0]; }
Point3D &GetV1() { return v[1]; }
Point3D &GetV2() { return v[2]; }
};
class HFSlimMZ0p3 {
public:
HFSlimMZ0p3();
~HFSlimMZ0p3();
void
FillFromImage(Image &image, int smooth=3);
void
TestInstance() const
{}
void
SetScale (Stuff::Scalar xs, Stuff::Scalar ys, Stuff::Scalar zs)
{ Check_Object(this); dX = xs; dY = ys; dZ = zs; }
void
SetDetailTextureInfo(
const char *name,
Scalar xOff, Scalar zOff,
Scalar xFac, Scalar zFac,
Scalar dStart, Scalar dEnd,
MLRState::AlphaMode alphaMode
)
{
detailInfo.name = name;
detailInfo.xOff = xOff;
detailInfo.zOff = zOff;
detailInfo.xFac = xFac;
detailInfo.zFac = zFac;
detailInfo.dStart = dStart;
detailInfo.dEnd = dEnd;
detailInfo.alphaMode = alphaMode;
}
void
SetBorderPixels(int bp)
{ borderPixelFun = bp/256.0f; }
int GetOptPolyCount() {return OptPolyCount; }
Scalar
GetXinM()
{ return (X-1) * dX; }
Scalar
GetZinM()
{ return (Z-1) * dZ; }
int
GetX()
{ return X; }
int
GetZ()
{ return Z; }
Stuff::Scalar
GetXScale()
{ return dX; }
Stuff::Scalar
GetZScale()
{ return dZ; }
Stuff::Scalar
GetYScale()
{ return dY; }
Scalar
GetX(int x)
{ return x*dX; }
Scalar
GetZ(int z)
{ return z*dZ; }
Scalar
GetX(Scalar x)
{ return x; }
Scalar
GetZ(Scalar z)
{ return z; }
Scalar
GetHeight(int, int);
Stuff::ExtentBox
GetExtents();
void
GetZoneDimensions(int *xd, int *zd)
{ *xd = xDim; *zd = zDim; }
Stuff::DynamicArrayOf<ElementRenderer::GridElement*>*
GetTerrainArray()
{ return &simpleTerrainGroup; }
void
SetOffset(Stuff::Scalar offset)
{ Offset = offset; };
bool
SetMegaTexture(
int nrOfLevels,
int bucketSize,
const char *megaBaseName
);
void
OptimizeHField(int depth=0, int binSize=64);
Stuff::Scalar
GetOffset()
{ return Offset; };
void
SetAllDepth(int d)
{ maxAllDepth = d; }
void
SetOffset(Stuff::Scalar xo, Stuff::Scalar zo)
{ Check_Object(this); xOffset = xo; zOffset = zo; }
protected:
void
Blur2D(int);
bool
CreateMesh(
MLR_Terrain2*,
DynamicArrayOf<ToDrawTriangle*>& tdtrilist,
Stuff::ExtentBox*
);
bool
BuildTile(
MLR_Terrain2*,
DynamicArrayOf<unsigned char>& onOffPoints,
int maxNumOfTrianglesPerMesh,
Scalar xMin,
Scalar zMin,
Scalar xMax,
Scalar zMax
);
DynamicArrayOf<ToDrawTriangle*> toSortTriangles;
DynamicArrayOf<ToDrawTriangle> tdtrilist;
// X, Z number of points, the length of the terrain would be (X-1)*dX
int X, Z, visHeight;
Stuff::Scalar dX, dY, dZ;
int OptPolyCount;
Stuff::DynamicArrayOf<float> field;
int side, meshX, meshZ;
Stuff::DynamicArrayOf<ElementRenderer::GridElement*> simpleTerrainGroup;
Stuff::DynamicArrayOf<MidLevelRenderer::MLRShape*> terrain;
MidLevelRenderer::MLRState state0, state1;
MidLevelRenderer::DetailTextureInfo detailInfo;
Scalar borderPixelFun;
unsigned char maxAllDepth;
Stuff::Scalar xOffset, zOffset;
int
xDim, zDim;
private:
Stuff::Scalar Offset;
};
#endif
File diff suppressed because it is too large Load Diff
+274
View File
@@ -0,0 +1,274 @@
#if !defined(HFSLIMMZL_HPP)
#define HFSLIMMZL_HPP
#include "ImageLib\image.h"
#include "terra\terra.hpp"
extern bool doWater;
extern Scalar waterLevel;
extern bool doBSP;
struct DetailLevelInfo {
unsigned short width, height;
unsigned char *array;
};
struct TriangleStruct;
struct TrianglePointAngleStruct {
TriangleStruct *tri;
float angle;
int pos;
};
struct PointStruct {
PointStruct() : myTri(12) { p = Point3D::Identity; connectedTo = 0; }
Point3D p;
int connectedTo;
DynamicArrayOf<TrianglePointAngleStruct> myTri;
void Add (TriangleStruct *ts, int pos);
void CalculateAngles();
bool
CheckAngles(float, float);
void
TestInstance() const;
};
struct TriangleStruct {
static PointStruct *points;
int v[3];
Point3D center;
Scalar area;
Plane plane;
TriangleStruct():
plane(
Normal3D::Down,
0.0f
)
{}
void GetSurfaceAreaAndCentroid();
// bool IntersectTriangle(TriangleStruct*);
Point3D &GetPoint(int i) { Verify(points!=NULL); return points[v[i]].p; }
};
class HFSlimMZL {
public:
HFSlimMZL();
~HFSlimMZL();
void
FillFromImage(Image &image, int smooth=3);
void
TestInstance() const
{}
void
SetScale (Stuff::Scalar xs, Stuff::Scalar ys, Stuff::Scalar zs)
{ Check_Object(this); dX = xs; dY = ys; dZ = zs; }
void
SetDetailTextureInfo(
const char *name,
Scalar xOff, Scalar zOff,
Scalar xFac, Scalar zFac,
Scalar dStart, Scalar dEnd,
MLRState::AlphaMode alphaMode
)
{
detailInfo.name = name;
detailInfo.xOff = xOff;
detailInfo.zOff = zOff;
detailInfo.xFac = xFac;
detailInfo.zFac = zFac;
detailInfo.dStart = dStart;
detailInfo.dEnd = dEnd;
detailInfo.alphaMode = alphaMode;
}
void
SetBorderPixels(int bp)
{ borderPixelFun = bp/256.0f; }
int GetOptPolyCount() {return OptPolyCount; }
Scalar
GetXinM()
{ return (X-1) * dX; }
Scalar
GetZinM()
{ return (Z-1) * dZ; }
int
GetX()
{ return X; }
int
GetZ()
{ return Z; }
Stuff::Scalar
GetXScale()
{ return dX; }
Stuff::Scalar
GetZScale()
{ return dZ; }
Stuff::Scalar
GetYScale()
{ return dY; }
Scalar
GetX(int x)
{ return x*dX; }
Scalar
GetZ(int z)
{ return z*dZ; }
Scalar
GetX(Scalar x)
{ return x; }
Scalar
GetZ(Scalar z)
{ return z; }
Scalar
GetHeight(int, int);
Stuff::ExtentBox
GetExtents();
void
GetZoneDimensions(int *xd, int *zd)
{ *xd = xDim; *zd = zDim; }
Stuff::DynamicArrayOf<ElementRenderer::GridElement*>*
GetTerrainArray()
{ return &simpleTerrainGroup; }
void
SetOffset(Stuff::Scalar offset)
{ Offset = offset; };
bool
SetMegaTexture(
int nrOfLevels,
int bucketSize,
const char *megaBaseName
);
void
OptimizeHField(int depth=0, int binSize=64);
Stuff::Scalar
GetOffset()
{ return Offset; };
void
SetAllDepth(int d)
{ maxAllDepth = d; }
void
SetOffset(Stuff::Scalar xo, Stuff::Scalar zo)
{ Check_Object(this); xOffset = xo; zOffset = zo; }
protected:
void
Blur2D(int);
typedef Stuff::Scalar frameArray[8][4];
bool
CreateMesh(
ListElement *parent,
int index,
int levDiff,
DynamicArrayOf<TriangleStruct*>& tdtrilist,
frameArray *frame,
MidLevelRenderer::MLRState *state = NULL
);
bool
BinSort(
ListElement *parent,
int index,
int levDiff,
DynamicArrayOf<TriangleStruct*>& tdtrilist,
int binSize,
frameArray *frame,
MidLevelRenderer::MLRState *state = NULL
);
void
BuildTile(
DynamicArrayOf<TriangleStruct*>& tempTrianglesPtr,
int index,
int depth, int maxdepth,
int numOfTriangles,
DynamicArrayOf<unsigned char>& onOffPoints,
int maxNumOfTrianglesPerMesh,
Scalar xOffset,
Scalar zOffset,
Scalar xGrid,
Scalar zGrid,
int tileX,
int tileZ
);
void
CreateTile(
ElementRenderer::ListElement *list,
DynamicArrayOf<TriangleStruct*>& tempTrianglesPtr,
int index,
int depth, int maxdepth,
int maxNumOfTrianglesPerMesh,
Scalar xOffset,
Scalar zOffset,
Scalar xGrid,
Scalar zGrid,
int tileX,
int tileZ,
const char *texRoot
);
// X, Z number of points, the length of the terrain would be (X-1)*dX
int X, Z, visHeight;
Stuff::Scalar dX, dY, dZ;
int OptPolyCount;
Stuff::DynamicArrayOf<float> field;
int side, meshX, meshZ;
Stuff::DynamicArrayOf<ElementRenderer::GridElement*> simpleTerrainGroup;
Stuff::DynamicArrayOf<MidLevelRenderer::MLRShape*> terrain;
MidLevelRenderer::MLRState state0, state1;
MidLevelRenderer::DetailTextureInfo detailInfo;
Scalar borderPixelFun;
unsigned char maxAllDepth;
Stuff::Scalar xOffset, zOffset;
int
xDim, zDim;
private:
Stuff::Scalar Offset;
};
#endif
+67
View File
@@ -0,0 +1,67 @@
#include<stdafx.h>
#include"Layer.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
void TextureLayer::Import(const char *tname)
{
LoadTexture(tname);
}
void TextureLayer::Import(Image &img)
{
Img=img;
Loaded=true;
}
void HeightFieldLayer::Import(const char *tname)
{
CString tstr(tname);
tstr+=".TGA";
Img.Load((char *)(LPCTSTR)tstr);
Loaded=true;
}
void HeightFieldLayer::Import(Image &img)
{
Img=img;
Loaded=true;
}
void TextureLayer::LoadTexture(const char *tname)
{
Name=tname;
Texture = MLRTexturePool::Instance->Add(tname);
CString tstr(tname);
tstr+=".TGA";
Img.Load((char *)(LPCTSTR)tstr);
SetState();
MLRTexturePool::Instance->LoadImages();
Loaded=true;
}
Layer &Layer::operator=(Layer &lay)
{
Img=lay.Img;
Name=lay.Name;
Texture=lay.Texture;
State=lay.State;
Loaded=lay.Loaded;
return *this;
}
void Layer::SetState()
{
State.SetTextureHandle(Texture->GetTextureHandle());
State.SetRenderDeltaMask(MLRState::TextureMask);
State.SetZBufferCompareOn();
State.SetZBufferWriteOn();
State.SetFilterMode(MLRState::TriLinearFilterMode);
State.SetPriority(MLRState::DefaultPriority);
}
+56
View File
@@ -0,0 +1,56 @@
#ifndef LAYER_H_
#define LAYER_H_
#include <afx.h>
#include <MLR\MLR.hpp>
#include <MLR\MLRHeaders.hpp>
#include"ImageLib\image.h"
class Layer
{
private:
protected:
bool Loaded;
public:
void SetState();
Image Img;
CString Name;
MidLevelRenderer::MLRTexture *Texture;
MidLevelRenderer::MLRState State;
bool IsLoaded() {return Loaded;}
Layer() {Loaded=false; Texture=NULL;}
virtual void Import(const char *tname)=0;
virtual void Import(Image &img)=0;
Layer &operator=(Layer &lay);
};
class HeightFieldLayer:public Layer
{
private:
protected:
public:
virtual void Import(const char *tname);
virtual void Import(Image &img);
};
class TextureLayer:public Layer
{
private:
protected:
public:
void LoadTexture(const char *tname);
virtual void Import(const char *tname);
virtual void Import(Image &img);
};
#endif
+296
View File
@@ -0,0 +1,296 @@
// LayerDlg.cpp : implementation file
//
#include "stdafx.h"
#include "TCTb.h"
#include "LayerDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CLayerDlg dialog
extern CTCTbApp theApp;
CLayerDlg::CLayerDlg(CWnd* pParent /*=NULL*/)
: CDialog(CLayerDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CLayerDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
for(int i=1;i<MAX_LAYERS;i++) LayStatus[i]=LS_UNCREATED;
LayStatus[0]=LS_VISIBLE;
LastLay=1;
imlist=NULL;
}
void CLayerDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CLayerDlg)
DDX_Control(pDX, IDC_LAYERLIST, LayList);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CLayerDlg, CDialog)
//{{AFX_MSG_MAP(CLayerDlg)
ON_WM_CLOSE()
ON_WM_LBUTTONDBLCLK()
ON_NOTIFY(NM_DBLCLK, IDC_LAYERLIST, OnDblclkLayerlist)
ON_BN_CLICKED(IDC_MAKEINVISIBLE, OnMakeinvisible)
ON_BN_CLICKED(IDC_MAKEVISIBLE, OnMakevisible)
ON_BN_CLICKED(IDC_SHOWALL, OnShowall)
ON_BN_CLICKED(IDC_SHOWHEIGHT, OnShowheight)
ON_WM_RBUTTONDOWN()
ON_NOTIFY(NM_RCLICK, IDC_LAYERLIST, OnRclickLayerlist)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLayerDlg message handlers
CLayerDlg::~CLayerDlg()
{
if(imlist)
{
delete imlist;
imlist=NULL;
}
}
void CLayerDlg::OnClose()
{
// ShowWindow(SW_MINIMIZE);
ShowWindow(SW_HIDE);
//CDialog::OnClose();
}
void CLayerDlg::OnOK()
{
//CDialog::OnOK();
}
void CLayerDlg::OnCancel()
{
//CDialog::OnCancel();
}
void CLayerDlg::OnLButtonDblClk(UINT nFlags, CPoint point)
{
CDialog::OnLButtonDblClk(nFlags, point);
}
void CLayerDlg::UpdateLayers()
{
int i;
LVITEM itm;
for(i=1;i<MAX_LAYERS;i++) // CHeck that the Height Field and a layer is not visible at the same time
if(LayStatus[i]==LS_VISIBLE) LayStatus[0]=LS_HIDDEN;
for(i=0;i<MAX_LAYERS;i++)
{
//itm.iItem=i;
//itm.iSubItem=0;
//LayList.GetItem(&itm);
switch(LayStatus[i])
{
case LS_HIDDEN:
LayList.SetItemText(i,1,"NO");
itm.iImage=(i==0)?1:3;
break;
case LS_VISIBLE:
LayList.SetItemText(i,1,"YES");
itm.iImage=(i==0)?0:2;
break;
case LS_UNCREATED:
break;
}
//LayList.SetItem(&itm);
}
//theApp.UpdateScreen();
}
void CLayerDlg::OnDblclkLayerlist(NMHDR* pNMHDR, LRESULT* pResult)
{
POSITION p;
int sel;
p=LayList.GetFirstSelectedItemPosition();
sel=LayList.GetNextSelectedItem(p);
ToggleItem(sel);
UpdateLayers();
*pResult = 0;
}
void CLayerDlg::Showall()
{
int i;
for(i=1;i<MAX_LAYERS;i++)
{
if(LayStatus[i]!=LS_UNCREATED)
{
LayStatus[i]=LS_VISIBLE;
}
}
UpdateLayers();
}
void CLayerDlg::Showheight()
{
int i;
for(i=1;i<MAX_LAYERS;i++)
{
if(LayStatus[i]!=LS_UNCREATED)
{
LayStatus[i]=LS_HIDDEN;
}
}
LayStatus[0]=LS_VISIBLE;
UpdateLayers();
}
void CLayerDlg::OnMakeinvisible()
{
POSITION p;
int sel;
p=LayList.GetFirstSelectedItemPosition();
while(p)
{
sel=LayList.GetNextSelectedItem(p);
if(LayStatus[sel]!=LS_UNCREATED)
LayStatus[sel]=LS_HIDDEN;
}
UpdateLayers();
}
void CLayerDlg::OnMakevisible()
{
POSITION p;
int sel;
p=LayList.GetFirstSelectedItemPosition();
while(p)
{
sel=LayList.GetNextSelectedItem(p);
if(LayStatus[sel]!=LS_UNCREATED)
LayStatus[sel]=LS_VISIBLE;
}
UpdateLayers();
}
void CLayerDlg::ToggleItem(int sel)
{
int i;
switch(LayStatus[sel])
{
case LS_HIDDEN:
LayStatus[sel]=LS_VISIBLE;
break;
case LS_VISIBLE:
LayStatus[sel]=LS_HIDDEN;
break;
case LS_UNCREATED:
break;
}
if(sel==0 && LayStatus[0]==LS_VISIBLE)
{
for(i=1;i<MAX_LAYERS;i++)
if(LayStatus[i]!=LS_UNCREATED)
LayStatus[i]=LS_HIDDEN;
}
}
void CLayerDlg::OnShowall()
{
Showall();
}
void CLayerDlg::OnShowheight()
{
Showheight();
}
void CLayerDlg::AddLayer(CString &lname)
{
LayList.InsertItem(LastLay,lname,0);
LayStatus[LastLay]=LS_HIDDEN;
LastLay++;
UpdateLayers();
}
BOOL CLayerDlg::OnInitDialog()
{
CDialog::OnInitDialog();
if(!imlist)
{
imlist=new CImageList;
imlist->Create(16,16,ILC_COLOR24|ILC_MASK,4,0);
// imlist->Add(ExtractIcon(m_hInstance,"shell32.dll",12));
// imlist->Add(ExtractIcon(m_hInstance,"shell32.dll",24));
imlist->Add(::LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_HFICON)));
imlist->Add(::LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_HFICON2)));
imlist->Add(::LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_BMP)));
imlist->Add(::LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_BMP2)));
}
LayList.InsertItem(0,"Height Map",0);
LayList.SetItemText(0,1,"YES");
LayList.SetImageList(imlist,LVSIL_SMALL);
LayList.InsertColumn(0,"Layer Name",LVCFMT_LEFT,100);
LayList.InsertColumn(1,"Visible",LVCFMT_LEFT,100);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CLayerDlg::OnRButtonDown(UINT nFlags, CPoint point)
{
CDialog::OnRButtonDown(nFlags, point);
}
void CLayerDlg::OnRclickLayerlist(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
CHFAttribDlg dlg;
POSITION p;
int sel;
p=LayList.GetFirstSelectedItemPosition();
sel=LayList.GetNextSelectedItem(p);
if(sel==0) //Height field
{
if(dlg.DoModal()==IDOK)
{
}
}
*pResult = 0;
}
+68
View File
@@ -0,0 +1,68 @@
#if !defined(AFX_LAYERDLG_H__5411C8C3_643D_11D2_8408_00A0C933BCAC__INCLUDED_)
#define AFX_LAYERDLG_H__5411C8C3_643D_11D2_8408_00A0C933BCAC__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// LayerDlg.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CLayerDlg dialog
#include "HFAttribDlg.h"
class CLayerDlg : public CDialog
{
// Construction
public:
void AddLayer(CString &lname);
void ToggleItem(int sel);
void UpdateLayers();
CLayerDlg(CWnd* pParent = NULL); // standard constructor
~CLayerDlg();
LAYSTAT LayStatus[MAX_LAYERS];
int LastLay;
void Showall();
void Showheight();
CImageList *imlist;
// Dialog Data
//{{AFX_DATA(CLayerDlg)
enum { IDD = IDD_LAYERWND };
CListCtrl LayList;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CLayerDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CLayerDlg)
afx_msg void OnClose();
virtual void OnOK();
virtual void OnCancel();
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
afx_msg void OnDblclkLayerlist(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnMakeinvisible();
afx_msg void OnMakevisible();
afx_msg void OnShowall();
afx_msg void OnShowheight();
virtual BOOL OnInitDialog();
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
afx_msg void OnRclickLayerlist(NMHDR* pNMHDR, LRESULT* pResult);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_LAYERDLG_H__5411C8C3_643D_11D2_8408_00A0C933BCAC__INCLUDED_)
@@ -0,0 +1,71 @@
// LimitedFileDialog.cpp : implementation file
//
#include "stdafx.h"
#include "TCTb.h"
#include "LimitedFileDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CLimitedFileDialog
IMPLEMENT_DYNAMIC(CLimitedFileDialog, CFileDialog)
CLimitedFileDialog::CLimitedFileDialog(BOOL bOpenFileDialog, LPCTSTR lpszDefExt, LPCTSTR lpszFileName,
DWORD dwFlags, LPCTSTR lpszFilter, CWnd* pParentWnd) :
CFileDialog(bOpenFileDialog, lpszDefExt, lpszFileName, dwFlags, lpszFilter, pParentWnd)
{
}
BEGIN_MESSAGE_MAP(CLimitedFileDialog, CFileDialog)
//{{AFX_MSG_MAP(CLimitedFileDialog)
ON_WM_CREATE()
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CLimitedFileDialog::OnFolderChange()
{
}
void CLimitedFileDialog::SetDir(CString &dir)
{
Path=dir;
}
int CLimitedFileDialog::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFileDialog::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
return 0;
}
BOOL CLimitedFileDialog::OnInitDialog()
{
CFileDialog::OnInitDialog();
SetWindowText(wstr);
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CLimitedFileDialog::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
SetWindowText(wstr);
// Do not call CFileDialog::OnPaint() for painting messages
}
@@ -0,0 +1,41 @@
#if !defined(AFX_LIMITEDFILEDIALOG_H__76210A85_6FE0_11D2_8409_00A0C933BCAC__INCLUDED_)
#define AFX_LIMITEDFILEDIALOG_H__76210A85_6FE0_11D2_8409_00A0C933BCAC__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// LimitedFileDialog.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CLimitedFileDialog dialog
class CLimitedFileDialog : public CFileDialog
{
DECLARE_DYNAMIC(CLimitedFileDialog)
public:
void SetDir(CString &dir);
void OnFolderChange();
CLimitedFileDialog(BOOL bOpenFileDialog, // TRUE for FileOpen, FALSE for FileSaveAs
LPCTSTR lpszDefExt = NULL,
LPCTSTR lpszFileName = NULL,
DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
LPCTSTR lpszFilter = NULL,
CWnd* pParentWnd = NULL);
CString wstr;
protected:
CString Path;
//{{AFX_MSG(CLimitedFileDialog)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
virtual BOOL OnInitDialog();
afx_msg void OnPaint();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_LIMITEDFILEDIALOG_H__76210A85_6FE0_11D2_8409_00A0C933BCAC__INCLUDED_)
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,222 @@
#if !defined(MLR_TERRAIN_HEIGHTFIELD_HPP)
#define MLR_TERRAIN_HEIGHTFIELD_HPP
#include <MLR\MLR_I_DeT_PMesh.hpp>
// #include <Proxies\ProxyHeaders.hpp>
#include "terra\terra.hpp"
class CFinalBitmapWnd;
class CProgressDlg;
extern CFinalBitmapWnd *Wnd2D;
struct ToDrawTriangle
{
Point3D v[3];
Point3D center;
Scalar area;
void SetPoint(int idx,float x,float y,float z);
void GetSurfaceAreaAndCentroid();
Point3D &GetV0() { return v[0]; }
Point3D &GetV1() { return v[1]; }
Point3D &GetV2() { return v[2]; }
};
struct HeightFieldFileHeader {
int signature;
int version;
unsigned int totalSizeOfFile;
Scalar minX, maxX;
Scalar minZ, maxZ;
long vertexCountX;
long vertexCountZ;
};
class MLRHeightField {
public:
MLRHeightField();
~MLRHeightField();
void
TestInstance() const
{}
int GetFullPolyCount() {return (X-1)*(Z-1)*2; }
int GetOptPolyCount() {return OptPolyCount; }
ElementRenderer::GroupElement*
GetGroup()
{ return terrainGroup; }
Scalar
GetXinM()
{ return (X-1) * dX; }
Scalar
GetZinM()
{ return (Z-1) * dZ; }
int
GetX()
{ return X; }
int
GetZ()
{ return Z; }
Stuff::Scalar
GetXScale()
{ return dX; }
Stuff::Scalar
GetZScale()
{ return dZ; }
Stuff::Scalar
GetYScale()
{ return dY; }
Scalar
GetHeight(int, int);
Scalar
GetHeight(Scalar, Scalar);
Stuff::ExtentBox
GetExtents();
bool
SaveHeightFieldInformations(MString& file_name);
int
GetNrOfIZs()
{ return nrOfIZs; };
void
SetOffset(Stuff::Scalar offset)
{ Offset = offset; };
void
SetDetailTextureInfo(
const char *name,
Scalar xOff, Scalar zOff,
Scalar xFac, Scalar zFac,
MidLevelRenderer::MLRState::AlphaMode alphaMode
)
{
detailInfo.name = name;
detailInfo.xOff = xOff;
detailInfo.zOff = zOff;
detailInfo.xFac = xFac;
detailInfo.zFac = zFac;
detailInfo.alphaMode = alphaMode;
}
bool
SetMegaTexture(
int nrOfLevels,
const char *mega_base_name
);
void
OptimizeHField(int mode=0, int depth=0, int binSize=64);
Stuff::Scalar
GetOffset()
{ return Offset; };
bool
IsFullDisplayed()
{
return (terrainGroup->FindElement(fullTerrainGroup->GetName())!=NULL);
}
bool
IsOptDisplayed()
{
return (terrainGroup->FindElement(simpleTerrainGroup->GetName())!=NULL);
}
void
DisplayFull(bool bl);
void
DisplayOpt(bool bl);
ElementRenderer::GroupElement *
GetFullTerrain() { Check_Pointer(this); return fullTerrainGroup; }
ElementRenderer::ListElement *
GetOptTerrain() { Check_Pointer(this); return simpleTerrainGroup; }
protected:
void
MakeTerrainFromField();
void
Blur2D();
bool
CreateMesh(
ListElement *parent,
int index,
DynamicArrayOf<ToDrawTriangle*>& tdtrilist,
Stuff::ExtentBox*,
MidLevelRenderer::MLRState *state = NULL
);
bool
BinSort(
ListElement *parent,
int index,
DynamicArrayOf<ToDrawTriangle*>& tdtrilist,
int binSize,
CProgressDlg *pdlg,
Stuff::ExtentBox*,
MidLevelRenderer::MLRState *state = NULL
);
void
MLRHeightField::DescentToUnderMountain(
int depth,
ElementRenderer::ListElement *group,
Point3D *points,
unsigned char *onOffPoints,
int numOfTriangles,
int maxNumOfTrianglesPerMesh,
Scalar x0,
Scalar z0,
Scalar x1,
Scalar z1,
int tileX,
int tileZ,
const char *texRoot
);
// X, Z number of points, the length of the terrain would be (X-1)*dX
int X, Z, visHeight;
Stuff::Scalar dX, dY, dZ;
int OptPolyCount;
Stuff::DynamicArrayOf<float> field;
int side, meshX, meshZ;
ElementRenderer::GroupElement *terrainGroup;
ElementRenderer::GroupElement *fullTerrainGroup;
ElementRenderer::ListElement *simpleTerrainGroup;
Stuff::DynamicArrayOf<MidLevelRenderer::MLRShape*> terrain;
MidLevelRenderer::MLRState state0, state1;
MidLevelRenderer::DetailTextureInfo detailInfo;
int
nrOfIZs;
private:
Stuff::Scalar Offset;
};
#endif
+200
View File
@@ -0,0 +1,200 @@
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "TCTb.h"
#include "MainFrm.h"
//#include <MLR\MLR.hpp>
//#include <GameOS\GameOS.hpp>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CTCTbApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
ON_WM_PAINT()
ON_WM_MOVE()
ON_WM_CLOSE()
//}}AFX_MSG_MAP
// Global help commands
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR, // status line indicator
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
extern CTCTbApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame()
{
// TODO: add member initialization code here
}
CMainFrame::~CMainFrame()
{
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CMDIFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CMDIFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CMDIFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
void CMainFrame::OnStartLoop()
{
}
/*
void CMainFrame::OnWindowTileh()
{
MDITile(MDITILE_HORIZONTAL|MDITILE_SKIPDISABLED);
}
void CMainFrame::OnWindowTilev()
{
MDITile(MDITILE_VERTICAL|MDITILE_SKIPDISABLED);
}
void CMainFrame::OnWindowCascade()
{
MDICascade(MDITILE_SKIPDISABLED);
}
*/
LRESULT CMainFrame::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_CREATE:
case WM_MOVE:
case WM_ACTIVATE:
case WM_SETFOCUS:
case WM_DESTROY:
{
// GameOSWinProc(m_hWnd, message, wParam, lParam);
break;
}
case WM_SYSCOMMAND:
{
if( (wParam&0xfff0)==SC_SCREENSAVE || wParam==SC_MONITORPOWER)
{
// GameOSWinProc(m_hWnd, message, wParam, lParam);
}
break;
}
}
return CMDIFrameWnd::WindowProc(message, wParam, lParam);
}
void CMainFrame::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
// Do not call CMDIFrameWnd::OnPaint() for painting messages
}
void CMainFrame::OnMove(int x, int y)
{
CMDIFrameWnd::OnMove(x, y);
if(theApp.RVWnd) theApp.RVWnd->Fix3DView();
// TODO: Add your message handler code here
}
void CMainFrame::OnClose()
{
// TODO: Add your message handler code here and/or call default
theApp.PutSavedState();
theApp.GOSCleanUp();
CMDIFrameWnd::OnClose();
}
+63
View File
@@ -0,0 +1,63 @@
// MainFrm.h : interface of the CMainFrame class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_MAINFRM_H__D9E64DD4_5915_11D2_8408_00A0C933BCAC__INCLUDED_)
#define AFX_MAINFRM_H__D9E64DD4_5915_11D2_8408_00A0C933BCAC__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CMainFrame : public CMDIFrameWnd
{
DECLARE_DYNAMIC(CMainFrame)
public:
CMainFrame();
void OnStartLoop();
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMainFrame)
public:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CMainFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected: // control bar embedded members
CStatusBar m_wndStatusBar;
CToolBar m_wndToolBar;
// Generated message map functions
protected:
//{{AFX_MSG(CMainFrame)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnPaint();
afx_msg void OnMove(int x, int y);
afx_msg void OnClose();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MAINFRM_H__D9E64DD4_5915_11D2_8408_00A0C933BCAC__INCLUDED_)
+786
View File
@@ -0,0 +1,786 @@
#include <ElementRenderer\GroupElement.hpp>
#include <ElementRenderer\ListElement.hpp>
#include <ElementRenderer\ShapeElement.hpp>
#include <MLR\MLRShape.hpp>
#include <MLR\MLRIndexedPrimitiveBase.hpp>
#include <Adept\Tile.hpp>
//#define BSP_BUG "jmalbert"
#undef BSP_BUG
extern bool Debug_Tile;
enum {
Inside_Plane = 1,
On_Plane = 2,
Outside_Plane = 4,
Split_Plane = Inside_Plane|Outside_Plane
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
FindPlanes(
ElementRenderer::Element *element,
Stuff::DynamicArrayOf<Stuff::Plane> *planes,
int *planes_filled
)
{
Check_Object(element);
Check_Object(planes);
Check_Pointer(planes_filled);
//
//-----------------------
// Spin through the group
//-----------------------
//
if (element->IsDerivedFrom(ElementRenderer::GroupElement::DefaultData))
{
ElementRenderer::GroupElement *group =
Cast_Object(ElementRenderer::GroupElement *, element);
Stuff::ChainIteratorOf<ElementRenderer::Element*> *children =
group->MakeIterator();
Register_Object(children);
ElementRenderer::Element *child;
while ((child = children->ReadAndNext()) != NULL)
{
Check_Object(child);
FindPlanes(child, planes, planes_filled);
}
Unregister_Object(children);
delete children;
}
//
//----------------------
// Spin through the list
//----------------------
//
else if (element->IsDerivedFrom(ElementRenderer::ListElement::DefaultData))
{
ElementRenderer::ListElement *list =
Cast_Object(ElementRenderer::ListElement *, element);
for (unsigned i=0; i<list->GetActiveCount(); ++i)
{
ElementRenderer::Element *child = list->GetIndexedElement(i);
Check_Object(child);
FindPlanes(child, planes, planes_filled);
}
}
//
//-----------------------
// Spin through the shape
//-----------------------
//
else if (element->IsDerivedFrom(ElementRenderer::ShapeElement::DefaultData))
{
ElementRenderer::ShapeElement *shape =
Cast_Object(ElementRenderer::ShapeElement *, element);
MidLevelRenderer::MLRShape *mlr_shape = shape->GetMLRShape();
Check_Object(mlr_shape);
for (int p=0; p<mlr_shape->GetNum(); ++p)
{
MidLevelRenderer::MLRPrimitiveBase *primitive = mlr_shape->Find(p);
Check_Object(primitive);
//
//----------------------------------------------------------------
// We have gotten the given primitive, now we need to loop through
// the faces
//----------------------------------------------------------------
//
const Stuff::Point3D *points;
int point_count;
primitive->GetCoordData(&points, &point_count);
MidLevelRenderer::MLRIndexedPrimitiveBase *indexed_primitive =
Cast_Object(
MidLevelRenderer::MLRIndexedPrimitiveBase *,
primitive
);
const BYTE *indices;
int index_count;
indexed_primitive->GetIndexData(&indices, &index_count);
Verify(!(index_count%3));
int face_count = index_count/3;
Verify(face_count == primitive->GetNumPrimitives());
//
//----------------------------------------------------------------
// We have gotten the given primitive, now we need to loop through
// the faces and get the points of each triangle
//----------------------------------------------------------------
//
int index=0;
for (int f=0; f<face_count; ++f)
{
Verify(index < index_count);
Verify(static_cast<unsigned>(indices[index]) < point_count);
const Stuff::Point3D *point1 = &points[indices[index++]];
Verify(index < index_count);
Verify(static_cast<unsigned>(indices[index]) < point_count);
const Stuff::Point3D *point2 = &points[indices[index++]];
Verify(index < index_count);
Verify(static_cast<unsigned>(indices[index]) < point_count);
const Stuff::Point3D *point3 = &points[indices[index++]];
#if defined(BSP_BUG)
if (Debug_Tile)
{
SPEW((
BSP_BUG,
"Tri %d\tv0=<%f,%f,%f>",
f,
point1->x,
point1->y,
point1->z
));
SPEW((
BSP_BUG,
"\t v1=<%f,%f,%f>",
point2->x,
point2->y,
point2->z
));
SPEW((
BSP_BUG,
"\t v1=<%f,%f,%f>",
point3->x,
point3->y,
point3->z
));
}
#endif
//
//---------------------------------------------
// Figure out the plane equation of the polygon
//---------------------------------------------
//
WORD plane = (*planes_filled)++;
(*planes)[plane].BuildPlane(
*point1,
*point2,
*point3
);
Verify((*planes)[plane].normal.y > Stuff::SMALL);
//
//-----------------------------------------------------------
// Now figure out the plane equation of a vertical plane thru
// each edge
//-----------------------------------------------------------
//
Stuff::Point3D temp = *point1;
temp.y += 10.0f;
(*planes)[(*planes_filled)++].BuildPlane(
*point1,
*point2,
temp
);
(*planes)[(*planes_filled)++].BuildPlane(
*point1,
temp,
*point3
);
temp = *point2;
temp.y += 10.0f;
(*planes)[(*planes_filled)++].BuildPlane(
temp,
*point2,
*point3
);
}
}
}
else
STOP(("Didn't handle this case"));
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
TestTriangles(
ElementRenderer::Element *element,
Stuff::DynamicArrayOf<Stuff::Plane> &planes,
Stuff::DynamicArrayOf<BYTE> *scoreboard,
int *triangles_tested
)
{
Check_Object(element);
Check_Object(&planes);
Check_Object(scoreboard);
Check_Pointer(triangles_tested);
//
//-----------------------
// Spin through the group
//-----------------------
//
if (element->IsDerivedFrom(ElementRenderer::GroupElement::DefaultData))
{
ElementRenderer::GroupElement *group =
Cast_Object(ElementRenderer::GroupElement *, element);
Stuff::ChainIteratorOf<ElementRenderer::Element*> *children =
group->MakeIterator();
Register_Object(children);
ElementRenderer::Element *child;
while ((child = children->ReadAndNext()) != NULL)
{
Check_Object(child);
TestTriangles(child, planes, scoreboard, triangles_tested);
}
Unregister_Object(children);
delete children;
}
//
//----------------------
// Spin through the list
//----------------------
//
else if (element->IsDerivedFrom(ElementRenderer::ListElement::DefaultData))
{
ElementRenderer::ListElement *list =
Cast_Object(ElementRenderer::ListElement *, element);
for (unsigned i=0; i<list->GetActiveCount(); ++i)
{
ElementRenderer::Element *child = list->GetIndexedElement(i);
Check_Object(child);
TestTriangles(child, planes, scoreboard, triangles_tested);
}
}
//
//-----------------------
// Spin through the shape
//-----------------------
//
else if (element->IsDerivedFrom(ElementRenderer::ShapeElement::DefaultData))
{
ElementRenderer::ShapeElement *shape =
Cast_Object(ElementRenderer::ShapeElement *, element);
MidLevelRenderer::MLRShape *mlr_shape = shape->GetMLRShape();
Check_Object(mlr_shape);
for (int p=0; p<mlr_shape->GetNum(); ++p)
{
MidLevelRenderer::MLRPrimitiveBase *primitive = mlr_shape->Find(p);
Check_Object(primitive);
//
//----------------------------------------------------------------
// We have gotten the given primitive, now we need to loop through
// the faces
//----------------------------------------------------------------
//
const Stuff::Point3D *points;
int point_count;
primitive->GetCoordData(&points, &point_count);
MidLevelRenderer::MLRIndexedPrimitiveBase *indexed_primitive =
Cast_Object(
MidLevelRenderer::MLRIndexedPrimitiveBase *,
primitive
);
const BYTE *indices;
int index_count;
indexed_primitive->GetIndexData(&indices, &index_count);
Verify(!(index_count%3));
int face_count = index_count/3;
Verify(face_count == primitive->GetNumPrimitives());
//
//----------------------------------------------------------------
// We have gotten the given primitive, now we need to loop through
// the faces and get the points of each triangle
//----------------------------------------------------------------
//
int index=0;
int score_index = *triangles_tested * planes.GetLength();
for (int f=0; f<face_count; ++f, ++(*triangles_tested))
{
Verify(index < index_count);
Verify(static_cast<unsigned>(indices[index]) < point_count);
const Stuff::Point3D *point1 = &points[indices[index++]];
Verify(index < index_count);
Verify(static_cast<unsigned>(indices[index]) < point_count);
const Stuff::Point3D *point2 = &points[indices[index++]];
Verify(index < index_count);
Verify(static_cast<unsigned>(indices[index]) < point_count);
const Stuff::Point3D *point3 = &points[indices[index++]];
#if defined(BSP_BUG)
if (Debug_Tile)
SPEW((BSP_BUG, "Tri %d\t+", f));
#endif
//
//-----------------------------------------------------
// Now we need to test these points against every plane
//-----------------------------------------------------
//
for (int t=0; t<planes.GetLength(); ++t, ++score_index)
{
Stuff::Scalar dist = planes[t].GetDistanceTo(*point1);
BYTE &entry = (*scoreboard)[score_index];
if (dist > 0.02)
entry = Outside_Plane;
else if (dist < -0.02)
entry = Inside_Plane;
else
entry = On_Plane;
dist = planes[t].GetDistanceTo(*point2);
if (dist > 0.02)
entry |= Outside_Plane;
else if (dist < -0.02)
entry |= Inside_Plane;
else
entry |= On_Plane;
dist = planes[t].GetDistanceTo(*point3);
if (dist > 0.02)
entry |= Outside_Plane;
else if (dist < -0.02)
entry |= Inside_Plane;
else
entry |= On_Plane;
//
//---------------------------------------------------------
// If we are on both sides of the plane, count us as on the
// plane
//---------------------------------------------------------
//
if ((entry&Split_Plane) == Split_Plane)
entry |= On_Plane;
Verify(entry != On_Plane || !(t&3));
#if defined(BSP_BUG)
if (Debug_Tile)
if ((t&3) == 3)
SPEW((BSP_BUG, "%d +", entry));
else
SPEW((BSP_BUG, "%d+", entry));
#endif
}
#if defined(BSP_BUG)
if (Debug_Tile)
SPEW((BSP_BUG, ""));
#endif
}
}
}
else
STOP(("Didn't handle this case"));
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
float
ComputeScore(
int outsides,
int insides,
int splits,
int total
)
{
//
//-----------------------------------------------------------------------
// The plane is useless if no triangles are reduced on either side of the
// plane, or if this is a real polygon plane and it splits another
// polygon
//-----------------------------------------------------------------------
//
float score;
if (
total == outsides || total == insides
|| (splits>0 && total>outsides+insides-splits)
)
score = 3.0f * total;
//
//---------------------------------------------------------------------
// Otherwise, base the score on the sum of the child triangle count and
// how balanced it is, giving a slight bias towards load over balance
//---------------------------------------------------------------------
//
else
{
float balance = Stuff::Fabs(static_cast<float>(outsides - insides));
score = outsides + insides + 0.9f*balance;
}
#if defined(BSP_BUG)
if (Debug_Tile)
SPEW((
BSP_BUG,
"o:%d i:%d s:%d -> %f",
outsides,
insides,
splits,
score
));
#endif
return score;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
SortTriangles(
Stuff::DynamicArrayOf<Adept::TerrainBSP> *bsp,
WORD *bsp_count,
Stuff::DynamicArrayOf<Stuff::Plane> *used_planes,
WORD *used_plane_count,
Stuff::DynamicArrayOf<BYTE> &scoreboard,
Stuff::DynamicArrayOf<Stuff::Plane> &reference_planes,
Stuff::DynamicArrayOf<int> &triangles
)
{
Check_Object(bsp);
Check_Pointer(bsp_count);
Check_Object(&scoreboard);
Check_Object(&reference_planes);
Check_Object(&triangles);
//
//---------------------------------------------------------------------
// Our first task is to compile the statistics for each of the possible
// splitting planes
//---------------------------------------------------------------------
//
int plane_count = reference_planes.GetLength();
Stuff::DynamicArrayOf<int>
insides(plane_count),
outsides(plane_count),
splits(plane_count);
unsigned triangle_count = triangles.GetLength();
int p,t;
#if defined(BSP_BUG)
if (Debug_Tile)
{
SPEW((BSP_BUG, "BSP %d:", *bsp_count));
SPEW((BSP_BUG, "\t+"));
for (t=0; t<triangles.GetLength(); ++t)
SPEW((BSP_BUG, "%d +", triangles[t]));
SPEW((BSP_BUG, ""));
}
#endif
for (p=0; p<plane_count; ++p)
{
insides[p] = 0;
outsides[p] = 0;
splits[p] = 0;
//
//--------------------------------------------------------------------
// Test each of the test triangles against the chosen plane and sum up
// the results
//--------------------------------------------------------------------
//
for (t=0; t<triangle_count; ++t)
{
switch (scoreboard[triangles[t]*plane_count + p])
{
case Outside_Plane:
case Outside_Plane|On_Plane:
++outsides[p];
break;
case Inside_Plane:
case Inside_Plane|On_Plane:
++insides[p];
break;
case On_Plane:
Verify(!(p&3));
break;
case Split_Plane|On_Plane:
++outsides[p];
++insides[p];
++splits[p];
break;
default:
STOP(("Shouldn't happen"));
break;
}
}
}
//
//------------------------------------------------------------------------
// Now that we have our results, we need to spin through the table looking
// for the best splitting plane
//------------------------------------------------------------------------
//
int best_plane = -1;
float best_score = 3.0f*triangle_count;
int b_o, b_i, b_s;
for (p=0; p<plane_count; ++p)
{
#if defined(BSP_BUG)
if (Debug_Tile)
SPEW((BSP_BUG, "\t\t%d -> +", p));
#endif
float score =
ComputeScore(outsides[p], insides[p], splits[p], triangle_count);
if (score < best_score)
{
best_plane = p;
best_score = score;
b_o = outsides[p];
b_i = insides[p];
b_s = splits[p];
}
}
#if defined(BSP_BUG)
if (Debug_Tile)
SPEW((
BSP_BUG,
"\t%d -> O:%d I:%d S:%d = %f ====",
best_plane,
b_o,
b_i,
b_s,
best_score
));
#endif
//
//-----------------------------------------------------
// We couldn't sort the rest so best plane will be zero
//-----------------------------------------------------
//
if (best_plane < 0)
{
best_plane = 0;
WORD new_plane;
for (new_plane=0; new_plane<*used_plane_count; ++new_plane)
{
if (
!memcmp(
&(*used_planes)[new_plane],
&reference_planes[best_plane],
sizeof(Stuff::Plane)
)
)
break;
}
if (new_plane == *used_plane_count)
{
new_plane = (*used_plane_count)++;
(*used_planes)[new_plane] = reference_planes[best_plane];
}
int new_bsp = (*bsp_count)++;
(*bsp)[new_bsp].m_planeIndex = new_plane;
(*bsp)[new_bsp].m_innerIndex = 0;
(*bsp)[new_bsp].m_outerIndex = 0;
return;
}
Verify(best_plane>=0 && best_plane<plane_count);
if (best_score == 3.0f*triangle_count)
STOP(("Can't sort this tree!"));
//
//-------------------------------------------------------
// Search the used plane array to see if the plane exists
//-------------------------------------------------------
//
WORD new_plane;
for (new_plane=0; new_plane<*used_plane_count; ++new_plane)
{
if (
!memcmp(
&(*used_planes)[new_plane],
&reference_planes[best_plane],
sizeof(Stuff::Plane)
)
)
break;
}
if (new_plane == *used_plane_count)
{
new_plane = (*used_plane_count)++;
(*used_planes)[new_plane] = reference_planes[best_plane];
}
//
//-------------------------------------------
// Copy this plane into the used planes array
//-------------------------------------------
//
int new_bsp = (*bsp_count)++;
(*bsp)[new_bsp].m_planeIndex = new_plane;
(*bsp)[new_bsp].m_innerIndex = 0;
(*bsp)[new_bsp].m_outerIndex = 0;
//
//----------------------------------------------------------------
// If all of the triangles are contained in the plane, we are done
//----------------------------------------------------------------
//
if (!insides[best_plane] && !outsides[best_plane])
return;
//
//--------------------------------------
// Split up the triangles into two lists
//--------------------------------------
//
int inside_count = insides[best_plane];
Stuff::DynamicArrayOf<int> inside_triangles(inside_count);
inside_count = 0;
int outside_count = outsides[best_plane];
Stuff::DynamicArrayOf<int> outside_triangles(outside_count);
outside_count = 0;
for (t=0; t<triangles.GetLength(); ++t)
{
BYTE flag = scoreboard[triangles[t]*plane_count + best_plane];
if (flag&Outside_Plane)
outside_triangles[outside_count++] = triangles[t];
if (flag&Inside_Plane)
inside_triangles[inside_count++] = triangles[t];
}
Verify(outside_triangles.GetLength() == outside_count);
Verify(inside_triangles.GetLength() == inside_count);
//
//--------------------------
// Recurse the inside branch
//--------------------------
//
if (inside_count > 0)
{
(*bsp)[new_bsp].m_innerIndex = *bsp_count;
#if defined(BSP_BUG)
if (Debug_Tile)
SPEW((BSP_BUG, "\tBSP %d.innerIndex = %d", new_bsp, *bsp_count));
#endif
SortTriangles(
bsp,
bsp_count,
used_planes,
used_plane_count,
scoreboard,
reference_planes,
inside_triangles
);
}
else
{
Verify(outside_count < triangles.GetLength());
Verify(!(best_plane&3));
}
//
//--------------------------
// Recurse the outside branch
//--------------------------
//
if (outside_count > 0)
{
(*bsp)[new_bsp].m_outerIndex = *bsp_count;
#if defined(BSP_BUG)
if (Debug_Tile)
SPEW((BSP_BUG, "\tBSP %d.outerIndex = %d", new_bsp, *bsp_count));
#endif
SortTriangles(
bsp,
bsp_count,
used_planes,
used_plane_count,
scoreboard,
reference_planes,
outside_triangles
);
}
else
{
Verify(inside_count < triangles.GetLength());
Verify(!(best_plane&3));
}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
MakeBSP(
Stuff::DynamicArrayOf<Stuff::Plane> *planes,
WORD *plane_count,
ElementRenderer::GroupElement *tile,
Stuff::MemoryStream *stream
)
{
Check_Object(tile);
Check_Object(stream);
//
//------------------------------------------------------------------------
// Count the number of triangles in the tile. We will end up computing
// four planes per triangle, one for the face, and one vertical plane thru
// each edge
//------------------------------------------------------------------------
//
int tri_count = tile->CountTriangles();
int ref_plane_count = 4*tri_count;
Stuff::DynamicArrayOf<Stuff::Plane> reference_planes(ref_plane_count);
int planes_filled = 0;
FindPlanes(tile, &reference_planes, &planes_filled);
Verify(planes_filled == ref_plane_count);
//
//-----------------------------------------------------------------------
// We now need to fill the scoreboard up with the poly to plane test data
//-----------------------------------------------------------------------
//
int total_tests = tri_count * ref_plane_count;
Stuff::DynamicArrayOf<BYTE> scoreboard(total_tests);
int triangles_tested = 0;
TestTriangles(tile, reference_planes, &scoreboard, &triangles_tested);
Verify(triangles_tested = tri_count);
//
//------------------------------------------------------------------------
// Now build the triangle index list in order to prime the sorting process
//------------------------------------------------------------------------
//
Stuff::DynamicArrayOf<int> triangles(tri_count);
for (int t=0; t<tri_count; ++t)
triangles[t] = t;
Stuff::DynamicArrayOf<Adept::TerrainBSP> bsp(ref_plane_count);
WORD bsp_count = 0;
//
//---------------
// Sort the puppy
//---------------
//
SortTriangles(
&bsp,
&bsp_count,
planes,
plane_count,
scoreboard,
reference_planes,
triangles
);
Verify(bsp_count < bsp.GetLength());
//
//-------------------
// Write out the data
//-------------------
//
*stream << bsp_count;
stream->WriteBytes(
bsp.GetData(),
bsp_count*sizeof(Adept::TerrainBSP)
);
}
@@ -0,0 +1,110 @@
// MiscCamProp.cpp : implementation file
//
#include "stdafx.h"
#include "TCTb.h"
#include "MiscCamProp.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMiscCamProp property page
IMPLEMENT_DYNCREATE(CMiscCamProp, CPropertyPage)
CMiscCamProp::CMiscCamProp() : CCamInfoPage(CMiscCamProp::IDD)
{
//{{AFX_DATA_INIT(CMiscCamProp)
m_FOVSli = 0;
m_FarClip = 0.0f;
m_NearClip = 0.0f;
m_FOV = 0;
//}}AFX_DATA_INIT
}
CMiscCamProp::~CMiscCamProp()
{
}
void CMiscCamProp::DoDataExchange(CDataExchange* pDX)
{
CCamInfoPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMiscCamProp)
DDX_Control(pDX, IDC_FOVTEXT, m_FOVText);
DDX_Control(pDX, IDC_FOVSLI, m_FOVSliCtrl);
DDX_Slider(pDX, IDC_FOVSLI, m_FOVSli);
DDX_Text(pDX, IDC_FARCLIP, m_FarClip);
DDX_Text(pDX, IDC_NEARCLIP, m_NearClip);
DDX_Text(pDX, IDC_FOVTEXT, m_FOV);
DDV_MinMaxInt(pDX, m_FOV, 1, 180);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMiscCamProp, CCamInfoPage)
//{{AFX_MSG_MAP(CMiscCamProp)
ON_WM_HSCROLL()
ON_EN_CHANGE(IDC_FARCLIP, OnChangeFarclip)
ON_EN_CHANGE(IDC_NEARCLIP, OnChangeNearclip)
ON_EN_CHANGE(IDC_FOVTEXT, OnChangeFovtext)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMiscCamProp message handlers
void CMiscCamProp::DataIn()
{
m_FOVSliCtrl.SetRange(1,180);
m_NearClip=CamInfo->NearClip;
m_FarClip=CamInfo->FarClip;
m_FOV=(int)(CamInfo->FOV*Degrees_Per_Radian);
m_FOVSli=(int)(CamInfo->FOV*Degrees_Per_Radian);
}
void CMiscCamProp::DataOut()
{
if(m_FarClip<m_NearClip) m_FarClip=m_NearClip;
CamInfo->FOV=m_FOV*Radians_Per_Degree;
CamInfo->NearClip=m_NearClip;
CamInfo->FarClip=m_FarClip;
}
void CMiscCamProp::UpdateControlStates()
{
}
void CMiscCamProp::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
CString tstr;
if(pScrollBar==(CScrollBar* )&m_FOVSliCtrl)
{
tstr.Format("%i",m_FOVSliCtrl.GetPos(),0xF8);
m_FOVText.SetWindowText(tstr);
CamInfo->FOV=m_FOVSliCtrl.GetPos()*Radians_Per_Degree;
m_FOV=m_FOVSliCtrl.GetPos();
}
CCamInfoPage::OnHScroll(nSBCode, nPos, pScrollBar);
}
void CMiscCamProp::OnChangeFarclip()
{
DelayedValidate();
}
void CMiscCamProp::OnChangeNearclip()
{
DelayedValidate();
}
void CMiscCamProp::OnChangeFovtext()
{
DelayedValidate();
}
@@ -0,0 +1,61 @@
#if !defined(AFX_MISCCAMPROP_H__DB172FD5_6E4E_11D2_8409_00A0C933BCAC__INCLUDED_)
#define AFX_MISCCAMPROP_H__DB172FD5_6E4E_11D2_8409_00A0C933BCAC__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// MiscCamProp.h : header file
//
#include"CamInfoPage.h"
/////////////////////////////////////////////////////////////////////////////
// CMiscCamProp dialog
class CMiscCamProp : public CCamInfoPage
{
DECLARE_DYNCREATE(CMiscCamProp)
// Construction
public:
CMiscCamProp();
~CMiscCamProp();
// Dialog Data
//{{AFX_DATA(CMiscCamProp)
enum { IDD = IDD_MISCCAMPROP };
CEdit m_FOVText;
CSliderCtrl m_FOVSliCtrl;
int m_FOVSli;
float m_FarClip;
float m_NearClip;
int m_FOV;
//}}AFX_DATA
// Overrides
// ClassWizard generate virtual function overrides
//{{AFX_VIRTUAL(CMiscCamProp)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CMiscCamProp)
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg void OnChangeFarclip();
afx_msg void OnChangeNearclip();
afx_msg void OnChangeFovtext();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
virtual void UpdateControlStates();
virtual void DataOut();
virtual void DataIn();
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MISCCAMPROP_H__DB172FD5_6E4E_11D2_8409_00A0C933BCAC__INCLUDED_)
@@ -0,0 +1,115 @@
// OptimizeOptions.cpp : implementation file
//
#include "stdafx.h"
#include "tctb.h"
#include "OptimizeOptions.h"
extern CTCTbApp theApp;
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// COptimizeOptions dialog
COptimizeOptions::COptimizeOptions(CWnd* pParent /*=NULL*/)
: CDialog(COptimizeOptions::IDD, pParent)
{
//{{AFX_DATA_INIT(COptimizeOptions)
m_opolys = _T("");
m_fpolys = 0;
m_bsizetext = _T("");
m_binfo = _T("");
//}}AFX_DATA_INIT
}
void COptimizeOptions::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(COptimizeOptions)
DDX_Control(pDX, IDC_BINSIZE, m_bsizesli);
DDX_Text(pDX, IDC_ORGPOLYS, m_opolys);
DDX_Text(pDX, IDC_FINPOLYS, m_fpolys);
DDX_Text(pDX, IDC_BSIZETEXT, m_bsizetext);
DDX_Text(pDX, IDC_BINFO, m_binfo);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(COptimizeOptions, CDialog)
//{{AFX_MSG_MAP(COptimizeOptions)
ON_WM_HSCROLL()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// COptimizeOptions message handlers
void COptimizeOptions::OnOK()
{
// TODO: Add extra validation here
UpdateData(TRUE);
int plimit;
plimit=atoi(m_opolys);
if(m_fpolys>plimit || m_fpolys<2)
{
MessageBox("Final Polys must be in range 2 - Original Polys","Invalid Input",MB_OK|MB_ICONWARNING);
m_fpolys=plimit/2;
UpdateData(FALSE);
return;
}
CDialog::OnOK();
}
BOOL COptimizeOptions::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_bsizesli.SetRange(10,MidLevelRenderer::Limits::Max_Number_Vertices_Per_Mesh/3-2);
m_bsizesli.SetPos(64);
float xm=theApp.RVWnd->ActiveHField->GetXinM();
float zm=theApp.RVWnd->ActiveHField->GetZinM();
float dim = static_cast<float>(sqrt(m_fpolys/m_bsizesli.GetPos()));
if(dim < 1.0f)
dim = 1.0f;
m_bsizetext.Format("%i",m_bsizesli.GetPos());
m_binfo.Format("Avg. Mesh Size: %.1f m x %.1f m", xm/dim, zm/dim);
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void COptimizeOptions::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default
float xm=theApp.RVWnd->ActiveHField->GetXinM();
float zm=theApp.RVWnd->ActiveHField->GetZinM();
UpdateData(TRUE);
float dim = static_cast<float>(sqrt(m_fpolys/m_bsizesli.GetPos()));
if(dim < 1.0f)
dim = 1.0f;
m_bsizetext.Format("%i",m_bsizesli.GetPos());
m_binfo.Format("Avg. Mesh Size: %.1f m x %.1f m", xm/dim, zm/dim);
UpdateData(FALSE);
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}
@@ -0,0 +1,52 @@
#if !defined(AFX_OPTIMIZEOPTIONS_H__945D1B21_A62B_11D2_A580_00104B62A145__INCLUDED_)
#define AFX_OPTIMIZEOPTIONS_H__945D1B21_A62B_11D2_A580_00104B62A145__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// OptimizeOptions.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// COptimizeOptions dialog
class COptimizeOptions : public CDialog
{
// Construction
public:
COptimizeOptions(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(COptimizeOptions)
enum { IDD = IDD_OPTOPT };
CSliderCtrl m_bsizesli;
CString m_opolys;
int m_fpolys;
CString m_bsizetext;
CString m_binfo;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(COptimizeOptions)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(COptimizeOptions)
virtual void OnOK();
virtual BOOL OnInitDialog();
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_OPTIMIZEOPTIONS_H__945D1B21_A62B_11D2_A580_00104B62A145__INCLUDED_)
+128
View File
@@ -0,0 +1,128 @@
// PathList.cpp : implementation file
//
#include "stdafx.h"
#include "tctb.h"
#include "PathList.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPathList property page
IMPLEMENT_DYNCREATE(CPathList, CPropertyPage)
CPathList::CPathList() : CPropertyPage(CPathList::IDD)
{
//{{AFX_DATA_INIT(CPathList)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
Changed=FALSE;
}
CPathList::~CPathList()
{
}
void CPathList::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPathList)
DDX_Control(pDX, IDC_PATHLIST, m_PList);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPathList, CPropertyPage)
//{{AFX_MSG_MAP(CPathList)
ON_BN_CLICKED(IDC_ADDPATH, OnAddpath)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPathList message handlers
void ILFree(LPITEMIDLIST pidl);
void CPathList::OnAddpath()
{
char pname[MAX_PATH];
BROWSEINFO bi;
bi.hwndOwner = m_hWnd;
bi.pidlRoot = NULL;
bi.pszDisplayName = NULL;
bi.lpszTitle = "Choose New Path...";
bi.ulFlags = BIF_RETURNONLYFSDIRS;
bi.lpfn = NULL;
bi.lParam = (LPARAM)this;
LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
if (SHGetPathFromIDList(pidl,pname))
{
m_PList.AddString(pname);
Changed=TRUE;
}
if (bi.pidlRoot)
{
ILFree( const_cast< ITEMIDLIST* >( bi.pidlRoot ) );
}
}
void CPathList::GetPaths(CString &str)
{
int i;
CString tstr;
str="";
for(i=0;i<m_PList.GetCount();i++)
{
m_PList.GetText(i,tstr);
str+=tstr+";";
}
}
void CPathList::SetPaths(CString &str)
{
CString fstr,cstr;
fstr=str;
int idx;
while(fstr.GetLength()>0)
{
idx=fstr.FindOneOf(";");
cstr=fstr.Left(idx);
fstr=fstr.Right(fstr.GetLength()-(idx+1));
}
}
void CPathList::AddPath(CString &pth)
{
m_PList.AddString(pth);
Changed=TRUE;
}
CString CPathList::GetPath(int i)
{
CString str;
m_PList.GetText(i,str);
return str;
}
int CPathList::GetTotalPaths()
{
return m_PList.GetCount();
}
+54
View File
@@ -0,0 +1,54 @@
#if !defined(AFX_PATHLIST_H__4ED6B683_7E0B_11D2_840A_00A0C933BCAC__INCLUDED_)
#define AFX_PATHLIST_H__4ED6B683_7E0B_11D2_840A_00A0C933BCAC__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// PathList.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CPathList dialog
class CPathList : public CPropertyPage
{
DECLARE_DYNCREATE(CPathList)
// Construction
public:
int GetTotalPaths();
CString GetPath(int i);
void AddPath(CString &pth);
void SetPaths(CString &str);
void GetPaths(CString &str);
BOOL Changed;
CPathList();
~CPathList();
// Dialog Data
//{{AFX_DATA(CPathList)
enum { IDD = IDD_FW_PLIST };
CListBox m_PList;
//}}AFX_DATA
// Overrides
// ClassWizard generate virtual function overrides
//{{AFX_VIRTUAL(CPathList)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CPathList)
afx_msg void OnAddpath();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_PATHLIST_H__4ED6B683_7E0B_11D2_840A_00A0C933BCAC__INCLUDED_)
+217
View File
@@ -0,0 +1,217 @@
// ProgDlg.cpp : implementation file
// CG: This file was added by the Progress Dialog component
#include "stdafx.h"
#include "resource.h"
#include "ProgDlg.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CProgressDlg dialog
CProgressDlg::CProgressDlg(UINT nCaptionID)
{
m_nCaptionID = CG_IDS_PROGRESS_CAPTION;
if (nCaptionID != 0)
m_nCaptionID = nCaptionID;
m_bCancel=FALSE;
m_nLower=0;
m_nUpper=100;
m_nStep=10;
//{{AFX_DATA_INIT(CProgressDlg)
m_errnum = _T("");
//}}AFX_DATA_INIT
m_bParentDisabled = FALSE;
}
CProgressDlg::~CProgressDlg()
{
if(m_hWnd!=NULL)
DestroyWindow();
}
BOOL CProgressDlg::DestroyWindow()
{
ReEnableParent();
return CDialog::DestroyWindow();
}
void CProgressDlg::ReEnableParent()
{
if(m_bParentDisabled && (m_pParentWnd!=NULL))
m_pParentWnd->EnableWindow(TRUE);
m_bParentDisabled=FALSE;
}
BOOL CProgressDlg::Create(CWnd *pParent)
{
// Get the true parent of the dialog
m_pParentWnd = CWnd::GetSafeOwner(pParent);
// m_bParentDisabled is used to re-enable the parent window
// when the dialog is destroyed. So we don't want to set
// it to TRUE unless the parent was already enabled.
if((m_pParentWnd!=NULL) && m_pParentWnd->IsWindowEnabled())
{
m_pParentWnd->EnableWindow(FALSE);
m_bParentDisabled = TRUE;
}
if(!CDialog::Create(CProgressDlg::IDD,pParent))
{
ReEnableParent();
return FALSE;
}
return TRUE;
}
void CProgressDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CProgressDlg)
DDX_Control(pDX, CG_IDC_PROGDLG_PROGRESS, m_Progress);
DDX_Text(pDX, IDC_ERRNUM, m_errnum);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CProgressDlg, CDialog)
//{{AFX_MSG_MAP(CProgressDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CProgressDlg::OnCancel()
{
m_bCancel=TRUE;
}
void CProgressDlg::SetRange(int nLower,int nUpper)
{
m_nLower = nLower;
m_nUpper = nUpper;
m_Progress.SetRange(nLower,nUpper);
}
int CProgressDlg::SetPos(int nPos)
{
PumpMessages();
int iResult = m_Progress.SetPos(nPos);
UpdatePercent(nPos);
return iResult;
}
int CProgressDlg::SetStep(int nStep)
{
m_nStep = nStep; // Store for later use in calculating percentage
return m_Progress.SetStep(nStep);
}
int CProgressDlg::OffsetPos(int nPos)
{
PumpMessages();
int iResult = m_Progress.OffsetPos(nPos);
UpdatePercent(iResult+nPos);
return iResult;
}
int CProgressDlg::StepIt()
{
PumpMessages();
int iResult = m_Progress.StepIt();
UpdatePercent(iResult+m_nStep);
return iResult;
}
void CProgressDlg::PumpMessages()
{
// Must call Create() before using the dialog
ASSERT(m_hWnd!=NULL);
MSG msg;
// Handle dialog messages
while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if(!IsDialogMessage(&msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
BOOL CProgressDlg::CheckCancelButton()
{
// Process all pending messages
PumpMessages();
// Reset m_bCancel to FALSE so that
// CheckCancelButton returns FALSE until the user
// clicks Cancel again. This will allow you to call
// CheckCancelButton and still continue the operation.
// If m_bCancel stayed TRUE, then the next call to
// CheckCancelButton would always return TRUE
BOOL bResult = m_bCancel;
m_bCancel = FALSE;
return bResult;
}
void CProgressDlg::UpdatePercent(int nNewPos)
{
CWnd *pWndPercent = GetDlgItem(CG_IDC_PROGDLG_PERCENT);
int nPercent;
int nDivisor = m_nUpper - m_nLower;
ASSERT(nDivisor>0); // m_nLower should be smaller than m_nUpper
int nDividend = (nNewPos - m_nLower);
ASSERT(nDividend>=0); // Current position should be greater than m_nLower
nPercent = nDividend * 100 / nDivisor;
// Since the Progress Control wraps, we will wrap the percentage
// along with it. However, don't reset 100% back to 0%
if(nPercent!=100)
nPercent %= 100;
// Display the percentage
CString strBuf;
strBuf.Format(_T("%d%c"),nPercent,_T('%'));
CString strCur; // get current percentage
pWndPercent->GetWindowText(strCur);
if (strCur != strBuf)
pWndPercent->SetWindowText(strBuf);
}
/////////////////////////////////////////////////////////////////////////////
// CProgressDlg message handlers
BOOL CProgressDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_Progress.SetRange(m_nLower,m_nUpper);
m_Progress.SetStep(m_nStep);
m_Progress.SetPos(m_nLower);
//CString strCaption;
//VERIFY(strCaption.LoadString(m_nCaptionID));
//SetWindowText(strCaption);
return TRUE;
}
void CProgressDlg::SetErrorText(float err)
{
m_errnum.Format("%3.5f",err);
UpdateData(FALSE);
}
+69
View File
@@ -0,0 +1,69 @@
// ProgDlg.h : header file
// CG: This file was added by the Progress Dialog component
/////////////////////////////////////////////////////////////////////////////
// CProgressDlg dialog
#ifndef __PROGDLG_H__
#define __PROGDLG_H__
class CProgressDlg : public CDialog
{
// Construction / Destruction
public:
void SetErrorText(float err);
CProgressDlg(UINT nCaptionID = 0); // standard constructor
~CProgressDlg();
BOOL Create(CWnd *pParent=NULL);
// Checking for Cancel button
BOOL CheckCancelButton();
// Progress Dialog manipulation
void SetRange(int nLower,int nUpper);
int SetStep(int nStep);
int SetPos(int nPos);
int OffsetPos(int nPos);
int StepIt();
// Dialog Data
//{{AFX_DATA(CProgressDlg)
enum { IDD = CG_IDD_PROGRESS };
CProgressCtrl m_Progress;
CString m_errnum;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CProgressDlg)
public:
virtual BOOL DestroyWindow();
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
UINT m_nCaptionID;
int m_nLower;
int m_nUpper;
int m_nStep;
BOOL m_bCancel;
BOOL m_bParentDisabled;
void ReEnableParent();
virtual void OnCancel();
virtual void OnOK() {};
void UpdatePercent(int nCurrent);
void PumpMessages();
// Generated message map functions
//{{AFX_MSG(CProgressDlg)
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#endif // __PROGDLG_H__
+102
View File
@@ -0,0 +1,102 @@
========================================================================
MICROSOFT FOUNDATION CLASS LIBRARY : TCTb
========================================================================
AppWizard has created this TCTb application for you. This application
not only demonstrates the basics of using the Microsoft Foundation classes
but is also a starting point for writing your application.
This file contains a summary of what you will find in each of the files that
make up your TCTb application.
TCTb.dsp
This file (the project file) contains information at the project level and
is used to build a single project or subproject. Other users can share the
project (.dsp) file, but they should export the makefiles locally.
TCTb.h
This is the main header file for the application. It includes other
project specific headers (including Resource.h) and declares the
CTCTbApp application class.
TCTb.cpp
This is the main application source file that contains the application
class CTCTbApp.
TCTb.rc
This is a listing of all of the Microsoft Windows resources that the
program uses. It includes the icons, bitmaps, and cursors that are stored
in the RES subdirectory. This file can be directly edited in Microsoft
Visual C++.
TCTb.clw
This file contains information used by ClassWizard to edit existing
classes or add new classes. ClassWizard also uses this file to store
information needed to create and edit message maps and dialog data
maps and to create prototype member functions.
res\TCTb.ico
This is an icon file, which is used as the application's icon. This
icon is included by the main resource file TCTb.rc.
res\TCTb.rc2
This file contains resources that are not edited by Microsoft
Visual C++. You should place all resources not editable by
the resource editor in this file.
/////////////////////////////////////////////////////////////////////////////
For the main frame window:
MainFrm.h, MainFrm.cpp
These files contain the frame class CMainFrame, which is derived from
CMDIFrameWnd and controls all MDI frame features.
res\Toolbar.bmp
This bitmap file is used to create tiled images for the toolbar.
The initial toolbar and status bar are constructed in the CMainFrame
class. Edit this toolbar bitmap using the resource editor, and
update the IDR_MAINFRAME TOOLBAR array in TCTb.rc to add
toolbar buttons.
/////////////////////////////////////////////////////////////////////////////
For the child frame window:
ChildFrm.h, ChildFrm.cpp
These files define and implement the CChildFrame class, which
supports the child windows in an MDI application.
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
Other standard files:
StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named TCTb.pch and a precompiled types file named StdAfx.obj.
Resource.h
This is the standard header file, which defines new resource IDs.
Microsoft Visual C++ reads and updates this file.
/////////////////////////////////////////////////////////////////////////////
Other notes:
AppWizard uses "TODO:" to indicate parts of the source code you
should add to or customize.
If your application uses MFC in a shared DLL, and your application is
in a language other than the operating system's current language, you
will need to copy the corresponding localized resources MFC42XXX.DLL
from the Microsoft Visual C++ CD-ROM onto the system or system32 directory,
and rename it to be MFCLOC.DLL. ("XXX" stands for the language abbreviation.
For example, MFC42DEU.DLL contains resources translated to German.) If you
don't do this, some of the UI elements of your application will remain in the
language of the operating system.
/////////////////////////////////////////////////////////////////////////////
@@ -0,0 +1,309 @@
// RenderedViewWnd.cpp : implementation file
//
#include "stdafx.h"
#include "RenderedViewWnd.h"
#include <ElementRenderer\ElementRenderer.hpp>
#include <ElementRenderer\GroupElement.hpp>
#include <ElementRenderer\ListElement.hpp>
#include <ElementRenderer\StateChange.hpp>
#include <ElementRenderer\CameraElement.hpp>
#include <ElementRenderer\SwitchElement.hpp>
#include <ElementRenderer\ShapeElement.hpp>
#include <gosFX\gosFX.hpp>
#include <MLR\MLR.hpp>
#include <MLR\MLRHeaders.hpp>
#include <MFCPlatform\MFCPlatform.hpp>
#include"TctHeightField.h"
#include"Tctb.h"
extern CTCTbApp theApp;
extern DWORD RunGameOSLogic();
//extern CTCTbApp theApp;
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CRenderedViewWnd
//IMPLEMENT_DYNCREATE(CRenderedViewWnd, CMDIChildWnd)
extern bool gActive;
extern bool gGotFocus;
CRenderedViewWnd::CRenderedViewWnd()
{
texture = NULL;
Scene = NULL;
ActiveHField = NULL;
Camera = NULL;
Camera_State =NULL;
OverLayMapLoaded = false;
}
CRenderedViewWnd::~CRenderedViewWnd()
{
}
BEGIN_MESSAGE_MAP(CRenderedViewWnd, CMDIChildWnd)
//{{AFX_MSG_MAP(CRenderedViewWnd)
ON_WM_CLOSE()
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRenderedViewWnd message handlers
void CRenderedViewWnd::OnClose()
{
//ShowWindow(SW_MINIMIZE);
ShowWindow(SW_HIDE);
//Don't Let it close
//CMDIChildWnd::OnClose();
}
LRESULT CRenderedViewWnd::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
if(Camera_State!=NULL)
{
switch(message)
{
case WM_ACTIVATE:
case WM_CHILDACTIVATE :
case WM_MDIACTIVATE:
gActive = true;
gGotFocus= true;
case WM_MDICASCADE:
case WM_MDICREATE:
case WM_MDIDESTROY:
case WM_MDIGETACTIVE:
case WM_MDIICONARRANGE:
case WM_MDIMAXIMIZE:
case WM_MDINEXT:
case WM_MDIREFRESHMENU:
case WM_MDIRESTORE:
case WM_MDISETMENU:
case WM_MDITILE:
case WM_CLOSE:
return CMDIChildWnd::WindowProc(message, wParam, lParam);
break;
}
return GameOSWinProc(m_hWnd, message, wParam, lParam);
}
return CMDIChildWnd::WindowProc(message, wParam, lParam);
}
void CRenderedViewWnd::Fix3DView()
{
//Fake a WM_MOVE to cause GOS to interogate the window
GameOSWinProc(m_hWnd, WM_MOVE, NULL, NULL);
}
void CRenderedViewWnd::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
// Fix3DView();
// if(RunGameOSLogic()) PostQuitMessage(0);
// Do not call CMDIChildWnd::OnPaint() for painting messages
}
void CRenderedViewWnd::PostGOSInit()
{
//
//------------------------
// Set up the texture pool
//------------------------
//
#ifdef _DEBUG
#undef new
#endif
pool = new TGAFilePool(theApp.TexturePath);
Register_Object(pool);
MLRTexturePool::Instance = new MLRTexturePool(pool);
Check_Object(MLRTexturePool::Instance);
Register_Object(MLRTexturePool::Instance);
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
/*
texture = MLRTexturePool::Instance->Add("Grass");
Check_Object(texture);
state.SetTexture(texture->GetTextureHandle());
state.SetRenderDeltaMask(MLRState::TextureMask);
state.SetZBufferCompareOn();
state.SetZBufferWriteOn();
state.SetFilterMode(MLRState::TriLinearFilterMode);
state.SetPriority(MLRState::DefaultPriority);
state2 = state;
state2.SetZBufferWriteOff();
state2.SetAlphaMode(MLRState::OneOneMode);
state2.SetPriority(MLRState::DefaultPriority + 1);
*/
//
//-------------------------------------------------------------------
// Build the scene root and a shifting node for testing element types
//-------------------------------------------------------------------
//
#ifdef _DEBUG
#undef new
#endif
Scene = new ElementRenderer::ListElement;
Register_Object(Scene);
Scene->SetSize(2);
Scene->SetName("Scene");
LinearMatrix4D matrix=LinearMatrix4D::Identity;
matrix.BuildTranslation(Point3D(0.0f, 0.0f, 0.0f));
Scene->SetLocalToParent(matrix);
//
//---------------
// Build a camera
//---------------
//
Camera_State = new ElementRenderer::StateChange();
Register_Object(Camera_State);
Camera_State->EnableBackfaceCulling();
Camera_State->EnableDithering();
Camera_State->EnablePerspectiveCorrection();
Camera_State->EnableZBufferWrite();
Camera_State->EnableZBufferCompare();
Camera_State->DisableFog();
Camera_State->SetFog(RGBAColor(0.3f, 0.3f, 0.3f, 1.0f),0.0,300.0,350.0);
// Camera_State->OverrideFogStart(100.0f);
// Camera_State->OverrideFogEnd(350.0f);
Camera = new ElementRenderer::CameraElement(Camera_State);
Register_Object(Camera);
Scene->AttachIndexedChild(1, Camera);
Camera->SetPerspective(1.0f, 350.0f, Pi_Over_3);
Camera->SetScene(Scene);
LinearMatrix4D origin;
origin.BuildRotation(EulerAngles(0.0f,0.0f,0.0f));
Camera->SetLocalToParent(origin);
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
if(ActiveHField) delete ActiveHField;
ActiveHField=new TCTHeightField;
ActiveHField->Attach(Scene,0);
Scene->Sync();
}
void CRenderedViewWnd::UpdateCamera(CameraInfo &CamInfo)
{
LinearMatrix4D origin = LinearMatrix4D::Identity;
Stuff::Point3D p3d;
Stuff::Vector3D v3d;
CamInfo.UpdateCPos();
if(CamInfo.TarATrkFlg)
{
CamInfo.TargetLoc.y=ActiveHField->GetHeight(CamInfo.TargetLoc.x,CamInfo.TargetLoc.z)+CamInfo.TarTrackAlt;
CamInfo.UpdateCPos();
}
if(CamInfo.CamATrkFlg)
CamInfo.Loc.y=ActiveHField->GetHeight(CamInfo.Loc.x,CamInfo.Loc.z)+CamInfo.CamTrackAlt;
p3d=CamInfo.Loc;
v3d=CamInfo.Dir;
// Set the camera matrix
Stuff::Scalar yaw,pitch;
if(v3d.z==0)
{
if(v3d.x>=0) yaw=0; else yaw=Stuff::Pi;
}
else
{
yaw=(float)atan(v3d.x/v3d.z);
if(v3d.z<0.0f) yaw+=Stuff::Pi;
}
pitch=(float)asin(-v3d.y);
origin.BuildRotation(EulerAngles(pitch,yaw,0.0f));
origin.BuildTranslation(Point3D(p3d.x,p3d.y,p3d.z));
Camera->SetPerspective(CamInfo.NearClip,CamInfo.FarClip,CamInfo.FOV);
Camera->SetLocalToParent(origin);
*Camera_State=CamInfo.State;
Scene->Sync();
}
void CRenderedViewWnd::ReDraw(CameraInfo &CamInfo)
{
gActive = true;
gGotFocus= true;
UpdateCamera(CamInfo);
if(Camera) Camera->DrawScene();
}
void CRenderedViewWnd::UpdateHField(TCTHeightField &tdat)
{
if(ActiveHField) ActiveHField->Clone(tdat);
ActiveHField->SetState(theApp.TData.BaseTexture.State,0);
ActiveHField->SetState(theApp.TData.DetailTexture.State,1);
//if(RunGameOSLogic()) PostQuitMessage(0);
}
void CRenderedViewWnd::PreGosCleanUp()
{
if(ActiveHField)
{
delete ActiveHField;
ActiveHField=NULL;
}
if(Scene)
{
Unregister_Object(Scene);
delete Scene;
}
Camera_State=NULL;
}
@@ -0,0 +1,79 @@
#if !defined(AFX_RENDEREDVIEWWND_H__7944DBC2_5A13_11D2_8408_00A0C933BCAC__INCLUDED_)
#define AFX_RENDEREDVIEWWND_H__7944DBC2_5A13_11D2_8408_00A0C933BCAC__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// RenderedViewWnd.h : header file
//
#include <ElementRenderer\ElementRenderer.hpp>
#include <ElementRenderer\GroupElement.hpp>
#include <ElementRenderer\ListElement.hpp>
#include <ElementRenderer\StateChange.hpp>
#include <ElementRenderer\CameraElement.hpp>
#include <ElementRenderer\SwitchElement.hpp>
#include <ElementRenderer\ShapeElement.hpp>
#include <gosFX\gosFX.hpp>
#include <MLR\MLR.hpp>
#include <MLR\MLRHeaders.hpp>
#include"CameraInfo.h"
#include"TCTTerrainData.h"
/////////////////////////////////////////////////////////////////////////////
// CRenderedViewWnd frame
class CRenderedViewWnd : public CMDIChildWnd
{
// DECLARE_DYNCREATE(CRenderedViewWnd)
protected:
// Attributes
public:
MLRState state,state2;
MLRTexture *texture;
ElementRenderer::CameraElement *Camera;
ElementRenderer::StateChange *Camera_State;
ElementRenderer::ListElement *Scene;
TCTHeightField *ActiveHField;
DrawScreenQuadsInformation OverLayMap;
bool OverLayMapLoaded;
TGAFilePool *pool;
CRenderedViewWnd(); // protected constructor used by dynamic creation
// Operations
public:
void PreGosCleanUp();
void UpdateHField(TCTHeightField &tdat);
void ReDraw(CameraInfo &CamInfo);
void UpdateCamera(CameraInfo &CamInfo);
void PostGOSInit();
void Fix3DView();
virtual ~CRenderedViewWnd();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CRenderedViewWnd)
protected:
virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CRenderedViewWnd)
afx_msg void OnClose();
afx_msg void OnPaint();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_RENDEREDVIEWWND_H__7944DBC2_5A13_11D2_8408_00A0C933BCAC__INCLUDED_)
Binary file not shown.
+13
View File
@@ -0,0 +1,13 @@
//
// TCTB.RC2 - resources Microsoft Visual C++ does not edit directly
//
#ifdef APSTUDIO_INVOKED
#error this file is not editable by Microsoft Visual C++
#endif //APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
// Add manually edited resources here...
/////////////////////////////////////////////////////////////////////////////
Binary file not shown.
Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More