-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathThreeD.cpp
More file actions
221 lines (193 loc) · 4.9 KB
/
Copy pathThreeD.cpp
File metadata and controls
221 lines (193 loc) · 4.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
// ThreeD.cpp: implementation of the CThreeD class.
//
//////////////////////////////////////////////////////////////////////
#include "ThreeD.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CThreeD::CThreeD()
{
this->m_hInstance = NULL;
this->m_hParent = NULL;
this->m_hDlg = NULL;
this->m_dwResourceDlg = IDD_3D;
this->rmf = NULL;
this->ms3d = NULL;
this->engine = NULL;
}
CThreeD::~CThreeD()
{
}
//////////////////////////////////////////////////////////////////////
// Purpose :
// Input :
// Output :
//////////////////////////////////////////////////////////////////////
LRESULT CThreeD::BaseProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
CThreeD *pDlg = 0;
// Is it the first message?
if (uMsg == WM_INITDIALOG)
{
// Get the object from the creation param
pDlg = reinterpret_cast<CThreeD *>(lParam);
pDlg->SetHandle(hDlg);
// Set it in the Window param
::SetWindowLong(hDlg, GWL_USERDATA, reinterpret_cast<long>(pDlg));
}
else
{
// Get the object from the window param
pDlg = reinterpret_cast<CThreeD *>(::GetWindowLong(hDlg, GWL_USERDATA));
}
if (pDlg)
pDlg->DlgProc(uMsg, wParam, lParam);
return FALSE;
}
//////////////////////////////////////////////////////////////////////
// Purpose :
// Input :
// Output :
//////////////////////////////////////////////////////////////////////
int CThreeD::ShowModal(HINSTANCE hInst, HWND hParent)
{
this->m_hInstance = hInst;
this->m_hParent = hParent;
return DialogBoxParam(hInst, MAKEINTRESOURCE(m_dwResourceDlg), hParent, (DLGPROC)BaseProc, (LPARAM)this);
}
//////////////////////////////////////////////////////////////////////
// Purpose :
// Input :
// Output :
//////////////////////////////////////////////////////////////////////
int CThreeD::ShowModalless(HINSTANCE hInst, HWND hParent)
{
this->m_hInstance = hInst;
this->m_hParent = hParent;
m_hDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(m_dwResourceDlg), hParent, (DLGPROC)BaseProc, (LPARAM)this);
ShowWindow(m_hDlg, SW_SHOW);
return 0;
}
//////////////////////////////////////////////////////////////////////
// Purpose : Set the handle of the created dialogwindow in this
// instance. Used in the wndproc of the clientwindowclass
// Input : Handle of the dialogwindow created by this instance
// Output :
//////////////////////////////////////////////////////////////////////
void CThreeD::SetHandle(HWND hWnd)
{
this->m_hDlg = hWnd;
}
//////////////////////////////////////////////////////////////////////
// Purpose :
// Input :
// Output :
//////////////////////////////////////////////////////////////////////
void CThreeD::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_INITDIALOG:
{
DEVMODE pDevmode;
EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &pDevmode);
engine = new CWtrEngine();
if (engine)
{
engine->InitEngine(this->m_hDlg, &pDevmode, false, NULL);
engine->GetCamera()->MoveForward(-20.0f);
SetTimer(this->m_hDlg, 2, 10, NULL);
}
SetFocus(this->m_hDlg);
break;
}
case WM_TIMER:
{
if (engine)
{
engine->PreRender();
if (this->rmf)
{
this->rmf->DrawGl();
}
if (this->ms3d)
{
this->ms3d->DrawGl();
}
engine->PostRender();
}
break;
}
case WM_COMMAND:
{
switch (wParam)
{
case IDCANCEL:
case IDOK:
{
EndDialog(m_hDlg, IDOK);
break;
}
}
break;
}
case WM_SIZE:
{
engine->Resize(LOWORD(lParam), HIWORD(lParam));
break;
}
case 0x020A:
engine->GetCamera()->MoveForward( ((short) HIWORD(wParam)) / 100);
case WM_LBUTTONDOWN:
CKeys::GetInstance()->ButtonDown(Left); break;
case WM_LBUTTONUP:
CKeys::GetInstance()->ButtonUp(Left); break;
case WM_RBUTTONDOWN:
CKeys::GetInstance()->ButtonDown(Right); break;
case WM_RBUTTONUP:
CKeys::GetInstance()->ButtonUp(Right); break;
case WM_MBUTTONDOWN:
CKeys::GetInstance()->ButtonDown(Middle); break;
case WM_MBUTTONUP:
CKeys::GetInstance()->ButtonUp(Middle); break;
case WM_KEYUP:
CKeys::GetInstance()->KeyUp(wParam); break;
case WM_KEYDOWN:
{
if (wParam == 'Z')
{
engine->ToggleCaptureCursor();
}
CKeys::GetInstance()->KeyDown(wParam);
break;
}
case WM_PAINT:
{
break;
}
case WM_CLOSE:
{
engine->Shutdown();
EndDialog(m_hDlg, IDOK);
break;
}
}
}
//////////////////////////////////////////////////////////////////////
// Purpose :
// Input :
// Output :
//////////////////////////////////////////////////////////////////////
void CThreeD::SetRMF(CRMFFile* rmf)
{
this->rmf = rmf;
}
//////////////////////////////////////////////////////////////////////
// Purpose :
// Input :
// Output :
//////////////////////////////////////////////////////////////////////
void CThreeD::SeMS3D(CMS3DFile* ms3d)
{
this->ms3d = ms3d;
}