From 357fc73101b4465a3d6f2ef2c609ee7c2e3f257c Mon Sep 17 00:00:00 2001 From: Mike Christel Date: Wed, 29 Jul 2009 12:41:21 +0000 Subject: [PATCH] Fixed vertex color, animation hierarchy, texture swapping bugs; added collision choices to exporter --- pandatool/src/maxegg/maxEgg.rc | 186 +++++++++++---------- pandatool/src/maxegg/maxNodeTree.cxx | 21 +++ pandatool/src/maxegg/maxNodeTree.h | 5 + pandatool/src/maxegg/maxOptionsDialog.cxx | 164 ++++++++++++++++++ pandatool/src/maxegg/maxOptionsDialog.h | 33 +++- pandatool/src/maxegg/maxResource.h | 20 ++- pandatool/src/maxegg/maxToEggConverter.cxx | 76 +++++++-- pandatool/src/maxegg/maxToEggConverter.h | 1 + 8 files changed, 400 insertions(+), 106 deletions(-) diff --git a/pandatool/src/maxegg/maxEgg.rc b/pandatool/src/maxegg/maxEgg.rc index 590a91ef31..d7b27e2d96 100755 --- a/pandatool/src/maxegg/maxEgg.rc +++ b/pandatool/src/maxegg/maxEgg.rc @@ -13,11 +13,11 @@ #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources +// Neutral resources -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU) #ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL #pragma code_page(1252) #endif //_WIN32 @@ -26,112 +26,64 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // Dialog // -IDD_PANEL DIALOGEX 0, 0, 109, 192 -STYLE DS_SETFONT | WS_CHILD | WS_VISIBLE -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - CTEXT "Panda 3D EGG Exporter",IDC_PANEL_TITLE,6,6,96,11,WS_BORDER - LTEXT "Eggs",IDC_EGGS_LABEL,6,19,62,8 - CONTROL "Custom1",IDC_LIST_EGGS,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | WS_TABSTOP,6,28,96,69,WS_EX_CLIENTEDGE - CONTROL "Add...",IDC_ADD_EGG,"CustButton",WS_TABSTOP,6,102,24,12 - CONTROL "Edit...",IDC_EDIT_EGG,"CustButton",WS_TABSTOP,36,102,30,12 - CONTROL "Remove",IDC_REMOVE_EGG,"CustButton",WS_TABSTOP,72,102,30,12 - CONTROL "Overwrite Existing Files",IDC_OVERWRITE_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,126,103,8,WS_EX_TRANSPARENT - CONTROL "Export Now",IDC_EXPORT,"CustButton",WS_TABSTOP,5,164,96,18 - CONTROL "Pview Output",IDC_PVIEW_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,138,103,8,WS_EX_TRANSPARENT - CONTROL "Log Output",IDC_LOGGING,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,148,90,11 -END - -IDD_EGG_DETAILS DIALOGEX 0, 0, 256, 169 +IDD_EGG_DETAILS DIALOGEX 0, 0, 256, 266 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Export Settings" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - LTEXT "Animation Type:",IDC_STATIC,6,5,54,8 - CONTROL "Model",IDC_MODEL,"Button",BS_AUTORADIOBUTTON,65,4,38,12 - CONTROL "Animation",IDC_ANIMATION,"Button",BS_AUTORADIOBUTTON,108,4,50,12 - CONTROL "Both",IDC_BOTH,"Button",BS_AUTORADIOBUTTON,164,4,35,12 - CONTROL "Static",IDC_POSE,"Button",BS_AUTORADIOBUTTON,206,4,38,12 - GROUPBOX "Options",IDC_STATIC,6,18,246,126,WS_GROUP - LTEXT "Filename",IDC_STATIC,12,30,66,8 + LTEXT "Animation Type:",IDC_STATIC,6,5,54,8,NOT WS_GROUP + CONTROL "Model",IDC_MODEL,"Button",BS_AUTORADIOBUTTON | BS_LEFT,65,4,38,12 + CONTROL "Animation",IDC_ANIMATION,"Button",BS_AUTORADIOBUTTON | BS_LEFT,108,4,50,12 + CONTROL "Both",IDC_BOTH,"Button",BS_AUTORADIOBUTTON | BS_LEFT,164,4,35,12 + CONTROL "Static",IDC_POSE,"Button",BS_AUTORADIOBUTTON | BS_LEFT,206,4,38,12 + GROUPBOX "Options",IDC_STATIC,5,17,246,230,WS_GROUP + LTEXT "Filename",IDC_STATIC,12,30,66,8,NOT WS_GROUP CONTROL "Custom1",IDC_FILENAME,"CustEdit",WS_TABSTOP,12,42,180,12 CONTROL "Browse...",IDC_BROWSE,"CustButton",WS_TABSTOP,198,42,48,12 - CONTROL "Export Entire Scene",IDC_EXPORT_ALL,"Button",BS_AUTORADIOBUTTON | WS_GROUP,12,60,114,8 - CONTROL "Export Meshes:",IDC_EXPORT_SELECTED,"Button",BS_AUTORADIOBUTTON,12,71,114,8 + CONTROL "Export Entire Scene",IDC_EXPORT_ALL,"Button",BS_AUTORADIOBUTTON | BS_LEFT | WS_GROUP,12,60,114,8 + CONTROL "Export Meshes:",IDC_EXPORT_SELECTED,"Button",BS_AUTORADIOBUTTON | BS_LEFT,12,71,114,8 LISTBOX IDC_LIST_EXPORT,12,84,114,36,LBS_SORT | LBS_NOINTEGRALHEIGHT | LBS_NOSEL | WS_VSCROLL | WS_TABSTOP CONTROL "Add...",IDC_ADD_EXPORT,"CustButton",WS_TABSTOP,12,126,54,12 CONTROL "Remove...",IDC_REMOVE_EXPORT,"CustButton",WS_TABSTOP,72,126,54,12 - CONTROL "Export All Frames",IDC_EXP_ALL_FRAMES,"Button",BS_AUTORADIOBUTTON | WS_GROUP,144,60,96,8 - CONTROL "Use Range:",IDC_EXP_SEL_FRAMES,"Button",BS_AUTORADIOBUTTON | BS_VCENTER,144,70,102,11 - LTEXT "Start Frame",IDC_SF_LABEL,144,86,42,8,WS_DISABLED - CONTROL "Custom4",IDC_SF,"CustEdit",WS_DISABLED | WS_TABSTOP,186,84,48,12 - LTEXT "End Frame",IDC_EF_LABEL,144,103,42,8,WS_DISABLED - CONTROL "Custom5",IDC_EF,"CustEdit",WS_DISABLED | WS_TABSTOP,186,101,48,12 - CONTROL "Double-sided Polygons",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,144,126,102,12 - CONTROL "OK",IDC_OK,"CustButton",WS_TABSTOP,162,150,42,12 - CONTROL "Cancel",IDC_CANCEL,"CustButton",WS_TABSTOP,210,150,42,12 + CONTROL "Export All Frames",IDC_EXP_ALL_FRAMES,"Button",BS_AUTORADIOBUTTON | BS_LEFT | WS_GROUP,144,60,96,8 + CONTROL "Use Range:",IDC_EXP_SEL_FRAMES,"Button",BS_AUTORADIOBUTTON | BS_LEFT | BS_VCENTER,144,71,102,8 + LTEXT "Start Frame",IDC_SF_LABEL,144,90,42,8,WS_DISABLED | NOT WS_GROUP + CONTROL "Custom4",IDC_SF,"CustEdit",WS_DISABLED | WS_TABSTOP,186,87,48,12 + LTEXT "End Frame",IDC_EF_LABEL,143,104,42,8,WS_DISABLED | NOT WS_GROUP + CONTROL "Custom5",IDC_EF,"CustEdit",WS_DISABLED | WS_TABSTOP,186,102,48,12 + CONTROL "Double-sided Polygons",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,144,126,102,12 + CONTROL "OK",IDC_OK,"CustButton",WS_TABSTOP,163,250,42,12 + CONTROL "Cancel",IDC_CANCEL,"CustButton",WS_TABSTOP,209,250,42,12 + CONTROL "Add Collision",IDC_COLLISION,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,15,146,52,10 + LTEXT "Collision Solid Type",IDC_STATIC,16,159,66,8,NOT WS_GROUP + LTEXT "Collide Flags",IDC_STATIC,16,200,66,8,NOT WS_GROUP + CONTROL "Plane",IDC_PLANE,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,75,170,50,10 + CONTROL "Sphere",IDC_SPHERE,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,129,170,50,10 + CONTROL "Polygon",IDC_POLYGON,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,183,170,50,10 + CONTROL "PolySet",IDC_POLYSET,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,21,170,50,9 + CONTROL "Tube",IDC_TUBE,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,21,183,50,10 + CONTROL "Inv-sphere",IDC_INSPHERE,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,75,183,50,10 + CONTROL "FloorMesh",IDC_FLOORMESH,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,129,183,50,10 + CONTROL "Descend",IDC_DESCEND,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,21,211,50,10 + CONTROL "Keep",IDC_KEEP,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,75,211,50,10 + CONTROL "Event",IDC_EVENT,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,129,211,50,10 + CONTROL "Solid",IDC_SOLID,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,183,211,50,10 + CONTROL "Center",IDC_CENTER,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,21,225,50,10 + CONTROL "Turnstile",IDC_TURNSTILE,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,183,225,50,10 + CONTROL "Level",IDC_LEVEL,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,129,225,50,10 + CONTROL "Intangible",IDC_INTANGIBLE,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,75,225,50,10 END -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_PANEL, DIALOG - BEGIN - BOTTOMMARGIN, 182 - END - - IDD_EGG_DETAILS, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 249 - TOPMARGIN, 7 - BOTTOMMARGIN, 162 - END -END -#endif // APSTUDIO_INVOKED - - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - ///////////////////////////////////////////////////////////////////////////// // // Version // -VS_VERSION_INFO VERSIONINFO +1 VERSIONINFO FILEVERSION 3,0,0,0 PRODUCTVERSION 3,0,0,0 - FILEFLAGSMASK 0x3fL + FILEFLAGSMASK 0x0L #ifdef _DEBUG FILEFLAGS 0x1L #else @@ -161,6 +113,60 @@ BEGIN END END +#endif // Neutral resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_PANEL DIALOGEX 0, 0, 109, 192 +STYLE DS_SETFONT | WS_POPUP | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_SYSMENU +FONT 8, "MS Sans Serif", 0, 0, 0x1 +BEGIN + CTEXT "Panda 3D EGG Exporter",IDC_PANEL_TITLE,6,6,96,11,WS_BORDER | NOT WS_GROUP + LTEXT "Eggs",IDC_EGGS_LABEL,6,19,62,8,NOT WS_GROUP + CONTROL "Custom1",IDC_LIST_EGGS,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | WS_TABSTOP,6,28,96,69,WS_EX_CLIENTEDGE + CONTROL "Add...",IDC_ADD_EGG,"CustButton",WS_TABSTOP,6,102,24,12 + CONTROL "Edit...",IDC_EDIT_EGG,"CustButton",WS_TABSTOP,36,102,30,12 + CONTROL "Remove",IDC_REMOVE_EGG,"CustButton",WS_TABSTOP,72,102,30,12 + CONTROL "Overwrite Existing Files",IDC_OVERWRITE_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,126,103,8,WS_EX_TRANSPARENT + CONTROL "Export Now",IDC_EXPORT,"CustButton",WS_TABSTOP,5,164,96,18 + CONTROL "Pview Output",IDC_PVIEW_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,138,103,8,WS_EX_TRANSPARENT + CONTROL "Log Output",IDC_LOGGING,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,148,90,11 +END + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.\0" +END + + +3 TEXTINCLUDE +BEGIN + "\r\0" +END + +#endif // APSTUDIO_INVOKED + ///////////////////////////////////////////////////////////////////////////// // diff --git a/pandatool/src/maxegg/maxNodeTree.cxx b/pandatool/src/maxegg/maxNodeTree.cxx index 455b31b93d..daa0e661ee 100755 --- a/pandatool/src/maxegg/maxNodeTree.cxx +++ b/pandatool/src/maxegg/maxNodeTree.cxx @@ -24,6 +24,10 @@ MaxNodeTree:: MaxNodeTree() { _root = new MaxNodeDesc; _fps = 0.0; + _has_collision = false; + _export_mesh = false; + _cs_type = EggGroup::CST_none; + _cf_type = EggGroup::CF_none; _egg_data = (EggData *)NULL; _egg_root = (EggGroupNode *)NULL; _skeleton_node = (EggGroupNode *)NULL; @@ -174,10 +178,27 @@ get_egg_group(MaxNodeDesc *node_desc) { if (node_desc->_parent == _root) { // The parent is the root. + // Set collision properties for the root if it has them: + if(_has_collision && !_export_mesh) + { + egg_group->set_collision_name(node_desc->get_name()); + egg_group->set_cs_type(_cs_type); + egg_group->set_collide_flags(_cf_type); + } _egg_root->add_child(egg_group); } else { // The parent is another node. + // if export mesh, the tag should be added at the second level + if(_has_collision && _export_mesh) + { + if(node_desc->_parent->_parent == _root) + { + egg_group->set_collision_name(node_desc->get_name()); + egg_group->set_cs_type(_cs_type); + egg_group->set_collide_flags(_cf_type); + } + } EggGroup *parent_egg_group = get_egg_group(node_desc->_parent); parent_egg_group->add_child(egg_group); } diff --git a/pandatool/src/maxegg/maxNodeTree.h b/pandatool/src/maxegg/maxNodeTree.h index 9b455dfe40..63f087f99a 100755 --- a/pandatool/src/maxegg/maxNodeTree.h +++ b/pandatool/src/maxegg/maxNodeTree.h @@ -44,6 +44,11 @@ public: MaxNodeDesc* _root; float _fps; + // the flag for the setting up collision + bool _has_collision; + EggGroup::CollideFlags _cf_type; + EggGroup::CollisionSolidType _cs_type; + bool _export_mesh; private: EggData *_egg_data; diff --git a/pandatool/src/maxegg/maxOptionsDialog.cxx b/pandatool/src/maxegg/maxOptionsDialog.cxx index 8459a06538..dfe2833436 100644 --- a/pandatool/src/maxegg/maxOptionsDialog.cxx +++ b/pandatool/src/maxegg/maxOptionsDialog.cxx @@ -232,6 +232,11 @@ MaxEggOptions::MaxEggOptions() { _start_frame = INT_MIN; _end_frame = INT_MIN; _double_sided = false; + // initialize newly added collision options, too + _add_collision = false; + _cs_type = CS_none; + _cf_type = CF_none; + _file_name[0]=0; _short_name[0]=0; _path_replace = new PathReplace; @@ -398,6 +403,90 @@ INT_PTR CALLBACK MaxOptionsDialogProc( HWND hWnd, UINT message, WPARAM wParam, L "Panda3D Exporter", MB_YESNO | MB_ICONQUESTION) != IDYES) CheckDlgButton(hWnd, IDC_CHECK1, BST_UNCHECKED); return TRUE; break; + // add IDC_COLLISION and related: + case IDC_COLLISION: + if(IsDlgButtonChecked(hWnd,IDC_COLLISION)) + if(MessageBox(hWnd, "Exporting the egg with collision tag in it? Some choices may hurt performance in Panda3D","Panda3D Exporter", + MB_YESNO | MB_ICONQUESTION) != IDYES) + CheckDlgButton(hWnd,IDC_COLLISION, BST_UNCHECKED); + return TRUE; break; + case IDC_PLANE: + if(IsDlgButtonChecked(hWnd,IDC_PLANE)) + { + CheckDlgButton(hWnd,IDC_SPHERE, BST_UNCHECKED); + CheckDlgButton(hWnd,IDC_POLYSET, BST_UNCHECKED); + CheckDlgButton(hWnd,IDC_POLYGON, BST_UNCHECKED); + CheckDlgButton(hWnd,IDC_TUBE, BST_UNCHECKED); + CheckDlgButton(hWnd,IDC_INSPHERE, BST_UNCHECKED); + CheckDlgButton(hWnd,IDC_FLOORMESH, BST_UNCHECKED); + } + return TRUE; break; + case IDC_SPHERE: + if(IsDlgButtonChecked(hWnd,IDC_SPHERE)) + { + CheckDlgButton(hWnd,IDC_PLANE, BST_UNCHECKED); + CheckDlgButton(hWnd,IDC_POLYSET, BST_UNCHECKED); + CheckDlgButton(hWnd,IDC_POLYGON, BST_UNCHECKED); + CheckDlgButton(hWnd,IDC_TUBE, BST_UNCHECKED); + CheckDlgButton(hWnd,IDC_INSPHERE, BST_UNCHECKED); + CheckDlgButton(hWnd,IDC_FLOORMESH, BST_UNCHECKED); + } + return TRUE; break; + case IDC_POLYGON: + if(IsDlgButtonChecked(hWnd,IDC_POLYGON)) + { + CheckDlgButton(hWnd,IDC_PLANE, BST_UNCHECKED); + CheckDlgButton(hWnd,IDC_POLYSET, BST_UNCHECKED); + CheckDlgButton(hWnd,IDC_SPHERE, BST_UNCHECKED); + CheckDlgButton(hWnd,IDC_TUBE, BST_UNCHECKED); + CheckDlgButton(hWnd,IDC_INSPHERE, BST_UNCHECKED); + CheckDlgButton(hWnd,IDC_FLOORMESH, BST_UNCHECKED); + } + return TRUE; break; + case IDC_POLYSET: + if(IsDlgButtonChecked(hWnd,IDC_POLYSET)) + { + CheckDlgButton(hWnd,IDC_PLANE, BST_UNCHECKED); + CheckDlgButton(hWnd,IDC_SPHERE, BST_UNCHECKED); + CheckDlgButton(hWnd,IDC_POLYGON, BST_UNCHECKED); + CheckDlgButton(hWnd,IDC_TUBE, BST_UNCHECKED); + CheckDlgButton(hWnd,IDC_INSPHERE, BST_UNCHECKED); + CheckDlgButton(hWnd,IDC_FLOORMESH, BST_UNCHECKED); + } + return TRUE; break; + case IDC_TUBE: + if(IsDlgButtonChecked(hWnd,IDC_TUBE)) + { + CheckDlgButton(hWnd,IDC_PLANE, BST_UNCHECKED); + CheckDlgButton(hWnd,IDC_POLYSET, BST_UNCHECKED); + CheckDlgButton(hWnd,IDC_POLYGON, BST_UNCHECKED); + CheckDlgButton(hWnd,IDC_SPHERE, BST_UNCHECKED); + CheckDlgButton(hWnd,IDC_INSPHERE, BST_UNCHECKED); + CheckDlgButton(hWnd,IDC_FLOORMESH, BST_UNCHECKED); + } + return TRUE; break; + case IDC_INSPHERE: + if(IsDlgButtonChecked(hWnd,IDC_INSPHERE)) + { + CheckDlgButton(hWnd,IDC_PLANE, BST_UNCHECKED); + CheckDlgButton(hWnd,IDC_POLYSET, BST_UNCHECKED); + CheckDlgButton(hWnd,IDC_POLYGON, BST_UNCHECKED); + CheckDlgButton(hWnd,IDC_TUBE, BST_UNCHECKED); + CheckDlgButton(hWnd,IDC_SPHERE, BST_UNCHECKED); + CheckDlgButton(hWnd,IDC_FLOORMESH, BST_UNCHECKED); + } + return TRUE; break; + case IDC_FLOORMESH: + if(IsDlgButtonChecked(hWnd,IDC_FLOORMESH)) + { + CheckDlgButton(hWnd,IDC_PLANE, BST_UNCHECKED); + CheckDlgButton(hWnd,IDC_POLYSET, BST_UNCHECKED); + CheckDlgButton(hWnd,IDC_POLYGON, BST_UNCHECKED); + CheckDlgButton(hWnd,IDC_TUBE, BST_UNCHECKED); + CheckDlgButton(hWnd,IDC_INSPHERE, BST_UNCHECKED); + CheckDlgButton(hWnd,IDC_SPHERE, BST_UNCHECKED); + } + return TRUE; break; default: //char buf[255]; //sprintf(buf, "%d", LOWORD(wParam)); @@ -454,6 +543,39 @@ void MaxOptionsDialog::UpdateUI(HWND hWnd) { CheckDlgButton(hWnd, IDC_CHECK1, _double_sided ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hWnd, IDC_COLLISION, + _add_collision ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hWnd, IDC_PLANE, + (_cs_type==CS_plane)? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hWnd, IDC_SPHERE, + (_cs_type==CS_sphere)? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hWnd, IDC_POLYGON, + (_cs_type==CS_polygon)? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hWnd, IDC_POLYSET, + (_cs_type==CS_polyset)? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hWnd, IDC_TUBE, + (_cs_type==CS_tube)? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hWnd, IDC_INSPHERE, + (_cs_type==CS_insphere)? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hWnd, IDC_FLOORMESH, + (_cs_type==CS_floormesh)? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hWnd, IDC_DESCEND, + (_cf_type&CF_descend) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hWnd, IDC_KEEP, + (_cf_type&CF_keep) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hWnd, IDC_EVENT, + (_cf_type&CF_event) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hWnd, IDC_SOLID, + (_cf_type&CF_solid) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hWnd, IDC_CENTER, + (_cf_type&CF_center) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hWnd, IDC_TURNSTILE, + (_cf_type&CF_turnstile) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hWnd, IDC_LEVEL, + (_cf_type&CF_level) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hWnd, IDC_INTANGIBLE, + (_cf_type&CF_intangible) ? BST_CHECKED : BST_UNCHECKED); + SetICustEdit(hWnd, IDC_FILENAME, _file_name); if (_start_frame != INT_MIN) { SetICustEdit(hWnd, IDC_SF, _start_frame); @@ -553,6 +675,39 @@ bool MaxOptionsDialog::UpdateFromUI(HWND hWnd) { _end_frame = newEF; _anim_type = newAnimType; _double_sided = IsDlgButtonChecked(hWnd, IDC_CHECK1); + _add_collision = IsDlgButtonChecked(hWnd, IDC_COLLISION); + if(IsDlgButtonChecked(hWnd, IDC_PLANE)) + _cs_type = CS_plane; + if(IsDlgButtonChecked(hWnd, IDC_SPHERE)) + _cs_type = CS_sphere; + if(IsDlgButtonChecked(hWnd, IDC_POLYSET)) + _cs_type = CS_polyset; + if(IsDlgButtonChecked(hWnd, IDC_POLYGON)) + _cs_type = CS_polygon; + if(IsDlgButtonChecked(hWnd, IDC_TUBE)) + _cs_type = CS_tube; + if(IsDlgButtonChecked(hWnd, IDC_INSPHERE)) + _cs_type = CS_insphere; + if(IsDlgButtonChecked(hWnd, IDC_FLOORMESH)) + _cs_type = CS_floormesh; + + if(IsDlgButtonChecked(hWnd, IDC_DESCEND)) + _cf_type = (CF_Type)(_cf_type | CF_descend); + if(IsDlgButtonChecked(hWnd, IDC_KEEP)) + _cf_type = (CF_Type)(_cf_type | CF_keep); + if(IsDlgButtonChecked(hWnd, IDC_EVENT)) + _cf_type = (CF_Type)(_cf_type | CF_event); + if(IsDlgButtonChecked(hWnd, IDC_SOLID)) + _cf_type = (CF_Type)(_cf_type | CF_solid); + if(IsDlgButtonChecked(hWnd, IDC_CENTER)) + _cf_type = (CF_Type)(_cf_type | CF_center); + if(IsDlgButtonChecked(hWnd, IDC_TURNSTILE)) + _cf_type = (CF_Type)(_cf_type | CF_turnstile); + if(IsDlgButtonChecked(hWnd, IDC_LEVEL)) + _cf_type = (CF_Type)(_cf_type | CF_level); + if(IsDlgButtonChecked(hWnd, IDC_INTANGIBLE)) + _cf_type = (CF_Type)(_cf_type | CF_intangible); + _export_whole_scene = IsDlgButtonChecked(hWnd, IDC_EXPORT_ALL); _export_all_frames = IsDlgButtonChecked(hWnd, IDC_EXP_ALL_FRAMES); @@ -607,6 +762,11 @@ IOResult MaxOptionsDialog::Save(ISave *isave) { ChunkSave(isave, CHUNK_SF, _start_frame); ChunkSave(isave, CHUNK_EF, _end_frame); ChunkSave(isave, CHUNK_DBL_SIDED, _double_sided); + // save the collision options: + ChunkSave(isave, CHUNK_ADD_COLLISION, _add_collision); + ChunkSave(isave, CHUNK_CS_TYPE, _cs_type); + ChunkSave(isave, CHUNK_CF_TYPE, _cf_type); + ChunkSave(isave, CHUNK_EGG_CHECKED, _checked); ChunkSave(isave, CHUNK_EXPORT_FULL, _export_whole_scene); ChunkSave(isave, CHUNK_ALL_FRAMES, _export_all_frames); @@ -629,6 +789,10 @@ IOResult MaxOptionsDialog::Load(ILoad *iload) { case CHUNK_SF: _start_frame = ChunkLoadInt(iload); break; case CHUNK_EF: _end_frame = ChunkLoadInt(iload); break; case CHUNK_DBL_SIDED: _double_sided = ChunkLoadBool(iload); break; + case CHUNK_ADD_COLLISION: _add_collision = ChunkLoadBool(iload); break; + case CHUNK_CS_TYPE: _cs_type = (CS_Type)ChunkLoadInt(iload); break; + case CHUNK_CF_TYPE: _cf_type = (CF_Type)ChunkLoadInt(iload); break; + case CHUNK_EGG_CHECKED: _checked = ChunkLoadBool(iload); break; case CHUNK_EXPORT_FULL: _export_whole_scene = ChunkLoadBool(iload); break; case CHUNK_ALL_FRAMES: _export_all_frames = ChunkLoadBool(iload); break; diff --git a/pandatool/src/maxegg/maxOptionsDialog.h b/pandatool/src/maxegg/maxOptionsDialog.h index b86477bba2..34e62f3b65 100644 --- a/pandatool/src/maxegg/maxOptionsDialog.h +++ b/pandatool/src/maxegg/maxOptionsDialog.h @@ -12,7 +12,6 @@ #pragma conform(forScope, off) - /* Externed Globals */ extern HINSTANCE hInstance; @@ -33,6 +32,10 @@ extern HINSTANCE hInstance; #define CHUNK_NODE_LIST 0x1200 #define CHUNK_NODE_HANDLE 0x1201 +#define CHUNK_ADD_COLLISION 0x1202 +#define CHUNK_CS_TYPE 0x1203 +#define CHUNK_CF_TYPE 0x1204 + //Global functions void ChunkSave(ISave *isave, int chunkid, int value); void ChunkSave(ISave *isave, int chunkid, bool value); @@ -57,11 +60,39 @@ struct MaxEggOptions AT_both }; + enum CS_Type{ + CS_none = 0x00000000, + CS_plane = 0x00010000, + CS_polygon = 0x00020000, + CS_polyset = 0x00030000, + CS_sphere = 0x00040000, + CS_tube = 0x00050000, + CS_insphere = 0x00060000, + CS_floormesh = 0x00080000 + }; + + enum CF_Type{ + CF_none = 0x00000000, + CF_descend = 0x00100000, + CF_event = 0x00200000, + CF_keep = 0x00400000, + CF_solid = 0x00800000, + CF_center = 0x01000000, + CF_turnstile = 0x02000000, + CF_level = 0x04000000, + CF_intangible = 0x08000000, + }; + IObjParam *_max_interface; Anim_Type _anim_type; int _start_frame; int _end_frame; bool _double_sided; + + bool _add_collision; + CS_Type _cs_type; + CF_Type _cf_type; + bool _successful; bool _export_whole_scene; bool _export_all_frames; diff --git a/pandatool/src/maxegg/maxResource.h b/pandatool/src/maxegg/maxResource.h index d5836e62b2..e1d1da9921 100755 --- a/pandatool/src/maxegg/maxResource.h +++ b/pandatool/src/maxegg/maxResource.h @@ -1,6 +1,6 @@ //{{NO_DEPENDENCIES}} // Microsoft Visual C++ generated include file. -// Used by MaxEgg.rc +// Used by maxEgg.rc // #define IDS_LIBDESCRIPTION 1 #define IDS_CATEGORY 2 @@ -40,6 +40,22 @@ #define IDC_OK 1058 #define IDC_CANCEL 1059 #define IDC_LOGGING 1060 +#define IDC_COLLISION 1061 +#define IDC_PLANE 1062 +#define IDC_SPHERE 1063 +#define IDC_POLYGON 1064 +#define IDC_POLYSET 1067 +#define IDC_TUBE 1068 +#define IDC_INSPHERE 1069 +#define IDC_FLOORMESH 1070 +#define IDC_DESCEND 1071 +#define IDC_KEEP 1072 +#define IDC_EVENT 1073 +#define IDC_SOLID 1074 +#define IDC_CENTER 1076 +#define IDC_TURNSTILE 1077 +#define IDC_LEVEL 1078 +#define IDC_INTANGIBLE 1079 // Next default values for new objects // @@ -47,7 +63,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 103 #define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1061 +#define _APS_NEXT_CONTROL_VALUE 1080 #define _APS_NEXT_SYMED_VALUE 102 #endif #endif diff --git a/pandatool/src/maxegg/maxToEggConverter.cxx b/pandatool/src/maxegg/maxToEggConverter.cxx index 10c9dc0c7d..74d2dfad02 100755 --- a/pandatool/src/maxegg/maxToEggConverter.cxx +++ b/pandatool/src/maxegg/maxToEggConverter.cxx @@ -2,6 +2,11 @@ // Created by Corey Revilla and Ken Strickland (6/22/03) // from mayaToEggConverter.cxx created by drose (10Nov99) // +// Updated by Fei Wang, Carnegie Mellon University Entertainment +// Technology Center student, 29Jul2009: Fixed vertex color, +// animation hierarchy, texture swapping bugs; added collision choices to +// exporter. +// //////////////////////////////////////////////////////////////////// // // PANDA 3D SOFTWARE @@ -90,9 +95,24 @@ bool MaxToEggConverter::convert(MaxEggOptions *options) { bool all_ok = true; + // check if we need the collision set, set the _tree's m_b_has collision to be true + if(_options->_add_collision) + { + _tree._has_collision = true; + + _tree._cs_type = (EggGroup::CollisionSolidType)(_options->_cs_type); + _tree._cf_type = (EggGroup::CollideFlags)(_options->_cf_type); + + } + else + { + _tree._has_collision = false; + } if (_options->_export_whole_scene) { + _tree._export_mesh = false; all_ok = _tree.build_complete_hierarchy(_options->_max_interface->GetRootNode(), NULL, 0); } else { + _tree._export_mesh = true; all_ok = _tree.build_complete_hierarchy(_options->_max_interface->GetRootNode(), &_options->_node_list.front(), _options->_node_list.size()); } @@ -656,10 +676,11 @@ make_polyset(INode *max_node, Mesh *mesh, vert.set_normal(n3d); // Get the vertex color - if(mesh->vcFace) { // if has vcFace, has used vertex color - VertColor vertexColor = get_max_vertex_color(mesh, iFace, iVertex); - Colorf pVC(vertexColor.x, vertexColor.y, vertexColor.z, 1); - vert.set_color(pVC); + if(mesh->vcFace) // if has vcFace, has used vertex color + { + VertColor vertexColor = get_max_vertex_color(mesh, iFace, iVertex); + Colorf pVC(vertexColor.x, vertexColor.y, vertexColor.z, 1); + vert.set_color(pVC); } // Get the UVs for this vertex @@ -668,7 +689,11 @@ make_polyset(INode *max_node, Mesh *mesh, ostringstream uvname; uvname << "m" << channel; UVVert uvw = get_max_vertex_texcoord(mesh, iFace, iVertex, channel); - vert.set_uv( uvname.str(), TexCoordd(uvw.x, uvw.y)); + // changes allow the first channel to be swapped + if(channel ==1) + vert.set_uv( TexCoordd(uvw.x, uvw.y)); + else + vert.set_uv( uvname.str(), TexCoordd(uvw.x, uvw.y)); } vert.set_external_index(face.v[iVertex]); @@ -726,17 +751,38 @@ UVVert MaxToEggConverter::get_max_vertex_texcoord(Mesh *mesh, int faceNo, int ve return uvVert; } -VertColor MaxToEggConverter::get_max_vertex_color(Mesh *mesh, int FaceNo, int VertexNo) { +VertColor MaxToEggConverter::get_max_vertex_color(Mesh *mesh,int FaceNo,int VertexNo, int channel) { + VertColor vc(0,0,0); - // We get the color from vcFace - TVFace& _vcface = mesh->vcFace[FaceNo]; - // Get its index into the vertCol array - int VertexColorIndex = _vcface.t[VertexNo]; - // Get its color - vc = mesh->vertCol[VertexColorIndex]; + if(mesh->mapSupport(channel)) + { + // We get the color from vcFace + TVFace& _vcface = mesh->vcFace[FaceNo]; + //Get its index into the vertCol array + int VertexColorIndex = _vcface.t[VertexNo]; + //Get its color + vc =mesh->vertCol[VertexColorIndex]; + } + else + { + TVFace *pTVFace = mesh->mapFaces(channel); + vc = mesh->vertCol[pTVFace[FaceNo].t[VertexNo]]; + } return vc; } +VertColor MaxToEggConverter::get_max_vertex_color(Mesh *mesh,int FaceNo,int VertexNo) +{ + VertColor vc(0,0,0); + // We get the color from vcFace + TVFace& _vcface = mesh->vcFace[FaceNo]; + //Get its index into the vertCol array + int VertexColorIndex = _vcface.t[VertexNo]; + //Get its color + vc =mesh->vertCol[VertexColorIndex]; + return vc; +} + Point3 MaxToEggConverter::get_max_vertex_normal(Mesh *mesh, int faceNo, int vertNo) { Face f = mesh->faces[faceNo]; @@ -1222,7 +1268,11 @@ std::string MaxToEggConverter::get_uv_name(int channel) { void MaxToEggConverter:: apply_texture_properties(EggTexture &tex, int channel) { - tex.set_uv_name(get_uv_name(channel)); + // we leave a channel 1 for texture swapping, so don't name it + if(channel == 1) + tex.set_uv_name(""); + else + tex.set_uv_name(get_uv_name(channel)); tex.set_minfilter(EggTexture::FT_linear_mipmap_linear); tex.set_magfilter(EggTexture::FT_linear); diff --git a/pandatool/src/maxegg/maxToEggConverter.h b/pandatool/src/maxegg/maxToEggConverter.h index 397681e1b0..fb89bad35c 100755 --- a/pandatool/src/maxegg/maxToEggConverter.h +++ b/pandatool/src/maxegg/maxToEggConverter.h @@ -87,6 +87,7 @@ class MaxToEggConverter { Point3 get_max_vertex_normal(Mesh *mesh, int faceNo, int vertNo); VertColor get_max_vertex_color(Mesh *mesh, int FaceNo, int VertexNo); + VertColor get_max_vertex_color(Mesh *mesh,int FaceNo,int VertexNo, int channel); UVVert get_max_vertex_texcoord(Mesh *mesh, int faceNo, int vertNo, int channel); void get_vertex_weights(INode *max_node, EggVertexPool *vpool);