w3dutil.cpp 66 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /* $Header: /Commando/Code/Tools/max2w3d/w3dutil.cpp 48 4/03/02 9:38a Moumine_ballo $ */
  19. /***********************************************************************************************
  20. *** Confidential - Westwood Studios ***
  21. ***********************************************************************************************
  22. * *
  23. * Project Name : Commando Tools - W3D export *
  24. * *
  25. * $Archive:: /Commando/Code/Tools/max2w3d/w3dutil.cpp $*
  26. * *
  27. * $Author:: Moumine_ballo $*
  28. * *
  29. * $Modtime:: 3/18/02 3:35p $*
  30. * *
  31. * $Revision:: 48 $*
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  36. #include "w3dutil.h"
  37. #include "w3ddesc.h"
  38. #include "rcmenu.h"
  39. #include "util.h"
  40. #include "nodelist.h"
  41. #include "tchar.h"
  42. #include "gamemtl.h"
  43. #include "notify.h"
  44. #include "gennamesdialog.h"
  45. #include "genmtlnamesdialog.h"
  46. #include "genlodextensiondialog.h"
  47. #include "floaterdialog.h"
  48. #include <StdMat.h>
  49. //Moumine 3/18/2002 3:22:21 PM
  50. #if defined W3D_BIPED
  51. #include "bipexp.h"
  52. #endif
  53. #define DAZZLE_SETTINGS_FILENAME "dazzle.ini"
  54. #define DAZZLE_TYPES_SECTION "Dazzles_List"
  55. #define DAZZLE_SECTION_BUFFERSIZE 32767
  56. static BOOL CALLBACK _settings_form_dlg_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
  57. static BOOL CALLBACK _w3d_utility_tools_dlg_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
  58. static BOOL CALLBACK _w3d_utility_cstools_dlg_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
  59. static VisibleSelectedINodeFilter _INodeFilter;
  60. /**********************************************************************************************
  61. **
  62. ** MaterialReferenceMaker - Class to support Export Utilities in the W3D Tools panel.
  63. **
  64. **********************************************************************************************/
  65. class MaterialReferenceMaker : public ReferenceMaker
  66. {
  67. public:
  68. ~MaterialReferenceMaker() {DeleteAllRefs();}
  69. virtual int NumRefs();
  70. virtual RefTargetHandle GetReference (int i);
  71. virtual void SetReference (int i, RefTargetHandle rtarg);
  72. RefResult NotifyRefChanged (Interval changeInt,RefTargetHandle hTarget,PartID& partID, RefMessage message);
  73. Mtl *MaterialPtr;
  74. static int ReferenceCount;
  75. };
  76. int MaterialReferenceMaker::NumRefs()
  77. {
  78. return (ReferenceCount);
  79. }
  80. RefTargetHandle MaterialReferenceMaker::GetReference (int i)
  81. {
  82. assert (i < ReferenceCount);
  83. return (MaterialPtr);
  84. }
  85. void MaterialReferenceMaker::SetReference (int i, RefTargetHandle rtarg)
  86. {
  87. assert (i < ReferenceCount);
  88. MaterialPtr = (Mtl*) rtarg;
  89. }
  90. RefResult MaterialReferenceMaker::NotifyRefChanged(Interval changeInt,RefTargetHandle hTarget,PartID& partID, RefMessage message)
  91. {
  92. return (REF_SUCCEED);
  93. }
  94. int MaterialReferenceMaker::ReferenceCount;
  95. /**********************************************************************************************
  96. **
  97. ** SettingsFormClass - code for the W3DUTILITY_SETTINGS_DIALOG. Used in the command panel
  98. ** and in the floating settings dialog.
  99. **
  100. **********************************************************************************************/
  101. class SettingsFormClass
  102. {
  103. public:
  104. SettingsFormClass(HWND hwnd);
  105. ~SettingsFormClass(void);
  106. bool Dialog_Proc(HWND hWnd,UINT message,WPARAM wParam,LPARAM);
  107. void Selection_Changed(void);
  108. static void Update_All_Instances(void);
  109. private:
  110. void Init(void);
  111. void Destroy(void);
  112. void Disable_Controls(void);
  113. void Update_Controls(INodeListClass * nodelist = NULL);
  114. HWND Hwnd;
  115. ISpinnerControl * RegionSpin;
  116. SettingsFormClass * Next;
  117. static SettingsFormClass * ActiveList;
  118. };
  119. /**********************************************************************************************
  120. **
  121. ** W3DUtilityClass - Utility plugin which presents windows controls for setting all of
  122. ** the W3D export options for the currently selected nodes
  123. **
  124. **********************************************************************************************/
  125. class W3DUtilityClass : public UtilityObj
  126. {
  127. public:
  128. W3DUtilityClass();
  129. ~W3DUtilityClass();
  130. void BeginEditParams(Interface *ip,IUtil *iu);
  131. void EndEditParams(Interface *ip,IUtil *iu);
  132. void SelectionSetChanged(Interface *ip,IUtil *iu);
  133. void DeleteThis() {}
  134. void Select_Hierarchy(void);
  135. void Select_Geometry(void);
  136. void Select_Alpha(void);
  137. void Select_Physical(void);
  138. void Select_Projectile(void);
  139. void Select_Vis(void);
  140. void CSRemoveNonUniformScale(void);
  141. public:
  142. Interface * InterfacePtr;
  143. FloaterDialogClass SettingsFloater;
  144. HWND SettingsPanelHWND;
  145. HWND ToolsPanelHWND;
  146. bool UpdateSpinnerValue;
  147. GenNamesDialogClass::OptionsStruct NameOptions;
  148. GenMtlNamesDialogClass::OptionsStruct MtlNameOptions;
  149. GenLodExtensionDialogClass::OptionsStruct LodExtensionOptions;
  150. int WorkingNameIndex;
  151. enum {
  152. NONE = 0,
  153. HIDE,
  154. SELECT_GEOM,
  155. SELECT_HIER,
  156. SELECT_ALPHA,
  157. SELECT_PHYSICAL,
  158. SELECT_PROJECTILE,
  159. SELECT_VIS,
  160. GENERATE_NAME,
  161. GENERATE_MATERIAL_NAME,
  162. GENERATE_LOD_EXTENSION,
  163. CS_REMOVE_NUSCALE,
  164. };
  165. enum MaterialConversionEnum {
  166. GAME_REFERENCE_COUNT,
  167. GAME_TO_STANDARD,
  168. STANDARD_TO_GAME
  169. };
  170. struct NodeStatesStruct
  171. {
  172. int ExportHierarchy;
  173. int ExportGeometry;
  174. int GeometryTwoSided;
  175. int GeometryHidden;
  176. int GeometryZNormals;
  177. int GeometryVertexAlpha;
  178. int GeometryCastShadow;
  179. int GeometryShatterable;
  180. int GeometryNPatch;
  181. int CollisionPhysical;
  182. int CollisionProjectile;
  183. int CollisionVis;
  184. int CollisionCamera;
  185. int CollisionVehicle;
  186. bool GeometryCameraAligned;
  187. bool GeometryCameraOriented;
  188. bool GeometryNormal;
  189. bool GeometryAABox;
  190. bool GeometryOBBox;
  191. bool GeometryNull;
  192. bool GeometryDazzle;
  193. bool GeometryAggregate;
  194. int DamageRegion;
  195. int DazzleCount;
  196. char DazzleType[128];
  197. };
  198. /*
  199. ** Evaluate the status of nodes in the given list
  200. */
  201. static int eval_tri_state(int totalcount,int oncount);
  202. static void eval_node_states(INodeListClass * node_list,NodeStatesStruct * ns);
  203. /*
  204. ** Update the controls in any active settings panels
  205. */
  206. static void update_settings_controls(INodeListClass * node_list = NULL);
  207. /*
  208. ** Modify the state of all selected nodes
  209. */
  210. static void set_hierarchy_in_all_selected(INodeListClass * list,bool onoff);
  211. static void set_geometry_in_all_selected(INodeListClass * list,bool onoff);
  212. static void enable_hidden_in_all_selected(INodeListClass * list,bool onoff);
  213. static void enable_two_sided_in_all_selected(INodeListClass * list,bool onoff);
  214. static void enable_znormals_in_all_selected(INodeListClass * list,bool onoff);
  215. static void enable_vertex_alpha_in_all_selected(INodeListClass * list,bool onoff);
  216. static void enable_shadow_in_all_selected(INodeListClass * list,bool onoff);
  217. static void enable_shatterable_in_all_selected(INodeListClass * list,bool onoff);
  218. static void enable_npatches_in_all_selected(INodeListClass * list,bool onoff);
  219. static void enable_physical_collision_in_all_selected(INodeListClass * list,bool onoff);
  220. static void enable_projectile_collision_in_all_selected(INodeListClass * list,bool onoff);
  221. static void enable_vis_collision_in_all_selected(INodeListClass * list,bool onoff);
  222. static void enable_camera_collision_in_all_selected(INodeListClass * list,bool onoff);
  223. static void enable_vehicle_collision_in_all_selected(INodeListClass * list,bool onoff);
  224. static void set_geometry_type_in_all_selected(INodeListClass * list,int geotype);
  225. static void set_dazzle_type_in_all_selected(INodeListClass * list,char * dazzletype);
  226. static void set_region_in_all_selected(INodeListClass * list,char region);
  227. /*
  228. ** Functions used by the tools rollup in the command panel
  229. */
  230. void descend_tree(INode * node,int action);
  231. void hide_node(INode * node);
  232. void select_geometry_node(INode * node);
  233. void select_hierarchy_node(INode * node);
  234. void select_alpha_node(INode * node);
  235. void select_physical_node(INode * node);
  236. void select_projectile_node(INode * node);
  237. void select_vis_node(INode * node);
  238. bool is_alpha_material(Mtl * nodemtl);
  239. bool is_alpha_mesh(INode * node,Mtl * nodemtl);
  240. void cs_remove_nu_scale(INode * node);
  241. void generate_names(void);
  242. void generate_node_name(INode * node);
  243. void generate_material_names(void);
  244. void generate_material_names_for_node(INode * node);
  245. void generate_material_names(Mtl * mtl);
  246. void generate_lod_extensions(void);
  247. void generate_lod_ext(INode * node);
  248. void create_floater(void);
  249. void export_with_standard_materials();
  250. int convert_materials (MaterialConversionEnum conversion, MaterialReferenceMaker *gamenodematerials);
  251. StdMat * new_standard_material (GameMtl *gamemtl);
  252. static W3DAppData0Struct * get_app_data_0(INode * node);
  253. static W3DAppData1Struct * get_app_data_1(INode * node);
  254. static W3DAppData2Struct * get_app_data_2(INode * node);
  255. static W3DDazzleAppDataStruct * get_dazzle_app_data(INode * node);
  256. };
  257. static W3DUtilityClass TheW3DUtility;
  258. /**********************************************************************************************
  259. **
  260. ** W3DUtilityClassDesc - Class Descriptor for the W3D Utility
  261. **
  262. **********************************************************************************************/
  263. class W3DUtilityClassDesc:public ClassDesc
  264. {
  265. public:
  266. int IsPublic() { return 1; }
  267. void * Create(BOOL loading = FALSE) { return &TheW3DUtility; }
  268. const TCHAR * ClassName() { return Get_String(IDS_W3D_UTILITY_CLASS_NAME); }
  269. SClass_ID SuperClassID() { return UTILITY_CLASS_ID; }
  270. Class_ID ClassID() { return W3DUtilityClassID; }
  271. const TCHAR* Category() { return Get_String(IDS_W3DMENU_CATEGORY); }
  272. };
  273. static W3DUtilityClassDesc W3DUtilityDesc;
  274. ClassDesc * Get_W3D_Utility_Desc(void)
  275. {
  276. return &W3DUtilityDesc;
  277. }
  278. /**********************************************************************************************
  279. **
  280. ** W3DUtilityClass Implementation
  281. **
  282. **********************************************************************************************/
  283. W3DUtilityClass::W3DUtilityClass(void)
  284. {
  285. InterfacePtr = NULL;
  286. SettingsPanelHWND = NULL;
  287. ToolsPanelHWND = NULL;
  288. UpdateSpinnerValue = true;
  289. }
  290. W3DUtilityClass::~W3DUtilityClass(void)
  291. {
  292. }
  293. void W3DUtilityClass::BeginEditParams(Interface *ip,IUtil *iu)
  294. {
  295. InterfacePtr = ip;
  296. SettingsPanelHWND = InterfacePtr->AddRollupPage(
  297. AppInstance,
  298. MAKEINTRESOURCE(IDD_W3DUTILITY_SETTINGS_DIALOG),
  299. _settings_form_dlg_proc,
  300. Get_String(IDS_W3DUTILITY_SETTINGS),
  301. 0);
  302. ToolsPanelHWND = InterfacePtr->AddRollupPage(
  303. AppInstance,
  304. MAKEINTRESOURCE(IDD_W3DUTILITY_TOOLS_DIALOG),
  305. _w3d_utility_tools_dlg_proc,
  306. Get_String(IDS_W3DUTILITY_TOOLS),
  307. 0);
  308. #if defined W3D_BIPED
  309. //Moumine 3/18/2002 2:25:02 PM
  310. ToolsPanelHWND = InterfacePtr->AddRollupPage(
  311. AppInstance,
  312. MAKEINTRESOURCE(IDD_W3DUTILITY_CSTOOLS),
  313. _w3d_utility_cstools_dlg_proc,
  314. Get_String(IDS_W3DUTILITY_CSTOOLS),
  315. 0);
  316. #endif
  317. //End Moumine
  318. // TheRCMenu.Bind(TheW3DUtility.InterfacePtr,&TheW3DUtility);
  319. // RightClickMenuManager *rcm = ip->GetRightClickMenuManager();
  320. // if (TheRCMenu.Installed!=TRUE) {
  321. // rcm->Register(&TheRCMenu);
  322. // }
  323. SettingsFormClass::Update_All_Instances();
  324. }
  325. void W3DUtilityClass::EndEditParams(Interface *ip,IUtil *iu)
  326. {
  327. InterfacePtr = NULL;
  328. ip->DeleteRollupPage(SettingsPanelHWND);
  329. ip->DeleteRollupPage(ToolsPanelHWND);
  330. SettingsPanelHWND = NULL;
  331. ToolsPanelHWND = NULL;
  332. }
  333. void W3DUtilityClass::SelectionSetChanged(Interface *ip,IUtil *iu)
  334. {
  335. // (gth) the settings panels which need to respond to the selection set changing
  336. // are now registered directly with MAX and don't need to be updated here
  337. // update_dialog();
  338. }
  339. int W3DUtilityClass::eval_tri_state(int totalcount,int oncount)
  340. {
  341. if (oncount == 0) {
  342. return 0;
  343. }
  344. if (oncount == totalcount) {
  345. return 1;
  346. }
  347. return 2;
  348. }
  349. void W3DUtilityClass::eval_node_states(INodeListClass * list,NodeStatesStruct * ns)
  350. {
  351. // initialize the counters and booleans
  352. ns->ExportHierarchy = 0;
  353. ns->ExportGeometry = 0;
  354. ns->GeometryHidden = 0;
  355. ns->GeometryTwoSided = 0;
  356. ns->GeometryZNormals = 0;
  357. ns->GeometryVertexAlpha = 0;
  358. ns->GeometryCastShadow = 0;
  359. ns->GeometryShatterable = 0;
  360. ns->GeometryNPatch = 0;
  361. ns->CollisionPhysical = 0;
  362. ns->CollisionProjectile = 0;
  363. ns->CollisionVis = 0;
  364. ns->CollisionCamera = 0;
  365. ns->CollisionVehicle = 0;
  366. ns->GeometryCameraAligned = false;
  367. ns->GeometryCameraOriented = false;
  368. ns->GeometryNormal = false;
  369. ns->GeometryAABox = false;
  370. ns->GeometryOBBox = false;
  371. ns->GeometryNull = false;
  372. ns->GeometryDazzle = false;
  373. ns->GeometryAggregate = false;
  374. /*
  375. ** ns->DamageRegion will be MAX_DAMAGE_REGIONS if not all
  376. ** of the selected nodes are in the same damage region. If
  377. ** they are, then ns->DamageRegion will be the region they
  378. ** share.
  379. */
  380. if (list->Num_Nodes() > 0)
  381. {
  382. // Use the first damage region for comparing to the others.
  383. W3DAppData1Struct *wdata = get_app_data_1((*list)[0]);
  384. ns->DamageRegion = wdata->DamageRegion;
  385. }
  386. else
  387. ns->DamageRegion = MAX_DAMAGE_REGIONS;
  388. /*
  389. ** ns->DazzleType will be DEFAULT if not all of the selected
  390. ** nodes are the same. If they are the same, it will be the
  391. ** dazzle type that they all share
  392. */
  393. ns->DazzleCount = 0;
  394. if (list->Num_Nodes() > 0) {
  395. W3DDazzleAppDataStruct * dazzledata = get_dazzle_app_data((*list)[0]);
  396. strncpy(ns->DazzleType,dazzledata->DazzleType,sizeof(ns->DazzleType));
  397. } else {
  398. strcpy(ns->DazzleType,"DEFAULT");
  399. }
  400. /*
  401. ** evaluate each node
  402. */
  403. for (unsigned int ni=0; ni<list->Num_Nodes(); ni++) {
  404. W3DAppData2Struct * wdata = get_app_data_2((*list)[ni]);
  405. assert(wdata);
  406. ns->ExportHierarchy += (wdata->Is_Bone() ? 1 : 0);
  407. ns->ExportGeometry += (wdata->Is_Geometry() ? 1 : 0);
  408. ns->GeometryHidden += (wdata->Is_Hidden_Enabled() ? 1 : 0);
  409. ns->GeometryTwoSided += (wdata->Is_Two_Sided_Enabled() ? 1 : 0);
  410. ns->GeometryZNormals += (wdata->Is_ZNormals_Enabled() ? 1 : 0);
  411. ns->GeometryVertexAlpha += (wdata->Is_Vertex_Alpha_Enabled() ? 1 : 0);
  412. ns->GeometryCastShadow += (wdata->Is_Shadow_Enabled() ? 1 : 0);
  413. ns->GeometryShatterable += (wdata->Is_Shatterable_Enabled() ? 1 : 0);
  414. ns->GeometryNPatch += (wdata->Is_NPatchable_Enabled() ? 1 : 0);
  415. ns->CollisionPhysical += (wdata->Is_Physical_Collision_Enabled() ? 1 : 0);
  416. ns->CollisionProjectile += (wdata->Is_Projectile_Collision_Enabled() ? 1 : 0);
  417. ns->CollisionVis += (wdata->Is_Vis_Collision_Enabled() ? 1 : 0);
  418. ns->CollisionCamera += (wdata->Is_Camera_Collision_Enabled() ? 1 : 0);
  419. ns->CollisionVehicle += (wdata->Is_Vehicle_Collision_Enabled() ? 1 : 0);
  420. switch (wdata->Get_Geometry_Type()) {
  421. case W3DAppData2Struct::GEO_TYPE_CAMERA_ALIGNED: ns->GeometryCameraAligned = true; break;
  422. case W3DAppData2Struct::GEO_TYPE_CAMERA_ORIENTED: ns->GeometryCameraOriented = true; break;
  423. case W3DAppData2Struct::GEO_TYPE_NORMAL_MESH: ns->GeometryNormal = true; break;
  424. case W3DAppData2Struct::GEO_TYPE_AABOX: ns->GeometryAABox = true; break;
  425. case W3DAppData2Struct::GEO_TYPE_OBBOX: ns->GeometryOBBox = true; break;
  426. case W3DAppData2Struct::GEO_TYPE_NULL: ns->GeometryNull = true; break;
  427. case W3DAppData2Struct::GEO_TYPE_DAZZLE: ns->GeometryDazzle = true; ns->DazzleCount++; break;
  428. case W3DAppData2Struct::GEO_TYPE_AGGREGATE: ns->GeometryAggregate = true; break;
  429. }
  430. // Compare this damage region to our existing one. If it's not the same,
  431. // use MAX_DAMAGE_REGION (an invalid value) as a sentinel value.
  432. if (ns->DamageRegion != MAX_DAMAGE_REGIONS)
  433. {
  434. W3DAppData1Struct *wdata1 = get_app_data_1((*list)[ni]);
  435. assert(wdata1);
  436. if (wdata1->DamageRegion != ns->DamageRegion)
  437. ns->DamageRegion = MAX_DAMAGE_REGIONS;
  438. }
  439. // compare this objects dazzle type to our existing one. If its not
  440. // the same, use 'DEFAULT'.
  441. W3DDazzleAppDataStruct * dazzledata = get_dazzle_app_data((*list)[ni]);
  442. if (strcmp(ns->DazzleType,dazzledata->DazzleType) != 0) {
  443. strcpy(ns->DazzleType,"DEFAULT");
  444. }
  445. }
  446. // If any of the counters are zero, that means none of the objects had that
  447. // bit set. If any of them are equal to the number of objects, then they
  448. // all had that bit set. Otherwise, there was a mix and we should use the
  449. // third state for the checkbox (greyed out check).
  450. int count = list->Num_Nodes();
  451. ns->ExportHierarchy = eval_tri_state(count, ns->ExportHierarchy);
  452. ns->ExportGeometry = eval_tri_state(count, ns->ExportGeometry);
  453. ns->GeometryHidden = eval_tri_state(count, ns->GeometryHidden);
  454. ns->GeometryTwoSided = eval_tri_state(count, ns->GeometryTwoSided);
  455. ns->GeometryZNormals = eval_tri_state(count, ns->GeometryZNormals);
  456. ns->GeometryVertexAlpha = eval_tri_state(count, ns->GeometryVertexAlpha);
  457. ns->GeometryCastShadow = eval_tri_state(count, ns->GeometryCastShadow);
  458. ns->GeometryShatterable = eval_tri_state(count, ns->GeometryShatterable);
  459. ns->GeometryNPatch = eval_tri_state(count, ns->GeometryNPatch);
  460. ns->CollisionPhysical = eval_tri_state(count, ns->CollisionPhysical);
  461. ns->CollisionProjectile = eval_tri_state(count, ns->CollisionProjectile);
  462. ns->CollisionVis = eval_tri_state(count, ns->CollisionVis);
  463. ns->CollisionCamera = eval_tri_state(count, ns->CollisionCamera);
  464. ns->CollisionVehicle = eval_tri_state(count, ns->CollisionVehicle);
  465. }
  466. void W3DUtilityClass::update_settings_controls(INodeListClass * node_list)
  467. {
  468. SettingsFormClass::Update_All_Instances();
  469. }
  470. void W3DUtilityClass::set_hierarchy_in_all_selected(INodeListClass * node_list,bool onoff)
  471. {
  472. for (unsigned int ni=0; ni<node_list->Num_Nodes(); ni++) {
  473. W3DAppData2Struct * wdata = get_app_data_2((*node_list)[ni]);
  474. wdata->Enable_Export_Transform(onoff);
  475. }
  476. update_settings_controls(node_list);
  477. }
  478. void W3DUtilityClass::set_geometry_in_all_selected(INodeListClass * node_list,bool onoff)
  479. {
  480. for (unsigned int ni=0; ni<node_list->Num_Nodes(); ni++) {
  481. W3DAppData2Struct * wdata = get_app_data_2((*node_list)[ni]);
  482. wdata->Enable_Export_Geometry(onoff);
  483. }
  484. update_settings_controls(node_list);
  485. }
  486. void W3DUtilityClass::enable_hidden_in_all_selected(INodeListClass * node_list,bool onoff)
  487. {
  488. for (unsigned int ni=0; ni<node_list->Num_Nodes(); ni++) {
  489. W3DAppData2Struct * wdata = get_app_data_2((*node_list)[ni]);
  490. wdata->Enable_Hidden(onoff);
  491. }
  492. update_settings_controls(node_list);
  493. }
  494. void W3DUtilityClass::enable_two_sided_in_all_selected(INodeListClass * node_list,bool onoff)
  495. {
  496. for (unsigned int ni=0; ni<node_list->Num_Nodes(); ni++) {
  497. W3DAppData2Struct * wdata = get_app_data_2((*node_list)[ni]);
  498. wdata->Enable_Two_Sided(onoff);
  499. }
  500. update_settings_controls(node_list);
  501. }
  502. void W3DUtilityClass::enable_znormals_in_all_selected(INodeListClass * node_list,bool onoff)
  503. {
  504. for (unsigned int ni=0; ni<node_list->Num_Nodes(); ni++) {
  505. W3DAppData2Struct * wdata = get_app_data_2((*node_list)[ni]);
  506. wdata->Enable_ZNormals(onoff);
  507. }
  508. update_settings_controls(node_list);
  509. }
  510. void W3DUtilityClass::enable_vertex_alpha_in_all_selected(INodeListClass * node_list,bool onoff)
  511. {
  512. for (unsigned int ni=0; ni<node_list->Num_Nodes(); ni++) {
  513. W3DAppData2Struct * wdata = get_app_data_2((*node_list)[ni]);
  514. wdata->Enable_Vertex_Alpha(onoff);
  515. }
  516. update_settings_controls(node_list);
  517. }
  518. void W3DUtilityClass::enable_shadow_in_all_selected(INodeListClass * node_list,bool onoff)
  519. {
  520. for (unsigned int ni=0; ni<node_list->Num_Nodes(); ni++) {
  521. W3DAppData2Struct * wdata = get_app_data_2((*node_list)[ni]);
  522. wdata->Enable_Shadow(onoff);
  523. }
  524. update_settings_controls(node_list);
  525. }
  526. void W3DUtilityClass::enable_shatterable_in_all_selected(INodeListClass * node_list,bool onoff)
  527. {
  528. for (unsigned int ni=0; ni<node_list->Num_Nodes(); ni++) {
  529. W3DAppData2Struct * wdata = get_app_data_2((*node_list)[ni]);
  530. wdata->Enable_Shatterable(onoff);
  531. }
  532. update_settings_controls(node_list);
  533. }
  534. void W3DUtilityClass::enable_npatches_in_all_selected(INodeListClass * node_list,bool onoff)
  535. {
  536. for (unsigned int ni=0; ni<node_list->Num_Nodes(); ni++) {
  537. W3DAppData2Struct * wdata = get_app_data_2((*node_list)[ni]);
  538. wdata->Enable_NPatchable(onoff);
  539. }
  540. update_settings_controls(node_list);
  541. }
  542. void W3DUtilityClass::enable_physical_collision_in_all_selected(INodeListClass * node_list,bool onoff)
  543. {
  544. for (unsigned int ni=0; ni<node_list->Num_Nodes(); ni++) {
  545. W3DAppData2Struct * wdata = get_app_data_2((*node_list)[ni]);
  546. wdata->Enable_Physical_Collision(onoff);
  547. }
  548. update_settings_controls(node_list);
  549. }
  550. void W3DUtilityClass::enable_projectile_collision_in_all_selected(INodeListClass * node_list,bool onoff)
  551. {
  552. for (unsigned int ni=0; ni<node_list->Num_Nodes(); ni++) {
  553. W3DAppData2Struct * wdata = get_app_data_2((*node_list)[ni]);
  554. wdata->Enable_Projectile_Collision(onoff);
  555. }
  556. update_settings_controls(node_list);
  557. }
  558. void W3DUtilityClass::enable_vis_collision_in_all_selected(INodeListClass * node_list,bool onoff)
  559. {
  560. for (unsigned int ni=0; ni<node_list->Num_Nodes(); ni++) {
  561. W3DAppData2Struct * wdata = get_app_data_2((*node_list)[ni]);
  562. wdata->Enable_Vis_Collision(onoff);
  563. }
  564. update_settings_controls(node_list);
  565. }
  566. void W3DUtilityClass::enable_camera_collision_in_all_selected(INodeListClass * node_list,bool onoff)
  567. {
  568. for (unsigned int ni=0; ni<node_list->Num_Nodes(); ni++) {
  569. W3DAppData2Struct * wdata = get_app_data_2((*node_list)[ni]);
  570. wdata->Enable_Camera_Collision(onoff);
  571. }
  572. update_settings_controls(node_list);
  573. }
  574. void W3DUtilityClass::enable_vehicle_collision_in_all_selected(INodeListClass * node_list,bool onoff)
  575. {
  576. for (unsigned int ni=0; ni<node_list->Num_Nodes(); ni++) {
  577. W3DAppData2Struct * wdata = get_app_data_2((*node_list)[ni]);
  578. wdata->Enable_Vehicle_Collision(onoff);
  579. }
  580. update_settings_controls(node_list);
  581. }
  582. void W3DUtilityClass::set_geometry_type_in_all_selected(INodeListClass * node_list,int geotype)
  583. {
  584. for (unsigned int ni=0; ni<node_list->Num_Nodes(); ni++) {
  585. W3DAppData2Struct * wdata = get_app_data_2((*node_list)[ni]);
  586. wdata->Set_Geometry_Type((W3DAppData2Struct::GeometryTypeEnum)geotype);
  587. }
  588. update_settings_controls(node_list);
  589. }
  590. void W3DUtilityClass::set_dazzle_type_in_all_selected(INodeListClass * node_list,char * dazzle_type)
  591. {
  592. for (unsigned int ni=0; ni<node_list->Num_Nodes(); ni++) {
  593. W3DDazzleAppDataStruct * dazzledata = get_dazzle_app_data((*node_list)[ni]);
  594. strncpy(dazzledata->DazzleType,dazzle_type,sizeof(dazzledata->DazzleType) - 1);
  595. }
  596. update_settings_controls(node_list);
  597. }
  598. void W3DUtilityClass::set_region_in_all_selected(INodeListClass * list,char region)
  599. {
  600. if (list->Num_Nodes() == 0) return;
  601. // Damage regions are stored in each node's AppData1.
  602. for (int i = 0; i < list->Num_Nodes(); i++)
  603. {
  604. W3DAppData1Struct *wdata = get_app_data_1((*list)[i]);
  605. wdata->DamageRegion = region;
  606. }
  607. update_settings_controls(list);
  608. }
  609. void W3DUtilityClass::generate_names(void)
  610. {
  611. GenNamesDialogClass dialog(InterfacePtr);
  612. bool retval = dialog.Get_Options(&NameOptions);
  613. WorkingNameIndex = NameOptions.NameIndex;
  614. if (retval) {
  615. descend_tree(InterfacePtr->GetRootNode(),GENERATE_NAME);
  616. }
  617. }
  618. void W3DUtilityClass::generate_material_names(void)
  619. {
  620. GenMtlNamesDialogClass dialog(InterfacePtr);
  621. bool retval = dialog.Get_Options(&MtlNameOptions);
  622. WorkingNameIndex = MtlNameOptions.NameIndex;
  623. if (retval) {
  624. descend_tree(InterfacePtr->GetRootNode(),GENERATE_MATERIAL_NAME);
  625. }
  626. }
  627. void W3DUtilityClass::generate_lod_extensions(void)
  628. {
  629. GenLodExtensionDialogClass dialog(InterfacePtr);
  630. bool retval = dialog.Get_Options(&LodExtensionOptions);
  631. if (retval) {
  632. descend_tree(InterfacePtr->GetRootNode(),GENERATE_LOD_EXTENSION);
  633. }
  634. }
  635. void W3DUtilityClass::generate_lod_ext(INode * node)
  636. {
  637. /*
  638. ** Only works on selected nodes.
  639. */
  640. if (!node->Selected())
  641. return;
  642. /*
  643. ** If this node already has an LOD extension, we'll replace it
  644. ** with the new LOD index. Otherwise we'll tack it on the end.
  645. ** Display a error message if the name is too long to append
  646. ** the extension, and skip the node without changing the name.
  647. */
  648. char msg[256];
  649. char newname[W3D_NAME_LEN];
  650. char *oldname = node->GetName();
  651. char *ext = strrchr(oldname, '.');
  652. int old_lod;
  653. if ( (ext != NULL) && (sscanf(ext, ".%d", &old_lod) == 1) )
  654. {
  655. /*
  656. ** An existing LOD index. If it's different than the new
  657. ** one, replace it.
  658. */
  659. if (old_lod == LodExtensionOptions.LodIndex)
  660. return; // same lod index
  661. /*
  662. ** Room for the new extension? (2 because when we export, the extension will,
  663. ** be replaced by a single character [A..Z] to indicate the LOD level.
  664. ** ie. 2==strlen("A")+1)
  665. */
  666. if (ext - oldname + 2 <= W3D_NAME_LEN)
  667. {
  668. *ext = '\0';
  669. sprintf(newname, "%s.%02d", oldname, LodExtensionOptions.LodIndex);
  670. *ext = '.';
  671. node->SetName(newname);
  672. }
  673. else
  674. {
  675. *ext = '\0';
  676. sprintf(msg, "The maximum W3D object name is %d characters. Adding the LOD "
  677. "extension to \"%s\" will pass this limit! Please shorten its name.",
  678. W3D_NAME_LEN - 1, oldname);
  679. *ext = '.';
  680. MessageBox(NULL, msg, "Error", MB_OK);
  681. }
  682. }
  683. else
  684. {
  685. /*
  686. ** Room for the new extension? (2 because when we export, the extension will,
  687. ** be replaced by a single character [A..Z] to indicate the LOD level.
  688. ** ie. 2==strlen("A")+1)
  689. */
  690. if (strlen(oldname) + 2 <= W3D_NAME_LEN)
  691. {
  692. sprintf(newname, "%s.%02d", oldname, LodExtensionOptions.LodIndex);
  693. node->SetName(newname);
  694. }
  695. else
  696. {
  697. sprintf(msg, "The maximum W3D object name is %d characters. Adding the LOD "
  698. "extension to \"%s\" will pass this limit! Please shorten its name.",
  699. W3D_NAME_LEN - 1, oldname);
  700. MessageBox(NULL, msg, "Error", MB_OK);
  701. }
  702. }
  703. }
  704. void W3DUtilityClass::create_floater(void)
  705. {
  706. SettingsFloater.Create(InterfacePtr,IDD_W3DUTILITY_SETTINGS_DIALOG,_settings_form_dlg_proc);
  707. SettingsFormClass::Update_All_Instances();
  708. }
  709. void W3DUtilityClass::export_with_standard_materials()
  710. {
  711. char *convertingmessage = "Converting materials...";
  712. // Count the no. of references to game materials.
  713. MaterialReferenceMaker::ReferenceCount = convert_materials (GAME_REFERENCE_COUNT, NULL);
  714. MaterialReferenceMaker *gamenodematerials = NULL;
  715. if (MaterialReferenceMaker::ReferenceCount > 0) {
  716. gamenodematerials = new MaterialReferenceMaker [MaterialReferenceMaker::ReferenceCount];
  717. assert (gamenodematerials != NULL);
  718. }
  719. InterfacePtr->PushPrompt (convertingmessage);
  720. SetCursor (LoadCursor (NULL, IDC_WAIT));
  721. convert_materials (GAME_TO_STANDARD, gamenodematerials);
  722. InterfacePtr->PopPrompt();
  723. InterfacePtr->FileExport();
  724. UpdateWindow (InterfacePtr->GetMAXHWnd());
  725. InterfacePtr->PushPrompt (convertingmessage);
  726. SetCursor (LoadCursor (NULL, IDC_WAIT));
  727. convert_materials (STANDARD_TO_GAME, gamenodematerials);
  728. InterfacePtr->PopPrompt();
  729. // Clean-up.
  730. if (gamenodematerials != NULL) delete [] gamenodematerials;
  731. }
  732. int W3DUtilityClass::convert_materials (MaterialConversionEnum conversion, MaterialReferenceMaker *gamenodematerials)
  733. {
  734. int gamenodematerialindex = 0;
  735. INode *rootnode = InterfacePtr->GetRootNode();
  736. if (rootnode != NULL) {
  737. INodeListClass *meshlist = new INodeListClass (rootnode, 0);
  738. if (meshlist != NULL) {
  739. for (unsigned nodeindex = 0; nodeindex < meshlist->Num_Nodes(); nodeindex++) {
  740. Mtl *nodemtl = ((*meshlist) [nodeindex])->GetMtl();
  741. // Is this a non-null material?
  742. if (nodemtl != NULL) {
  743. // Is this not a multi-material?
  744. if (!nodemtl->IsMultiMtl()) {
  745. switch (conversion) {
  746. case GAME_REFERENCE_COUNT:
  747. if (nodemtl->ClassID() == GameMaterialClassID) {
  748. assert (((GameMtl*) nodemtl)->Substitute_Material() == NULL);
  749. }
  750. break;
  751. case GAME_TO_STANDARD:
  752. if (nodemtl->ClassID() == GameMaterialClassID) {
  753. // Make a reference to the game material to ensure that it is not deleted by the system.
  754. gamenodematerials [gamenodematerialindex].MakeRefByID (FOREVER, gamenodematerialindex, nodemtl);
  755. // Does this material already have an equivalent standard material?
  756. if (((GameMtl*) nodemtl)->Substitute_Material() == NULL) {
  757. ((GameMtl*) nodemtl)->Set_Substitute_Material (new_standard_material ((GameMtl*) nodemtl));
  758. }
  759. ((*meshlist) [nodeindex])->SetMtl (((GameMtl*) nodemtl)->Substitute_Material());
  760. } else {
  761. gamenodematerials [gamenodematerialindex].MaterialPtr = NULL;
  762. }
  763. break;
  764. case STANDARD_TO_GAME:
  765. // Change materials to game materials if they were previously game materials before being
  766. // converted to standard materials.
  767. if (gamenodematerials [gamenodematerialindex].MaterialPtr != NULL) {
  768. ((*meshlist) [nodeindex])->SetMtl (gamenodematerials [gamenodematerialindex].MaterialPtr);
  769. ((GameMtl*) gamenodematerials [gamenodematerialindex].MaterialPtr)->Set_Substitute_Material (NULL);
  770. }
  771. break;
  772. }
  773. gamenodematerialindex++;
  774. } else {
  775. // For each sub-material...
  776. for (int materialindex = 0; materialindex < nodemtl->NumSubMtls(); materialindex++) {
  777. Mtl *submaterial = nodemtl->GetSubMtl (materialindex);
  778. // Is this a non-null submaterial?
  779. if (submaterial != NULL) {
  780. switch (conversion) {
  781. case GAME_REFERENCE_COUNT:
  782. if (submaterial->ClassID() == GameMaterialClassID) {
  783. assert (((GameMtl*) submaterial)->Substitute_Material() == NULL);
  784. }
  785. break;
  786. case GAME_TO_STANDARD:
  787. if (submaterial->ClassID() == GameMaterialClassID) {
  788. // Make a reference to the game material to ensure that it is not deleted by the system.
  789. gamenodematerials [gamenodematerialindex].MakeRefByID (FOREVER, gamenodematerialindex, submaterial);
  790. // Does this material already have an equivalent standard material?
  791. if (((GameMtl*) submaterial)->Substitute_Material() == NULL) {
  792. ((GameMtl*) submaterial)->Set_Substitute_Material (new_standard_material ((GameMtl*) submaterial));
  793. }
  794. nodemtl->SetSubMtl (materialindex, ((GameMtl*) submaterial)->Substitute_Material());
  795. } else {
  796. gamenodematerials [gamenodematerialindex].MaterialPtr = NULL;
  797. }
  798. break;
  799. case STANDARD_TO_GAME:
  800. // Change materials to game materials if they were previously game materials before being
  801. // converted to standard materials.
  802. if (gamenodematerials [gamenodematerialindex].MaterialPtr != NULL) {
  803. nodemtl->SetSubMtl (materialindex, gamenodematerials [gamenodematerialindex].MaterialPtr);
  804. ((GameMtl*) gamenodematerials [gamenodematerialindex].MaterialPtr)->Set_Substitute_Material (NULL);
  805. }
  806. break;
  807. }
  808. gamenodematerialindex++;
  809. }
  810. }
  811. }
  812. }
  813. }
  814. // Clean-up.
  815. delete meshlist;
  816. }
  817. }
  818. return (gamenodematerialindex);
  819. }
  820. StdMat *W3DUtilityClass::new_standard_material (GameMtl *gamemtl)
  821. {
  822. Color emissive;
  823. // Create a new standard material.
  824. StdMat *stdmtl = NewDefaultStdMat();
  825. // Set its properties by translating the supplied game material.
  826. // NOTE 0: Only consider pass 0 in the game material - ignore all other passes.
  827. // NOTE 1: Use defaults for all standard material attributes that cannot be
  828. // converted from the game material in a meaningful way.
  829. stdmtl->SetName (gamemtl->GetName());
  830. stdmtl->SetAmbient (gamemtl->GetAmbient(), 0);
  831. stdmtl->SetDiffuse (gamemtl->GetDiffuse(), 0);
  832. stdmtl->SetSpecular (gamemtl->GetSpecular(), 0);
  833. stdmtl->SetOpacity (gamemtl->Get_Opacity (0, 0), 0);
  834. stdmtl->SetShininess (gamemtl->Get_Shininess (0, 0), 0);
  835. stdmtl->SetShinStr (gamemtl->GetShinStr(), 0);
  836. stdmtl->SetSubTexmap (ID_DI, gamemtl->Get_Texture (0, 0));
  837. emissive = gamemtl->Get_Emissive (0, 0);
  838. stdmtl->SetSelfIllum ((emissive.r + emissive.g + emissive.b) / 3.0f, 0);
  839. return (stdmtl);
  840. }
  841. void W3DUtilityClass::Select_Hierarchy(void)
  842. {
  843. InterfacePtr->SelectNode(NULL);
  844. INode * root = InterfacePtr->GetRootNode();
  845. descend_tree(root,SELECT_HIER);
  846. InterfacePtr->ForceCompleteRedraw();
  847. }
  848. //Moumine 3/18/2002 2:34:14 PM
  849. //============================================================================================
  850. void W3DUtilityClass::CSRemoveNonUniformScale(void)
  851. {
  852. InterfacePtr->SelectNode(NULL);
  853. INode * root = InterfacePtr->GetRootNode();
  854. descend_tree(root,CS_REMOVE_NUSCALE);
  855. InterfacePtr->ForceCompleteRedraw();
  856. }
  857. //End Moumine
  858. //============================================================================================
  859. void W3DUtilityClass::Select_Geometry(void)
  860. {
  861. InterfacePtr->SelectNode(NULL);
  862. INode * root = InterfacePtr->GetRootNode();
  863. descend_tree(root,SELECT_GEOM);
  864. InterfacePtr->ForceCompleteRedraw();
  865. }
  866. void W3DUtilityClass::Select_Alpha(void)
  867. {
  868. InterfacePtr->SelectNode(NULL);
  869. INode * root = InterfacePtr->GetRootNode();
  870. descend_tree(root,SELECT_ALPHA);
  871. InterfacePtr->ForceCompleteRedraw();
  872. }
  873. void W3DUtilityClass::Select_Physical(void)
  874. {
  875. InterfacePtr->SelectNode(NULL);
  876. INode * root = InterfacePtr->GetRootNode();
  877. descend_tree(root,SELECT_PHYSICAL);
  878. InterfacePtr->ForceCompleteRedraw();
  879. }
  880. void W3DUtilityClass::Select_Projectile(void)
  881. {
  882. InterfacePtr->SelectNode(NULL);
  883. INode * root = InterfacePtr->GetRootNode();
  884. descend_tree(root,SELECT_PROJECTILE);
  885. InterfacePtr->ForceCompleteRedraw();
  886. }
  887. void W3DUtilityClass::Select_Vis(void)
  888. {
  889. InterfacePtr->SelectNode(NULL);
  890. INode * root = InterfacePtr->GetRootNode();
  891. descend_tree(root,SELECT_VIS);
  892. InterfacePtr->ForceCompleteRedraw();
  893. }
  894. void W3DUtilityClass::descend_tree(INode * node,int func)
  895. {
  896. if (!node) return;
  897. switch (func)
  898. {
  899. case HIDE:
  900. hide_node(node);
  901. break;
  902. case SELECT_GEOM:
  903. select_geometry_node(node);
  904. break;
  905. case SELECT_HIER:
  906. select_hierarchy_node(node);
  907. break;
  908. case SELECT_ALPHA:
  909. select_alpha_node(node);
  910. break;
  911. case SELECT_PHYSICAL:
  912. select_physical_node(node);
  913. break;
  914. case SELECT_PROJECTILE:
  915. select_projectile_node(node);
  916. break;
  917. case SELECT_VIS:
  918. select_vis_node(node);
  919. break;
  920. case GENERATE_NAME:
  921. generate_node_name(node);
  922. break;
  923. case GENERATE_MATERIAL_NAME:
  924. generate_material_names_for_node(node);
  925. break;
  926. case GENERATE_LOD_EXTENSION:
  927. generate_lod_ext(node);
  928. break;
  929. //Moumine 3/18/2002 3:04:05 PM
  930. case CS_REMOVE_NUSCALE:
  931. cs_remove_nu_scale(node);
  932. break;
  933. //End Moumine
  934. default:
  935. break;
  936. };
  937. for (int i=0; i<node->NumberOfChildren(); i++) {
  938. INode * child = node->GetChildNode(i);
  939. descend_tree(child,func);
  940. }
  941. }
  942. void W3DUtilityClass::hide_node(INode * node)
  943. {
  944. if (!node->IsHidden()) node->Hide(TRUE);
  945. InterfacePtr->NodeInvalidateRect(node);
  946. }
  947. void W3DUtilityClass::select_geometry_node(INode * node)
  948. {
  949. if (Is_Geometry(node) && !node->IsHidden()) {
  950. InterfacePtr->SelectNode(node,0);
  951. }
  952. }
  953. //Moumine 3/18/2002 3:06:27 PM
  954. //============================================================================================
  955. void W3DUtilityClass::cs_remove_nu_scale(INode * node){
  956. Control* ctrl = node->GetTMController();
  957. if(ctrl){
  958. Class_ID clsid = ctrl->ClassID();
  959. #if defined W3D_BIPED
  960. if( clsid == BIPSLAVE_CONTROL_CLASS_ID || clsid == FOOTPRINT_CLASS_ID || clsid == BIPBODY_CONTROL_CLASS_ID){
  961. IBipedExport* ibipExport = (IBipedExport*) ctrl->GetInterface(I_BIPINTERFACE);
  962. assert(ibipExport);
  963. ibipExport->RemoveNonUniformScale(TRUE);
  964. }
  965. #endif
  966. }
  967. }
  968. //End Moumine
  969. //============================================================================================
  970. void W3DUtilityClass::select_hierarchy_node(INode * node)
  971. {
  972. if (Is_Bone(node) && !node->IsHidden()) {
  973. InterfacePtr->SelectNode(node,0);
  974. }
  975. }
  976. void W3DUtilityClass::select_alpha_node(INode * node)
  977. {
  978. if (node->IsHidden() || !Is_Geometry(node)) {
  979. return;
  980. }
  981. Mtl * nodemtl = node->GetMtl();
  982. if (is_alpha_material(nodemtl)) {
  983. if (is_alpha_mesh(node,nodemtl)) {
  984. InterfacePtr->SelectNode(node,0);
  985. }
  986. }
  987. }
  988. void W3DUtilityClass::select_physical_node(INode * node)
  989. {
  990. if (!node->IsHidden() && Is_Geometry(node) && Is_Physical_Collision(node)) {
  991. InterfacePtr->SelectNode(node,0);
  992. }
  993. }
  994. void W3DUtilityClass::select_projectile_node(INode * node)
  995. {
  996. if (!node->IsHidden() && Is_Geometry(node) && Is_Projectile_Collision(node)) {
  997. InterfacePtr->SelectNode(node,0);
  998. }
  999. }
  1000. void W3DUtilityClass::select_vis_node(INode * node)
  1001. {
  1002. if (!node->IsHidden() && Is_Geometry(node) && Is_Vis_Collision(node)) {
  1003. InterfacePtr->SelectNode(node,0);
  1004. }
  1005. }
  1006. bool W3DUtilityClass::is_alpha_material(Mtl * nodemtl)
  1007. {
  1008. if (nodemtl == NULL) {
  1009. return false;
  1010. }
  1011. bool is_alpha = false;
  1012. if (nodemtl->IsMultiMtl()) {
  1013. for (int mi=0; mi<nodemtl->NumSubMtls(); mi++) {
  1014. is_alpha |= is_alpha_material(nodemtl->GetSubMtl(mi));
  1015. }
  1016. } else {
  1017. if (nodemtl->ClassID() == GameMaterialClassID) {
  1018. GameMtl * gamemtl = (GameMtl *)nodemtl;
  1019. if ( (gamemtl->Get_Dest_Blend(0) == W3DSHADER_DESTBLENDFUNC_SRC_ALPHA) ||
  1020. (gamemtl->Get_Dest_Blend(0) == W3DSHADER_DESTBLENDFUNC_ONE_MINUS_SRC_ALPHA) ||
  1021. (gamemtl->Get_Src_Blend(0) == W3DSHADER_SRCBLENDFUNC_SRC_ALPHA) ||
  1022. (gamemtl->Get_Src_Blend(0) == W3DSHADER_SRCBLENDFUNC_ONE_MINUS_SRC_ALPHA) ||
  1023. (gamemtl->Get_Alpha_Test(0) == W3DSHADER_ALPHATEST_ENABLE) )
  1024. {
  1025. is_alpha = true;
  1026. }
  1027. }
  1028. }
  1029. return is_alpha;
  1030. }
  1031. bool W3DUtilityClass::is_alpha_mesh(INode * node,Mtl * nodemtl)
  1032. {
  1033. Object * obj = node->EvalWorldState(0).obj;
  1034. TriObject * tri = (TriObject *)obj->ConvertToType(0, triObjectClassID);
  1035. if (tri != NULL) {
  1036. Mesh & mesh = tri->mesh;
  1037. int face_index;
  1038. int mat_index;
  1039. if (nodemtl == NULL) {
  1040. return false;
  1041. } else if (nodemtl->NumSubMtls() <= 1) {
  1042. return is_alpha_material(nodemtl);
  1043. } else {
  1044. int sub_mtl_count = nodemtl->NumSubMtls();
  1045. bool * sub_mtl_flags = new bool[sub_mtl_count];
  1046. // Initialize each sub-material flag to false (indicates that the material is un-used)
  1047. for (mat_index=0; mat_index<sub_mtl_count; mat_index++) {
  1048. sub_mtl_flags[mat_index] = false;
  1049. }
  1050. // Set a true for each material actually referenced by the mesh
  1051. for (face_index=0; face_index<mesh.getNumFaces(); face_index++) {
  1052. int max_mat_index = mesh.faces[face_index].getMatID();
  1053. int mat_index = (max_mat_index % sub_mtl_count);
  1054. sub_mtl_flags[mat_index] = true;
  1055. }
  1056. // Loop over the used materials and return true if any are alpha materials
  1057. for (mat_index=0; mat_index<sub_mtl_count; mat_index++) {
  1058. if (sub_mtl_flags[mat_index]) {
  1059. if (is_alpha_material(nodemtl->GetSubMtl(mat_index))) {
  1060. return true;
  1061. }
  1062. }
  1063. }
  1064. }
  1065. }
  1066. return false;
  1067. }
  1068. void W3DUtilityClass::generate_node_name(INode * node)
  1069. {
  1070. TCHAR temp_string[256];
  1071. if (NameOptions.OnlyAffectSelected && !node->Selected()) {
  1072. return;
  1073. }
  1074. if (!Is_Bone(node) && !Is_Geometry(node)) {
  1075. return;
  1076. }
  1077. if (NameOptions.AssignNames) {
  1078. _stprintf(temp_string,"%s%03d",NameOptions.RootName,WorkingNameIndex);
  1079. node->SetName(temp_string);
  1080. WorkingNameIndex++;
  1081. }
  1082. if (NameOptions.AssignPrefix) {
  1083. _stprintf(temp_string,"%s%s",NameOptions.PrefixName,node->GetName());
  1084. node->SetName(temp_string);
  1085. }
  1086. if (NameOptions.AssignSuffix) {
  1087. _stprintf(temp_string,"%s%s",node->GetName(),NameOptions.SuffixName);
  1088. node->SetName(temp_string);
  1089. }
  1090. if (NameOptions.AssignCollisionBits) {
  1091. W3DAppData2Struct * wdata = W3DAppData2Struct::Get_App_Data(node);
  1092. assert(wdata);
  1093. wdata->Enable_Physical_Collision(NameOptions.PhysicalCollision);
  1094. wdata->Enable_Projectile_Collision(NameOptions.ProjectileCollision);
  1095. wdata->Enable_Vis_Collision(NameOptions.VisCollision);
  1096. wdata->Enable_Camera_Collision(NameOptions.CameraCollision);
  1097. wdata->Enable_Vehicle_Collision(NameOptions.VehicleCollision);
  1098. }
  1099. }
  1100. void W3DUtilityClass::generate_material_names_for_node(INode * node)
  1101. {
  1102. if (MtlNameOptions.OnlyAffectSelected && !node->Selected()) {
  1103. return;
  1104. }
  1105. generate_material_names(node->GetMtl());
  1106. }
  1107. void W3DUtilityClass::generate_material_names(Mtl * mtl)
  1108. {
  1109. if (mtl == NULL) {
  1110. return;
  1111. }
  1112. // set the name of this material and increment the index
  1113. TCHAR newname[GenMtlNamesDialogClass::MAX_MATERIAL_NAME_LEN];
  1114. _stprintf(newname,"%s%03d",MtlNameOptions.RootName,WorkingNameIndex);
  1115. mtl->SetName(newname);
  1116. WorkingNameIndex++;
  1117. // recurse into children
  1118. if (mtl->IsMultiMtl()) {
  1119. for (int mi=0; mi<mtl->NumSubMtls(); mi++) {
  1120. generate_material_names(mtl->GetSubMtl(mi));
  1121. }
  1122. }
  1123. }
  1124. W3DAppData0Struct * W3DUtilityClass::get_app_data_0(INode * node)
  1125. {
  1126. /*
  1127. ** Try to get our AppData which has the export flags
  1128. */
  1129. W3DAppData0Struct * wdata = NULL;
  1130. AppDataChunk * appdata = node->GetAppDataChunk(W3DUtilityClassID,UTILITY_CLASS_ID,0);
  1131. /*
  1132. ** If there wasn't one, return NULL since this app data chunk is obsolete now.
  1133. ** If there was one, get the data from it
  1134. */
  1135. if (appdata) {
  1136. wdata = (W3DAppData0Struct *)(appdata->data);
  1137. }
  1138. return wdata;
  1139. }
  1140. W3DAppData1Struct * W3DUtilityClass::get_app_data_1(INode * node)
  1141. {
  1142. // Try to get our AppData which has the damage region
  1143. W3DAppData1Struct * wdata = NULL;
  1144. AppDataChunk * appdata = node->GetAppDataChunk(W3DUtilityClassID,UTILITY_CLASS_ID,1);
  1145. // If there wasn't one, add one. If there was one, get the data from it
  1146. if (appdata) {
  1147. wdata = (W3DAppData1Struct *)(appdata->data);
  1148. } else {
  1149. wdata = new W3DAppData1Struct;
  1150. node->AddAppDataChunk(W3DUtilityClassID,UTILITY_CLASS_ID,1,sizeof(W3DAppData1Struct),wdata);
  1151. appdata = node->GetAppDataChunk(W3DUtilityClassID,UTILITY_CLASS_ID,1);
  1152. assert(appdata);
  1153. }
  1154. return wdata;
  1155. }
  1156. W3DAppData2Struct * W3DUtilityClass::get_app_data_2(INode * node)
  1157. {
  1158. return W3DAppData2Struct::Get_App_Data(node);
  1159. }
  1160. W3DDazzleAppDataStruct * W3DUtilityClass::get_dazzle_app_data(INode * node)
  1161. {
  1162. return W3DDazzleAppDataStruct::Get_App_Data(node);
  1163. }
  1164. //Moumine 3/18/2002 2:26:44 PM
  1165. /**********************************************************************************************
  1166. **
  1167. ** Dialog procs for the W3DUtilityClass
  1168. **
  1169. **********************************************************************************************/
  1170. static BOOL CALLBACK _w3d_utility_cstools_dlg_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam){
  1171. switch (msg) {
  1172. case WM_LBUTTONDOWN:
  1173. case WM_LBUTTONUP:
  1174. case WM_MOUSEMOVE:
  1175. TheW3DUtility.InterfacePtr->RollupMouseMessage(hWnd,msg,wParam,lParam);
  1176. break;
  1177. case WM_COMMAND:{
  1178. switch (LOWORD(wParam)){
  1179. case IDC_REMOVE_NONUNIFORM:{
  1180. TheW3DUtility.CSRemoveNonUniformScale();
  1181. break;
  1182. }
  1183. }
  1184. return TRUE;
  1185. }
  1186. default:
  1187. return FALSE;
  1188. }
  1189. return FALSE;
  1190. }
  1191. //End Moumine
  1192. /**********************************************************************************************
  1193. **
  1194. ** Dialog procs for the W3DUtilityClass
  1195. **
  1196. **********************************************************************************************/
  1197. static BOOL CALLBACK _w3d_utility_tools_dlg_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
  1198. {
  1199. switch (msg) {
  1200. case WM_LBUTTONDOWN:
  1201. case WM_LBUTTONUP:
  1202. case WM_MOUSEMOVE:
  1203. TheW3DUtility.InterfacePtr->RollupMouseMessage(hWnd,msg,wParam,lParam);
  1204. break;
  1205. case WM_COMMAND:
  1206. {
  1207. switch (LOWORD(wParam))
  1208. {
  1209. /*
  1210. ** Buttons
  1211. */
  1212. case IDC_SELECT_GEOMETRY:
  1213. TheW3DUtility.Select_Geometry();
  1214. break;
  1215. case IDC_SELECT_HIERARCHY:
  1216. TheW3DUtility.Select_Hierarchy();
  1217. break;
  1218. case IDC_SELECT_ALPHA_MESHES:
  1219. TheW3DUtility.Select_Alpha();
  1220. break;
  1221. case IDC_SELECT_PHYSICAL:
  1222. TheW3DUtility.Select_Physical();
  1223. break;
  1224. case IDC_SELECT_PROJECTILE:
  1225. TheW3DUtility.Select_Projectile();
  1226. break;
  1227. case IDC_SELECT_VIS:
  1228. TheW3DUtility.Select_Vis();
  1229. break;
  1230. case IDC_COLLECTION_NAMES_GENERATE:
  1231. TheW3DUtility.generate_names();
  1232. TheW3DUtility.update_settings_controls();
  1233. break;
  1234. case IDC_MATERIAL_NAMES_GENERATE:
  1235. TheW3DUtility.generate_material_names();
  1236. TheW3DUtility.update_settings_controls();
  1237. break;
  1238. case IDC_LOD_EXTENSION_GENERATE:
  1239. TheW3DUtility.generate_lod_extensions();
  1240. TheW3DUtility.update_settings_controls();
  1241. break;
  1242. case IDC_EXPORT_STANDARD_MATERIALS:
  1243. TheW3DUtility.export_with_standard_materials();
  1244. break;
  1245. case IDC_CREATE_SETTINGS_FLOATER:
  1246. TheW3DUtility.create_floater();
  1247. break;
  1248. }
  1249. return TRUE;
  1250. }
  1251. default:
  1252. return FALSE;
  1253. }
  1254. return TRUE;
  1255. }
  1256. /**********************************************************************************************
  1257. **
  1258. ** SettingsFormClass Implementation
  1259. ** NOTE: When you use the _settings_form_dlg_proc, a SettingsFormClass will automatically
  1260. ** be allocated and attached to the dialog. You can cause all of the active forms to
  1261. ** refresh their status by calling Update_All_Instances. The forms will be destroyed when
  1262. ** the window is destroyed.
  1263. **
  1264. **********************************************************************************************/
  1265. SettingsFormClass * SettingsFormClass::ActiveList = NULL;
  1266. BOOL CALLBACK _settings_form_dlg_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
  1267. {
  1268. if (msg == WM_INITDIALOG) {
  1269. SettingsFormClass * form = new SettingsFormClass(hWnd);
  1270. ::SetProp(hWnd,"SettingsFormClass",(HANDLE)form);
  1271. }
  1272. SettingsFormClass * form = (SettingsFormClass *)::GetProp(hWnd,"SettingsFormClass");
  1273. if (form) {
  1274. return form->Dialog_Proc(hWnd,msg,wParam,lParam);
  1275. } else {
  1276. return FALSE;
  1277. }
  1278. }
  1279. static void _settings_form_selection_changed_callback(void * param,NotifyInfo * info)
  1280. {
  1281. ((SettingsFormClass*)param)->Selection_Changed();
  1282. }
  1283. SettingsFormClass::SettingsFormClass(HWND hwnd) :
  1284. Hwnd(hwnd),
  1285. RegionSpin(NULL)
  1286. {
  1287. /*
  1288. ** Link into the active list
  1289. */
  1290. Next = ActiveList;
  1291. ActiveList = this;
  1292. /*
  1293. ** Register with MAX
  1294. */
  1295. ::RegisterNotification(_settings_form_selection_changed_callback, this, NOTIFY_SELECTIONSET_CHANGED);
  1296. }
  1297. SettingsFormClass::~SettingsFormClass(void)
  1298. {
  1299. /*
  1300. ** Unregister from MAX
  1301. */
  1302. ::UnRegisterNotification(_settings_form_selection_changed_callback, this, NOTIFY_SELECTIONSET_CHANGED);
  1303. /*
  1304. ** Unlink from the active list
  1305. */
  1306. if (ActiveList == this) {
  1307. ActiveList = Next;
  1308. } else {
  1309. SettingsFormClass * prev = ActiveList;
  1310. SettingsFormClass * cur = ActiveList->Next;
  1311. while ((cur != this) && (cur != NULL)) {
  1312. cur = cur->Next;
  1313. prev = prev->Next;
  1314. }
  1315. assert(cur == this);
  1316. if (cur == this) {
  1317. prev->Next = cur->Next;
  1318. }
  1319. }
  1320. Hwnd = NULL;
  1321. }
  1322. void SettingsFormClass::Update_All_Instances(void)
  1323. {
  1324. if (ActiveList == NULL) {
  1325. return;
  1326. }
  1327. /*
  1328. ** Build a list of the selected nodes
  1329. */
  1330. INodeListClass node_list( ::GetCOREInterface()->GetRootNode(),
  1331. ::GetCOREInterface()->GetTime(),
  1332. &_INodeFilter );
  1333. /*
  1334. ** Update all settings forms
  1335. */
  1336. SettingsFormClass * form = ActiveList;
  1337. while (form != NULL) {
  1338. form->Update_Controls(&node_list);
  1339. form = form->Next;
  1340. }
  1341. }
  1342. void SettingsFormClass::Init(void)
  1343. {
  1344. // Initialize the contents of the dazzle combo
  1345. // Reset the dazzle combo
  1346. HWND dazzle_combo = GetDlgItem(Hwnd,IDC_DAZZLE_COMBO);
  1347. assert(dazzle_combo != NULL);
  1348. SendMessage(dazzle_combo,CB_RESETCONTENT,0,0);
  1349. // Load the section of Dazzle.INI that defines all of the types. The windows function
  1350. // that I'm using here, reads in a NULL-terminated string for each entry in the section. Each
  1351. // string is of the form 'key=value'. Based on my testing, it appears that windows removes any white
  1352. // space before or after the equal sign as well.
  1353. char dllpath[_MAX_PATH];
  1354. ::GetModuleFileName(AppInstance,dllpath,sizeof(dllpath));
  1355. char * last_slash = strrchr(dllpath,'\\');
  1356. last_slash++;
  1357. strcpy(last_slash,DAZZLE_SETTINGS_FILENAME);
  1358. char * dazzle_types_buffer = new char[DAZZLE_SECTION_BUFFERSIZE]; // max size of a section for Win95
  1359. ::GetPrivateProfileSection( DAZZLE_TYPES_SECTION, dazzle_types_buffer, DAZZLE_SECTION_BUFFERSIZE, dllpath);
  1360. // Now we need to handle each string in the section buffer; skipping the 'key=' and adding
  1361. // the dazzle type name into the combo box.
  1362. char * entry = dazzle_types_buffer;
  1363. if (entry != NULL) {
  1364. while (*entry != NULL) {
  1365. entry = strchr(entry,'=');
  1366. if (entry != NULL) {
  1367. entry++;
  1368. ::SendMessage(dazzle_combo,CB_ADDSTRING,0,(LPARAM)entry);
  1369. entry += strlen(entry) + 1;
  1370. }
  1371. }
  1372. } else {
  1373. ::SendMessage(dazzle_combo,CB_ADDSTRING,0,(LPARAM)"Default");
  1374. }
  1375. ::SendMessage(dazzle_combo,CB_SETCURSEL,(WPARAM)0,0);
  1376. delete dazzle_types_buffer;
  1377. /*
  1378. ** Setup the damage region spinner control.
  1379. */
  1380. RegionSpin = SetupIntSpinner
  1381. (
  1382. Hwnd,
  1383. IDC_DAMREG_INDEX_SPIN,
  1384. IDC_DAMREG_INDEX_EDIT,
  1385. NO_DAMAGE_REGION, MAX_DAMAGE_REGIONS-1, NO_DAMAGE_REGION
  1386. );
  1387. }
  1388. void SettingsFormClass::Destroy(void)
  1389. {
  1390. ReleaseISpinner(RegionSpin);
  1391. RegionSpin = NULL;
  1392. }
  1393. bool SettingsFormClass::Dialog_Proc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)
  1394. {
  1395. int check;
  1396. switch (message) {
  1397. case WM_INITDIALOG:
  1398. Init();
  1399. break;
  1400. case WM_DESTROY:
  1401. Destroy();
  1402. delete this;
  1403. break;
  1404. case WM_COMMAND:
  1405. {
  1406. /*
  1407. ** handle the tri-state checkboxes.
  1408. ** MAKE SURE YOU PUT ANY NEW CHECKBOX ID's IN HERE!!!
  1409. */
  1410. int control_id = LOWORD(wParam);
  1411. if ( (control_id == IDC_HIERARCHY_CHECK) ||
  1412. (control_id == IDC_GEOMETRY_CHECK) ||
  1413. (control_id == IDC_GEOMETRY_HIDE) ||
  1414. (control_id == IDC_GEOMETRY_TWO_SIDED) ||
  1415. (control_id == IDC_GEOMETRY_ZNORMALS) ||
  1416. (control_id == IDC_GEOMETRY_VERTEX_ALPHA) ||
  1417. (control_id == IDC_GEOMETRY_CAST_SHADOW) ||
  1418. (control_id == IDC_GEOMETRY_SHATTERABLE) ||
  1419. (control_id == IDC_GEOMETRY_NPATCH) ||
  1420. (control_id == IDC_COLLISION_PHYSICAL) ||
  1421. (control_id == IDC_COLLISION_PROJECTILE) ||
  1422. (control_id == IDC_COLLISION_VIS) ||
  1423. (control_id == IDC_COLLISION_CAMERA) ||
  1424. (control_id == IDC_COLLISION_VEHICLE))
  1425. {
  1426. check = !SendDlgItemMessage(hWnd,LOWORD(wParam),BM_GETCHECK,0,0L);
  1427. SendDlgItemMessage(hWnd,LOWORD(wParam),BM_SETCHECK,check,0L);
  1428. }
  1429. INodeListClass node_list( ::GetCOREInterface()->GetRootNode(),
  1430. ::GetCOREInterface()->GetTime(),
  1431. &_INodeFilter );
  1432. switch (LOWORD(wParam))
  1433. {
  1434. /*
  1435. ** Tri-State Checkboxes, make sure that the ID of all checkboxes is present
  1436. ** in the 'if' statement above!
  1437. */
  1438. case IDC_HIERARCHY_CHECK:
  1439. W3DUtilityClass::set_hierarchy_in_all_selected(&node_list,check == BST_CHECKED);
  1440. break;
  1441. case IDC_GEOMETRY_CHECK:
  1442. W3DUtilityClass::set_geometry_in_all_selected(&node_list,check == BST_CHECKED);
  1443. break;
  1444. case IDC_GEOMETRY_HIDE:
  1445. W3DUtilityClass::enable_hidden_in_all_selected(&node_list,check == BST_CHECKED);
  1446. break;
  1447. case IDC_GEOMETRY_TWO_SIDED:
  1448. W3DUtilityClass::enable_two_sided_in_all_selected(&node_list,check == BST_CHECKED);
  1449. break;
  1450. case IDC_GEOMETRY_ZNORMALS:
  1451. W3DUtilityClass::enable_znormals_in_all_selected(&node_list,check == BST_CHECKED);
  1452. break;
  1453. case IDC_GEOMETRY_VERTEX_ALPHA:
  1454. W3DUtilityClass::enable_vertex_alpha_in_all_selected(&node_list,check == BST_CHECKED);
  1455. break;
  1456. case IDC_GEOMETRY_CAST_SHADOW:
  1457. W3DUtilityClass::enable_shadow_in_all_selected(&node_list,check == BST_CHECKED);
  1458. break;
  1459. case IDC_GEOMETRY_SHATTERABLE:
  1460. W3DUtilityClass::enable_shatterable_in_all_selected(&node_list,check == BST_CHECKED);
  1461. break;
  1462. case IDC_GEOMETRY_NPATCH:
  1463. W3DUtilityClass::enable_npatches_in_all_selected(&node_list,check == BST_CHECKED);
  1464. break;
  1465. case IDC_COLLISION_PHYSICAL:
  1466. W3DUtilityClass::enable_physical_collision_in_all_selected(&node_list,check == BST_CHECKED);
  1467. break;
  1468. case IDC_COLLISION_PROJECTILE:
  1469. W3DUtilityClass::enable_projectile_collision_in_all_selected(&node_list,check == BST_CHECKED);
  1470. break;
  1471. case IDC_COLLISION_VIS:
  1472. W3DUtilityClass::enable_vis_collision_in_all_selected(&node_list,check == BST_CHECKED);
  1473. break;
  1474. case IDC_COLLISION_CAMERA:
  1475. W3DUtilityClass::enable_camera_collision_in_all_selected(&node_list,check == BST_CHECKED);
  1476. break;
  1477. case IDC_COLLISION_VEHICLE:
  1478. W3DUtilityClass::enable_vehicle_collision_in_all_selected(&node_list,check == BST_CHECKED);
  1479. break;
  1480. /*
  1481. ** Radio buttons for the Geometry type
  1482. */
  1483. case IDC_GEOMETRY_NORMAL:
  1484. W3DUtilityClass::set_geometry_type_in_all_selected(&node_list,W3DAppData2Struct::GEO_TYPE_NORMAL_MESH);
  1485. break;
  1486. case IDC_GEOMETRY_CAMERA_ALIGNED:
  1487. W3DUtilityClass::set_geometry_type_in_all_selected(&node_list,W3DAppData2Struct::GEO_TYPE_CAMERA_ALIGNED);
  1488. break;
  1489. case IDC_GEOMETRY_CAMERA_ORIENTED:
  1490. W3DUtilityClass::set_geometry_type_in_all_selected(&node_list,W3DAppData2Struct::GEO_TYPE_CAMERA_ORIENTED);
  1491. break;
  1492. case IDC_GEOMETRY_NULL:
  1493. W3DUtilityClass::set_geometry_type_in_all_selected(&node_list,W3DAppData2Struct::GEO_TYPE_NULL);
  1494. break;
  1495. case IDC_GEOMETRY_AABOX:
  1496. W3DUtilityClass::set_geometry_type_in_all_selected(&node_list,W3DAppData2Struct::GEO_TYPE_AABOX);
  1497. break;
  1498. case IDC_GEOMETRY_OBBOX:
  1499. W3DUtilityClass::set_geometry_type_in_all_selected(&node_list,W3DAppData2Struct::GEO_TYPE_OBBOX);
  1500. break;
  1501. case IDC_GEOMETRY_AGGREGATE:
  1502. W3DUtilityClass::set_geometry_type_in_all_selected(&node_list,W3DAppData2Struct::GEO_TYPE_AGGREGATE);
  1503. break;
  1504. case IDC_GEOMETRY_DAZZLE:
  1505. W3DUtilityClass::set_geometry_type_in_all_selected(&node_list,W3DAppData2Struct::GEO_TYPE_DAZZLE);
  1506. break;
  1507. /*
  1508. ** Dazzle type setting. Whenever the user changes the selected dazzle type, apply
  1509. ** the new setting to all selected nodes.
  1510. */
  1511. case IDC_DAZZLE_COMBO:
  1512. if (HIWORD(wParam) == CBN_SELCHANGE) {
  1513. HWND dazzle_combo = GetDlgItem(hWnd,IDC_DAZZLE_COMBO);
  1514. if (dazzle_combo != NULL) {
  1515. char dazzle_type[128];
  1516. int cursel = ::SendMessage(dazzle_combo,CB_GETCURSEL,0,0);
  1517. int len = ::SendMessage(dazzle_combo,CB_GETLBTEXTLEN,cursel,0);
  1518. if (len < 128) {
  1519. ::SendMessage(dazzle_combo,CB_GETLBTEXT,(WPARAM)cursel,(LPARAM)dazzle_type);
  1520. W3DUtilityClass::set_dazzle_type_in_all_selected(&node_list,dazzle_type);
  1521. }
  1522. }
  1523. }
  1524. break;
  1525. }
  1526. return TRUE;
  1527. }
  1528. /*
  1529. ** Spinners
  1530. */
  1531. case CC_SPINNER_CHANGE:
  1532. {
  1533. INodeListClass node_list( ::GetCOREInterface()->GetRootNode(),
  1534. ::GetCOREInterface()->GetTime(),
  1535. &_INodeFilter );
  1536. W3DUtilityClass::set_region_in_all_selected(&node_list,RegionSpin->GetIVal());
  1537. break;
  1538. }
  1539. /*
  1540. ** Max Custom Edit boxes
  1541. */
  1542. case WM_CUSTEDIT_ENTER:
  1543. {
  1544. INodeListClass node_list( ::GetCOREInterface()->GetRootNode(),
  1545. ::GetCOREInterface()->GetTime(),
  1546. &_INodeFilter );
  1547. ICustEdit * edit_ctrl = GetICustEdit(GetDlgItem(hWnd,wParam));
  1548. if (wParam == IDC_OBJ_NAME) {
  1549. if (edit_ctrl && node_list.Num_Nodes() == 1) {
  1550. char buffer[64];
  1551. edit_ctrl->GetText(buffer,sizeof(buffer));
  1552. node_list[0]->SetName(buffer);
  1553. Update_All_Instances();
  1554. }
  1555. }
  1556. ReleaseICustEdit(edit_ctrl);
  1557. break;
  1558. }
  1559. default:
  1560. return FALSE;
  1561. }
  1562. return TRUE;
  1563. }
  1564. void SettingsFormClass::Selection_Changed(void)
  1565. {
  1566. INodeListClass node_list( ::GetCOREInterface()->GetRootNode(),
  1567. ::GetCOREInterface()->GetTime(),
  1568. &_INodeFilter );
  1569. Update_Controls(&node_list);
  1570. }
  1571. void SettingsFormClass::Update_Controls(INodeListClass * node_list)
  1572. {
  1573. /*
  1574. ** Update name of currently selected object
  1575. ** "Multiple" if more than one, "None" if no selected objs...
  1576. */
  1577. ICustEdit * edit_ctrl = GetICustEdit(GetDlgItem(Hwnd,IDC_OBJ_NAME));
  1578. if (edit_ctrl != NULL) {
  1579. if (node_list->Num_Nodes() == 0) {
  1580. edit_ctrl->Enable(FALSE);
  1581. edit_ctrl->SetText(Get_String(IDS_NO_OBJECT));
  1582. } else if (node_list->Num_Nodes() == 1) {
  1583. edit_ctrl->Enable(TRUE);
  1584. edit_ctrl->SetText((*node_list)[0]->GetName());
  1585. } else {
  1586. edit_ctrl->Enable(FALSE);
  1587. edit_ctrl->SetText(Get_String(IDS_MULTIPLE_OBJECTS));
  1588. }
  1589. ReleaseICustEdit(edit_ctrl);
  1590. }
  1591. if (node_list->Num_Nodes() == 0) {
  1592. Disable_Controls();
  1593. return;
  1594. }
  1595. W3DUtilityClass::NodeStatesStruct ns;
  1596. W3DUtilityClass::eval_node_states(node_list,&ns);
  1597. /*
  1598. ** Enable hierarchy and geometry checks since they are always available
  1599. */
  1600. EnableWindow(GetDlgItem(Hwnd,IDC_HIERARCHY_CHECK),TRUE);
  1601. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_CHECK),TRUE);
  1602. /*
  1603. ** Enable/Disable the geometry controls
  1604. */
  1605. if (ns.ExportGeometry == 1) {
  1606. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_CAMERA_ALIGNED),TRUE);
  1607. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_CAMERA_ORIENTED),TRUE);
  1608. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_NORMAL),TRUE);
  1609. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_NULL),TRUE);
  1610. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_AABOX),TRUE);
  1611. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_OBBOX),TRUE);
  1612. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_AGGREGATE),TRUE);
  1613. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_DAZZLE),TRUE);
  1614. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_HIDE),TRUE);
  1615. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_TWO_SIDED),TRUE);
  1616. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_ZNORMALS),TRUE);
  1617. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_VERTEX_ALPHA),TRUE);
  1618. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_CAST_SHADOW),TRUE);
  1619. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_SHATTERABLE),TRUE);
  1620. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_NPATCH),TRUE);
  1621. EnableWindow(GetDlgItem(Hwnd,IDC_COLLISION_PHYSICAL),TRUE);
  1622. EnableWindow(GetDlgItem(Hwnd,IDC_COLLISION_PROJECTILE),TRUE);
  1623. EnableWindow(GetDlgItem(Hwnd,IDC_COLLISION_VIS),TRUE);
  1624. EnableWindow(GetDlgItem(Hwnd,IDC_COLLISION_CAMERA),TRUE);
  1625. EnableWindow(GetDlgItem(Hwnd,IDC_COLLISION_VEHICLE),TRUE);
  1626. } else {
  1627. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_CAMERA_ALIGNED),FALSE);
  1628. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_CAMERA_ORIENTED),FALSE);
  1629. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_NORMAL),FALSE);
  1630. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_NULL),FALSE);
  1631. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_AABOX),FALSE);
  1632. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_OBBOX),FALSE);
  1633. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_AGGREGATE),FALSE);
  1634. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_DAZZLE),FALSE);
  1635. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_HIDE),FALSE);
  1636. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_TWO_SIDED),FALSE);
  1637. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_ZNORMALS),FALSE);
  1638. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_VERTEX_ALPHA),FALSE);
  1639. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_CAST_SHADOW),FALSE);
  1640. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_SHATTERABLE),FALSE);
  1641. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_NPATCH),FALSE);
  1642. EnableWindow(GetDlgItem(Hwnd,IDC_COLLISION_PHYSICAL),FALSE);
  1643. EnableWindow(GetDlgItem(Hwnd,IDC_COLLISION_PROJECTILE),FALSE);
  1644. EnableWindow(GetDlgItem(Hwnd,IDC_COLLISION_VIS),FALSE);
  1645. EnableWindow(GetDlgItem(Hwnd,IDC_COLLISION_CAMERA),FALSE);
  1646. EnableWindow(GetDlgItem(Hwnd,IDC_COLLISION_VEHICLE),FALSE);
  1647. }
  1648. /*
  1649. ** Set the checks based on the nodes states:
  1650. ** no check - none of the selected nodes had this setting
  1651. ** check - all of the selected nodes had this setting
  1652. ** grey check - some of the selected nodes had this setting
  1653. */
  1654. SendDlgItemMessage(Hwnd,IDC_HIERARCHY_CHECK,BM_SETCHECK,ns.ExportHierarchy,0L);
  1655. SendDlgItemMessage(Hwnd,IDC_GEOMETRY_CHECK,BM_SETCHECK,ns.ExportGeometry,0L);
  1656. SendDlgItemMessage(Hwnd,IDC_GEOMETRY_HIDE,BM_SETCHECK,ns.GeometryHidden,0L);
  1657. SendDlgItemMessage(Hwnd,IDC_GEOMETRY_TWO_SIDED,BM_SETCHECK,ns.GeometryTwoSided,0L);
  1658. SendDlgItemMessage(Hwnd,IDC_GEOMETRY_ZNORMALS,BM_SETCHECK,ns.GeometryZNormals,0L);
  1659. SendDlgItemMessage(Hwnd,IDC_GEOMETRY_VERTEX_ALPHA,BM_SETCHECK,ns.GeometryVertexAlpha,0L);
  1660. SendDlgItemMessage(Hwnd,IDC_GEOMETRY_CAST_SHADOW,BM_SETCHECK,ns.GeometryCastShadow,0L);
  1661. SendDlgItemMessage(Hwnd,IDC_GEOMETRY_SHATTERABLE,BM_SETCHECK,ns.GeometryShatterable,0L);
  1662. SendDlgItemMessage(Hwnd,IDC_GEOMETRY_NPATCH,BM_SETCHECK,ns.GeometryNPatch,0L);
  1663. SendDlgItemMessage(Hwnd,IDC_COLLISION_PHYSICAL,BM_SETCHECK,ns.CollisionPhysical,0L);
  1664. SendDlgItemMessage(Hwnd,IDC_COLLISION_PROJECTILE,BM_SETCHECK,ns.CollisionProjectile,0L);
  1665. SendDlgItemMessage(Hwnd,IDC_COLLISION_VIS,BM_SETCHECK,ns.CollisionVis,0L);
  1666. SendDlgItemMessage(Hwnd,IDC_COLLISION_CAMERA,BM_SETCHECK,ns.CollisionCamera,0L);
  1667. SendDlgItemMessage(Hwnd,IDC_COLLISION_VEHICLE,BM_SETCHECK,ns.CollisionVehicle,0L);
  1668. /*
  1669. ** The damage region spinner should only be enabled if
  1670. ** Export Hierarchy is checked for all selected nodes.
  1671. */
  1672. BOOL spinner_enable = false;
  1673. if (ns.ExportHierarchy == 1)
  1674. {
  1675. if (ns.DamageRegion != MAX_DAMAGE_REGIONS)
  1676. {
  1677. // Show the damage region in the spinner.
  1678. RegionSpin->SetIndeterminate(FALSE);
  1679. RegionSpin->SetValue(ns.DamageRegion, FALSE);
  1680. }
  1681. else
  1682. {
  1683. // The selected objects aren't all in the same region.
  1684. RegionSpin->SetIndeterminate(TRUE);
  1685. }
  1686. spinner_enable = true;
  1687. }
  1688. EnableWindow(GetDlgItem(Hwnd,IDC_DAMREG_INDEX_EDIT),spinner_enable);
  1689. EnableWindow(GetDlgItem(Hwnd,IDC_DAMREG_INDEX_SPIN),spinner_enable);
  1690. /*
  1691. ** The dazzle combo box should only be enabled if
  1692. ** Export Geometry, and geometry type dazzle is set for all
  1693. ** selected nodes.
  1694. */
  1695. bool dazzle_combo_enable = false;
  1696. if (ns.ExportGeometry == 1) {
  1697. if (ns.DazzleCount == node_list->Num_Nodes()) {
  1698. dazzle_combo_enable = true;
  1699. }
  1700. }
  1701. HWND dazzle_combo = GetDlgItem(Hwnd,IDC_DAZZLE_COMBO);
  1702. EnableWindow(dazzle_combo,dazzle_combo_enable);
  1703. int selindex = ::SendMessage(dazzle_combo,CB_FINDSTRING,(WPARAM)0,(LPARAM)ns.DazzleType);
  1704. if (selindex != CB_ERR) {
  1705. ::SendMessage(dazzle_combo,CB_SETCURSEL,(WPARAM)selindex,(LPARAM)0);
  1706. } else {
  1707. ::SendMessage(dazzle_combo,CB_SETCURSEL,(WPARAM)0,(LPARAM)0);
  1708. }
  1709. /*
  1710. ** Set any radio buttons present
  1711. */
  1712. CheckDlgButton(Hwnd,IDC_GEOMETRY_CAMERA_ALIGNED,(ns.GeometryCameraAligned ? BST_CHECKED : BST_UNCHECKED));
  1713. CheckDlgButton(Hwnd,IDC_GEOMETRY_CAMERA_ORIENTED,(ns.GeometryCameraOriented ? BST_CHECKED : BST_UNCHECKED));
  1714. CheckDlgButton(Hwnd,IDC_GEOMETRY_NORMAL,(ns.GeometryNormal ? BST_CHECKED : BST_UNCHECKED));
  1715. CheckDlgButton(Hwnd,IDC_GEOMETRY_NULL,(ns.GeometryNull ? BST_CHECKED : BST_UNCHECKED));
  1716. CheckDlgButton(Hwnd,IDC_GEOMETRY_AABOX,(ns.GeometryAABox ? BST_CHECKED : BST_UNCHECKED));
  1717. CheckDlgButton(Hwnd,IDC_GEOMETRY_OBBOX,(ns.GeometryOBBox ? BST_CHECKED : BST_UNCHECKED));
  1718. CheckDlgButton(Hwnd,IDC_GEOMETRY_AGGREGATE,(ns.GeometryAggregate ? BST_CHECKED : BST_UNCHECKED));
  1719. CheckDlgButton(Hwnd,IDC_GEOMETRY_DAZZLE,(ns.GeometryDazzle ? BST_CHECKED : BST_UNCHECKED));
  1720. }
  1721. void SettingsFormClass::Disable_Controls(void)
  1722. {
  1723. EnableWindow(GetDlgItem(Hwnd,IDC_OBJ_NAME),FALSE);
  1724. EnableWindow(GetDlgItem(Hwnd,IDC_HIERARCHY_CHECK),FALSE);
  1725. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_CHECK),FALSE);
  1726. EnableWindow(GetDlgItem(Hwnd,IDC_DAMREG_INDEX_EDIT),FALSE);
  1727. EnableWindow(GetDlgItem(Hwnd,IDC_DAMREG_INDEX_SPIN),FALSE);
  1728. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_NORMAL),FALSE);
  1729. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_CAMERA_ALIGNED),FALSE);
  1730. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_CAMERA_ORIENTED),FALSE);
  1731. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_AABOX),FALSE);
  1732. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_OBBOX),FALSE);
  1733. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_NULL),FALSE);
  1734. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_AGGREGATE),FALSE);
  1735. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_DAZZLE),FALSE);
  1736. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_HIDE),FALSE);
  1737. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_TWO_SIDED),FALSE);
  1738. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_ZNORMALS),FALSE);
  1739. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_VERTEX_ALPHA),FALSE);
  1740. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_CAST_SHADOW),FALSE);
  1741. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_SHATTERABLE),FALSE);
  1742. EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_NPATCH),FALSE);
  1743. EnableWindow(GetDlgItem(Hwnd,IDC_COLLISION_PHYSICAL),FALSE);
  1744. EnableWindow(GetDlgItem(Hwnd,IDC_COLLISION_PROJECTILE),FALSE);
  1745. EnableWindow(GetDlgItem(Hwnd,IDC_COLLISION_VIS),FALSE);
  1746. EnableWindow(GetDlgItem(Hwnd,IDC_COLLISION_CAMERA),FALSE);
  1747. EnableWindow(GetDlgItem(Hwnd,IDC_COLLISION_VEHICLE),FALSE);
  1748. EnableWindow(GetDlgItem(Hwnd,IDC_DAZZLE_COMBO),FALSE);
  1749. CheckDlgButton(Hwnd,IDC_HIERARCHY_CHECK,BST_UNCHECKED);
  1750. CheckDlgButton(Hwnd,IDC_GEOMETRY_CHECK,BST_UNCHECKED);
  1751. CheckDlgButton(Hwnd,IDC_GEOMETRY_CAMERA_ALIGNED,BST_UNCHECKED);
  1752. CheckDlgButton(Hwnd,IDC_GEOMETRY_CAMERA_ORIENTED,BST_UNCHECKED);
  1753. CheckDlgButton(Hwnd,IDC_GEOMETRY_NORMAL,BST_UNCHECKED);
  1754. CheckDlgButton(Hwnd,IDC_GEOMETRY_AABOX,BST_UNCHECKED);
  1755. CheckDlgButton(Hwnd,IDC_GEOMETRY_OBBOX,BST_UNCHECKED);
  1756. CheckDlgButton(Hwnd,IDC_GEOMETRY_NULL,BST_UNCHECKED);
  1757. CheckDlgButton(Hwnd,IDC_GEOMETRY_AGGREGATE,BST_UNCHECKED);
  1758. CheckDlgButton(Hwnd,IDC_GEOMETRY_DAZZLE,BST_UNCHECKED);
  1759. CheckDlgButton(Hwnd,IDC_GEOMETRY_HIDE,BST_UNCHECKED);
  1760. CheckDlgButton(Hwnd,IDC_GEOMETRY_TWO_SIDED,BST_UNCHECKED);
  1761. CheckDlgButton(Hwnd,IDC_GEOMETRY_ZNORMALS,BST_UNCHECKED);
  1762. CheckDlgButton(Hwnd,IDC_GEOMETRY_VERTEX_ALPHA,BST_UNCHECKED);
  1763. CheckDlgButton(Hwnd,IDC_GEOMETRY_CAST_SHADOW,BST_UNCHECKED);
  1764. CheckDlgButton(Hwnd,IDC_GEOMETRY_SHATTERABLE,BST_UNCHECKED);
  1765. CheckDlgButton(Hwnd,IDC_GEOMETRY_NPATCH,BST_UNCHECKED);
  1766. CheckDlgButton(Hwnd,IDC_COLLISION_PHYSICAL,BST_UNCHECKED);
  1767. CheckDlgButton(Hwnd,IDC_COLLISION_PROJECTILE,BST_UNCHECKED);
  1768. CheckDlgButton(Hwnd,IDC_COLLISION_VIS,BST_UNCHECKED);
  1769. CheckDlgButton(Hwnd,IDC_COLLISION_CAMERA,BST_UNCHECKED);
  1770. CheckDlgButton(Hwnd,IDC_COLLISION_VEHICLE,BST_UNCHECKED);
  1771. }
  1772. /*
  1773. ** Functions to access the W3D AppData of any INode.
  1774. */
  1775. W3DAppData0Struct * GetW3DAppData0 (INode *node)
  1776. {
  1777. return TheW3DUtility.get_app_data_0(node);
  1778. }
  1779. W3DAppData1Struct * GetW3DAppData1 (INode *node)
  1780. {
  1781. return TheW3DUtility.get_app_data_1(node);
  1782. }
  1783. W3DAppData2Struct * GetW3DAppData2 (INode *node)
  1784. {
  1785. return TheW3DUtility.get_app_data_2(node);
  1786. }
  1787. W3DDazzleAppDataStruct * GetW3DDazzleAppData(INode *node)
  1788. {
  1789. return TheW3DUtility.get_dazzle_app_data(node);
  1790. }