Completion of summer project by Fei Wang (CMU ETC student) to update Max exporter: added enableAddCollisionChoices

This commit is contained in:
Mike Christel 2009-08-24 13:27:04 +00:00
parent 50b9fd055b
commit f4e14c8455

View File

@ -5,6 +5,9 @@
This file implements the classes that are used to choose This file implements the classes that are used to choose
what to export from 3D Studio max what to export from 3D Studio max
Updated by Fei Wang, Carnegie Mellon University Entertainment
Technology Center student, 14Aug2009: added enableAddCollisionChoices
*/ */
#include "maxEgg.h" #include "maxEgg.h"
@ -141,6 +144,29 @@ void enableChooserControls(HWND hWnd, BOOL val) {
EnableWindow(GetDlgItem(hWnd, IDC_REMOVE_EXPORT), val); EnableWindow(GetDlgItem(hWnd, IDC_REMOVE_EXPORT), val);
} }
void enableAddCollision(HWND hWnd, BOOL val) {
EnableWindow(GetDlgItem(hWnd, IDC_COLLISION), val);
}
void enableAddCollisionChoices(HWND hWnd, BOOL val) {
EnableWindow(GetDlgItem(hWnd, IDC_PLANE), val);
EnableWindow(GetDlgItem(hWnd, IDC_SPHERE), val);
EnableWindow(GetDlgItem(hWnd, IDC_POLYGON), val);
EnableWindow(GetDlgItem(hWnd, IDC_POLYSET), val);
EnableWindow(GetDlgItem(hWnd, IDC_TUBE), val);
EnableWindow(GetDlgItem(hWnd, IDC_INSPHERE), val);
EnableWindow(GetDlgItem(hWnd, IDC_FLOORMESH), val);
EnableWindow(GetDlgItem(hWnd, IDC_DESCEND), val);
EnableWindow(GetDlgItem(hWnd, IDC_KEEP), val);
EnableWindow(GetDlgItem(hWnd, IDC_EVENT), val);
EnableWindow(GetDlgItem(hWnd, IDC_SOLID), val);
EnableWindow(GetDlgItem(hWnd, IDC_CENTER), val);
EnableWindow(GetDlgItem(hWnd, IDC_TURNSTILE), val);
EnableWindow(GetDlgItem(hWnd, IDC_LEVEL), val);
EnableWindow(GetDlgItem(hWnd, IDC_INTANGIBLE), val);
}
#define ANIM_RAD_NONE 0 #define ANIM_RAD_NONE 0
#define ANIM_RAD_EXPALL 1 #define ANIM_RAD_EXPALL 1
#define ANIM_RAD_EXPSEL 2 #define ANIM_RAD_EXPSEL 2
@ -197,6 +223,7 @@ int AddNodeCB::filter(INode *node) {
//Adds all of the selected items to the list //Adds all of the selected items to the list
void AddNodeCB::proc(INodeTab &nodeTab) { void AddNodeCB::proc(INodeTab &nodeTab) {
for (int i = 0; i < nodeTab.Count(); i++) for (int i = 0; i < nodeTab.Count(); i++)
ph->AddNode(nodeTab[i]->GetHandle()); ph->AddNode(nodeTab[i]->GetHandle());
ph->RefreshNodeList(hWnd); ph->RefreshNodeList(hWnd);
@ -259,6 +286,10 @@ INT_PTR CALLBACK MaxOptionsDialogProc( HWND hWnd, UINT message, WPARAM wParam, L
// this line is very necessary to pass the plugin as the lParam // this line is very necessary to pass the plugin as the lParam
SetWindowLongPtr(hWnd,GWLP_USERDATA,lParam); SetWindowLongPtr(hWnd,GWLP_USERDATA,lParam);
((MaxOptionsDialog*)lParam)->UpdateUI(hWnd); ((MaxOptionsDialog*)lParam)->UpdateUI(hWnd);
if(IsDlgButtonChecked(hWnd,IDC_COLLISION) && !IsDlgButtonChecked(hWnd, IDC_ANIMATION))
enableAddCollisionChoices(hWnd, TRUE);
else
enableAddCollisionChoices(hWnd, FALSE);
return TRUE; break; return TRUE; break;
case WM_CLOSE: case WM_CLOSE:
@ -277,6 +308,11 @@ INT_PTR CALLBACK MaxOptionsDialogProc( HWND hWnd, UINT message, WPARAM wParam, L
enableAnimControls(hWnd, FALSE); enableAnimControls(hWnd, FALSE);
if (imp->_prev_type == MaxEggOptions::AT_chan) imp->ClearNodeList(hWnd); if (imp->_prev_type == MaxEggOptions::AT_chan) imp->ClearNodeList(hWnd);
imp->_prev_type = MaxEggOptions::AT_model; imp->_prev_type = MaxEggOptions::AT_model;
enableAddCollision(hWnd, TRUE);
if(IsDlgButtonChecked(hWnd,IDC_COLLISION))
{
enableAddCollisionChoices(hWnd, TRUE);
}
return TRUE; return TRUE;
} }
break; break;
@ -290,6 +326,9 @@ INT_PTR CALLBACK MaxOptionsDialogProc( HWND hWnd, UINT message, WPARAM wParam, L
enableAnimControls(hWnd, IsDlgButtonChecked(hWnd, IDC_EXP_SEL_FRAMES)); enableAnimControls(hWnd, IsDlgButtonChecked(hWnd, IDC_EXP_SEL_FRAMES));
if (imp->_prev_type != MaxEggOptions::AT_chan) imp->ClearNodeList(hWnd); if (imp->_prev_type != MaxEggOptions::AT_chan) imp->ClearNodeList(hWnd);
imp->_prev_type = MaxEggOptions::AT_chan; imp->_prev_type = MaxEggOptions::AT_chan;
CheckRadioButton(hWnd, IDC_EXP_ALL_FRAMES, IDC_EXP_SEL_FRAMES, IDC_EXP_ALL_FRAMES);
enableAddCollision(hWnd, FALSE);
enableAddCollisionChoices(hWnd, FALSE);
return TRUE; return TRUE;
} }
break; break;
@ -302,6 +341,12 @@ INT_PTR CALLBACK MaxOptionsDialogProc( HWND hWnd, UINT message, WPARAM wParam, L
enableAnimControls(hWnd, IsDlgButtonChecked(hWnd, IDC_EXP_SEL_FRAMES)); enableAnimControls(hWnd, IsDlgButtonChecked(hWnd, IDC_EXP_SEL_FRAMES));
if (imp->_prev_type == MaxEggOptions::AT_chan) imp->ClearNodeList(hWnd); if (imp->_prev_type == MaxEggOptions::AT_chan) imp->ClearNodeList(hWnd);
imp->_prev_type = MaxEggOptions::AT_both; imp->_prev_type = MaxEggOptions::AT_both;
CheckRadioButton(hWnd, IDC_EXP_ALL_FRAMES, IDC_EXP_SEL_FRAMES, IDC_EXP_ALL_FRAMES);
enableAddCollision(hWnd, TRUE);
if(IsDlgButtonChecked(hWnd,IDC_COLLISION))
{
enableAddCollisionChoices(hWnd, TRUE);
}
return TRUE; return TRUE;
} }
break; break;
@ -315,12 +360,25 @@ INT_PTR CALLBACK MaxOptionsDialogProc( HWND hWnd, UINT message, WPARAM wParam, L
CheckRadioButton(hWnd, IDC_EXP_ALL_FRAMES, IDC_EXP_SEL_FRAMES, IDC_EXP_SEL_FRAMES); CheckRadioButton(hWnd, IDC_EXP_ALL_FRAMES, IDC_EXP_SEL_FRAMES, IDC_EXP_SEL_FRAMES);
if (imp->_prev_type == MaxEggOptions::AT_chan) imp->ClearNodeList(hWnd); if (imp->_prev_type == MaxEggOptions::AT_chan) imp->ClearNodeList(hWnd);
imp->_prev_type = MaxEggOptions::AT_pose; imp->_prev_type = MaxEggOptions::AT_pose;
enableAddCollision(hWnd, TRUE);
if(IsDlgButtonChecked(hWnd,IDC_COLLISION))
{
enableAddCollisionChoices(hWnd, TRUE);
}
return TRUE; return TRUE;
} }
break; break;
case IDC_EXP_ALL_FRAMES: case IDC_EXP_ALL_FRAMES:
if (HIWORD(wParam) == BN_CLICKED) { if (HIWORD(wParam) == BN_CLICKED) {
enableAnimControls(hWnd, FALSE); enableAnimControls(hWnd, FALSE);
if(imp->_prev_type == MaxEggOptions::AT_chan)
{
CheckRadioButton(hWnd, IDC_MODEL, IDC_POSE, IDC_ANIMATION);
}
if(imp->_prev_type == MaxEggOptions::AT_both)
{
CheckRadioButton(hWnd, IDC_MODEL, IDC_POSE, IDC_BOTH);
}
return TRUE; return TRUE;
} }
break; break;
@ -328,6 +386,14 @@ INT_PTR CALLBACK MaxOptionsDialogProc( HWND hWnd, UINT message, WPARAM wParam, L
case IDC_EXP_SEL_FRAMES: case IDC_EXP_SEL_FRAMES:
if (HIWORD(wParam) == BN_CLICKED) { if (HIWORD(wParam) == BN_CLICKED) {
enableAnimControls(hWnd, TRUE); enableAnimControls(hWnd, TRUE);
if(imp->_prev_type == MaxEggOptions::AT_chan)
{
CheckRadioButton(hWnd, IDC_MODEL, IDC_POSE, IDC_ANIMATION);
}
if(imp->_prev_type == MaxEggOptions::AT_both)
{
CheckRadioButton(hWnd, IDC_MODEL, IDC_POSE, IDC_BOTH);
}
return TRUE; return TRUE;
} }
break; break;
@ -346,6 +412,8 @@ INT_PTR CALLBACK MaxOptionsDialogProc( HWND hWnd, UINT message, WPARAM wParam, L
} }
break; break;
// deal with adding meshes
case IDC_ADD_EXPORT: case IDC_ADD_EXPORT:
{ {
if (!imp->_choosing_nodes) { if (!imp->_choosing_nodes) {
@ -406,9 +474,19 @@ INT_PTR CALLBACK MaxOptionsDialogProc( HWND hWnd, UINT message, WPARAM wParam, L
// add IDC_COLLISION and related: // add IDC_COLLISION and related:
case IDC_COLLISION: case IDC_COLLISION:
if(IsDlgButtonChecked(hWnd,IDC_COLLISION)) if(IsDlgButtonChecked(hWnd,IDC_COLLISION))
{
enableAddCollisionChoices(hWnd, TRUE);
if(MessageBox(hWnd, "Exporting the egg with collision tag in it? Some choices may hurt performance in Panda3D","Panda3D Exporter", 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) MB_YESNO | MB_ICONQUESTION) != IDYES)
CheckDlgButton(hWnd,IDC_COLLISION, BST_UNCHECKED); {
CheckDlgButton(hWnd,IDC_COLLISION, BST_UNCHECKED);
enableAddCollisionChoices(hWnd, FALSE);
}
}
else
{
enableAddCollisionChoices(hWnd, FALSE);
}
return TRUE; break; return TRUE; break;
case IDC_PLANE: case IDC_PLANE:
if(IsDlgButtonChecked(hWnd,IDC_PLANE)) if(IsDlgButtonChecked(hWnd,IDC_PLANE))
@ -542,40 +620,56 @@ void MaxOptionsDialog::UpdateUI(HWND hWnd) {
CheckDlgButton(hWnd, IDC_CHECK1, CheckDlgButton(hWnd, IDC_CHECK1,
_double_sided ? BST_CHECKED : BST_UNCHECKED); _double_sided ? BST_CHECKED : BST_UNCHECKED);
// update collision button
CheckDlgButton(hWnd, IDC_COLLISION, CheckDlgButton(hWnd, IDC_COLLISION,
_add_collision ? BST_CHECKED : BST_UNCHECKED); _add_collision ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hWnd, IDC_PLANE, CheckDlgButton(hWnd, IDC_PLANE,
(_cs_type==CS_plane)? BST_CHECKED : BST_UNCHECKED); (_cs_type==CS_plane)? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hWnd, IDC_SPHERE, CheckDlgButton(hWnd, IDC_SPHERE,
(_cs_type==CS_sphere)? BST_CHECKED : BST_UNCHECKED); (_cs_type==CS_sphere)? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hWnd, IDC_POLYGON, CheckDlgButton(hWnd, IDC_POLYGON,
(_cs_type==CS_polygon)? BST_CHECKED : BST_UNCHECKED); (_cs_type==CS_polygon)? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hWnd, IDC_POLYSET, CheckDlgButton(hWnd, IDC_POLYSET,
(_cs_type==CS_polyset)? BST_CHECKED : BST_UNCHECKED); (_cs_type==CS_polyset)? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hWnd, IDC_TUBE, CheckDlgButton(hWnd, IDC_TUBE,
(_cs_type==CS_tube)? BST_CHECKED : BST_UNCHECKED); (_cs_type==CS_tube)? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hWnd, IDC_INSPHERE, CheckDlgButton(hWnd, IDC_INSPHERE,
(_cs_type==CS_insphere)? BST_CHECKED : BST_UNCHECKED); (_cs_type==CS_insphere)? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hWnd, IDC_FLOORMESH, CheckDlgButton(hWnd, IDC_FLOORMESH,
(_cs_type==CS_floormesh)? BST_CHECKED : BST_UNCHECKED); (_cs_type==CS_floormesh)? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hWnd, IDC_DESCEND, CheckDlgButton(hWnd, IDC_DESCEND,
(_cf_type&CF_descend) ? BST_CHECKED : BST_UNCHECKED); (_cf_type&CF_descend) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hWnd, IDC_KEEP, CheckDlgButton(hWnd, IDC_KEEP,
(_cf_type&CF_keep) ? BST_CHECKED : BST_UNCHECKED); (_cf_type&CF_keep) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hWnd, IDC_EVENT, CheckDlgButton(hWnd, IDC_EVENT,
(_cf_type&CF_event) ? BST_CHECKED : BST_UNCHECKED); (_cf_type&CF_event) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hWnd, IDC_SOLID, CheckDlgButton(hWnd, IDC_SOLID,
(_cf_type&CF_solid) ? BST_CHECKED : BST_UNCHECKED); (_cf_type&CF_solid) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hWnd, IDC_CENTER, CheckDlgButton(hWnd, IDC_CENTER,
(_cf_type&CF_center) ? BST_CHECKED : BST_UNCHECKED); (_cf_type&CF_center) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hWnd, IDC_TURNSTILE, CheckDlgButton(hWnd, IDC_TURNSTILE,
(_cf_type&CF_turnstile) ? BST_CHECKED : BST_UNCHECKED); (_cf_type&CF_turnstile) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hWnd, IDC_LEVEL, CheckDlgButton(hWnd, IDC_LEVEL,
(_cf_type&CF_level) ? BST_CHECKED : BST_UNCHECKED); (_cf_type&CF_level) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hWnd, IDC_INTANGIBLE, CheckDlgButton(hWnd, IDC_INTANGIBLE,
(_cf_type&CF_intangible) ? BST_CHECKED : BST_UNCHECKED); (_cf_type&CF_intangible) ? BST_CHECKED : BST_UNCHECKED);
SetICustEdit(hWnd, IDC_FILENAME, _file_name); SetICustEdit(hWnd, IDC_FILENAME, _file_name);
if (_start_frame != INT_MIN) { if (_start_frame != INT_MIN) {
SetICustEdit(hWnd, IDC_SF, _start_frame); SetICustEdit(hWnd, IDC_SF, _start_frame);
@ -768,8 +862,9 @@ IOResult MaxOptionsDialog::Save(ISave *isave) {
ChunkSave(isave, CHUNK_CF_TYPE, _cf_type); ChunkSave(isave, CHUNK_CF_TYPE, _cf_type);
ChunkSave(isave, CHUNK_EGG_CHECKED, _checked); ChunkSave(isave, CHUNK_EGG_CHECKED, _checked);
ChunkSave(isave, CHUNK_EXPORT_FULL, _export_whole_scene);
ChunkSave(isave, CHUNK_ALL_FRAMES, _export_all_frames); ChunkSave(isave, CHUNK_ALL_FRAMES, _export_all_frames);
ChunkSave(isave, CHUNK_EXPORT_FULL, _export_whole_scene);
isave->BeginChunk(CHUNK_NODE_LIST); isave->BeginChunk(CHUNK_NODE_LIST);
for (int i = 0; i < _node_list.size(); i++) for (int i = 0; i < _node_list.size(); i++)
ChunkSave(isave, CHUNK_NODE_HANDLE, _node_list[i]); ChunkSave(isave, CHUNK_NODE_HANDLE, _node_list[i]);
@ -794,8 +889,9 @@ IOResult MaxOptionsDialog::Load(ILoad *iload) {
case CHUNK_CF_TYPE: _cf_type = (CF_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_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; case CHUNK_ALL_FRAMES: _export_all_frames = ChunkLoadBool(iload); break;
case CHUNK_EXPORT_FULL: _export_whole_scene = ChunkLoadBool(iload); break;
case CHUNK_NODE_LIST: case CHUNK_NODE_LIST:
res = iload->OpenChunk(); res = iload->OpenChunk();
while (res == IO_OK) { while (res == IO_OK) {