15 const double meshVerts[252][3] = {
16 {0.729464, -0.919852, 0.714986},
17 {0.466137, -0.594656, 0.160201},
18 {-0.265897, -1.14704, 0.714986},
19 {0.466137, -0.594656, 0.160201},
20 {-0.177333, -0.741523, 0.160201},
21 {-0.265897, -1.14704, 0.714986},
22 {-0.265897, -1.14704, 0.714986},
23 {-0.177333, -0.741523, 0.160201},
24 {-1.06411, -0.510479, 0.714986},
25 {-0.177333, -0.741523, 0.160201},
26 {-0.693356, -0.330009, 0.160201},
27 {-1.06411, -0.510479, 0.714986},
28 {-1.06411, 0.510479, 0.714986},
29 {-1.06411, -0.510479, 0.714986},
30 {-0.693356, 0.330009, 0.160201},
31 {-0.693356, -0.330009, 0.160201},
32 {-0.693356, 0.330009, 0.160201},
33 {-1.06411, -0.510479, 0.714986},
34 {-0.265897, 1.14704, 0.714986},
35 {-1.06411, 0.510479, 0.714986},
36 {-0.177333, 0.741523, 0.160201},
37 {-0.693356, 0.330009, 0.160201},
38 {-0.177333, 0.741523, 0.160201},
39 {-1.06411, 0.510479, 0.714986},
40 {0.729464, 0.919852, 0.714986},
41 {-0.265897, 1.14704, 0.714986},
42 {0.466137, 0.594656, 0.160201},
43 {-0.177333, 0.741523, 0.160201},
44 {0.466137, 0.594656, 0.160201},
45 {-0.265897, 1.14704, 0.714986},
46 {1.17244, 0.0, 0.714986},
47 {0.729464, 0.919852, 0.714986},
48 {0.752508, 0.0, 0.160201},
49 {0.466137, 0.594656, 0.160201},
50 {0.752508, 0.0, 0.160201},
51 {0.729464, 0.919852, 0.714986},
52 {0.729464, -0.919852, 0.714986},
53 {1.17244, 0.0, 0.714986},
54 {0.466137, -0.594656, 0.160201},
55 {0.752508, 0.0, 0.160201},
56 {0.466137, -0.594656, 0.160201},
57 {1.17244, 0.0, 0.714986},
58 {-0.286334, -1.26822, 1.44995},
59 {0.814187, -1.01703, 1.44995},
60 {-0.265897, -1.14704, 0.714986},
61 {0.729464, -0.919852, 0.714986},
62 {-0.265897, -1.14704, 0.714986},
63 {0.814187, -1.01703, 1.44995},
64 {-1.16888, -0.564412, 1.44995},
65 {-0.286334, -1.26822, 1.44995},
66 {-1.06411, -0.510479, 0.714986},
67 {-0.265897, -1.14704, 0.714986},
68 {-1.06411, -0.510479, 0.714986},
69 {-0.286334, -1.26822, 1.44995},
70 {-1.16888, 0.564411, 1.44995},
71 {-1.16888, -0.564412, 1.44995},
72 {-1.06411, 0.510479, 0.714986},
73 {-1.06411, -0.510479, 0.714986},
74 {-1.06411, 0.510479, 0.714986},
75 {-1.16888, -0.564412, 1.44995},
76 {-1.16888, 0.564411, 1.44995},
77 {-1.06411, 0.510479, 0.714986},
78 {-0.286334, 1.26822, 1.44995},
79 {-1.06411, 0.510479, 0.714986},
80 {-0.265897, 1.14704, 0.714986},
81 {-0.286334, 1.26822, 1.44995},
82 {-0.286334, 1.26822, 1.44995},
83 {-0.265897, 1.14704, 0.714986},
84 {0.814187, 1.01703, 1.44995},
85 {-0.265897, 1.14704, 0.714986},
86 {0.729464, 0.919852, 0.714986},
87 {0.814187, 1.01703, 1.44995},
88 {1.30396, 0.0, 1.44995},
89 {0.814187, 1.01703, 1.44995},
90 {1.17244, 0.0, 0.714986},
91 {0.729464, 0.919852, 0.714986},
92 {1.17244, 0.0, 0.714986},
93 {0.814187, 1.01703, 1.44995},
94 {1.30396, 0.0, 1.44995},
95 {1.17244, 0.0, 0.714986},
96 {0.814187, -1.01703, 1.44995},
97 {1.17244, 0.0, 0.714986},
98 {0.729464, -0.919852, 0.714986},
99 {0.814187, -1.01703, 1.44995},
100 {-0.286334, -1.26822, 1.44995},
101 {-0.227573, -1.05763, 2.16723},
102 {0.814187, -1.01703, 1.44995},
103 {0.814187, -1.01703, 1.44995},
104 {-0.227573, -1.05763, 2.16723},
105 {0.690208, -0.848157, 2.16723},
106 {-1.16888, -0.564412, 1.44995},
107 {-0.963577, -0.470692, 2.16723},
108 {-0.286334, -1.26822, 1.44995},
109 {-0.286334, -1.26822, 1.44995},
110 {-0.963577, -0.470692, 2.16723},
111 {-0.227573, -1.05763, 2.16723},
112 {-1.16888, -0.564412, 1.44995},
113 {-1.16888, 0.564411, 1.44995},
114 {-0.963577, -0.470692, 2.16723},
115 {-1.16888, 0.564411, 1.44995},
116 {-0.963577, 0.470692, 2.16723},
117 {-0.963577, -0.470692, 2.16723},
118 {-1.16888, 0.564411, 1.44995},
119 {-0.286334, 1.26822, 1.44995},
120 {-0.963577, 0.470692, 2.16723},
121 {-0.286334, 1.26822, 1.44995},
122 {-0.227574, 1.05763, 2.16723},
123 {-0.963577, 0.470692, 2.16723},
124 {-0.286334, 1.26822, 1.44995},
125 {0.814187, 1.01703, 1.44995},
126 {-0.227574, 1.05763, 2.16723},
127 {0.814187, 1.01703, 1.44995},
128 {0.690208, 0.848157, 2.16723},
129 {-0.227574, 1.05763, 2.16723},
130 {0.814187, 1.01703, 1.44995},
131 {1.30396, 0.0, 1.44995},
132 {0.690208, 0.848157, 2.16723},
133 {1.30396, 0.0, 1.44995},
134 {1.09866, 0.0, 2.16723},
135 {0.690208, 0.848157, 2.16723},
136 {0.814187, -1.01703, 1.44995},
137 {0.690208, -0.848157, 2.16723},
138 {1.30396, 0.0, 1.44995},
139 {1.30396, 0.0, 1.44995},
140 {0.690208, -0.848157, 2.16723},
141 {1.09866, 0.0, 2.16723},
142 {-0.227573, -1.05763, 2.16723},
143 {-0.154893, -0.759032, 2.72566},
144 {0.690208, -0.848157, 2.16723},
145 {0.690208, -0.848157, 2.16723},
146 {-0.154893, -0.759032, 2.72566},
147 {0.50377, -0.608696, 2.72566},
148 {-0.963577, -0.470692, 2.16723},
149 {-0.683099, -0.337801, 2.72566},
150 {-0.227573, -1.05763, 2.16723},
151 {-0.227573, -1.05763, 2.16723},
152 {-0.683099, -0.337801, 2.72566},
153 {-0.154893, -0.759032, 2.72566},
154 {-0.963577, -0.470692, 2.16723},
155 {-0.963577, 0.470692, 2.16723},
156 {-0.683099, -0.337801, 2.72566},
157 {-0.963577, 0.470692, 2.16723},
158 {-0.683099, 0.337801, 2.72566},
159 {-0.683099, -0.337801, 2.72566},
160 {-0.963577, 0.470692, 2.16723},
161 {-0.227574, 1.05763, 2.16723},
162 {-0.683099, 0.337801, 2.72566},
163 {-0.227574, 1.05763, 2.16723},
164 {-0.154893, 0.759032, 2.72566},
165 {-0.683099, 0.337801, 2.72566},
166 {-0.227574, 1.05763, 2.16723},
167 {0.690208, 0.848157, 2.16723},
168 {-0.154893, 0.759032, 2.72566},
169 {0.690208, 0.848157, 2.16723},
170 {0.50377, 0.608696, 2.72566},
171 {-0.154893, 0.759032, 2.72566},
172 {0.690208, 0.848157, 2.16723},
173 {1.09866, 0.0, 2.16723},
174 {0.50377, 0.608696, 2.72566},
175 {1.09866, 0.0, 2.16723},
176 {0.796903, 0.0, 2.72566},
177 {0.50377, 0.608696, 2.72566},
178 {1.09866, 0.0, 2.16723},
179 {0.690208, -0.848157, 2.16723},
180 {0.796903, 0.0, 2.72566},
181 {0.690208, -0.848157, 2.16723},
182 {0.50377, -0.608696, 2.72566},
183 {0.796903, 0.0, 2.72566},
184 {0.50377, -0.608696, 2.72566},
185 {-0.154893, -0.759032, 2.72566},
186 {0.259722, -0.299638, 3.11175},
187 {-0.154893, -0.759032, 2.72566},
188 {-0.0645132, -0.373643, 3.11175},
189 {0.259722, -0.299638, 3.11175},
190 {-0.154893, -0.759032, 2.72566},
191 {-0.683099, -0.337801, 2.72566},
192 {-0.0645132, -0.373643, 3.11175},
193 {-0.683099, -0.337801, 2.72566},
194 {-0.324529, -0.166287, 3.11175},
195 {-0.0645132, -0.373643, 3.11175},
196 {-0.683099, -0.337801, 2.72566},
197 {-0.683099, 0.337801, 2.72566},
198 {-0.324529, -0.166287, 3.11175},
199 {-0.683099, 0.337801, 2.72566},
200 {-0.324529, 0.166287, 3.11175},
201 {-0.324529, -0.166287, 3.11175},
202 {-0.683099, 0.337801, 2.72566},
203 {-0.154893, 0.759032, 2.72566},
204 {-0.324529, 0.166287, 3.11175},
205 {-0.154893, 0.759032, 2.72566},
206 {-0.0645132, 0.373642, 3.11175},
207 {-0.324529, 0.166287, 3.11175},
208 {-0.154893, 0.759032, 2.72566},
209 {0.50377, 0.608696, 2.72566},
210 {-0.0645132, 0.373642, 3.11175},
211 {0.50377, 0.608696, 2.72566},
212 {0.259722, 0.299638, 3.11175},
213 {-0.0645132, 0.373642, 3.11175},
214 {0.50377, 0.608696, 2.72566},
215 {0.796903, 0.0, 2.72566},
216 {0.259722, 0.299638, 3.11175},
217 {0.796903, 0.0, 2.72566},
218 {0.40402, 0.0, 3.11175},
219 {0.259722, 0.299638, 3.11175},
220 {0.796903, 0.0, 2.72566},
221 {0.50377, -0.608696, 2.72566},
222 {0.40402, 0.0, 3.11175},
223 {0.50377, -0.608696, 2.72566},
224 {0.259722, -0.299638, 3.11175},
225 {0.40402, 0.0, 3.11175},
226 {-0.177333, -0.741523, 0.160201},
227 {0.466137, -0.594656, 0.160201},
228 {-0.00334214, 0.0, 0.00443203},
229 {-0.693356, -0.330009, 0.160201},
230 {-0.177333, -0.741523, 0.160201},
231 {-0.00334214, 0.0, 0.00443203},
232 {-0.693356, 0.330009, 0.160201},
233 {-0.693356, -0.330009, 0.160201},
234 {-0.00334214, 0.0, 0.00443203},
235 {-0.177333, 0.741523, 0.160201},
236 {-0.693356, 0.330009, 0.160201},
237 {-0.00334214, 0.0, 0.00443203},
238 {0.466137, 0.594656, 0.160201},
239 {-0.177333, 0.741523, 0.160201},
240 {-0.00334214, 0.0, 0.00443203},
241 {0.752508, 0.0, 0.160201},
242 {0.466137, 0.594656, 0.160201},
243 {-0.00334214, 0.0, 0.00443203},
244 {0.466137, -0.594656, 0.160201},
245 {0.752508, 0.0, 0.160201},
246 {-0.00334214, 0.0, 0.00443203},
247 {0.259722, -0.299638, 3.11175},
248 {-0.0645132, -0.373643, 3.11175},
249 {0.0207683, 0.0, 3.20912},
250 {-0.0645132, -0.373643, 3.11175},
251 {-0.324529, -0.166287, 3.11175},
252 {0.0207683, 0.0, 3.20912},
253 {-0.324529, -0.166287, 3.11175},
254 {-0.324529, 0.166287, 3.11175},
255 {0.0207683, 0.0, 3.20912},
256 {-0.324529, 0.166287, 3.11175},
257 {-0.0645132, 0.373642, 3.11175},
258 {0.0207683, 0.0, 3.20912},
259 {-0.0645132, 0.373642, 3.11175},
260 {0.259722, 0.299638, 3.11175},
261 {0.0207683, 0.0, 3.20912},
262 {0.259722, 0.299638, 3.11175},
263 {0.40402, 0.0, 3.11175},
264 {0.0207683, 0.0, 3.20912},
265 {0.40402, 0.0, 3.11175},
266 {0.259722, -0.299638, 3.11175},
267 {0.0207683, 0.0, 3.20912}
272 #pragma warning(disable: 4800) 278 class MaxEggPluginClassDesc :
public ClassDesc
281 int IsPublic() {
return TRUE; }
282 void *Create(BOOL loading = FALSE) {
return new MaxEggPlugin(); }
283 const TCHAR *ClassName() {
return GetString(IDS_CLASS_NAME); }
284 SClass_ID SuperClassID() {
return HELPER_CLASS_ID; }
285 Class_ID ClassID() {
return MaxEggPlugin_CLASS_ID; }
286 const TCHAR *Category() {
return GetString(IDS_CATEGORY); }
288 const TCHAR *
InternalName() {
return _T(
"MaxEggPlugin"); }
292 static MaxEggPluginClassDesc MaxEggPluginDesc;
295 ClassDesc* GetMaxEggPluginDesc() {
return &MaxEggPluginDesc; }
298 Mesh MaxEggPlugin::mesh;
299 short MaxEggPlugin::meshBuilt=0;
300 HWND MaxEggPlugin::hMaxEggParams =
nullptr;
301 IObjParam *MaxEggPlugin::iObjParams;
307 INT_PTR CALLBACK MaxEggPluginOptionsDlgProc( HWND hWnd, UINT message,
308 WPARAM wParam, LPARAM lParam )
316 if ( !imp && message != WM_INITDIALOG )
return FALSE;
323 SetWindowLongPtr(hWnd,GWLP_USERDATA,lParam);
324 SetDlgFont( hWnd, imp->iObjParams->GetAppHFont() );
325 MaxEggPlugin::hMaxEggParams = hWnd;
328 case WM_MOUSEACTIVATE:
329 imp->iObjParams->RealizeParamPanel();
335 imp->iObjParams->RollupMouseMessage(hWnd,message,wParam,lParam);
341 switch( LOWORD(wParam) ) {
342 case IDC_OVERWRITE_CHECK:
344 (IsDlgButtonChecked(hWnd, IDC_OVERWRITE_CHECK) == BST_CHECKED);
346 case IDC_PVIEW_CHECK:
348 (IsDlgButtonChecked(hWnd, IDC_PVIEW_CHECK) == BST_CHECKED);
352 (IsDlgButtonChecked(hWnd, IDC_LOGGING) == BST_CHECKED);
356 tempEgg->SetMaxInterface(imp->iObjParams);
357 tempEgg->SetAnimRange();
358 res = DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_EGG_DETAILS),
359 hWnd, MaxOptionsDialogProc, (LPARAM)tempEgg);
361 imp->SaveCheckState();
362 imp->AddEgg(tempEgg);
368 sel = ListView_GetSelectionMark(GetDlgItem(hWnd, IDC_LIST_EGGS));
372 tempEgg->SetAnimRange();
373 tempEgg->CullBadNodes();
374 DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_EGG_DETAILS),
375 hWnd, MaxOptionsDialogProc, (LPARAM)tempEgg);
377 imp->SaveCheckState();
382 sel = ListView_GetSelectionMark(GetDlgItem(hWnd, IDC_LIST_EGGS));
384 imp->SaveCheckState();
397 MaxEggPlugin::MaxEggPlugin() :
398 autoOverwrite(false), pview(true), logOutput(false), numEggs(0), maxEggs(5)
404 MaxEggPlugin::~MaxEggPlugin() {
405 for (
int i = 0; i < numEggs; i++)
delete eggList[i];
410 if (numEggs >= maxEggs) {
414 for (
int i = 0; i < numEggs; i++) newList[i] = eggList[i];
419 eggList[numEggs++] = newEgg;
422 void MaxEggPlugin::RemoveEgg(
int i) {
423 if (i >= 0 && i < numEggs) {
425 for (
int j = i+1; j < numEggs;) eggList[i++] = eggList[j++];
430 void MaxEggPlugin::BeginEditParams( IObjParam *ip, ULONG flags,Animatable *prev )
433 for (
int i=0; i<numEggs; i++) {
434 eggList[i]->SetMaxInterface(ip);
437 if ( !hMaxEggParams ) {
438 hMaxEggParams = ip->AddRollupPage(hInstance,
439 MAKEINTRESOURCE(IDD_PANEL),
440 MaxEggPluginOptionsDlgProc,
441 GetString(IDS_PARAMS),
443 ip->RegisterDlgWnd(hMaxEggParams);
445 SetWindowLongPtr( hMaxEggParams, GWLP_USERDATA, (LPARAM)
this );
451 void MaxEggPlugin::EndEditParams( IObjParam *ip, ULONG flags,Animatable *prev)
454 if ( flags&END_EDIT_REMOVEUI ) {
455 ip->UnRegisterDlgWnd(hMaxEggParams);
456 ip->DeleteRollupPage(hMaxEggParams);
457 hMaxEggParams =
nullptr;
459 SetWindowLongPtr( hMaxEggParams, GWLP_USERDATA, 0L );
463 void MaxEggPlugin::SaveCheckState() {
464 if (!hMaxEggParams)
return;
465 HWND lv = GetDlgItem(hMaxEggParams, IDC_LIST_EGGS);
466 for (
int i = 0; i < numEggs; i++)
467 eggList[i]->_checked = ListView_GetCheckState(lv, i);
470 void MaxEggPlugin::UpdateUI() {
471 HWND lv = GetDlgItem(hMaxEggParams, IDC_LIST_EGGS);
474 if (ListView_GetColumnWidth(lv, 1) <= 0 || ListView_GetColumnWidth(lv, 1) > 10000) {
476 ListView_SetExtendedListViewStyleEx(lv, LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT,
477 LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT);
479 pCol.fmt = LVCFMT_LEFT;
481 pCol.pszText = _T(
"Filename");
482 pCol.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
484 ListView_InsertColumn(lv, 0, &pCol);
487 pCol.pszText = _T(
"Type");
488 ListView_InsertColumn(lv, 1, &pCol);
492 ListView_DeleteAllItems(lv);
494 Item.mask = LVIF_TEXT;
496 for (
int i = 0; i < numEggs; i++) {
499 Item.pszText = eggList[i]->_short_name;
500 ListView_InsertItem(lv, &Item);
502 switch(eggList[i]->_anim_type) {
503 case MaxEggOptions::AT_chan: Item.pszText = _T(
"Animation");
break;
504 case MaxEggOptions::AT_both: Item.pszText = _T(
"Both");
break;
505 case MaxEggOptions::AT_pose: Item.pszText = _T(
"Static");
break;
506 case MaxEggOptions::AT_model: Item.pszText = _T(
"Model");
break;
507 default: Item.pszText = _T(
"Model");
break;
509 ListView_SetItem(lv, &Item);
510 ListView_SetCheckState(lv, i, eggList[i]->_checked);
514 CheckDlgButton(hMaxEggParams, IDC_OVERWRITE_CHECK,
515 autoOverwrite ? BST_CHECKED : BST_UNCHECKED);
516 CheckDlgButton(hMaxEggParams, IDC_PVIEW_CHECK,
517 pview ? BST_CHECKED : BST_UNCHECKED);
518 CheckDlgButton(hMaxEggParams, IDC_LOGGING,
519 logOutput ? BST_CHECKED : BST_UNCHECKED);
522 void MaxEggPlugin::DoExport() {
523 int good = 0, bad = 0;
525 std::basic_stringstream<TCHAR> status;
529 for (
int i = 0; i < numEggs; i++) {
530 if (eggList[i]->_checked) {
533 bool do_write =
true;
535 if (!autoOverwrite && GetFileAttributes(eggList[i]->_file_name) != INVALID_FILE_ATTRIBUTES) {
537 _stprintf(msg, _T(
"Overwrite file \"%s.egg\"?"), eggList[i]->_short_name);
538 do_write = (MessageBox(hMaxEggParams, msg, _T(
"Panda3D Exporter"), MB_YESNO | MB_ICONQUESTION) == IDYES);
544 status << _T(
"Successfully created ") << eggList[i]->_short_name << _T(
".egg\n");
547 status << _T(
"Could not export ") << eggList[i]->_short_name << _T(
".egg\n");
551 status << _T(
"Skipped file ") << eggList[i]->_short_name << _T(
".egg\n");
558 if (good == 0 && bad == 0) {
559 mask |= MB_ICONEXCLAMATION;
560 MessageBox(hMaxEggParams, _T(
"Nothing to export!"), _T(
"Panda3D Export results"), mask);
562 if (bad > 0) mask |= MB_ICONEXCLAMATION;
563 else mask |= MB_ICONINFORMATION;
564 MessageBox(hMaxEggParams, status.str().c_str(), _T(
"Panda3D Export results"), mask);
568 if (pview && good > 0) {
569 for (i = 0; i < numEggs; i++) {
570 if (eggList[i]->_checked && eggList[i]->_successful) {
571 if (eggList[i]->_anim_type != MaxEggOptions::AT_chan) {
572 PROCESS_INFORMATION pi;
575 memset(&si, 0,
sizeof(si));
581 if (numEggs == 2 && eggList[i]->_anim_type == MaxEggOptions::AT_model &&
582 eggList[1-i]->_checked && eggList[1-i]->_successful &&
583 eggList[1-i]->_anim_type == MaxEggOptions::AT_chan) {
584 _stprintf(cmdLine, _T(
"pview \"%s\" \"%s\""), eggList[i]->_file_name, eggList[1-i]->_file_name);
586 _stprintf(cmdLine, _T(
"pview \"%s\""), eggList[i]->_file_name);
588 CreateProcess(
nullptr, cmdLine,
nullptr,
nullptr, FALSE, CREATE_NEW_CONSOLE,
589 nullptr,
nullptr, &si, &pi);
598 void MaxEggPlugin::BuildMesh()
601 if(meshBuilt)
return;
603 mesh.setNumVerts(252);
604 mesh.setNumFaces(84);
605 mesh.setSmoothFlags(0);
606 mesh.setNumTVerts (0);
607 mesh.setNumTVFaces (0);
609 for (i=0; i<252; i++)
610 mesh.setVert(i, meshVerts[i][0]*10, meshVerts[i][1]*10, meshVerts[i][2]*10);
611 for (i=0; i<84; i++) {
612 mesh.faces[i].setEdgeVisFlags(1, 1, 0);
613 mesh.faces[i].setSmGroup(0);
614 mesh.faces[i].setVerts(i*3, i*3+1, i*3+2);
617 mesh.InvalidateGeomCache();
618 mesh.BuildStripsAndEdges();
626 class MaxEggPluginCreateMouseCallBack:
public CreateMouseCallBack
629 int proc( ViewExp *vpt,
int msg,
int point,
int flags, IPoint2 m, Matrix3& mat );
632 int MaxEggPluginCreateMouseCallBack::proc(ViewExp *vpt,
int msg,
int point,
int flags, IPoint2 m, Matrix3& mat )
634 if (msg==MOUSE_POINT||msg==MOUSE_MOVE) {
637 mat.SetTrans(vpt->SnapPoint(m,m,
nullptr,SNAP_IN_PLANE));
640 mat.SetTrans(vpt->SnapPoint(m,m,
nullptr,SNAP_IN_PLANE));
641 if (msg==MOUSE_POINT)
return CREATE_STOP;
644 }
else if (msg == MOUSE_ABORT) {
647 return CREATE_CONTINUE;
650 static MaxEggPluginCreateMouseCallBack MaxEggCreateMouseCB;
652 CreateMouseCallBack* MaxEggPlugin::GetCreateMouseCallBack()
653 {
return &MaxEggCreateMouseCB; }
657 void MaxEggPlugin::GetMat(TimeValue t, INode* inode, ViewExp* vpt, Matrix3& tm)
659 tm = inode->GetObjectTM(t);
661 PN_stdfloat scaleFactor = vpt->NonScalingObjectSize()*vpt->GetVPWorldWidth(tm.GetTrans())/(PN_stdfloat)360.0;
662 tm.Scale(Point3(scaleFactor,scaleFactor,scaleFactor));
665 void MaxEggPlugin::GetDeformBBox(TimeValue t, Box3& box, Matrix3 *tm, BOOL useSel )
667 box = mesh.getBoundingBox(tm);
670 void MaxEggPlugin::GetLocalBoundBox(TimeValue t, INode* inode, ViewExp* vpt, Box3& box )
672 Matrix3 m = inode->GetObjectTM(t);
675 PN_stdfloat scaleFactor = vpt->GetVPWorldWidth(m.GetTrans())/360.0f;
676 box = mesh.getBoundingBox();
677 box.Scale(scaleFactor);
680 void MaxEggPlugin::GetWorldBoundBox(TimeValue t, INode* inode, ViewExp* vpt, Box3& box )
682 int i, nv; Matrix3 tm; Point3 pt;
683 GetMat(t,inode,vpt,tm);
684 nv = mesh.getNumVerts();
687 box += tm*mesh.getVert(i);
690 int MaxEggPlugin::HitTest(TimeValue t, INode *inode,
int type,
int crossing,
int flags, IPoint2 *p, ViewExp *vpt)
697 MakeHitRegion(hitRegion,type,crossing,4,p);
698 gw->setRndLimits(((savedLimits = gw->getRndLimits()) | GW_PICK) & ~GW_ILLUM);
699 GetMat(t,inode,vpt,m);
702 if (mesh.select( gw, mtl, &hitRegion, flags & HIT_ABORTONHIT ))
707 int MaxEggPlugin::Display(TimeValue t, INode* inode, ViewExp *vpt,
int flags)
713 GetMat(t,inode,vpt,m);
715 DWORD rlim = gw->getRndLimits();
716 gw->setRndLimits(GW_WIREFRAME|GW_BACKCULL);
717 if (inode->Selected())
718 gw->setColor( LINE_COLOR, GetSelColor());
719 else if(!inode->IsFrozen())
720 gw->setColor( LINE_COLOR, GetUIColor(COLOR_TAPE_OBJ));
721 mesh.render( gw, mtl,
nullptr, COMP_ALL);
725 RefResult MaxEggPlugin::NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message )
731 ObjectState MaxEggPlugin::Eval(TimeValue time)
733 return ObjectState(
this);
736 Interval MaxEggPlugin::ObjectValidity(TimeValue t)
739 ivalid.SetInfinite();
743 RefTargetHandle MaxEggPlugin::Clone(RemapDir& remap)
751 IOResult MaxEggPlugin::Save(ISave *isave) {
753 for (
int i = 0; i < numEggs; i++)
754 eggList[i]->Save(isave);
755 ChunkSave(isave, CHUNK_OVERWRITE_FLAG, autoOverwrite);
756 ChunkSave(isave, CHUNK_PVIEW_FLAG, pview);
757 ChunkSave(isave, CHUNK_LOG_OUTPUT, logOutput);
762 IOResult MaxEggPlugin::Load(ILoad *iload) {
763 IOResult res = iload->OpenChunk();
766 while (res == IO_OK) {
767 switch(iload->CurChunkID()) {
768 case CHUNK_OVERWRITE_FLAG: autoOverwrite = ChunkLoadBool(iload);
break;
769 case CHUNK_PVIEW_FLAG: pview = ChunkLoadBool(iload);
break;
770 case CHUNK_LOG_OUTPUT: logOutput = ChunkLoadBool(iload);
break;
771 case CHUNK_EGG_EXP_OPTIONS:
773 temp->SetMaxInterface(iObjParams);
779 res = iload->OpenChunk();
791 extern ClassDesc* GetMaxEggPluginDesc();
794 int controlsInit = FALSE;
802 BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved)
804 hInstance = hinstDLL;
809 #if MAX_VERSION_MAJOR < 14 813 InitCustomControls(hInstance);
815 InitCommonControls();
823 __declspec( dllexport )
const TCHAR* LibDescription()
825 return GetString(IDS_LIBDESCRIPTION);
830 __declspec( dllexport )
int LibNumberClasses()
837 __declspec( dllexport ) ClassDesc* LibClassDesc(
int i)
840 case 0:
return GetMaxEggPluginDesc();
841 default:
return nullptr;
848 __declspec( dllexport ) ULONG LibVersion()
850 return VERSION_3DSMAX;
853 TCHAR *GetString(
int id)
855 static TCHAR buf[256];
858 return LoadString(hInstance,
id, buf,
sizeof(buf)) ? buf :
nullptr;
bool convert(MaxEggOptions *options)
Fills up the egg_data structure according to the global Max model data.
A window, fullscreen or on a desktop, into which a graphics device sends its output for interactive d...
Defines the way an object appears in the presence of lighting.
Encodes a string name in a hash table, mapping it to a pointer.
This class supervises the construction of an EggData structure from a Max model.