00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "pandatoolbase.h"
00027
00028
00029 #include "maxEggLoader.h"
00030 #include "Max.h"
00031 #include "maxImportRes.h"
00032 #include "istdplug.h"
00033
00034
00035 #include "notifyCategoryProxy.h"
00036
00037 #include <iostream>
00038 #include <sstream>
00039
00040 class MaxEggImporter : public SceneImport
00041 {
00042 public:
00043
00044 MaxEggImporter();
00045 ~MaxEggImporter();
00046 int ExtCount();
00047 const TCHAR * Ext(int n);
00048 const TCHAR * LongDesc();
00049 const TCHAR * ShortDesc();
00050 const TCHAR * AuthorName();
00051 const TCHAR * CopyrightMessage();
00052 const TCHAR * OtherMessage1();
00053 const TCHAR * OtherMessage2();
00054 unsigned int Version();
00055 void ShowAbout(HWND hWnd);
00056 int DoImport(const TCHAR *name,ImpInterface *ei,Interface *i, BOOL suppressPrompts);
00057
00058 public:
00059
00060 static BOOL _merge;
00061 static BOOL _importmodel;
00062 static BOOL _importanim;
00063 };
00064
00065 BOOL MaxEggImporter::_merge = TRUE;
00066 BOOL MaxEggImporter::_importmodel = TRUE;
00067 BOOL MaxEggImporter::_importanim = FALSE;
00068
00069 MaxEggImporter::MaxEggImporter()
00070 {
00071 }
00072
00073 MaxEggImporter::~MaxEggImporter()
00074 {
00075 }
00076
00077 int MaxEggImporter::ExtCount()
00078 {
00079
00080 return 1;
00081 }
00082
00083 const TCHAR * MaxEggImporter::Ext(int n)
00084 {
00085
00086 switch(n) {
00087 case 0: return _T("egg");
00088 default: return _T("");
00089 }
00090 }
00091
00092 const TCHAR * MaxEggImporter::LongDesc()
00093 {
00094 return _T("Panda3D Egg Importer");
00095 }
00096
00097 const TCHAR * MaxEggImporter::ShortDesc()
00098 {
00099 return _T("Panda3D Egg");
00100 }
00101
00102 const TCHAR * MaxEggImporter::AuthorName()
00103 {
00104 return _T("Joshua Yelon");
00105 }
00106
00107 const TCHAR * MaxEggImporter::CopyrightMessage()
00108 {
00109 return _T("Copyight (c) 2005 Josh Yelon");
00110 }
00111
00112 const TCHAR * MaxEggImporter::OtherMessage1()
00113 {
00114 return _T("");
00115 }
00116
00117 const TCHAR * MaxEggImporter::OtherMessage2()
00118 {
00119 return _T("");
00120 }
00121
00122 unsigned int MaxEggImporter::Version()
00123 {
00124 return 100;
00125 }
00126
00127 static INT_PTR CALLBACK AboutBoxDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
00128 {
00129 switch (msg) {
00130 case WM_INITDIALOG:
00131 CenterWindow(hWnd, GetParent(hWnd));
00132 break;
00133 case WM_COMMAND:
00134 switch (LOWORD(wParam)) {
00135 case IDOK:
00136 EndDialog(hWnd, 1);
00137 break;
00138 }
00139 break;
00140 default:
00141 return FALSE;
00142 }
00143 return TRUE;
00144 }
00145
00146 void MaxEggImporter::ShowAbout(HWND hWnd)
00147 {
00148 DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_ABOUTBOX),
00149 hWnd, AboutBoxDlgProc, 0);
00150 }
00151
00152
00153 static INT_PTR CALLBACK ImportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
00154 {
00155 MaxEggImporter *imp = (MaxEggImporter*) GetWindowLongPtr(hWnd, GWLP_USERDATA);
00156 switch (msg) {
00157 case WM_INITDIALOG:
00158 imp = (MaxEggImporter*)lParam;
00159 SetWindowLongPtr(hWnd, GWLP_USERDATA, lParam);
00160 CenterWindow(hWnd, GetParent(hWnd));
00161 CheckDlgButton(hWnd, IDC_MERGE, imp->_merge);
00162 CheckDlgButton(hWnd, IDC_IMPORTMODEL, imp->_importmodel);
00163 CheckDlgButton(hWnd, IDC_IMPORTANIM, imp->_importanim);
00164 break;
00165 case WM_COMMAND:
00166 switch (LOWORD(wParam)) {
00167 case IDOK:
00168 imp->_merge = IsDlgButtonChecked(hWnd, IDC_MERGE);
00169 imp->_importmodel = IsDlgButtonChecked(hWnd, IDC_IMPORTMODEL);
00170 imp->_importanim = IsDlgButtonChecked(hWnd, IDC_IMPORTANIM);
00171 EndDialog(hWnd, 1);
00172 break;
00173 case IDCANCEL:
00174 EndDialog(hWnd, 0);
00175 break;
00176 }
00177 break;
00178 default:
00179 return FALSE;
00180 }
00181 return TRUE;
00182 }
00183
00184 int MaxEggImporter::DoImport(const TCHAR *name,ImpInterface *ii,Interface *i, BOOL suppressPrompts) {
00185
00186 if (!DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_IMPORT_DLG),
00187 i->GetMAXHWnd(), ImportDlgProc, (LPARAM)this)) {
00188 return 1;
00189 }
00190
00191 std::ostringstream log;
00192 Notify::ptr()->set_ostream_ptr(&log, false);
00193 bool ok = MaxLoadEggFile(name, _merge ? true:false, _importmodel ? true:false, _importanim ? true:false);
00194 string txt = log.str();
00195 if (txt != "") {
00196 MessageBox(NULL, txt.c_str(), "Panda3D Importer", MB_OK);
00197 } else {
00198 if (!ok) MessageBox(NULL, "Import Failed, unknown reason\n", "Panda3D Importer", MB_OK);
00199 }
00200 Notify::ptr()->set_ostream_ptr(NULL, false);
00201 return 1;
00202 }
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214 HINSTANCE hInstance;
00215
00216 BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved) {
00217 static int controlsInit = FALSE;
00218 hInstance = hinstDLL;
00219
00220 if (!controlsInit) {
00221 controlsInit = TRUE;
00222
00223
00224
00225 #if MAX_VERSION_MAJOR < 14
00226 InitCustomControls(hInstance);
00227 #endif
00228 InitCommonControls();
00229 }
00230
00231 return (TRUE);
00232 }
00233
00234 #define PANDAEGGIMP_CLASS_ID1 0x377193ab
00235 #define PANDAEGGIMP_CLASS_ID2 0x897afe12
00236
00237 class MaxEggImporterClassDesc: public ClassDesc {
00238 public:
00239 int IsPublic() {return 1;}
00240 void *Create(BOOL loading = FALSE) {return new MaxEggImporter;}
00241 const TCHAR *ClassName() {return _T("MaxEggImporter");}
00242 SClass_ID SuperClassID() {return SCENE_IMPORT_CLASS_ID;}
00243 Class_ID ClassID() {return Class_ID(PANDAEGGIMP_CLASS_ID1,PANDAEGGIMP_CLASS_ID2);}
00244 const TCHAR *Category() {return _T("Chrutilities");}
00245 };
00246
00247 static MaxEggImporterClassDesc MaxEggImporterDesc;
00248
00249 __declspec( dllexport ) const TCHAR* LibDescription()
00250 {
00251 return _T("Panda3D Egg Importer");
00252 }
00253
00254 __declspec( dllexport ) int LibNumberClasses()
00255 {
00256 return 1;
00257 }
00258
00259 __declspec( dllexport ) ClassDesc* LibClassDesc(int i)
00260 {
00261 switch(i) {
00262 case 0: return &MaxEggImporterDesc;
00263 default: return 0;
00264 }
00265 }
00266
00267 __declspec( dllexport ) ULONG LibVersion()
00268 {
00269 return VERSION_3DSMAX;
00270 }
00271