mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 16:58:40 -04:00
Completion of summer project by Fei Wang (CMU ETC student) to update Max exporter: added enableAddCollisionChoices
This commit is contained in:
parent
50b9fd055b
commit
f4e14c8455
@ -5,6 +5,9 @@
|
||||
|
||||
This file implements the classes that are used to choose
|
||||
what to export from 3D Studio max
|
||||
|
||||
Updated by Fei Wang, Carnegie Mellon University Entertainment
|
||||
Technology Center student, 14Aug2009: added enableAddCollisionChoices
|
||||
*/
|
||||
|
||||
#include "maxEgg.h"
|
||||
@ -141,6 +144,29 @@ void enableChooserControls(HWND hWnd, BOOL 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_EXPALL 1
|
||||
#define ANIM_RAD_EXPSEL 2
|
||||
@ -197,6 +223,7 @@ int AddNodeCB::filter(INode *node) {
|
||||
|
||||
//Adds all of the selected items to the list
|
||||
void AddNodeCB::proc(INodeTab &nodeTab) {
|
||||
|
||||
for (int i = 0; i < nodeTab.Count(); i++)
|
||||
ph->AddNode(nodeTab[i]->GetHandle());
|
||||
ph->RefreshNodeList(hWnd);
|
||||
@ -235,7 +262,7 @@ MaxEggOptions::MaxEggOptions() {
|
||||
// initialize newly added collision options, too
|
||||
_add_collision = false;
|
||||
_cs_type = CS_none;
|
||||
_cf_type = CF_none;
|
||||
_cf_type = CF_none;
|
||||
|
||||
_file_name[0]=0;
|
||||
_short_name[0]=0;
|
||||
@ -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
|
||||
SetWindowLongPtr(hWnd,GWLP_USERDATA,lParam);
|
||||
((MaxOptionsDialog*)lParam)->UpdateUI(hWnd);
|
||||
if(IsDlgButtonChecked(hWnd,IDC_COLLISION) && !IsDlgButtonChecked(hWnd, IDC_ANIMATION))
|
||||
enableAddCollisionChoices(hWnd, TRUE);
|
||||
else
|
||||
enableAddCollisionChoices(hWnd, FALSE);
|
||||
return TRUE; break;
|
||||
|
||||
case WM_CLOSE:
|
||||
@ -277,6 +308,11 @@ INT_PTR CALLBACK MaxOptionsDialogProc( HWND hWnd, UINT message, WPARAM wParam, L
|
||||
enableAnimControls(hWnd, FALSE);
|
||||
if (imp->_prev_type == MaxEggOptions::AT_chan) imp->ClearNodeList(hWnd);
|
||||
imp->_prev_type = MaxEggOptions::AT_model;
|
||||
enableAddCollision(hWnd, TRUE);
|
||||
if(IsDlgButtonChecked(hWnd,IDC_COLLISION))
|
||||
{
|
||||
enableAddCollisionChoices(hWnd, TRUE);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
@ -290,6 +326,9 @@ INT_PTR CALLBACK MaxOptionsDialogProc( HWND hWnd, UINT message, WPARAM wParam, L
|
||||
enableAnimControls(hWnd, IsDlgButtonChecked(hWnd, IDC_EXP_SEL_FRAMES));
|
||||
if (imp->_prev_type != MaxEggOptions::AT_chan) imp->ClearNodeList(hWnd);
|
||||
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;
|
||||
}
|
||||
break;
|
||||
@ -302,6 +341,12 @@ INT_PTR CALLBACK MaxOptionsDialogProc( HWND hWnd, UINT message, WPARAM wParam, L
|
||||
enableAnimControls(hWnd, IsDlgButtonChecked(hWnd, IDC_EXP_SEL_FRAMES));
|
||||
if (imp->_prev_type == MaxEggOptions::AT_chan) imp->ClearNodeList(hWnd);
|
||||
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;
|
||||
}
|
||||
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);
|
||||
if (imp->_prev_type == MaxEggOptions::AT_chan) imp->ClearNodeList(hWnd);
|
||||
imp->_prev_type = MaxEggOptions::AT_pose;
|
||||
enableAddCollision(hWnd, TRUE);
|
||||
if(IsDlgButtonChecked(hWnd,IDC_COLLISION))
|
||||
{
|
||||
enableAddCollisionChoices(hWnd, TRUE);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
case IDC_EXP_ALL_FRAMES:
|
||||
if (HIWORD(wParam) == BN_CLICKED) {
|
||||
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;
|
||||
}
|
||||
break;
|
||||
@ -328,6 +386,14 @@ INT_PTR CALLBACK MaxOptionsDialogProc( HWND hWnd, UINT message, WPARAM wParam, L
|
||||
case IDC_EXP_SEL_FRAMES:
|
||||
if (HIWORD(wParam) == BN_CLICKED) {
|
||||
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;
|
||||
}
|
||||
break;
|
||||
@ -346,6 +412,8 @@ INT_PTR CALLBACK MaxOptionsDialogProc( HWND hWnd, UINT message, WPARAM wParam, L
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
// deal with adding meshes
|
||||
case IDC_ADD_EXPORT:
|
||||
{
|
||||
if (!imp->_choosing_nodes) {
|
||||
@ -406,9 +474,19 @@ INT_PTR CALLBACK MaxOptionsDialogProc( HWND hWnd, UINT message, WPARAM wParam, L
|
||||
// add IDC_COLLISION and related:
|
||||
case 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",
|
||||
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;
|
||||
case IDC_PLANE:
|
||||
if(IsDlgButtonChecked(hWnd,IDC_PLANE))
|
||||
@ -542,40 +620,56 @@ void MaxOptionsDialog::UpdateUI(HWND hWnd) {
|
||||
|
||||
CheckDlgButton(hWnd, IDC_CHECK1,
|
||||
_double_sided ? BST_CHECKED : BST_UNCHECKED);
|
||||
|
||||
// update collision button
|
||||
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);
|
||||
@ -768,8 +862,9 @@ IOResult MaxOptionsDialog::Save(ISave *isave) {
|
||||
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);
|
||||
ChunkSave(isave, CHUNK_EXPORT_FULL, _export_whole_scene);
|
||||
|
||||
isave->BeginChunk(CHUNK_NODE_LIST);
|
||||
for (int i = 0; i < _node_list.size(); 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_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_EXPORT_FULL: _export_whole_scene = ChunkLoadBool(iload); break;
|
||||
|
||||
case CHUNK_NODE_LIST:
|
||||
res = iload->OpenChunk();
|
||||
while (res == IO_OK) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user