-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathSceneSetPropertiesWnd.cpp
More file actions
480 lines (421 loc) · 15.3 KB
/
SceneSetPropertiesWnd.cpp
File metadata and controls
480 lines (421 loc) · 15.3 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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
#include "stdafx.h"
#include "SceneSetPropertiesWnd.h"
#include "Resource.h"
#include "EditScene.h"
#include "BaseApplication.h"
SceneSetPropertiesWnd::SceneSetPropertiesWnd()
{
}
SceneSetPropertiesWnd::~SceneSetPropertiesWnd()
{
}
BEGIN_MESSAGE_MAP(SceneSetPropertiesWnd, CDockablePane)
ON_WM_CREATE()
ON_WM_SIZE()
ON_WM_SETFOCUS()
ON_WM_SETTINGCHANGE()
ON_CBN_SELCHANGE(1,ComBoxSelectChanged)
ON_REGISTERED_MESSAGE(AFX_WM_PROPERTY_CHANGED,OnPropertyChanged) //处理属性变化事件
END_MESSAGE_MAP()
void SceneSetPropertiesWnd::AdjustLayout()
{
if (GetSafeHwnd() == NULL)
{
return;
}
CRect rectClient,rectCombo;
GetClientRect(rectClient);
m_wndObjectCombo.GetWindowRect(&rectCombo);
int cyCmb = rectCombo.Size().cy;
m_wndObjectCombo.SetWindowPos(NULL, rectClient.left, rectClient.top, rectClient.Width(), 200, SWP_NOACTIVATE | SWP_NOZORDER);
m_wndPropList.SetWindowPos(NULL, rectClient.left, rectClient.top + cyCmb, rectClient.Width(), rectClient.Height() - cyCmb, SWP_NOACTIVATE | SWP_NOZORDER);
}
int SceneSetPropertiesWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDockablePane::OnCreate(lpCreateStruct) == -1)
return -1;
CRect rectDummy;
rectDummy.SetRectEmpty();
const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | WS_BORDER | CBS_SORT | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
if (!m_wndObjectCombo.Create(dwViewStyle, rectDummy, this, 1))
{
TRACE0("未能创建属性组合 \n");
return -1;
}
m_wndObjectCombo.AddString(_T("物理引擎设置"));
m_wndObjectCombo.AddString(_T("浏览设置"));
m_wndObjectCombo.AddString(_T("单位设置"));
m_wndObjectCombo.SetCurSel(0);
if (!m_wndPropList.Create(WS_VISIBLE | WS_CHILD, rectDummy, this, 2))
{
TRACE0("未能创建属性网格\n");
return -1;
}
//InitPropList();
AdjustLayout();
return 0;
}
void SceneSetPropertiesWnd::OnSize(UINT nType, int cx, int cy)
{
CDockablePane::OnSize(nType, cx, cy);
AdjustLayout();
}
void SceneSetPropertiesWnd::OnExpandAllProperties()
{
m_wndPropList.ExpandAll();
}
void SceneSetPropertiesWnd::OnUpdateExpandAllProperties(CCmdUI* /* pCmdUI */)
{
}
void SceneSetPropertiesWnd::OnSortProperties()
{
m_wndPropList.SetAlphabeticMode(!m_wndPropList.IsAlphabeticMode());
}
void SceneSetPropertiesWnd::OnUpdateSortProperties(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(m_wndPropList.IsAlphabeticMode());
}
void SceneSetPropertiesWnd::OnProperties1()
{
// TODO: 在此处添加命令处理程序代码
}
void SceneSetPropertiesWnd::OnUpdateProperties1(CCmdUI* /*pCmdUI*/)
{
// TODO: 在此处添加命令更新 UI 处理程序代码
}
void SceneSetPropertiesWnd::OnProperties2()
{
// TODO: 在此处添加命令处理程序代码
}
void SceneSetPropertiesWnd::OnUpdateProperties2(CCmdUI* /*pCmdUI*/)
{
// TODO: 在此处添加命令更新 UI 处理程序代码
}
void SceneSetPropertiesWnd::InitPropList()
{
m_wndPropList.EnableHeaderCtrl(FALSE);
m_wndPropList.EnableDescriptionArea();
m_wndPropList.SetVSDotNetLook();
m_wndPropList.MarkModifiedProperties();
CMFCPropertyGridProperty* pGroup1 = new CMFCPropertyGridProperty(_T("外观"));
pGroup1->AddSubItem(new CMFCPropertyGridProperty(_T("三维外观"), (_variant_t) false, _T("指定窗口的字体不使用粗体,并且控件将使用三维边框")));
CMFCPropertyGridProperty* pProp = new CMFCPropertyGridProperty(_T("边框"), _T("对话框外框"), _T("其中之一:“无”、“细”、“可调整大小”或“对话框外框”"));
pProp->AddOption(_T("无"));
pProp->AddOption(_T("细"));
pProp->AddOption(_T("可调整大小"));
pProp->AddOption(_T("对话框外框"));
pProp->AllowEdit(FALSE);
pGroup1->AddSubItem(pProp);
pGroup1->AddSubItem(new CMFCPropertyGridProperty(_T("标题"), (_variant_t) _T("关于"), _T("指定窗口标题栏中显示的文本")));
m_wndPropList.AddProperty(pGroup1);
CMFCPropertyGridProperty* pSize = new CMFCPropertyGridProperty(_T("窗口大小"), 0, TRUE);
pProp = new CMFCPropertyGridProperty(_T("高度"), (_variant_t) 250l, _T("指定窗口的高度"));
pProp->EnableSpinControl(TRUE, 50, 300);
pSize->AddSubItem(pProp);
pProp = new CMFCPropertyGridProperty( _T("宽度"), (_variant_t) 150l, _T("指定窗口的宽度"));
pProp->EnableSpinControl(TRUE, 50, 200);
pSize->AddSubItem(pProp);
m_wndPropList.AddProperty(pSize);
;
CMFCPropertyGridProperty* pGroup3 = new CMFCPropertyGridProperty(_T("杂项"));
pProp = new CMFCPropertyGridProperty(_T("(名称)"), _T("应用程序"));
pProp->Enable(FALSE);
pGroup3->AddSubItem(pProp);
CMFCPropertyGridColorProperty* pColorProp = new CMFCPropertyGridColorProperty(_T("窗口颜色"), RGB(210, 192, 254), NULL, _T("指定默认的窗口颜色"));
pColorProp->EnableOtherButton(_T("其他..."));
pColorProp->EnableAutomaticButton(_T("默认"), ::GetSysColor(COLOR_3DFACE));
pGroup3->AddSubItem(pColorProp);
static const TCHAR szFilter[] = _T("图标文件(*.ico)|*.ico|所有文件(*.*)|*.*||");
pGroup3->AddSubItem(new CMFCPropertyGridFileProperty(_T("图标"), TRUE, _T(""), _T("ico"), 0, szFilter, _T("指定窗口图标")));
pGroup3->AddSubItem(new CMFCPropertyGridFileProperty(_T("文件夹"), _T("c:\\")));
m_wndPropList.AddProperty(pGroup3);
CMFCPropertyGridProperty* pGroup4 = new CMFCPropertyGridProperty(_T("层次结构"));
CMFCPropertyGridProperty* pGroup41 = new CMFCPropertyGridProperty(_T("第一个子级"));
pGroup4->AddSubItem(pGroup41);
CMFCPropertyGridProperty* pGroup411 = new CMFCPropertyGridProperty(_T("第二个子级"));
pGroup41->AddSubItem(pGroup411);
pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("项 1"), (_variant_t) _T("值 1"), _T("此为说明")));
pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("项 2"), (_variant_t) _T("值 2"), _T("此为说明")));
pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("项 3"), (_variant_t) _T("值 3"), _T("此为说明")));
pGroup4->Expand(FALSE);
m_wndPropList.AddProperty(pGroup4);
}
void SceneSetPropertiesWnd::OnSetFocus(CWnd* pOldWnd)
{
CDockablePane::OnSetFocus(pOldWnd);
m_wndPropList.SetFocus();
}
void SceneSetPropertiesWnd::OnSettingChange(UINT uFlags, LPCTSTR lpszSection)
{
CDockablePane::OnSettingChange(uFlags, lpszSection);
}
void SceneSetPropertiesWnd::ComBoxSelectChanged()
{
currentSet=m_wndObjectCombo.GetCurSel();
if (currentSet==0)
{
InitUnitSetProp();
}
else if (currentSet==1)
{
InitViewSetPeop();
}
else if (currentSet==2)
{
InitPhsicsSetProp();
}
}
void SceneSetPropertiesWnd::InitPhsicsSetProp()
{
EditScene* mscene=BaseApplication::getInstance()->mscene;
m_wndPropList.RemoveAll();
m_wndPropList.EnableHeaderCtrl(FALSE);
m_wndPropList.EnableDescriptionArea();
m_wndPropList.SetVSDotNetLook();
m_wndPropList.MarkModifiedProperties(); //改变的属性用粗体//
CMFCPropertyGridProperty* pUsePhysics = new CMFCPropertyGridProperty(_T("物理引擎"), _T("启用"), _T("是否启用物理引擎,只有启用物理引擎下面的设置才能生效。请在添加物体之前设置,否则有可能导致显示不正确"));
pUsePhysics->AddOption(_T("启用"));
pUsePhysics->AddOption(_T("关闭"));
if (mscene->bOpenPhysis)
{
pUsePhysics->SetValue(_T("启用"));
}
else pUsePhysics->SetValue(_T("关闭"));
m_wndPropList.AddProperty(pUsePhysics);
CMFCPropertyGridProperty* pAutoSleep = new CMFCPropertyGridProperty(_T("自动休眠"), _T("禁止"), _T("当开启此项后,当物体静止时不再模拟,可以节省部分CPU,请谨慎使用"));
pAutoSleep->AddOption(_T("禁止"));
pAutoSleep->AddOption(_T("允许"));
if (mscene->bEnagleAutoSleep)
{
pUsePhysics->SetValue(_T("允许"));
}
else pUsePhysics->SetValue(_T("禁止"));
m_wndPropList.AddProperty(pAutoSleep);
CMFCPropertyGridProperty* pGravity = new CMFCPropertyGridProperty(_T("重力"));
CMFCPropertyGridProperty* pProp= new CMFCPropertyGridProperty(_T("X方向重力"),(_variant_t)mscene->gravity.x, _T("x方向重力"));
pGravity->AddSubItem(pProp);
pProp =new CMFCPropertyGridProperty(_T("Y方向重力"),(_variant_t)mscene->gravity.y, _T("y方向重力"));
pGravity->AddSubItem(pProp);
pProp =new CMFCPropertyGridProperty(_T("X方向重力"),(_variant_t)mscene->gravity.z, _T("z方向重力"));
pGravity->AddSubItem(pProp);
m_wndPropList.AddProperty(pGravity);
CMFCPropertyGridProperty* pSoftCFm= new CMFCPropertyGridProperty(_T("全局混合力"),(_variant_t)mscene->softCFM, _T("全局混合力,建议取值0.001-1之间"));
m_wndPropList.AddProperty(pSoftCFm);
CMFCPropertyGridProperty* pNumIterations= new CMFCPropertyGridProperty(_T("模拟迭代步数"),(_variant_t)mscene->QuicksetpNumIterations, _T("模拟迭代步数,越大越精细准确,速度越慢,默认32,建议16-64之间"));
m_wndPropList.AddProperty(pNumIterations);
}
void SceneSetPropertiesWnd::InitUnitSetProp()
{
EditScene* mscene=BaseApplication::getInstance()->mscene;
m_wndPropList.RemoveAll();
m_wndPropList.EnableHeaderCtrl(FALSE);
m_wndPropList.EnableDescriptionArea();
m_wndPropList.SetVSDotNetLook();
m_wndPropList.MarkModifiedProperties(); //改变的属性用粗体//
CMFCPropertyGridProperty* pUserUnit = new CMFCPropertyGridProperty(_T("模型单位"), _T(""), _T("模型单位设置,默认分米,决定建立模型时,模型的缩放,如果您觉得模型过大或过小请调整此设置,1米=3.28英尺,1英寸=2.54厘米"));
pUserUnit->AddOption(_T("毫米"));
pUserUnit->AddOption(_T("厘米"));
pUserUnit->AddOption(_T("分米"));
pUserUnit->AddOption(_T("米"));
pUserUnit->AddOption(_T("英尺"));
pUserUnit->AddOption(_T("英寸"));
float unint = BaseApplication::getInstance()->mscene->mUnit;
if (unint >= 0.009998 && unint <= 0.010099)
{
pUserUnit->SetValue(_T("毫米"));
}
else if (unint >= 0.099998 && unint<= 0.100099)
{
pUserUnit->SetValue(_T("厘米"));
}
else if (unint == 1)
{
pUserUnit->SetValue(_T("分米"));
}
else if (unint == 10)
{
pUserUnit->SetValue(_T("米"));
}
else if (unint >= 3.047999 && unint<= 3.048001 )
{
pUserUnit->SetValue(_T("英尺"));
}
else if (unint >= 0.253898 && unint <= 0.254001)
{
pUserUnit->SetValue(_T("英寸"));
}
else pUserUnit->SetValue(_T("未定义"));
m_wndPropList.AddProperty(pUserUnit);
CMFCPropertyGridProperty* pSelfUnit = new CMFCPropertyGridProperty(_T("自定义比例"),(_variant_t)mscene->mUnit, _T("自定义缩放比例,系统以分米为标准,例如若您的模型以毫米为单位建立,则缩放到分米对应比例是0.01"));
m_wndPropList.AddProperty(pSelfUnit);
}
void SceneSetPropertiesWnd::InitViewSetPeop()
{
InputManager *InputMgr=InputManager::getInstance();
if (NULL!=InputMgr)
{
m_wndPropList.RemoveAll();
m_wndPropList.EnableHeaderCtrl(FALSE);
m_wndPropList.EnableDescriptionArea();
m_wndPropList.SetVSDotNetLook();
m_wndPropList.MarkModifiedProperties(); //改变的属性用粗体//
CMFCPropertyGridProperty* pCamViewSpeed = new CMFCPropertyGridProperty(_T("相机速度"), (_variant_t)InputMgr->viewSpeed, _T("编辑场景时,相机的移动速度"));
pCamViewSpeed->EnableSpinControl(TRUE,1,50);
m_wndPropList.AddProperty(pCamViewSpeed);
CMFCPropertyGridProperty* pMouseZSpeed = new CMFCPropertyGridProperty(_T("滚轮微调速度"), (_variant_t)(int)InputMgr->mouseZViewSpeed, _T("滚轮缩放调节距离的速度,建议设置的比较小,有利于精细调节距离"));
pMouseZSpeed->EnableSpinControl(TRUE,1,50);
m_wndPropList.AddProperty(pMouseZSpeed);
CMFCPropertyGridProperty* pEditspeed = new CMFCPropertyGridProperty(_T("物体编辑速度"), (_variant_t)(int)(InputMgr->mEditPointor->EditSpeed *100), _T("滚轮缩放调节距离的速度,建议设置的比较小,有利于精细调节距离"));
pEditspeed->EnableSpinControl(TRUE,1,100);
m_wndPropList.AddProperty(pEditspeed);
Hero *h=Hero::getInstance();
if(NULL!=h)
{
CMFCPropertyGridProperty* pMoveSpeed = new CMFCPropertyGridProperty(_T("人物移动速度"), (_variant_t)(int)h->mMoveSpeed, _T("浏览模式下,人物的移动速度"));
pMoveSpeed->EnableSpinControl(TRUE,10,100);
m_wndPropList.AddProperty(pMoveSpeed);
}
}
}
LRESULT SceneSetPropertiesWnd::OnPropertyChanged( WPARAM wParam,LPARAM lParam )
{
CMFCPropertyGridProperty* pProp = (CMFCPropertyGridProperty*)lParam;
int i= (int)pProp->GetData();
CString PropName=pProp->GetName(); //被改变的参数名//
COleVariant value = pProp->GetValue(); //改变之后的值//
if (PropName==CString(_T("自定义比例")))
{
float val = value.fltVal;
BaseApplication::getInstance()->mscene->mUnit = val;
return 0;
}
else if (PropName==CString(_T("模型单位")))
{
CString str;
str=value.bstrVal; //从COleVariant 到CString
if (str == _T("毫米"))
{
BaseApplication::getInstance()->mscene->mUnit = 0.01;
InitUnitSetProp();
}
else if (str == _T("厘米"))
{
BaseApplication::getInstance()->mscene->mUnit = 0.1;
InitUnitSetProp();
}
else if (str == _T("分米"))
{
BaseApplication::getInstance()->mscene->mUnit = 1;
InitUnitSetProp();
}
else if (str == _T("米"))
{
BaseApplication::getInstance()->mscene->mUnit = 10;
InitUnitSetProp();
}
else if (str == _T("英尺"))
{
BaseApplication::getInstance()->mscene->mUnit =3.048;
InitUnitSetProp();
}
else if (str == _T("英寸"))
{
BaseApplication::getInstance()->mscene->mUnit =0.25390;
InitUnitSetProp();
}
return 0;
}
else if (PropName==CString(_T("相机速度")))
{
int val = value.intVal;
InputManager *InputMgr=InputManager::getInstance();
if (NULL != InputMgr) { InputMgr->viewSpeed = val; }
return 0;
}
else if (PropName==CString(_T("滚轮微调速度")))
{
int val = value.intVal;
InputManager *InputMgr=InputManager::getInstance();
if (NULL != InputMgr) { InputMgr->mouseZViewSpeed = val; }
return 0;
}
else if (PropName==CString(_T("物体编辑速度")))
{
float val = value.intVal / 100.0;
InputManager *InputMgr=InputManager::getInstance();
if (NULL != InputMgr) { InputMgr->mEditPointor->EditSpeed = val; }
return 0;
}
else if (PropName==CString(_T("人物移动速度")))
{
int val = value.intVal;
Hero *h=Hero::getInstance();
if(NULL!=h) { h->mMoveSpeed = val; }
return 0;
}
else if (PropName==CString(_T("物理引擎")))
{
CString str;
str=value.bstrVal; //从COleVariant 到CString
if (str == _T("启用"))
{
BaseApplication::getInstance()->mscene->bOpenPhysis = true;
}
else
{
BaseApplication::getInstance()->mscene->bOpenPhysis = false;
}
}
else if (PropName==CString(_T("自动休眠")))
{
CString str;
str=value.bstrVal; //从COleVariant 到CString
EditScene *scene = BaseApplication::getInstance()->mscene;
if (str == _T("允许"))
{
scene->bEnagleAutoSleep = true;
dWorldSetAutoDisableFlag (scene->mOdeWorld,scene->bEnagleAutoSleep);
}
else
{
BaseApplication::getInstance()->mscene->bEnagleAutoSleep = false;
dWorldSetAutoDisableFlag (scene->mOdeWorld,scene->bEnagleAutoSleep);
}
}
else if (PropName == CString(_T("X方向重力")))
{
EditScene *scene = BaseApplication::getInstance()->mscene;
float val = value.fltVal;
BaseApplication::getInstance()->mscene->gravity.x = val;
dWorldSetGravity (scene->mOdeWorld,scene->gravity.x,scene->gravity.y,scene->gravity.z);
}
else if (PropName == CString(_T("Y方向重力")))
{
EditScene *scene = BaseApplication::getInstance()->mscene;
float val = value.fltVal;
BaseApplication::getInstance()->mscene->gravity.y = val;
dWorldSetGravity (scene->mOdeWorld,scene->gravity.x,scene->gravity.y,scene->gravity.z);
}
else if (PropName == CString(_T("Z方向重力")))
{
EditScene *scene = BaseApplication::getInstance()->mscene;
float val = value.fltVal;
BaseApplication::getInstance()->mscene->gravity.z = val;
dWorldSetGravity (scene->mOdeWorld,scene->gravity.x,scene->gravity.y,scene->gravity.z);
}
else if (PropName == CString(_T("全局混合力")))
{
EditScene *scene = BaseApplication::getInstance()->mscene;
float val = value.fltVal;
scene->softCFM = val;
dWorldSetCFM(scene->mOdeWorld,scene->softCFM);
}
else if (PropName == CString(_T("模拟迭代步数")))
{
EditScene *scene = BaseApplication::getInstance()->mscene;
int val = value.intVal;
scene->QuicksetpNumIterations = val;
dWorldSetQuickStepNumIterations (scene->mOdeWorld, scene->QuicksetpNumIterations);
}
return 0;
}