MainFrm.cpp 125 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464
  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. // MainFrm.cpp : implementation of the CMainFrame class
  19. //
  20. #include "stdafx.h"
  21. #include "w3dview.h"
  22. #include "mainfrm.h"
  23. #include "datatreeview.h"
  24. #include "graphicview.h"
  25. #include "deviceselectiondialog.h"
  26. #include "globals.h"
  27. #include "w3dviewdoc.h"
  28. #include "viewerassetmgr.h"
  29. #include "assetpropertysheet.h"
  30. #include "meshproppage.h"
  31. #include "animationproppage.h"
  32. #include "hierarchyproppage.h"
  33. #include "resource.h"
  34. #include "distlod.h"
  35. #include "animationspeed.h"
  36. #include "ambientlightdialog.h"
  37. #include "scenelightdialog.h"
  38. #include "backgroundcolordialog.h"
  39. #include "savesettingsdialog.h"
  40. #include "editloddialog.h"
  41. #include "w3derr.h"
  42. #include "backgroundobjectdialog.h"
  43. #include "backgroundbmpdialog.h"
  44. #include "toolbar.h"
  45. #include "emitterpropertysheet.h"
  46. #include "part_ldr.h"
  47. #include "agg_def.h"
  48. #include "bonemgrdialog.h"
  49. #include "utils.h"
  50. #include "light.h"
  51. #include "aggregatenamedialog.h"
  52. #include "loddefs.h"
  53. #include "part_emt.h"
  54. #include "restrictedfiledialog.h"
  55. #include "hlod.h"
  56. #include "viewerscene.h"
  57. #include "emitterinstancelist.h"
  58. #include "mmsystem.h"
  59. #include "advancedanimsheet.h"
  60. #include "camerasettingsdialog.h"
  61. #include "directorydialog.h"
  62. #include "texturepathdialog.h"
  63. #include "resolutiondialog.h"
  64. #include "spherepropertysheet.h"
  65. #include "ringpropertysheet.h"
  66. #include "addtolineupdialog.h"
  67. #include "cameradistancedialog.h"
  68. #include "soundeditdialog.h"
  69. #include "wwaudio.h"
  70. #include "soundrobj.h"
  71. #include "rddesc.h"
  72. #include "scaledialog.h"
  73. #include "gammadialog.h"
  74. #include "animatedsoundoptionsdialog.h"
  75. //#undef STRICT
  76. #include "ww3d.h"
  77. #ifdef _DEBUG
  78. #define new DEBUG_NEW
  79. #undef THIS_FILE
  80. static char THIS_FILE[] = __FILE__;
  81. #endif
  82. /////////////////////////////////////////////////////////////////////////////
  83. //
  84. // External Functions
  85. //
  86. void Set_Highest_LOD (RenderObjClass *render_obj); // DataTreeView.cpp
  87. /////////////////////////////////////////////////////////////////////////////
  88. //
  89. // Local Constants
  90. //
  91. const int SPECIAL_MENU_SLOT = 6;
  92. /////////////////////////////////////////////////////////////////////////////
  93. //
  94. // Local Inlines
  95. //
  96. __inline void Adjust_Light_Intensity (Vector3 &color, float inc)
  97. {
  98. color.X = color.X + inc;
  99. color.Y = color.Y + inc;
  100. color.Z = color.Z + inc;
  101. color.X = (color.X < 0) ? 0 : color.X;
  102. color.Y = (color.Y < 0) ? 0 : color.Y;
  103. color.Z = (color.Z < 0) ? 0 : color.Z;
  104. color.X = (color.X > 1.0F) ? 1.0F : color.X;
  105. color.Y = (color.Y > 1.0F) ? 1.0F : color.Y;
  106. color.Z = (color.Z > 1.0F) ? 1.0F : color.Z;
  107. return ;
  108. }
  109. /////////////////////////////////////////////////////////////////////////////
  110. // CMainFrame
  111. IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
  112. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  113. //{{AFX_MSG_MAP(CMainFrame)
  114. ON_WM_CREATE()
  115. ON_COMMAND(IDM_OBJECT_PROPERTIES, OnObjectProperties)
  116. ON_UPDATE_COMMAND_UI(IDM_OBJECT_PROPERTIES, OnUpdateObjectProperties)
  117. ON_COMMAND(IDM_LOD_GENERATE, OnLodGenerate)
  118. ON_WM_ACTIVATEAPP()
  119. ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
  120. ON_COMMAND(IDM_ANI_SPEED, OnAniSpeed)
  121. ON_COMMAND(IDM_ANI_STOP, OnAniStop)
  122. ON_COMMAND(IDM_ANI_START, OnAniStart)
  123. ON_COMMAND(IDM_ANI_PAUSE, OnAniPause)
  124. ON_COMMAND(IDM_CAMERA_BACK, OnCameraBack)
  125. ON_COMMAND(IDM_CAMERA_BOTTOM, OnCameraBottom)
  126. ON_COMMAND(IDM_CAMERA_FRONT, OnCameraFront)
  127. ON_COMMAND(IDM_CAMERA_LEFT, OnCameraLeft)
  128. ON_COMMAND(IDM_CAMERA_RESET, OnCameraReset)
  129. ON_COMMAND(IDM_CAMERA_RIGHT, OnCameraRight)
  130. ON_COMMAND(IDM_CAMERA_TOP, OnCameraTop)
  131. ON_COMMAND(IDM_OBJECT_ROTATE_Z, OnObjectRotateZ)
  132. ON_COMMAND(IDM_OBJECT_ROTATE_Y, OnObjectRotateY)
  133. ON_COMMAND(IDM_OBJECT_ROTATE_X, OnObjectRotateX)
  134. ON_COMMAND(IDM_LIGHT_AMBIENT, OnLightAmbient)
  135. ON_COMMAND(IDM_LIGHT_SCENE, OnLightScene)
  136. ON_COMMAND(IDM_BACKGROUND_COLOR, OnBackgroundColor)
  137. ON_COMMAND(IDM_BACKGROUND_BMP, OnBackgroundBMP)
  138. ON_COMMAND(IDM_SAVE_SETTINGS, OnSaveSettings)
  139. ON_COMMAND(IDM_LOAD_SETTINGS, OnLoadSettings)
  140. ON_COMMAND(IDM_LOD_SET_SWITCH, OnLODSetSwitch)
  141. ON_COMMAND(IDM_LOD_SAVE, OnLODSave)
  142. ON_COMMAND(IDM_LOD_SAVEALL, OnLODSaveAll)
  143. ON_COMMAND(IDM_BACKGROUND_OBJECT, OnBackgroundObject)
  144. ON_UPDATE_COMMAND_UI(IDM_VIEW_ANIMATION_BAR, OnUpdateViewAnimationBar)
  145. ON_UPDATE_COMMAND_UI(IDM_VIEW_OBJECT_BAR, OnUpdateViewObjectBar)
  146. ON_COMMAND(IDM_VIEW_ANIMATION_BAR, OnViewAnimationBar)
  147. ON_COMMAND(IDM_VIEW_OBJECT_BAR, OnViewObjectBar)
  148. ON_COMMAND(IDM_ANI_STEP_FWD, OnAniStepFwd)
  149. ON_COMMAND(IDM_ANI_STEP_BKWD, OnAniStepBkwd)
  150. ON_COMMAND(IDM_OBJECT_RESET, OnObjectReset)
  151. ON_COMMAND(IDM_CAMERA_ALLOW_ROTATE_X, OnCameraAllowRotateX)
  152. ON_COMMAND(IDM_CAMERA_ALLOW_ROTATE_Y, OnCameraAllowRotateY)
  153. ON_COMMAND(IDM_CAMERA_ALLOW_ROTATE_Z, OnCameraAllowRotateZ)
  154. ON_UPDATE_COMMAND_UI(IDM_CAMERA_ALLOW_ROTATE_X, OnUpdateCameraAllowRotateX)
  155. ON_UPDATE_COMMAND_UI(IDM_CAMERA_ALLOW_ROTATE_Y, OnUpdateCameraAllowRotateY)
  156. ON_UPDATE_COMMAND_UI(IDM_CAMERA_ALLOW_ROTATE_Z, OnUpdateCameraAllowRotateZ)
  157. ON_UPDATE_COMMAND_UI(IDM_OBJECT_ROTATE_X, OnUpdateObjectRotateX)
  158. ON_UPDATE_COMMAND_UI(IDM_OBJECT_ROTATE_Y, OnUpdateObjectRotateY)
  159. ON_UPDATE_COMMAND_UI(IDM_OBJECT_ROTATE_Z, OnUpdateObjectRotateZ)
  160. ON_COMMAND(IDM_DEVICE_CHANGE, OnDeviceChange)
  161. ON_COMMAND(IDM_VIEW_FULLSCREEN, OnViewFullscreen)
  162. ON_UPDATE_COMMAND_UI(IDM_VIEW_FULLSCREEN, OnUpdateViewFullscreen)
  163. ON_WM_WINDOWPOSCHANGING()
  164. ON_WM_GETMINMAXINFO()
  165. ON_COMMAND(IDM_CREATE_EMITTER, OnCreateEmitter)
  166. ON_COMMAND(IDM_EDIT_EMITTER, OnEditEmitter)
  167. ON_UPDATE_COMMAND_UI(IDM_EDIT_EMITTER, OnUpdateEditEmitter)
  168. ON_COMMAND(IDM_SAVE_EMITTER, OnSaveEmitter)
  169. ON_UPDATE_COMMAND_UI(IDM_SAVE_EMITTER, OnUpdateSaveEmitter)
  170. ON_COMMAND(IDM_BONE_AUTO_ASSIGN, OnBoneAutoAssign)
  171. ON_COMMAND(IDM_BONE_MANAGEMENT, OnBoneManagement)
  172. ON_COMMAND(IDM_SAVE_AGGREGATE, OnSaveAggregate)
  173. ON_COMMAND(IDM_CAMERA_ANIMATE, OnCameraAnimate)
  174. ON_UPDATE_COMMAND_UI(IDM_CAMERA_ANIMATE, OnUpdateCameraAnimate)
  175. ON_UPDATE_COMMAND_UI(IDM_LOD_SAVE, OnUpdateLodSave)
  176. ON_UPDATE_COMMAND_UI(IDM_SAVE_AGGREGATE, OnUpdateSaveAggregate)
  177. ON_COMMAND(IDM_CAMERA_RESET_ON_LOAD, OnCameraResetOnLoad)
  178. ON_UPDATE_COMMAND_UI(IDM_CAMERA_RESET_ON_LOAD, OnUpdateCameraResetOnLoad)
  179. ON_COMMAND(IDM_OBJECT_ROTATE_Y_BACK, OnObjectRotateYBack)
  180. ON_COMMAND(IDM_OBJECT_ROTATE_Z_BACK, OnObjectRotateZBack)
  181. ON_COMMAND(IDM_LIGHT_ROTATE_Y, OnLightRotateY)
  182. ON_COMMAND(IDM_LIGHT_ROTATE_Y_BACK, OnLightRotateYBack)
  183. ON_COMMAND(IDM_LIGHT_ROTATE_Z, OnLightRotateZ)
  184. ON_COMMAND(IDM_LIGHT_ROTATE_Z_BACK, OnLightRotateZBack)
  185. ON_WM_DESTROY()
  186. ON_COMMAND(IDM_DEC_LIGHT, OnDecLight)
  187. ON_COMMAND(IDM_INC_LIGHT, OnIncLight)
  188. ON_COMMAND(IDM_DEC_AMBIENT_LIGHT, OnDecAmbientLight)
  189. ON_COMMAND(IDM_INC_AMBIENT_LIGHT, OnIncAmbientLight)
  190. ON_COMMAND(IDM_MAKE_AGGREGATE, OnMakeAggregate)
  191. ON_COMMAND(IDM_RENAME_AGGREGATE, OnRenameAggregate)
  192. ON_COMMAND(IDM_CRASH_APP, OnCrashApp)
  193. ON_COMMAND(IDM_LOD_RECORD_SCREEN_AREA, OnLODRecordScreenArea)
  194. ON_COMMAND(IDM_LOD_INCLUDE_NULL, OnLODIncludeNull)
  195. ON_UPDATE_COMMAND_UI(IDM_LOD_INCLUDE_NULL, OnUpdateLODIncludeNull)
  196. ON_COMMAND(IDM_LOD_PREV_LEVEL, OnLodPrevLevel)
  197. ON_UPDATE_COMMAND_UI(IDM_LOD_PREV_LEVEL, OnUpdateLodPrevLevel)
  198. ON_COMMAND(IDM_LOD_NEXT_LEVEL, OnLodNextLevel)
  199. ON_UPDATE_COMMAND_UI(IDM_LOD_NEXT_LEVEL, OnUpdateLodNextLevel)
  200. ON_COMMAND(IDM_LOD_AUTOSWITCH, OnLodAutoswitch)
  201. ON_UPDATE_COMMAND_UI(IDM_LOD_AUTOSWITCH, OnUpdateLodAutoswitch)
  202. ON_UPDATE_COMMAND_UI(IDM_MAKE_MOVIE, OnUpdateMakeMovie)
  203. ON_COMMAND(IDM_MAKE_MOVIE, OnMakeMovie)
  204. ON_COMMAND(IDM_SAVE_SCREENSHOT, OnSaveScreenshot)
  205. ON_COMMAND(IDM_SLIDESHOW_DOWN, OnSlideshowDown)
  206. ON_COMMAND(IDM_SLIDESHOW_UP, OnSlideshowUp)
  207. ON_COMMAND(IDM_ADVANCED_ANIM, OnAdvancedAnim)
  208. ON_UPDATE_COMMAND_UI(IDM_ADVANCED_ANIM, OnUpdateAdvancedAnim)
  209. ON_COMMAND(IDM_CAMERA_SETTINGS, OnCameraSettings)
  210. ON_COMMAND(IDM_COPY_SCREEN_SIZE, OnCopyScreenSize)
  211. ON_COMMAND(IDC_LIST_MISSING_TEXTURES, OnListMissingTextures)
  212. ON_COMMAND(IDC_COPY_ASSETS, OnCopyAssets)
  213. ON_UPDATE_COMMAND_UI(IDC_COPY_ASSETS, OnUpdateCopyAssets)
  214. ON_COMMAND(IDM_LIGHTING_EXPOSE, OnLightingExpose)
  215. ON_UPDATE_COMMAND_UI(IDM_LIGHTING_EXPOSE, OnUpdateLightingExpose)
  216. ON_COMMAND(IDM_TEXTURE_PATH, OnTexturePath)
  217. ON_COMMAND(IDM_CHANGE_RESOLUTION, OnChangeResolution)
  218. ON_COMMAND(IDM_CREATE_SPHERE, OnCreateSphere)
  219. ON_COMMAND(IDM_CREATE_RING, OnCreateRing)
  220. ON_UPDATE_COMMAND_UI(IDM_EDIT_PRIMITIVE, OnUpdateEditPrimitive)
  221. ON_COMMAND(IDM_EDIT_PRIMITIVE, OnEditPrimitive)
  222. ON_COMMAND(IDM_EXPORT_PRIMITIVE, OnExportPrimitive)
  223. ON_UPDATE_COMMAND_UI(IDM_EXPORT_PRIMITIVE, OnUpdateExportPrimitive)
  224. ON_COMMAND(IDM_KILL_SCENE_LIGHT, OnKillSceneLight)
  225. ON_COMMAND(IDM_PRELIT_MULTIPASS, OnPrelitMultipass)
  226. ON_UPDATE_COMMAND_UI(IDM_PRELIT_MULTIPASS, OnUpdatePrelitMultipass)
  227. ON_COMMAND(IDM_PRELIT_MULTITEX, OnPrelitMultitex)
  228. ON_UPDATE_COMMAND_UI(IDM_PRELIT_MULTITEX, OnUpdatePrelitMultitex)
  229. ON_COMMAND(IDM_PRELIT_VERTEX, OnPrelitVertex)
  230. ON_UPDATE_COMMAND_UI(IDM_PRELIT_VERTEX, OnUpdatePrelitVertex)
  231. ON_COMMAND(IDC_ADD_TO_LINEUP, OnAddToLineup)
  232. ON_UPDATE_COMMAND_UI(IDC_ADD_TO_LINEUP, OnUpdateAddToLineup)
  233. ON_COMMAND(IDM_IMPORT_FACIAL_ANIMS, OnImportFacialAnims)
  234. ON_UPDATE_COMMAND_UI(IDM_IMPORT_FACIAL_ANIMS, OnUpdateImportFacialAnims)
  235. ON_COMMAND(IDM_RESTRICT_ANIMS, OnRestrictAnims)
  236. ON_UPDATE_COMMAND_UI(IDM_RESTRICT_ANIMS, OnUpdateRestrictAnims)
  237. ON_COMMAND(IDM_BIND_SUBOBJECT_LOD, OnBindSubobjectLod)
  238. ON_UPDATE_COMMAND_UI(IDM_BIND_SUBOBJECT_LOD, OnUpdateBindSubobjectLod)
  239. ON_COMMAND(IDM_SET_CAMERA_DISTANCE, OnSetCameraDistance)
  240. ON_COMMAND(IDM_OBJECT_ALTERNATE_MATERIALS, OnObjectAlternateMaterials)
  241. ON_COMMAND(IDM_CREATE_SOUND_OBJECT, OnCreateSoundObject)
  242. ON_COMMAND(IDM_EDIT_SOUND_OBJECT, OnEditSoundObject)
  243. ON_UPDATE_COMMAND_UI(IDM_EDIT_SOUND_OBJECT, OnUpdateEditSoundObject)
  244. ON_COMMAND(IDM_EXPORT_SOUND_OBJ, OnExportSoundObj)
  245. ON_UPDATE_COMMAND_UI(IDM_EXPORT_SOUND_OBJ, OnUpdateExportSoundObj)
  246. ON_COMMAND(IDM_WIREFRAME_MODE, OnWireframeMode)
  247. ON_UPDATE_COMMAND_UI(IDM_WIREFRAME_MODE, OnUpdateWireframeMode)
  248. ON_UPDATE_COMMAND_UI(IDM_BACKGROUND_FOG, OnUpdateBackgroundFog)
  249. ON_COMMAND(IDM_BACKGROUND_FOG, OnBackgroundFog)
  250. ON_UPDATE_COMMAND_UI(IDM_SCALE_EMITTER, OnUpdateScaleEmitter)
  251. ON_COMMAND(IDM_SCALE_EMITTER, OnScaleEmitter)
  252. ON_UPDATE_COMMAND_UI(IDM_TOGGLE_SORTING, OnUpdateToggleSorting)
  253. ON_COMMAND(IDM_TOGGLE_SORTING, OnToggleSorting)
  254. ON_COMMAND(IDM_CAMERA_BONE_POS_X, OnCameraBonePosX)
  255. ON_UPDATE_COMMAND_UI(IDM_CAMERA_BONE_POS_X, OnUpdateCameraBonePosX)
  256. ON_COMMAND(ID_VIEW_PATCH_GAP_FILL, OnViewPatchGapFill)
  257. ON_UPDATE_COMMAND_UI(ID_VIEW_PATCH_GAP_FILL, OnUpdateViewPatchGapFill)
  258. ON_COMMAND(ID_VIEW_SUBDIVISION_1, OnViewSubdivision1)
  259. ON_UPDATE_COMMAND_UI(ID_VIEW_SUBDIVISION_1, OnUpdateViewSubdivision1)
  260. ON_COMMAND(ID_VIEW_SUBDIVISION_2, OnViewSubdivision2)
  261. ON_UPDATE_COMMAND_UI(ID_VIEW_SUBDIVISION_2, OnUpdateViewSubdivision2)
  262. ON_COMMAND(ID_VIEW_SUBDIVISION_3, OnViewSubdivision3)
  263. ON_UPDATE_COMMAND_UI(ID_VIEW_SUBDIVISION_3, OnUpdateViewSubdivision3)
  264. ON_COMMAND(ID_VIEW_SUBDIVISION_4, OnViewSubdivision4)
  265. ON_UPDATE_COMMAND_UI(ID_VIEW_SUBDIVISION_4, OnUpdateViewSubdivision4)
  266. ON_COMMAND(ID_VIEW_SUBDIVISION_5, OnViewSubdivision5)
  267. ON_UPDATE_COMMAND_UI(ID_VIEW_SUBDIVISION_5, OnUpdateViewSubdivision5)
  268. ON_COMMAND(ID_VIEW_SUBDIVISION_6, OnViewSubdivision6)
  269. ON_UPDATE_COMMAND_UI(ID_VIEW_SUBDIVISION_6, OnUpdateViewSubdivision6)
  270. ON_COMMAND(ID_VIEW_SUBDIVISION_7, OnViewSubdivision7)
  271. ON_UPDATE_COMMAND_UI(ID_VIEW_SUBDIVISION_7, OnUpdateViewSubdivision7)
  272. ON_COMMAND(ID_VIEW_SUBDIVISION_8, OnViewSubdivision8)
  273. ON_UPDATE_COMMAND_UI(ID_VIEW_SUBDIVISION_8, OnUpdateViewSubdivision8)
  274. ON_COMMAND(IDM_MUNGE_SORT_ON_LOAD, OnMungeSortOnLoad)
  275. ON_UPDATE_COMMAND_UI(IDM_MUNGE_SORT_ON_LOAD, OnUpdateMungeSortOnLoad)
  276. ON_COMMAND(IDM_ENABLE_GAMMA_CORRECTION, OnEnableGammaCorrection)
  277. ON_UPDATE_COMMAND_UI(IDM_ENABLE_GAMMA_CORRECTION, OnUpdateEnableGammaCorrection)
  278. ON_COMMAND(IDM_SET_GAMMA, OnSetGamma)
  279. ON_COMMAND(IDM_EDIT_ANIMATED_SOUNDS_OPTIONS, OnEditAnimatedSoundsOptions)
  280. //}}AFX_MSG_MAP
  281. END_MESSAGE_MAP()
  282. static UINT indicators[] =
  283. {
  284. ID_SEPARATOR, // status line indicator
  285. IDS_POLY_PANE,
  286. IDS_PARTICLE_PANE,
  287. IDS_DISTANCE_PANE,
  288. IDS_FRAME_PANE,
  289. IDS_FPS_PANE,
  290. IDS_RESOLUTION_PANE
  291. };
  292. typedef enum
  293. {
  294. PANE_POLYS = 1,
  295. PANE_PARTICLES,
  296. PANE_DISTANCE,
  297. PANE_FRAMES,
  298. PANE_FPS,
  299. PANE_RESOLUTION,
  300. PANE_MAX
  301. } STATBAR_PANES;
  302. ////////////////////////////////////////////////////////////////////////////
  303. //
  304. // CMainFrame
  305. //
  306. ////////////////////////////////////////////////////////////////////////////
  307. CMainFrame::CMainFrame (void)
  308. : m_currentAssetType (TypeUnknown),
  309. m_bShowAnimationBar (TRUE),
  310. m_bInitialized (FALSE)
  311. {
  312. return ;
  313. }
  314. ////////////////////////////////////////////////////////////////////////////
  315. //
  316. // ~CMainFrame
  317. //
  318. ////////////////////////////////////////////////////////////////////////////
  319. CMainFrame::~CMainFrame (void)
  320. {
  321. return ;
  322. }
  323. ////////////////////////////////////////////////////////////////////////////
  324. //
  325. // OnCreate
  326. //
  327. ////////////////////////////////////////////////////////////////////////////
  328. int
  329. CMainFrame::OnCreate (LPCREATESTRUCT lpCreateStruct)
  330. {
  331. //
  332. // HACK HACK
  333. //
  334. // This is done so the other pieces of the code
  335. // 'know' who their main window is...
  336. //
  337. theApp.m_pMainWnd = this;
  338. if (CFrameWnd::OnCreate(lpCreateStruct) == -1) {
  339. return -1;
  340. }
  341. if (!m_wndToolBar.Create(this) ||
  342. !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) {
  343. TRACE0("Failed to create toolbar\n");
  344. return -1; // fail to create
  345. }
  346. if (!m_wndStatusBar.Create(this) ||
  347. !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) {
  348. TRACE0("Failed to create status bar\n");
  349. return -1; // fail to create
  350. }
  351. m_objectToolbar.Create ("Object controls", this, 101);
  352. m_objectToolbar.AddButton (IDB_LOCK_X_UP, IDB_LOCK_X_DN, IDM_CAMERA_ALLOW_ROTATE_Y, CFancyToolbar::Type2State);
  353. m_objectToolbar.AddButton (IDB_LOCK_Y_UP, IDB_LOCK_Y_DN, IDM_CAMERA_ALLOW_ROTATE_X, CFancyToolbar::Type2State);
  354. m_objectToolbar.AddButton (IDB_LOCK_Z_UP, IDB_LOCK_Z_DN, IDM_CAMERA_ALLOW_ROTATE_Z, CFancyToolbar::Type2State);
  355. m_objectToolbar.AddButton (IDB_ROTATE_Z_UP, IDB_ROTATE_Z_DN, IDM_OBJECT_ROTATE_Z, CFancyToolbar::Type2State);
  356. m_animationToolbar.Create ("Animation controls", this, 102);
  357. m_animationToolbar.AddButton (IDB_PLAY_UP, IDB_PLAY_DN, IDM_ANI_START, CFancyToolbar::Type2State);
  358. m_animationToolbar.AddButton (IDB_STOP_UP, IDB_STOP_DN, IDM_ANI_STOP);
  359. m_animationToolbar.AddButton (IDB_PAUSE_UP, IDB_PAUSE_DN, IDM_ANI_PAUSE, CFancyToolbar::Type2State);
  360. m_animationToolbar.AddButton (IDB_REVERSE_UP, IDB_REVERSE_DN, IDM_ANI_STEP_BKWD);
  361. m_animationToolbar.AddButton (IDB_FFWD_UP, IDB_FFWD_DN, IDM_ANI_STEP_FWD);
  362. m_animationToolbar.ShowWindow (SW_HIDE);
  363. // TODO: Remove this if you don't want tool tips or a resizeable toolbar
  364. m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle () |
  365. CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  366. // TODO: Delete these three lines if you don't want the toolbar to
  367. // be dockable
  368. m_wndToolBar.ModifyStyle(0, TBSTYLE_FLAT);
  369. m_wndToolBar.EnableDocking (CBRS_ALIGN_ANY);
  370. EnableDocking (CBRS_ALIGN_ANY);
  371. DockControlBar (&m_wndToolBar);
  372. // Get the bounding rectangle of the window
  373. RECT rect;
  374. GetWindowRect (&rect);
  375. // Show the object toolbar
  376. FloatControlBar (&m_objectToolbar, CPoint(rect.left + 10, rect.bottom-100), CBRS_ALIGN_LEFT);
  377. // Float the animation bar, but don't show it
  378. FloatControlBar (&m_animationToolbar, CPoint(rect.left + 210, rect.bottom-100), CBRS_ALIGN_LEFT);
  379. ShowControlBar (&m_animationToolbar, FALSE, FALSE);
  380. // Don't show anything in these panes for now
  381. m_wndStatusBar.SetPaneText (PANE_POLYS, "");
  382. m_wndStatusBar.SetPaneText (PANE_PARTICLES, "");
  383. m_wndStatusBar.SetPaneText (PANE_DISTANCE, "");
  384. m_wndStatusBar.SetPaneText (PANE_FRAMES, "");
  385. m_wndStatusBar.SetPaneText (PANE_FPS, "");
  386. m_wndStatusBar.SetPaneText (PANE_RESOLUTION, "");
  387. // Make sure load on demand is activated
  388. _TheAssetMgr->Set_WW3D_Load_On_Demand (true);
  389. // Make sure fogging is turned on for all assets.
  390. _TheAssetMgr->Set_Activate_Fog_On_Load(true);
  391. GetWindowRect (&m_OrigRect);
  392. m_hEmittersSubMenu = ::GetSubMenu (::GetMenu (m_hWnd), 3);
  393. m_hEmittersSubMenu = ::GetSubMenu (m_hEmittersSubMenu, 3);
  394. Restore_Window_State ();
  395. m_bInitialized = TRUE;
  396. return (g_iDeviceIndex != -1) ? 0 : -1;
  397. }
  398. ////////////////////////////////////////////////////////////////////////////
  399. //
  400. // Restore_Window_State
  401. //
  402. ////////////////////////////////////////////////////////////////////////////
  403. void
  404. CMainFrame::Restore_Window_State (void)
  405. {
  406. //
  407. // Read the cached window information from the registry
  408. //
  409. CRect rect;
  410. rect.left = theApp.GetProfileInt ("Window", "Left", -1);
  411. rect.right = theApp.GetProfileInt ("Window", "Right", -1);
  412. rect.top = theApp.GetProfileInt ("Window", "Top", -1);
  413. rect.bottom = theApp.GetProfileInt ("Window", "Bottom", -1);
  414. bool is_max = (theApp.GetProfileInt ("Window", "Maximized", -1) == 1);
  415. if (rect.left != -1 && rect.right != -1 && rect.top != -1 && rect.bottom != -1) {
  416. if (is_max) {
  417. ::ShowWindow (m_hWnd, SW_MAXIMIZE);
  418. } else {
  419. ::SetWindowPos (m_hWnd, NULL, rect.left, rect.top, rect.Width (), rect.Height (), SWP_NOZORDER);
  420. }
  421. }
  422. return ;
  423. }
  424. ////////////////////////////////////////////////////////////////////////////
  425. //
  426. // RestoreOriginalSize
  427. //
  428. ////////////////////////////////////////////////////////////////////////////
  429. void
  430. CMainFrame::RestoreOriginalSize (void)
  431. {
  432. // Resize the window so its the same size it was when the application loaded
  433. SetWindowPos (NULL, 0, 0, m_OrigRect.right-m_OrigRect.left, m_OrigRect.bottom-m_OrigRect.top, SWP_NOMOVE | SWP_NOZORDER);
  434. return ;
  435. }
  436. ////////////////////////////////////////////////////////////////////////////
  437. //
  438. // OnCreateClient
  439. //
  440. ////////////////////////////////////////////////////////////////////////////
  441. BOOL
  442. CMainFrame::OnCreateClient
  443. (
  444. LPCREATESTRUCT /*lpcs*/,
  445. CCreateContext* pContext
  446. )
  447. {
  448. //
  449. // Start up the audio system
  450. //
  451. WWAudioClass *audio_mgr = new WWAudioClass;
  452. audio_mgr->Initialize ();
  453. // Create the main splitter window for the application
  454. BOOL bReturn = m_wndSplitter.CreateStatic (this, 1, 2);
  455. ASSERT (bReturn);
  456. if (bReturn) {
  457. // Create the tree view which will contain the textual contents
  458. // of the W3D file.
  459. bReturn &= m_wndSplitter.CreateView ( 0,
  460. 0,
  461. RUNTIME_CLASS (CDataTreeView),
  462. CSize (340, 10),
  463. pContext);
  464. // Create the 'graphic' view which will contain a pictoral representation
  465. // of the currently selected object
  466. bReturn &= m_wndSplitter.CreateView ( 0,
  467. 1,
  468. RUNTIME_CLASS (CGraphicView),
  469. CSize (120, 10),
  470. pContext);
  471. ASSERT (bReturn);
  472. if (bReturn) {
  473. // Get a pointer to the 'graphic' pane's window
  474. CGraphicView *pCGraphicView = (CGraphicView *)m_wndSplitter.GetPane (0, 1);
  475. BOOL bReturn = (pCGraphicView != NULL);
  476. // Were we successful in view's getting the pointer?
  477. ASSERT (pCGraphicView);
  478. if (pCGraphicView) {
  479. TCHAR szFileName[MAX_PATH];
  480. ::GetModuleFileName (NULL, szFileName, sizeof (szFileName));
  481. LPTSTR pszPath = ::strrchr (szFileName, '\\');
  482. if (pszPath) {
  483. pszPath[0] = 0;
  484. ::SetCurrentDirectory (szFileName);
  485. }
  486. // Initialize the WW3D engine using the window handle from
  487. // the graphic viewer class.
  488. bReturn = (WW3D::Init ((HWND)*pCGraphicView) == WW3D_ERROR_OK);
  489. ASSERT (bReturn);
  490. WW3D::Enable_Static_Sort_Lists(true);
  491. //
  492. // Initialize the device
  493. //
  494. g_iWidth = theApp.GetProfileInt ("Config", "DeviceWidth", 640);
  495. g_iHeight = theApp.GetProfileInt ("Config", "DeviceHeight", 480);
  496. Select_Device (false);
  497. //
  498. // Register the prototype loaders we'll need
  499. //
  500. WW3DAssetManager::Get_Instance()->Register_Prototype_Loader (&_HLodLoader);
  501. WW3DAssetManager::Get_Instance()->Register_Prototype_Loader (&_DistLODLoader);
  502. WW3DAssetManager::Get_Instance()->Register_Prototype_Loader (&_ParticleEmitterLoader);
  503. WW3DAssetManager::Get_Instance()->Register_Prototype_Loader (&_AggregateLoader);
  504. WW3DAssetManager::Get_Instance()->Register_Prototype_Loader (&_RingLoader);
  505. WW3DAssetManager::Get_Instance()->Register_Prototype_Loader (&_SphereLoader);
  506. WW3DAssetManager::Get_Instance()->Register_Prototype_Loader (&_SoundRenderObjLoader);
  507. //
  508. // Restore the N-Patch Subdivision Level and Gap-Filling settings from the last session.
  509. //
  510. int subdivision_level = ::AfxGetApp()->GetProfileInt("Config", "NPatchesSubdivision", 4);
  511. int gap_filling = ::AfxGetApp()->GetProfileInt("Config", "NPatchesGapFilling", 0);
  512. WW3D::Set_NPatches_Gap_Filling_Mode(gap_filling ? WW3D::NPATCHES_GAP_FILLING_ENABLED : WW3D::NPATCHES_GAP_FILLING_DISABLED);
  513. WW3D::Set_NPatches_Level((unsigned int)subdivision_level);
  514. //
  515. // Restore munge sort on load settings
  516. //
  517. int munge_sort=::AfxGetApp()->GetProfileInt("Config", "MungeSortOnLoad",0);
  518. WW3D::Enable_Munge_Sort_On_Load(munge_sort==1?true:false);
  519. int sort=::AfxGetApp()->GetProfileInt("Config", "EnableSorting",1);
  520. WW3D::Enable_Sorting(sort==1?true:false);
  521. // restore gamma settings
  522. int setting=::AfxGetApp()->GetProfileInt("Config","EnableGamma",0);
  523. if (setting) {
  524. float gamma=::AfxGetApp()->GetProfileInt("Config","Gamma",10);
  525. gamma=gamma/10.0f;
  526. if (gamma<1.0) gamma=1.0;
  527. if (gamma>3.0) gamma=3.0;
  528. DX8Wrapper::Set_Gamma(gamma,0.0f,1.0f);
  529. }
  530. }
  531. }
  532. }
  533. // Return the TRUE/FALSE result code
  534. return bReturn;
  535. }
  536. ////////////////////////////////////////////////////////////////////////////
  537. //
  538. // PreCreateWindow
  539. //
  540. ////////////////////////////////////////////////////////////////////////////
  541. BOOL
  542. CMainFrame::PreCreateWindow (CREATESTRUCT& cs)
  543. {
  544. // TODO: Modify the Window class or styles here by modifying
  545. // the CREATESTRUCT cs
  546. return CFrameWnd::PreCreateWindow(cs);
  547. }
  548. /////////////////////////////////////////////////////////////////////////////
  549. // CMainFrame diagnostics
  550. #ifdef _DEBUG
  551. void CMainFrame::AssertValid() const
  552. {
  553. CFrameWnd::AssertValid();
  554. }
  555. void CMainFrame::Dump(CDumpContext& dc) const
  556. {
  557. CFrameWnd::Dump(dc);
  558. }
  559. #endif //_DEBUG
  560. ////////////////////////////////////////////////////////////////////////////
  561. //
  562. // WindowProc
  563. //
  564. ////////////////////////////////////////////////////////////////////////////
  565. LRESULT
  566. CMainFrame::WindowProc
  567. (
  568. UINT message,
  569. WPARAM wParam,
  570. LPARAM lParam
  571. )
  572. {
  573. if (message == WM_CLOSE) {
  574. // We're closing the application so cleanup resources
  575. CW3DViewDoc *pdoc = (CW3DViewDoc *)GetActiveDocument ();
  576. if (pdoc != NULL) {
  577. // Ask the Doc to free its resources
  578. pdoc->CleanupResources ();
  579. }
  580. } else if (message == WM_COMMAND) {
  581. switch (LOWORD (wParam))
  582. {
  583. case IDM_SETTINGS1:
  584. case IDM_SETTINGS2:
  585. case IDM_SETTINGS3:
  586. case IDM_SETTINGS4:
  587. case IDM_SETTINGS5:
  588. case IDM_SETTINGS6:
  589. case IDM_SETTINGS7:
  590. case IDM_SETTINGS8:
  591. case IDM_SETTINGS9:
  592. {
  593. // Get the directory where this executable was run from
  594. TCHAR filename[MAX_PATH];
  595. ::GetModuleFileName (NULL, filename, sizeof (filename));
  596. // Strip the filename from the path
  597. LPTSTR ppath = ::strrchr (filename, '\\');
  598. if (ppath != NULL) {
  599. ppath[0] = 0;
  600. }
  601. // Concat the default.dat filename onto the path
  602. TCHAR full_path[MAX_PATH];
  603. ::strcat (filename, "\\settings");
  604. ::wsprintf (full_path, "%s%d.dat", filename, (LOWORD(wParam) - IDM_SETTINGS1) + 1);
  605. // Does the file exist in the directory?
  606. if (::GetFileAttributes (full_path) != 0xFFFFFFFF) {
  607. // Ask the document to load the settings from this data file
  608. CW3DViewDoc *pdoc = (CW3DViewDoc *)GetActiveDocument ();
  609. if (pdoc != NULL) {
  610. pdoc->LoadSettings (full_path);
  611. }
  612. }
  613. }
  614. break;
  615. }
  616. }
  617. // Allow the base class to process this message
  618. return CFrameWnd::WindowProc (message, wParam, lParam);
  619. }
  620. ////////////////////////////////////////////////////////////////////////////
  621. //
  622. // OnObjectProperties
  623. //
  624. ////////////////////////////////////////////////////////////////////////////
  625. void
  626. CMainFrame::OnObjectProperties (void)
  627. {
  628. // Dislay the properties for the currently selected object.
  629. ShowObjectProperties ();
  630. return ;
  631. }
  632. ////////////////////////////////////////////////////////////////////////////
  633. //
  634. // ShowObjectProperties
  635. //
  636. ////////////////////////////////////////////////////////////////////////////
  637. void
  638. CMainFrame::ShowObjectProperties (void)
  639. {
  640. // Get a pointer to the 'graphic' pane's window
  641. CDataTreeView *pCDataTreeView = (CDataTreeView *)m_wndSplitter.GetPane (0, 0);
  642. BOOL bReturn = (pCDataTreeView != NULL);
  643. // Were we successful in getting the view's pointer?
  644. ASSERT (pCDataTreeView);
  645. if (pCDataTreeView)
  646. {
  647. // What type of object is currently selected?
  648. switch (pCDataTreeView->GetCurrentSelectionType ())
  649. {
  650. case TypeMesh:
  651. {
  652. // Create a one-page property sheet that will display property information
  653. // for the mesh
  654. CMeshPropPage meshPropPage (pCDataTreeView->GetCurrentSelectionName ());
  655. CAssetPropertySheet propertySheet (IDS_MESH_PROP_TITLE, &meshPropPage, this);
  656. // Show the property sheet
  657. propertySheet.DoModal ();
  658. }
  659. break;
  660. case TypeHierarchy:
  661. {
  662. // Create a one-page property sheet that will display property information
  663. // for the hierarchy
  664. CHierarchyPropPage hierarchyPropPage (pCDataTreeView->GetCurrentSelectionName ());
  665. CAssetPropertySheet propertySheet (IDS_HIERARCHY_PROP_TITLE, &hierarchyPropPage, this);
  666. // Show the property sheet
  667. propertySheet.DoModal ();
  668. }
  669. break;
  670. case TypeAnimation:
  671. {
  672. // Create a one-page property sheet that will display property information
  673. // for the animation
  674. CAnimationPropPage animationPropPage;
  675. CAssetPropertySheet propertySheet (IDS_ANIMATION_PROP_TITLE, &animationPropPage, this);
  676. // Show the property sheet
  677. propertySheet.DoModal ();
  678. }
  679. break;
  680. case TypeSound:
  681. OnEditSoundObject ();
  682. break;
  683. case TypeEmitter:
  684. OnEditEmitter ();
  685. break;
  686. case TypePrimitives:
  687. OnEditPrimitive ();
  688. break;
  689. }
  690. }
  691. return ;
  692. }
  693. ////////////////////////////////////////////////////////////////////////////
  694. //
  695. // OnUpdateObjectProperties
  696. //
  697. ////////////////////////////////////////////////////////////////////////////
  698. void
  699. CMainFrame::OnUpdateObjectProperties (CCmdUI* pCmdUI)
  700. {
  701. // Get a pointer to the 'graphic' pane's window
  702. CDataTreeView *pCDataTreeView = (CDataTreeView *)m_wndSplitter.GetPane (0, 0);
  703. BOOL bReturn = (pCDataTreeView != NULL);
  704. // Were we successful in view's getting the pointer?
  705. ASSERT (pCDataTreeView);
  706. if (pCDataTreeView)
  707. {
  708. // Get the name of the currently selected object
  709. pCmdUI->Enable (pCDataTreeView->GetCurrentSelectionName () != NULL);
  710. }
  711. return ;
  712. }
  713. ////////////////////////////////////////////////////////////////////////////
  714. //
  715. // OnSelectionChanged
  716. //
  717. ////////////////////////////////////////////////////////////////////////////
  718. void
  719. CMainFrame::OnSelectionChanged (ASSET_TYPE newAssetType)
  720. {
  721. if (m_currentAssetType != newAssetType)
  722. {
  723. // What was the old type?
  724. switch (m_currentAssetType)
  725. {
  726. case TypeAnimation:
  727. case TypeCompressedAnimation:
  728. case TypeLOD:
  729. case TypeHierarchy:
  730. case TypeAggregate:
  731. {
  732. CMenu *pMainMenu = GetMenu ();
  733. if (pMainMenu)
  734. {
  735. // Remove the 'special' menu from the menubar
  736. pMainMenu->RemoveMenu (SPECIAL_MENU_SLOT, MF_BYPOSITION);
  737. DrawMenuBar ();
  738. }
  739. if ((m_currentAssetType == TypeAnimation) || (m_currentAssetType == TypeCompressedAnimation))
  740. {
  741. // Remember whether or not to show the animation bar next time
  742. m_bShowAnimationBar = m_animationToolbar.IsWindowVisible ();
  743. // Hide the animation control bar
  744. ShowControlBar (&m_animationToolbar, FALSE, FALSE);
  745. }
  746. }
  747. break;
  748. }
  749. // Whats the new type?
  750. switch (newAssetType)
  751. {
  752. case TypeCompressedAnimation:
  753. case TypeAnimation:
  754. {
  755. CMenu *pMainMenu = GetMenu ();
  756. if (pMainMenu)
  757. {
  758. // Load the menu from the resources
  759. HMENU hSubMenu = ::LoadMenu (::AfxGetResourceHandle (), MAKEINTRESOURCE(IDR_ANI_MENU));
  760. hSubMenu = ::GetSubMenu (hSubMenu, 0);
  761. // Add this menu to the menu bar
  762. MENUITEMINFO menuInfo = { sizeof (MENUITEMINFO), 0 };
  763. menuInfo.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_DATA;
  764. menuInfo.hSubMenu = hSubMenu;
  765. menuInfo.fType = MFT_STRING;
  766. menuInfo.dwTypeData = "&Animation";
  767. ::InsertMenuItem (*pMainMenu, SPECIAL_MENU_SLOT, TRUE, &menuInfo);
  768. // Redrew the menu
  769. DrawMenuBar ();
  770. }
  771. if (m_bShowAnimationBar)
  772. {
  773. // Show the animation bar
  774. OnViewAnimationBar ();
  775. }
  776. }
  777. break;
  778. case TypeHierarchy:
  779. {
  780. CMenu *pMainMenu = GetMenu ();
  781. if (pMainMenu)
  782. {
  783. // Load the menu from the resources
  784. HMENU hSubMenu = ::LoadMenu (::AfxGetResourceHandle (), MAKEINTRESOURCE(IDR_HIERARCHY_MENU));
  785. hSubMenu = ::GetSubMenu (hSubMenu, 0);
  786. // Add this menu to the menu bar
  787. MENUITEMINFO menuInfo = { sizeof (MENUITEMINFO), 0 };
  788. menuInfo.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_DATA;
  789. menuInfo.hSubMenu = hSubMenu;
  790. menuInfo.fType = MFT_STRING;
  791. menuInfo.dwTypeData = "&Hierarchy";
  792. ::InsertMenuItem (*pMainMenu, SPECIAL_MENU_SLOT, TRUE, &menuInfo);
  793. // Redrew the menu
  794. DrawMenuBar ();
  795. }
  796. }
  797. break;
  798. case TypeAggregate:
  799. {
  800. CMenu *pMainMenu = GetMenu ();
  801. if (pMainMenu)
  802. {
  803. // Load the menu from the resources
  804. HMENU hSubMenu = ::LoadMenu (::AfxGetResourceHandle (), MAKEINTRESOURCE(IDR_AGGREGATE_MENU));
  805. hSubMenu = ::GetSubMenu (hSubMenu, 0);
  806. // Add this menu to the menu bar
  807. MENUITEMINFO menuInfo = { sizeof (MENUITEMINFO), 0 };
  808. menuInfo.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_DATA;
  809. menuInfo.hSubMenu = hSubMenu;
  810. menuInfo.fType = MFT_STRING;
  811. menuInfo.dwTypeData = "&Aggregate";
  812. ::InsertMenuItem (*pMainMenu, SPECIAL_MENU_SLOT, TRUE, &menuInfo);
  813. // Redrew the menu
  814. DrawMenuBar ();
  815. }
  816. }
  817. break;
  818. case TypeLOD:
  819. {
  820. CMenu *pMainMenu = GetMenu ();
  821. if (pMainMenu)
  822. {
  823. // Load the menu from the resources
  824. HMENU hSubMenu = ::LoadMenu (::AfxGetResourceHandle (), MAKEINTRESOURCE(IDR_LOD_MENU));
  825. hSubMenu = ::GetSubMenu (hSubMenu, 0);
  826. // Add this menu to the menu bar
  827. MENUITEMINFO menuInfo = { sizeof (MENUITEMINFO), 0 };
  828. menuInfo.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_DATA;
  829. menuInfo.hSubMenu = hSubMenu;
  830. menuInfo.fType = MFT_STRING;
  831. menuInfo.dwTypeData = "&LOD";
  832. ::InsertMenuItem (*pMainMenu, SPECIAL_MENU_SLOT, TRUE, &menuInfo);
  833. // Redrew the menu
  834. DrawMenuBar ();
  835. }
  836. }
  837. break;
  838. }
  839. // Remember the new asset type for later
  840. m_currentAssetType = newAssetType;
  841. }
  842. return ;
  843. }
  844. ////////////////////////////////////////////////////////////////////////////
  845. //
  846. // OnLodGenerate
  847. //
  848. ////////////////////////////////////////////////////////////////////////////
  849. void
  850. CMainFrame::OnLodGenerate (void)
  851. {
  852. // Get a pointer to the 'data' pane's window
  853. CDataTreeView *ptree_view = (CDataTreeView *)m_wndSplitter.GetPane (0, 0);
  854. // Were we successful in view's getting the pointer?
  855. ASSERT (ptree_view != NULL);
  856. if ((ptree_view != NULL) &&
  857. ptree_view->GetCurrentSelectionName ()) {
  858. // Get the name of the currently selected hierarchy
  859. LPCTSTR pszName = ptree_view->GetCurrentSelectionName ();
  860. // Does this name fit with the format expected?
  861. LOD_NAMING_TYPE type = TYPE_COMMANDO;
  862. if (Is_LOD_Name_Valid (pszName, type)) {
  863. // Get the 'base' name from the hierarchy's name
  864. CString stringName = pszName;
  865. if (type == TYPE_COMMANDO) {
  866. stringName = stringName.Left (stringName.GetLength () - 2);
  867. } else {
  868. stringName = stringName.Left (stringName.GetLength () - 1);
  869. }
  870. // Get a pointer to the document so we can create an LOD
  871. CW3DViewDoc *pdoc = (CW3DViewDoc *)GetActiveDocument ();
  872. ASSERT (pdoc != NULL);
  873. if (pdoc != NULL) {
  874. // Attempt to generate an LOD from the name of the
  875. // currently selected hierarchy
  876. HLodPrototypeClass *plod_prototype = pdoc->GenerateLOD (stringName, type);
  877. if (plod_prototype != NULL) {
  878. // Add this prototype to the asset manager
  879. WW3DAssetManager::Get_Instance ()->Add_Prototype (plod_prototype);
  880. // Add this LOD to the tree view
  881. ptree_view->Add_Asset_To_Tree (plod_prototype->Get_Name (), TypeLOD, true);
  882. }
  883. }
  884. }
  885. }
  886. return ;
  887. }
  888. ////////////////////////////////////////////////////////////////////////////
  889. //
  890. // OnActivateApp
  891. //
  892. ////////////////////////////////////////////////////////////////////////////
  893. void
  894. CMainFrame::OnActivateApp
  895. (
  896. BOOL bActive,
  897. HTASK hTask
  898. )
  899. {
  900. // Get a pointer to the 'graphic' pane's window
  901. CGraphicView *pCGraphicView = (CGraphicView *)m_wndSplitter.GetPane (0, 1);
  902. // Were we successful in view's getting the pointer?
  903. ASSERT (pCGraphicView);
  904. if (pCGraphicView)
  905. {
  906. // Let the view know whether or not to actively update
  907. // its display (animation, etc)
  908. pCGraphicView->SetActiveUpdate (bActive);
  909. }
  910. // Allow the base class to process this message
  911. CFrameWnd::OnActivateApp(bActive, hTask);
  912. return ;
  913. }
  914. ////////////////////////////////////////////////////////////////////////////
  915. //
  916. // Update_Frame_Time
  917. //
  918. ////////////////////////////////////////////////////////////////////////////
  919. void
  920. CMainFrame::Update_Frame_Time (DWORD clocks)
  921. {
  922. static DWORD frames = 0;
  923. static DWORD total_clocks = 0;
  924. static DWORD last_update = 0;
  925. total_clocks += clocks;
  926. frames ++;
  927. //if (frames >= 20) {
  928. if ((::GetTickCount () - last_update) >= 1000) {
  929. //
  930. // Average the frame time
  931. //
  932. float frame_time = ((float) total_clocks) / ((float) frames);
  933. CString text;
  934. text.Format ("Clocks: %.2f", frame_time);
  935. //
  936. // Update the UI
  937. //
  938. m_wndStatusBar.SetPaneText (PANE_FPS, text);
  939. frames = 0;
  940. total_clocks = 0;
  941. last_update = ::GetTickCount ();
  942. }
  943. // Update the resolution display
  944. CGraphicView *pCGraphicView = (CGraphicView *)m_wndSplitter.GetPane (0, 1);
  945. if (pCGraphicView != NULL) {
  946. CRect rect;
  947. pCGraphicView->GetWindowRect(&rect);
  948. CString text;
  949. text.Format (" %d x %d ",rect.Width(),rect.Height());
  950. m_wndStatusBar.SetPaneText (PANE_RESOLUTION, text);
  951. }
  952. return ;
  953. }
  954. ////////////////////////////////////////////////////////////////////////////
  955. //
  956. // UpdatePolygonCount
  957. //
  958. ////////////////////////////////////////////////////////////////////////////
  959. void
  960. CMainFrame::UpdatePolygonCount (int iPolygons)
  961. {
  962. CString stringPolyCount;
  963. stringPolyCount.Format ("Polys %d", iPolygons);
  964. m_wndStatusBar.SetPaneText (PANE_POLYS, stringPolyCount);
  965. return ;
  966. }
  967. ////////////////////////////////////////////////////////////////////////////
  968. //
  969. // Update_Particle_Count
  970. //
  971. ////////////////////////////////////////////////////////////////////////////
  972. void
  973. CMainFrame::Update_Particle_Count (int particles)
  974. {
  975. CString count_string;
  976. count_string.Format ("Particles %d", particles);
  977. m_wndStatusBar.SetPaneText (PANE_PARTICLES, count_string);
  978. return ;
  979. }
  980. ////////////////////////////////////////////////////////////////////////////
  981. //
  982. // UpdateFrameCount
  983. //
  984. ////////////////////////////////////////////////////////////////////////////
  985. void
  986. CMainFrame::UpdateFrameCount
  987. (
  988. int iCurrentFrame,
  989. int iTotalFrames,
  990. float frame_rate
  991. )
  992. {
  993. CString frames;
  994. frames.Format ("Frame %d/%d at %.2f fps", iCurrentFrame, iTotalFrames, frame_rate);
  995. m_wndStatusBar.SetPaneText (PANE_FRAMES, frames);
  996. return ;
  997. }
  998. ////////////////////////////////////////////////////////////////////////////
  999. //
  1000. // UpdateCameraDistance
  1001. //
  1002. ////////////////////////////////////////////////////////////////////////////
  1003. void
  1004. CMainFrame::UpdateCameraDistance (float cameraDistance)
  1005. {
  1006. CString distance_string;
  1007. distance_string.Format ("Camera %.3f", cameraDistance);
  1008. m_wndStatusBar.SetPaneText (PANE_DISTANCE, distance_string);
  1009. return ;
  1010. }
  1011. ////////////////////////////////////////////////////////////////////////////
  1012. //
  1013. // OnFileOpen
  1014. //
  1015. ////////////////////////////////////////////////////////////////////////////
  1016. void
  1017. CMainFrame::OnFileOpen (void)
  1018. {
  1019. CW3DViewDoc *doc = (CW3DViewDoc *)GetActiveDocument ();
  1020. if (doc == NULL) {
  1021. return ;
  1022. }
  1023. CFileDialog openFileDialog (TRUE,
  1024. ".w3d",
  1025. NULL,
  1026. OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_ALLOWMULTISELECT | OFN_EXPLORER,
  1027. "Westwood 3D Files (*.w3d)|*.w3d||",
  1028. this);
  1029. TCHAR szFileNameList[MAX_PATH*10] = { 0 };
  1030. openFileDialog.m_ofn.lpstrFile = szFileNameList;
  1031. openFileDialog.m_ofn.nMaxFile = sizeof (szFileNameList);
  1032. openFileDialog.m_ofn.lpstrInitialDir = doc->Get_Last_Path ();
  1033. // Ask the user what files they want to load.
  1034. if (openFileDialog.DoModal () == IDOK)
  1035. {
  1036. // Show the wait cursor while we load assets
  1037. SetCursor (::LoadCursor (NULL, IDC_WAIT));
  1038. // Loop through all the selected files
  1039. POSITION pPos = openFileDialog.GetStartPosition ();
  1040. while (pPos != NULL)
  1041. {
  1042. // Ask the doc to load the assets from this file into memory
  1043. CString stringFileName = openFileDialog.GetNextPathName (pPos);
  1044. doc->LoadAssetsFromFile (stringFileName);
  1045. // Add this filename to the MRU
  1046. ::AfxGetApp ()->AddToRecentFileList (stringFileName);
  1047. }
  1048. CDataTreeView *pCDataTreeView = doc->GetDataTreeView ();
  1049. if (pCDataTreeView)
  1050. {
  1051. // Re-load the data list to include all new assets
  1052. pCDataTreeView->LoadAssetsIntoTree ();
  1053. }
  1054. // Restore the arrow cursor
  1055. SetCursor (::LoadCursor (NULL, IDC_ARROW));
  1056. }
  1057. return ;
  1058. }
  1059. ////////////////////////////////////////////////////////////////////////////
  1060. //
  1061. // OnAniSpeed
  1062. //
  1063. ////////////////////////////////////////////////////////////////////////////
  1064. void
  1065. CMainFrame::OnAniSpeed (void)
  1066. {
  1067. CGraphicView *pCGraphicView = (CGraphicView *)m_wndSplitter.GetPane (0, 1);
  1068. if (pCGraphicView)
  1069. {
  1070. float initialSpeed = pCGraphicView->GetAnimationSpeed ();
  1071. CAnimationSpeed animationSpeedDialog (this);
  1072. if (animationSpeedDialog.DoModal () != IDOK)
  1073. {
  1074. pCGraphicView->SetAnimationSpeed (initialSpeed);
  1075. }
  1076. }
  1077. return ;
  1078. }
  1079. ////////////////////////////////////////////////////////////////////////////
  1080. //
  1081. // OnAniStop
  1082. //
  1083. ////////////////////////////////////////////////////////////////////////////
  1084. void
  1085. CMainFrame::OnAniStop (void)
  1086. {
  1087. CGraphicView *pCGraphicView = (CGraphicView *)m_wndSplitter.GetPane (0, 1);
  1088. ASSERT (pCGraphicView);
  1089. if (pCGraphicView)
  1090. {
  1091. // Stop the animation
  1092. pCGraphicView->SetAnimationState (CGraphicView::AnimStopped);
  1093. // Pop the start and pause buttons on the toolbar
  1094. m_animationToolbar.SetButtonState (IDM_ANI_START, CFancyToolbar::StateUp);
  1095. m_animationToolbar.SetButtonState (IDM_ANI_PAUSE, CFancyToolbar::StateUp);
  1096. }
  1097. return ;
  1098. }
  1099. ////////////////////////////////////////////////////////////////////////////
  1100. //
  1101. // OnAniStart
  1102. //
  1103. ////////////////////////////////////////////////////////////////////////////
  1104. void
  1105. CMainFrame::OnAniStart (void)
  1106. {
  1107. CGraphicView *pCGraphicView = (CGraphicView *)m_wndSplitter.GetPane (0, 1);
  1108. ASSERT (pCGraphicView);
  1109. if (pCGraphicView)
  1110. {
  1111. // Start the animation
  1112. pCGraphicView->SetAnimationState (CGraphicView::AnimPlaying);
  1113. // Pop the pause button on the toolbar
  1114. m_animationToolbar.SetButtonState (IDM_ANI_PAUSE, CFancyToolbar::StateUp);
  1115. // Push the 'play' button
  1116. m_animationToolbar.SetButtonState (IDM_ANI_START, CFancyToolbar::StateDn);
  1117. }
  1118. return ;
  1119. }
  1120. ////////////////////////////////////////////////////////////////////////////
  1121. //
  1122. // OnAniPause
  1123. //
  1124. ////////////////////////////////////////////////////////////////////////////
  1125. void
  1126. CMainFrame::OnAniPause (void)
  1127. {
  1128. CGraphicView *pCGraphicView = (CGraphicView *)m_wndSplitter.GetPane (0, 1);
  1129. ASSERT (pCGraphicView);
  1130. if (pCGraphicView)
  1131. {
  1132. if (pCGraphicView->GetAnimationState () == CGraphicView::AnimPlaying)
  1133. {
  1134. // Pause the animation
  1135. pCGraphicView->SetAnimationState (CGraphicView::AnimPaused);
  1136. // Push the pause button on the toolbar
  1137. m_animationToolbar.SetButtonState (IDM_ANI_PAUSE, CFancyToolbar::StateDn);
  1138. }
  1139. else if (pCGraphicView->GetAnimationState () == CGraphicView::AnimPaused)
  1140. {
  1141. // Play the animation
  1142. pCGraphicView->SetAnimationState (CGraphicView::AnimPlaying);
  1143. // Pop the pause button on the toolbar
  1144. m_animationToolbar.SetButtonState (IDM_ANI_PAUSE, CFancyToolbar::StateUp);
  1145. }
  1146. else
  1147. {
  1148. // Pop the pause button on the toolbar
  1149. m_animationToolbar.SetButtonState (IDM_ANI_PAUSE, CFancyToolbar::StateUp);
  1150. }
  1151. }
  1152. return ;
  1153. }
  1154. ////////////////////////////////////////////////////////////////////////////
  1155. //
  1156. // OnCameraBack
  1157. //
  1158. ////////////////////////////////////////////////////////////////////////////
  1159. void
  1160. CMainFrame::OnCameraBack (void)
  1161. {
  1162. CGraphicView *pCGraphicView = (CGraphicView *)m_wndSplitter.GetPane (0, 1);
  1163. ASSERT (pCGraphicView);
  1164. if (pCGraphicView)
  1165. {
  1166. // Position the camera as requested
  1167. pCGraphicView->SetCameraPos (CGraphicView::CameraBack);
  1168. }
  1169. return ;
  1170. }
  1171. ////////////////////////////////////////////////////////////////////////////
  1172. //
  1173. // OnCameraBottom
  1174. //
  1175. ////////////////////////////////////////////////////////////////////////////
  1176. void
  1177. CMainFrame::OnCameraBottom (void)
  1178. {
  1179. CGraphicView *pCGraphicView = (CGraphicView *)m_wndSplitter.GetPane (0, 1);
  1180. ASSERT (pCGraphicView);
  1181. if (pCGraphicView)
  1182. {
  1183. // Position the camera as requested
  1184. pCGraphicView->SetCameraPos (CGraphicView::CameraBottom);
  1185. }
  1186. return ;
  1187. }
  1188. ////////////////////////////////////////////////////////////////////////////
  1189. //
  1190. // OnCameraFront
  1191. //
  1192. ////////////////////////////////////////////////////////////////////////////
  1193. void
  1194. CMainFrame::OnCameraFront (void)
  1195. {
  1196. CGraphicView *pCGraphicView = (CGraphicView *)m_wndSplitter.GetPane (0, 1);
  1197. ASSERT (pCGraphicView);
  1198. if (pCGraphicView)
  1199. {
  1200. // Position the camera as requested
  1201. pCGraphicView->SetCameraPos (CGraphicView::CameraFront);
  1202. }
  1203. return ;
  1204. }
  1205. ////////////////////////////////////////////////////////////////////////////
  1206. //
  1207. // OnCameraLeft
  1208. //
  1209. ////////////////////////////////////////////////////////////////////////////
  1210. void
  1211. CMainFrame::OnCameraLeft (void)
  1212. {
  1213. CGraphicView *pCGraphicView = (CGraphicView *)m_wndSplitter.GetPane (0, 1);
  1214. ASSERT (pCGraphicView);
  1215. if (pCGraphicView)
  1216. {
  1217. // Position the camera as requested
  1218. pCGraphicView->SetCameraPos (CGraphicView::CameraLeft);
  1219. }
  1220. return ;
  1221. }
  1222. ////////////////////////////////////////////////////////////////////////////
  1223. //
  1224. // OnCameraReset
  1225. //
  1226. ////////////////////////////////////////////////////////////////////////////
  1227. void
  1228. CMainFrame::OnCameraReset (void)
  1229. {
  1230. CGraphicView *pCGraphicView = (CGraphicView *)m_wndSplitter.GetPane (0, 1);
  1231. ASSERT (pCGraphicView);
  1232. if (pCGraphicView)
  1233. {
  1234. // Get a pointer to the current document
  1235. CW3DViewDoc *pCDoc = (CW3DViewDoc *)GetActiveDocument ();
  1236. if (pCDoc && pCDoc->GetDisplayedObject ())
  1237. {
  1238. // Reset the camera data
  1239. RenderObjClass *prender_obj = pCDoc->GetDisplayedObject ();
  1240. if (prender_obj->Class_ID () == RenderObjClass::CLASSID_PARTICLEEMITTER) {
  1241. pCGraphicView->Reset_Camera_To_Display_Emitter (*((ParticleEmitterClass *)prender_obj));
  1242. } else {
  1243. pCGraphicView->Reset_Camera_To_Display_Object (*prender_obj);
  1244. }
  1245. }
  1246. }
  1247. return ;
  1248. }
  1249. ////////////////////////////////////////////////////////////////////////////
  1250. //
  1251. // OnCameraRight
  1252. //
  1253. ////////////////////////////////////////////////////////////////////////////
  1254. void
  1255. CMainFrame::OnCameraRight (void)
  1256. {
  1257. CGraphicView *pCGraphicView = (CGraphicView *)m_wndSplitter.GetPane (0, 1);
  1258. ASSERT (pCGraphicView);
  1259. if (pCGraphicView)
  1260. {
  1261. // Position the camera as requested
  1262. pCGraphicView->SetCameraPos (CGraphicView::CameraRight);
  1263. }
  1264. return ;
  1265. }
  1266. ////////////////////////////////////////////////////////////////////////////
  1267. //
  1268. // OnCameraTop
  1269. //
  1270. ////////////////////////////////////////////////////////////////////////////
  1271. void
  1272. CMainFrame::OnCameraTop (void)
  1273. {
  1274. CGraphicView *pCGraphicView = (CGraphicView *)m_wndSplitter.GetPane (0, 1);
  1275. ASSERT (pCGraphicView);
  1276. if (pCGraphicView)
  1277. {
  1278. // Position the camera as requested
  1279. pCGraphicView->SetCameraPos (CGraphicView::CameraTop);
  1280. }
  1281. return ;
  1282. }
  1283. ////////////////////////////////////////////////////////////////////////////
  1284. //
  1285. // OnObjectRotateZ
  1286. //
  1287. ////////////////////////////////////////////////////////////////////////////
  1288. void
  1289. CMainFrame::OnObjectRotateZ (void)
  1290. {
  1291. CGraphicView *pCGraphicView = (CGraphicView *)m_wndSplitter.GetPane (0, 1);
  1292. ASSERT (pCGraphicView);
  1293. if (pCGraphicView)
  1294. {
  1295. int iZRotation = (pCGraphicView->GetObjectRotation () ^ (CGraphicView::RotateZ));
  1296. iZRotation &= ~CGraphicView::RotateZBack;
  1297. // Start or stop the rotation around Z
  1298. pCGraphicView->RotateObject ((CGraphicView::OBJECT_ROTATION)iZRotation);
  1299. if (iZRotation & ROTATION_Z)
  1300. {
  1301. // Force the toolbar button to be up
  1302. m_objectToolbar.SetButtonState (IDM_OBJECT_ROTATE_Z, CFancyToolbar::StateDn);
  1303. }
  1304. else
  1305. {
  1306. // Force the toolbar button to be up
  1307. m_objectToolbar.SetButtonState (IDM_OBJECT_ROTATE_Z, CFancyToolbar::StateUp);
  1308. }
  1309. }
  1310. return ;
  1311. }
  1312. ////////////////////////////////////////////////////////////////////////////
  1313. //
  1314. // OnObjectRotateY
  1315. //
  1316. ////////////////////////////////////////////////////////////////////////////
  1317. void
  1318. CMainFrame::OnObjectRotateY (void)
  1319. {
  1320. CGraphicView *pCGraphicView = (CGraphicView *)m_wndSplitter.GetPane (0, 1);
  1321. ASSERT (pCGraphicView);
  1322. if (pCGraphicView)
  1323. {
  1324. int iYRotation = (pCGraphicView->GetObjectRotation () ^ (CGraphicView::RotateY));
  1325. iYRotation &= ~CGraphicView::RotateYBack;
  1326. // Start or stop the rotation around Y
  1327. pCGraphicView->RotateObject ((CGraphicView::OBJECT_ROTATION)iYRotation);
  1328. }
  1329. return ;
  1330. }
  1331. ////////////////////////////////////////////////////////////////////////////
  1332. //
  1333. // OnObjectRotateX
  1334. //
  1335. ////////////////////////////////////////////////////////////////////////////
  1336. void
  1337. CMainFrame::OnObjectRotateX (void)
  1338. {
  1339. CGraphicView *pCGraphicView = (CGraphicView *)m_wndSplitter.GetPane (0, 1);
  1340. ASSERT (pCGraphicView);
  1341. if (pCGraphicView)
  1342. {
  1343. int iXRotation = (pCGraphicView->GetObjectRotation () ^ (CGraphicView::RotateX));
  1344. iXRotation &= ~CGraphicView::RotateXBack;
  1345. // Start or stop the rotation around X
  1346. pCGraphicView->RotateObject ((CGraphicView::OBJECT_ROTATION)iXRotation);
  1347. }
  1348. return ;
  1349. }
  1350. ////////////////////////////////////////////////////////////////////////////
  1351. //
  1352. // OnLightAmbient
  1353. //
  1354. ////////////////////////////////////////////////////////////////////////////
  1355. void
  1356. CMainFrame::OnLightAmbient (void)
  1357. {
  1358. // Show the ambient light dialog
  1359. CAmbientLightDialog ambientLightDialog (this);
  1360. ambientLightDialog.DoModal ();
  1361. return ;
  1362. }
  1363. ////////////////////////////////////////////////////////////////////////////
  1364. //
  1365. // OnLightAmbient
  1366. //
  1367. ////////////////////////////////////////////////////////////////////////////
  1368. void
  1369. CMainFrame::OnLightScene (void)
  1370. {
  1371. // Show the scene light dialog
  1372. CSceneLightDialog sceneLightDialog (this);
  1373. sceneLightDialog.DoModal ();
  1374. return ;
  1375. }
  1376. ////////////////////////////////////////////////////////////////////////////
  1377. //
  1378. // OnBackgroundColor
  1379. //
  1380. ////////////////////////////////////////////////////////////////////////////
  1381. void
  1382. CMainFrame::OnBackgroundColor (void)
  1383. {
  1384. // Show the background color
  1385. CBackgroundColorDialog backgroundColorDialog (this);
  1386. backgroundColorDialog.DoModal ();
  1387. return ;
  1388. }
  1389. ////////////////////////////////////////////////////////////////////////////
  1390. //
  1391. // OnUpdateBackgroundFog
  1392. //
  1393. ////////////////////////////////////////////////////////////////////////////
  1394. void
  1395. CMainFrame::OnUpdateBackgroundFog (CCmdUI* pCmdUI)
  1396. {
  1397. CW3DViewDoc *pdoc = (CW3DViewDoc *)GetActiveDocument ();
  1398. if (pdoc) {
  1399. pCmdUI->SetCheck(pdoc->IsFogEnabled());
  1400. }
  1401. }
  1402. ////////////////////////////////////////////////////////////////////////////
  1403. //
  1404. // OnBackgroundFog
  1405. //
  1406. ////////////////////////////////////////////////////////////////////////////
  1407. void
  1408. CMainFrame::OnBackgroundFog (void)
  1409. {
  1410. CW3DViewDoc *pdoc = (CW3DViewDoc *)GetActiveDocument ();
  1411. if (pdoc) {
  1412. // Toggle the fog setting.
  1413. pdoc->EnableFog(!pdoc->IsFogEnabled());
  1414. }
  1415. }
  1416. ////////////////////////////////////////////////////////////////////////////
  1417. //
  1418. // OnBackgroundBMP
  1419. //
  1420. ////////////////////////////////////////////////////////////////////////////
  1421. void
  1422. CMainFrame::OnBackgroundBMP (void)
  1423. {
  1424. // Show the background BMP dialog
  1425. CBackgroundBMPDialog backgroundBMPDialog (this);
  1426. backgroundBMPDialog.DoModal ();
  1427. return ;
  1428. }
  1429. ////////////////////////////////////////////////////////////////////////////
  1430. //
  1431. // OnSaveSettings
  1432. //
  1433. ////////////////////////////////////////////////////////////////////////////
  1434. void
  1435. CMainFrame::OnSaveSettings (void)
  1436. {
  1437. // Show the save settings dialog
  1438. CSaveSettingsDialog saveSettingsDialog (this);
  1439. saveSettingsDialog.DoModal ();
  1440. return ;
  1441. }
  1442. ////////////////////////////////////////////////////////////////////////////
  1443. //
  1444. // OnLoadSettings
  1445. //
  1446. ////////////////////////////////////////////////////////////////////////////
  1447. void
  1448. CMainFrame::OnLoadSettings (void)
  1449. {
  1450. // Get the active document
  1451. CW3DViewDoc *pCDoc = (CW3DViewDoc *)GetActiveDocument ();
  1452. if (pCDoc)
  1453. {
  1454. CFileDialog openFileDialog (TRUE,
  1455. ".dat",
  1456. NULL,
  1457. OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER,
  1458. "Settings data files (*.dat)|*.dat||",
  1459. this);
  1460. // Ask the user what settings file they wish to load
  1461. if (openFileDialog.DoModal () == IDOK)
  1462. {
  1463. // Ask the doc to load the settings from this file
  1464. pCDoc->LoadSettings (openFileDialog.GetPathName ());
  1465. }
  1466. }
  1467. return ;
  1468. }
  1469. ////////////////////////////////////////////////////////////////////////////
  1470. //
  1471. // OnLODSetSwitch
  1472. //
  1473. ////////////////////////////////////////////////////////////////////////////
  1474. void
  1475. CMainFrame::OnLODSetSwitch (void)
  1476. {
  1477. // Display the edit LOD dialog
  1478. CEditLODDialog editLODDialog (this);
  1479. editLODDialog.DoModal ();
  1480. return ;
  1481. }
  1482. ////////////////////////////////////////////////////////////////////////////
  1483. //
  1484. // OnLODSave
  1485. //
  1486. ////////////////////////////////////////////////////////////////////////////
  1487. void
  1488. CMainFrame::OnLODSave (void)
  1489. {
  1490. // Get the controlling doc object so we can have it save the
  1491. // LOD for us.
  1492. CW3DViewDoc *pdoc = (CW3DViewDoc *)GetActiveDocument ();
  1493. if (pdoc != NULL) {
  1494. pdoc->Save_Selected_LOD ();
  1495. }
  1496. return ;
  1497. }
  1498. ////////////////////////////////////////////////////////////////////////////
  1499. //
  1500. // OnLODSaveAll
  1501. //
  1502. ////////////////////////////////////////////////////////////////////////////
  1503. void
  1504. CMainFrame::OnLODSaveAll (void)
  1505. {
  1506. MessageBox ("Not implemented yet.", "Test", MB_OK | MB_ICONEXCLAMATION);
  1507. return ;
  1508. }
  1509. ////////////////////////////////////////////////////////////////////////////
  1510. //
  1511. // OnBackgroundObject
  1512. //
  1513. ////////////////////////////////////////////////////////////////////////////
  1514. void
  1515. CMainFrame::OnBackgroundObject (void)
  1516. {
  1517. // Display the background object dialog
  1518. CBackgroundObjectDialog backgroundObjectDialog (this);
  1519. backgroundObjectDialog.DoModal ();
  1520. return ;
  1521. }
  1522. ////////////////////////////////////////////////////////////////////////////
  1523. //
  1524. // OnUpdateViewAnimationBar
  1525. //
  1526. ////////////////////////////////////////////////////////////////////////////
  1527. void
  1528. CMainFrame::OnUpdateViewAnimationBar (CCmdUI* pCmdUI)
  1529. {
  1530. // Are we currently displaying an animation?
  1531. if ((m_currentAssetType != TypeAnimation) || (m_currentAssetType != TypeCompressedAnimation))
  1532. {
  1533. // Disable the option and clear the check
  1534. pCmdUI->Enable (FALSE);
  1535. pCmdUI->SetCheck (FALSE);
  1536. }
  1537. else
  1538. {
  1539. // Enable the option and set the correct state of the check
  1540. pCmdUI->Enable (TRUE);
  1541. pCmdUI->SetCheck (m_animationToolbar.IsWindowVisible ());
  1542. }
  1543. return ;
  1544. }
  1545. ////////////////////////////////////////////////////////////////////////////
  1546. //
  1547. // OnUpdateViewObjectBar
  1548. //
  1549. ////////////////////////////////////////////////////////////////////////////
  1550. void
  1551. CMainFrame::OnUpdateViewObjectBar (CCmdUI* pCmdUI)
  1552. {
  1553. // Enable the option and set the correct state of the check
  1554. pCmdUI->Enable (TRUE);
  1555. pCmdUI->SetCheck (m_objectToolbar.IsWindowVisible ());
  1556. return ;
  1557. }
  1558. ////////////////////////////////////////////////////////////////////////////
  1559. //
  1560. // OnViewAnimationBar
  1561. //
  1562. ////////////////////////////////////////////////////////////////////////////
  1563. void
  1564. CMainFrame::OnViewAnimationBar (void)
  1565. {
  1566. if (m_animationToolbar.IsWindowVisible () == FALSE)
  1567. {
  1568. // Show the animation control bar
  1569. ShowControlBar (&m_animationToolbar, TRUE, FALSE);
  1570. // Remember whether or not to auto show this toolbar
  1571. m_bShowAnimationBar = TRUE;
  1572. }
  1573. else
  1574. {
  1575. // Hide the animation control bar
  1576. ShowControlBar (&m_animationToolbar, FALSE, FALSE);
  1577. // Remember whether or not to auto show this toolbar
  1578. m_bShowAnimationBar = FALSE;
  1579. }
  1580. return ;
  1581. }
  1582. ////////////////////////////////////////////////////////////////////////////
  1583. //
  1584. // OnViewObjectBar
  1585. //
  1586. ////////////////////////////////////////////////////////////////////////////
  1587. void
  1588. CMainFrame::OnViewObjectBar (void)
  1589. {
  1590. if (m_objectToolbar.IsWindowVisible () == FALSE)
  1591. {
  1592. // Show the object control bar
  1593. ShowControlBar (&m_objectToolbar, TRUE, FALSE);
  1594. }
  1595. else
  1596. {
  1597. // Hide the object control bar
  1598. ShowControlBar (&m_objectToolbar, FALSE, FALSE);
  1599. }
  1600. return ;
  1601. }
  1602. ////////////////////////////////////////////////////////////////////////////
  1603. //
  1604. // OnAniStepFwd
  1605. //
  1606. ////////////////////////////////////////////////////////////////////////////
  1607. void
  1608. CMainFrame::OnAniStepFwd (void)
  1609. {
  1610. // Get the current doc
  1611. CW3DViewDoc *pCDoc = (CW3DViewDoc *)GetActiveDocument ();
  1612. if (pCDoc)
  1613. {
  1614. // Ask the doc to step the animation forward one frame
  1615. pCDoc->StepAnimation (1);
  1616. }
  1617. return ;
  1618. }
  1619. ////////////////////////////////////////////////////////////////////////////
  1620. //
  1621. // OnAniStepBkwd
  1622. //
  1623. ////////////////////////////////////////////////////////////////////////////
  1624. void
  1625. CMainFrame::OnAniStepBkwd (void)
  1626. {
  1627. // Get the current doc
  1628. CW3DViewDoc *pCDoc = (CW3DViewDoc *)GetActiveDocument ();
  1629. if (pCDoc)
  1630. {
  1631. // Ask the doc to step the animation backward one frame
  1632. pCDoc->StepAnimation (-1);
  1633. }
  1634. return ;
  1635. }
  1636. ////////////////////////////////////////////////////////////////////////////
  1637. //
  1638. // OnObjectReset
  1639. //
  1640. ////////////////////////////////////////////////////////////////////////////
  1641. void
  1642. CMainFrame::OnObjectReset (void)
  1643. {
  1644. // Get the graphic view
  1645. CGraphicView *pCGraphicView = (CGraphicView *)m_wndSplitter.GetPane (0, 1);
  1646. if (pCGraphicView)
  1647. {
  1648. // Ask the view to reset the rotation of the current object
  1649. pCGraphicView->ResetObject ();
  1650. }
  1651. return ;
  1652. }
  1653. ////////////////////////////////////////////////////////////////////////////
  1654. //
  1655. // OnUpdateCameraAllowRotateX
  1656. //
  1657. ////////////////////////////////////////////////////////////////////////////
  1658. void
  1659. CMainFrame::OnCameraAllowRotateX (void)
  1660. {
  1661. // Get the graphic view
  1662. CGraphicView *pCGraphicView = (CGraphicView *)m_wndSplitter.GetPane (0, 1);
  1663. if (pCGraphicView)
  1664. {
  1665. if (pCGraphicView->GetAllowedCameraRotation () != CGraphicView::OnlyRotateX)
  1666. {
  1667. // Enable rotatation about this axis
  1668. pCGraphicView->SetAllowedCameraRotation (CGraphicView::OnlyRotateX);
  1669. // Make sure the toolbar buttons are in the right state
  1670. m_objectToolbar.SetButtonState (IDM_CAMERA_ALLOW_ROTATE_X, CFancyToolbar::StateDn);
  1671. m_objectToolbar.SetButtonState (IDM_CAMERA_ALLOW_ROTATE_Y, CFancyToolbar::StateUp);
  1672. m_objectToolbar.SetButtonState (IDM_CAMERA_ALLOW_ROTATE_Z, CFancyToolbar::StateUp);
  1673. }
  1674. else
  1675. {
  1676. // Enable rotatation about this axis
  1677. pCGraphicView->SetAllowedCameraRotation (CGraphicView::FreeRotation);
  1678. // Make sure the toolbar buttons are in the right state
  1679. m_objectToolbar.SetButtonState (IDM_CAMERA_ALLOW_ROTATE_X, CFancyToolbar::StateUp);
  1680. m_objectToolbar.SetButtonState (IDM_CAMERA_ALLOW_ROTATE_Y, CFancyToolbar::StateUp);
  1681. m_objectToolbar.SetButtonState (IDM_CAMERA_ALLOW_ROTATE_Z, CFancyToolbar::StateUp);
  1682. }
  1683. }
  1684. return ;
  1685. }
  1686. ////////////////////////////////////////////////////////////////////////////
  1687. //
  1688. // OnCameraAllowRotateY
  1689. //
  1690. ////////////////////////////////////////////////////////////////////////////
  1691. void
  1692. CMainFrame::OnCameraAllowRotateY (void)
  1693. {
  1694. // Get the graphic view
  1695. CGraphicView *pCGraphicView = (CGraphicView *)m_wndSplitter.GetPane (0, 1);
  1696. if (pCGraphicView)
  1697. {
  1698. if (pCGraphicView->GetAllowedCameraRotation () != CGraphicView::OnlyRotateY)
  1699. {
  1700. // Enable rotatation about this axis
  1701. pCGraphicView->SetAllowedCameraRotation (CGraphicView::OnlyRotateY);
  1702. // Make sure the toolbar buttons are in the right state
  1703. m_objectToolbar.SetButtonState (IDM_CAMERA_ALLOW_ROTATE_X, CFancyToolbar::StateUp);
  1704. m_objectToolbar.SetButtonState (IDM_CAMERA_ALLOW_ROTATE_Y, CFancyToolbar::StateDn);
  1705. m_objectToolbar.SetButtonState (IDM_CAMERA_ALLOW_ROTATE_Z, CFancyToolbar::StateUp);
  1706. }
  1707. else
  1708. {
  1709. // Enable rotatation about this axis
  1710. pCGraphicView->SetAllowedCameraRotation (CGraphicView::FreeRotation);
  1711. // Make sure the toolbar buttons are in the right state
  1712. m_objectToolbar.SetButtonState (IDM_CAMERA_ALLOW_ROTATE_X, CFancyToolbar::StateUp);
  1713. m_objectToolbar.SetButtonState (IDM_CAMERA_ALLOW_ROTATE_Y, CFancyToolbar::StateUp);
  1714. m_objectToolbar.SetButtonState (IDM_CAMERA_ALLOW_ROTATE_Z, CFancyToolbar::StateUp);
  1715. }
  1716. }
  1717. return ;
  1718. }
  1719. ////////////////////////////////////////////////////////////////////////////
  1720. //
  1721. // OnCameraAllowRotateZ
  1722. //
  1723. ////////////////////////////////////////////////////////////////////////////
  1724. void
  1725. CMainFrame::OnCameraAllowRotateZ (void)
  1726. {
  1727. // Get the graphic view
  1728. CGraphicView *pCGraphicView = (CGraphicView *)m_wndSplitter.GetPane (0, 1);
  1729. if (pCGraphicView)
  1730. {
  1731. if (pCGraphicView->GetAllowedCameraRotation () != CGraphicView::OnlyRotateZ)
  1732. {
  1733. // Enable rotatation about this axis
  1734. pCGraphicView->SetAllowedCameraRotation (CGraphicView::OnlyRotateZ);
  1735. // Make sure the toolbar buttons are in the right state
  1736. m_objectToolbar.SetButtonState (IDM_CAMERA_ALLOW_ROTATE_X, CFancyToolbar::StateUp);
  1737. m_objectToolbar.SetButtonState (IDM_CAMERA_ALLOW_ROTATE_Y, CFancyToolbar::StateUp);
  1738. m_objectToolbar.SetButtonState (IDM_CAMERA_ALLOW_ROTATE_Z, CFancyToolbar::StateDn);
  1739. }
  1740. else
  1741. {
  1742. // Enable rotatation about this axis
  1743. pCGraphicView->SetAllowedCameraRotation (CGraphicView::FreeRotation);
  1744. // Make sure the toolbar buttons are in the right state
  1745. m_objectToolbar.SetButtonState (IDM_CAMERA_ALLOW_ROTATE_X, CFancyToolbar::StateUp);
  1746. m_objectToolbar.SetButtonState (IDM_CAMERA_ALLOW_ROTATE_Y, CFancyToolbar::StateUp);
  1747. m_objectToolbar.SetButtonState (IDM_CAMERA_ALLOW_ROTATE_Z, CFancyToolbar::StateUp);
  1748. }
  1749. }
  1750. return ;
  1751. }
  1752. ////////////////////////////////////////////////////////////////////////////
  1753. //
  1754. // OnUpdateCameraAllowRotateX
  1755. //
  1756. ////////////////////////////////////////////////////////////////////////////
  1757. void
  1758. CMainFrame::OnUpdateCameraAllowRotateX (CCmdUI* pCmdUI)
  1759. {
  1760. // Get the graphic view
  1761. CGraphicView *pCGraphicView = (CGraphicView *)m_wndSplitter.GetPane (0, 1);
  1762. if (pCGraphicView)
  1763. {
  1764. // Either turn the check on or off depending on the view's settings
  1765. pCmdUI->SetCheck (pCGraphicView->GetAllowedCameraRotation () == CGraphicView::OnlyRotateX);
  1766. }
  1767. return ;
  1768. }
  1769. ////////////////////////////////////////////////////////////////////////////
  1770. //
  1771. // OnUpdateCameraAllowRotateY
  1772. //
  1773. ////////////////////////////////////////////////////////////////////////////
  1774. void
  1775. CMainFrame::OnUpdateCameraAllowRotateY (CCmdUI* pCmdUI)
  1776. {
  1777. // Get the graphic view
  1778. CGraphicView *pCGraphicView = (CGraphicView *)m_wndSplitter.GetPane (0, 1);
  1779. if (pCGraphicView)
  1780. {
  1781. // Either turn the check on or off depending on the view's settings
  1782. pCmdUI->SetCheck (pCGraphicView->GetAllowedCameraRotation () == CGraphicView::OnlyRotateY);
  1783. }
  1784. return ;
  1785. }
  1786. ////////////////////////////////////////////////////////////////////////////
  1787. //
  1788. // OnUpdateCameraAllowRotateZ
  1789. //
  1790. ////////////////////////////////////////////////////////////////////////////
  1791. void
  1792. CMainFrame::OnUpdateCameraAllowRotateZ (CCmdUI* pCmdUI)
  1793. {
  1794. // Get the graphic view
  1795. CGraphicView *pCGraphicView = (CGraphicView *)m_wndSplitter.GetPane (0, 1);
  1796. if (pCGraphicView)
  1797. {
  1798. // Either turn the check on or off depending on the view's settings
  1799. pCmdUI->SetCheck (pCGraphicView->GetAllowedCameraRotation () == CGraphicView::OnlyRotateZ);
  1800. }
  1801. return ;
  1802. }
  1803. ////////////////////////////////////////////////////////////////////////////
  1804. //
  1805. // OnUpdateObjectRotateX
  1806. //
  1807. ////////////////////////////////////////////////////////////////////////////
  1808. void
  1809. CMainFrame::OnUpdateObjectRotateX (CCmdUI* pCmdUI)
  1810. {
  1811. CGraphicView *pCGraphicView = (CGraphicView *)m_wndSplitter.GetPane (0, 1);
  1812. ASSERT (pCGraphicView);
  1813. if (pCGraphicView)
  1814. {
  1815. // Set the check if we are currently rotating around X
  1816. pCmdUI->SetCheck ((pCGraphicView->GetObjectRotation () & (CGraphicView::RotateX)));
  1817. }
  1818. return ;
  1819. }
  1820. ////////////////////////////////////////////////////////////////////////////
  1821. //
  1822. // OnUpdateObjectRotateY
  1823. //
  1824. ////////////////////////////////////////////////////////////////////////////
  1825. void
  1826. CMainFrame::OnUpdateObjectRotateY (CCmdUI* pCmdUI)
  1827. {
  1828. CGraphicView *pCGraphicView = (CGraphicView *)m_wndSplitter.GetPane (0, 1);
  1829. ASSERT (pCGraphicView);
  1830. if (pCGraphicView)
  1831. {
  1832. // Set the check if we are currently rotating around Y
  1833. pCmdUI->SetCheck ((pCGraphicView->GetObjectRotation () & (CGraphicView::RotateY)));
  1834. }
  1835. return ;
  1836. }
  1837. ////////////////////////////////////////////////////////////////////////////
  1838. //
  1839. // OnUpdateObjectRotateZ
  1840. //
  1841. ////////////////////////////////////////////////////////////////////////////
  1842. void
  1843. CMainFrame::OnUpdateObjectRotateZ (CCmdUI* pCmdUI)
  1844. {
  1845. CGraphicView *pCGraphicView = (CGraphicView *)m_wndSplitter.GetPane (0, 1);
  1846. ASSERT (pCGraphicView);
  1847. if (pCGraphicView)
  1848. {
  1849. // Set the check if we are currently rotating around Z
  1850. pCmdUI->SetCheck ((pCGraphicView->GetObjectRotation () & (CGraphicView::RotateZ)));
  1851. }
  1852. return ;
  1853. }
  1854. ////////////////////////////////////////////////////////////////////////////
  1855. //
  1856. // Select_Device
  1857. //
  1858. ////////////////////////////////////////////////////////////////////////////
  1859. void
  1860. CMainFrame::Select_Device (bool show_dlg)
  1861. {
  1862. CGraphicView *pCGraphicView = (CGraphicView *)m_wndSplitter.GetPane (0, 1);
  1863. ASSERT (pCGraphicView);
  1864. if (pCGraphicView)
  1865. {
  1866. // Show a dialog to the user asking them which
  1867. // device they would like to use.
  1868. CDeviceSelectionDialog deviceSelDialog (show_dlg == false, this);
  1869. if (deviceSelDialog.DoModal () == IDOK)
  1870. {
  1871. // Record the user's selection from the dialog (as globals for now)
  1872. g_iDeviceIndex = deviceSelDialog.GetDeviceIndex ();
  1873. g_iBitsPerPixel = deviceSelDialog.GetBitsPerPixel ();
  1874. // Ask the view to initialize itself with the graphics engine
  1875. BOOL bReturn = pCGraphicView->InitializeGraphicView ();
  1876. ASSERT (bReturn);
  1877. if (bReturn) {
  1878. //
  1879. // Get information about the current device
  1880. //
  1881. const RenderDeviceDescClass &device_desc = WW3D::Get_Render_Device_Desc ();
  1882. CString driver_name = deviceSelDialog.GetDriverName ();
  1883. CString chipset = device_desc.Get_Hardware_Chipset ();
  1884. CString string_version = device_desc.Get_Driver_Version ();
  1885. chipset.MakeUpper ();
  1886. driver_name.MakeLower ();
  1887. //
  1888. // Check to ensure the drivers are valid if the user choose glide
  1889. //
  1890. if (::strstr (driver_name, "glide2") != NULL) {
  1891. // Is this glide driver an acceptable version?
  1892. float driver_version = ::atof (string_version);
  1893. bool is_voodoo2 = (::strstr (chipset , "VOODOO2") != NULL);
  1894. if ((is_voodoo2 && (driver_version < 2.54F)) ||
  1895. ((is_voodoo2 == false) && (driver_version < 2.46F))) {
  1896. // Let the user know we can't use these drivers
  1897. CString message;
  1898. message.LoadString (IDS_UNACCEPTABLE_GLIDE_MSG);
  1899. ::MessageBox (NULL, message, "Invalid Device", MB_OK | MB_ICONEXCLAMATION | MB_SETFOREGROUND);
  1900. // Force the user to choose a new device
  1901. Select_Device (true);
  1902. }
  1903. }
  1904. }
  1905. }
  1906. }
  1907. return ;
  1908. }
  1909. ////////////////////////////////////////////////////////////////////////////
  1910. //
  1911. // OnDeviceChange
  1912. //
  1913. ////////////////////////////////////////////////////////////////////////////
  1914. void
  1915. CMainFrame::OnDeviceChange (void)
  1916. {
  1917. #ifdef WW3D_DX8
  1918. Select_Device (true);
  1919. #else
  1920. ::MessageBox(m_hWnd,"Feature removed during conversion to DX8.","Unsupported Feature",MB_OK|MB_ICONEXCLAMATION);
  1921. #endif
  1922. return ;
  1923. }
  1924. ////////////////////////////////////////////////////////////////////////////
  1925. //
  1926. // OnViewFullscreen
  1927. //
  1928. ////////////////////////////////////////////////////////////////////////////
  1929. void
  1930. CMainFrame::OnViewFullscreen (void)
  1931. {
  1932. #ifdef WW3D_DX8
  1933. CGraphicView *pCGraphicView = (CGraphicView *)m_wndSplitter.GetPane (0, 1);
  1934. if (pCGraphicView->Is_Fullscreen ())
  1935. {
  1936. RestoreOriginalSize ();
  1937. }
  1938. pCGraphicView->Set_Fullscreen (!pCGraphicView->Is_Fullscreen ());
  1939. #else
  1940. ::MessageBox(m_hWnd,"Feature removed during conversion to DX8.","Unsupported Feature",MB_OK|MB_ICONEXCLAMATION);
  1941. #endif
  1942. return ;
  1943. }
  1944. ////////////////////////////////////////////////////////////////////////////
  1945. //
  1946. // OnUpdateViewFullscreen
  1947. //
  1948. ////////////////////////////////////////////////////////////////////////////
  1949. void
  1950. CMainFrame::OnUpdateViewFullscreen (CCmdUI* pCmdUI)
  1951. {
  1952. CGraphicView *pCGraphicView = (CGraphicView *)m_wndSplitter.GetPane (0, 1);
  1953. pCmdUI->SetCheck (pCGraphicView->Is_Fullscreen ());
  1954. return ;
  1955. }
  1956. ////////////////////////////////////////////////////////////////////////////
  1957. //
  1958. // OnWindowPosChanging
  1959. //
  1960. ////////////////////////////////////////////////////////////////////////////
  1961. void
  1962. CMainFrame::OnWindowPosChanging (WINDOWPOS FAR* lpwndpos)
  1963. {
  1964. CFrameWnd::OnWindowPosChanging (lpwndpos);
  1965. return ;
  1966. }
  1967. ////////////////////////////////////////////////////////////////////////////
  1968. //
  1969. // OnGetMinMaxInfo
  1970. //
  1971. ////////////////////////////////////////////////////////////////////////////
  1972. void
  1973. CMainFrame::OnGetMinMaxInfo (MINMAXINFO FAR* lpMMI)
  1974. {
  1975. CFrameWnd::OnGetMinMaxInfo(lpMMI);
  1976. return ;
  1977. }
  1978. ////////////////////////////////////////////////////////////////////////////
  1979. //
  1980. // OnCreateEmitter
  1981. //
  1982. ////////////////////////////////////////////////////////////////////////////
  1983. void
  1984. CMainFrame::OnCreateEmitter (void)
  1985. {
  1986. // Clear the current display
  1987. CW3DViewDoc *pdoc = (CW3DViewDoc *)GetActiveDocument ();
  1988. if (pdoc) {
  1989. pdoc->DisplayObject ((RenderObjClass *)NULL);
  1990. }
  1991. // Display the emitter property sheet
  1992. EmitterPropertySheetClass prop_sheet (NULL,
  1993. IDS_EMITTER_PROP_TITLE,
  1994. this);
  1995. prop_sheet.DoModal ();
  1996. return ;
  1997. }
  1998. ////////////////////////////////////////////////////////////////////////////
  1999. //
  2000. // OnEditEmitter
  2001. //
  2002. ////////////////////////////////////////////////////////////////////////////
  2003. void
  2004. CMainFrame::OnEditEmitter (void)
  2005. {
  2006. // Get a pointer to the doc object
  2007. CW3DViewDoc *pdoc = (CW3DViewDoc *)GetActiveDocument ();
  2008. if (pdoc != NULL) {
  2009. //
  2010. // Make a list of emitters containing the currently displayed emitter
  2011. //
  2012. ParticleEmitterClass *emitter = (ParticleEmitterClass *)pdoc->GetDisplayedObject ();
  2013. EmitterInstanceListClass *instance_list = new EmitterInstanceListClass;
  2014. instance_list->Add_Emitter (emitter);
  2015. //
  2016. // Show the emitter property sheet
  2017. //
  2018. EmitterPropertySheetClass prop_sheet (instance_list, IDS_EMITTER_PROP_TITLE, this);
  2019. prop_sheet.DoModal ();
  2020. }
  2021. return ;
  2022. }
  2023. ////////////////////////////////////////////////////////////////////////////
  2024. //
  2025. // OnUpdateEditEmitter
  2026. //
  2027. ////////////////////////////////////////////////////////////////////////////
  2028. void
  2029. CMainFrame::OnUpdateEditEmitter (CCmdUI *pCmdUI)
  2030. {
  2031. pCmdUI->Enable (m_currentAssetType == TypeEmitter);
  2032. return ;
  2033. }
  2034. ////////////////////////////////////////////////////////////////////////////
  2035. //
  2036. // OnScaleEmitter
  2037. //
  2038. ////////////////////////////////////////////////////////////////////////////
  2039. void
  2040. CMainFrame::OnScaleEmitter (void)
  2041. {
  2042. // Get a pointer to the doc object
  2043. CW3DViewDoc *pdoc = (CW3DViewDoc *)GetActiveDocument ();
  2044. if (pdoc != NULL) {
  2045. //
  2046. // Display a dialog that allows the user to choose the scaling factor
  2047. // to be applied to the current particle emitter.
  2048. //
  2049. ScaleDialogClass dlg(1.0, this, "Enter the scaling factor you want to apply to the current particle emitter");
  2050. if (dlg.DoModal() == IDCANCEL)
  2051. return ;
  2052. float scale = dlg.Get_Scale();
  2053. //
  2054. // Get and scale the current emitter.
  2055. //
  2056. ParticleEmitterClass *emitter = (ParticleEmitterClass *)pdoc->GetDisplayedObject();
  2057. emitter->Scale(scale);
  2058. //
  2059. // Ensure the prototype for this particle emitter is also updated,
  2060. // otherwise the change will be lost when the user switches away from
  2061. // the emitter (because the render object will be destroyed).
  2062. //
  2063. const char *name = emitter->Get_Name();
  2064. if (name && *name) {
  2065. WW3DAssetManager::Get_Instance()->Remove_Prototype (name);
  2066. }
  2067. ParticleEmitterDefClass *pdefinition = emitter->Build_Definition();
  2068. ParticleEmitterPrototypeClass *pprototype = new ParticleEmitterPrototypeClass (pdefinition);
  2069. WW3DAssetManager::Get_Instance()->Add_Prototype (pprototype);
  2070. }
  2071. }
  2072. ////////////////////////////////////////////////////////////////////////////
  2073. //
  2074. // OnUpdateScaleEmitter
  2075. //
  2076. ////////////////////////////////////////////////////////////////////////////
  2077. void
  2078. CMainFrame::OnUpdateScaleEmitter (CCmdUI* pCmdUI)
  2079. {
  2080. pCmdUI->Enable (m_currentAssetType == TypeEmitter);
  2081. return ;
  2082. }
  2083. ////////////////////////////////////////////////////////////////////////////
  2084. //
  2085. // OnSaveEmitter
  2086. //
  2087. ////////////////////////////////////////////////////////////////////////////
  2088. void
  2089. CMainFrame::OnSaveEmitter (void)
  2090. {
  2091. ((CW3DViewDoc *)GetActiveDocument ())->Save_Selected_Emitter ();
  2092. return ;
  2093. }
  2094. ////////////////////////////////////////////////////////////////////////////
  2095. //
  2096. // OnUpdateSaveEmitter
  2097. //
  2098. ////////////////////////////////////////////////////////////////////////////
  2099. void
  2100. CMainFrame::OnUpdateSaveEmitter (CCmdUI *pCmdUI)
  2101. {
  2102. pCmdUI->Enable (m_currentAssetType == TypeEmitter);
  2103. return ;
  2104. }
  2105. ////////////////////////////////////////////////////////////////////////////
  2106. //
  2107. // OnBoneAutoAssign
  2108. //
  2109. ////////////////////////////////////////////////////////////////////////////
  2110. void
  2111. CMainFrame::OnBoneAutoAssign (void)
  2112. {
  2113. ((CW3DViewDoc *)GetActiveDocument ())->Auto_Assign_Bones ();
  2114. return ;
  2115. }
  2116. ////////////////////////////////////////////////////////////////////////////
  2117. //
  2118. // OnBoneManagement
  2119. //
  2120. ////////////////////////////////////////////////////////////////////////////
  2121. void
  2122. CMainFrame::OnBoneManagement (void)
  2123. {
  2124. // Get the currently selected hierarchy model
  2125. RenderObjClass *prender_obj = ((CW3DViewDoc *)GetActiveDocument ())->GetDisplayedObject ();
  2126. // Show the bone manager dialog
  2127. BoneMgrDialogClass dialog (prender_obj, this);
  2128. dialog.DoModal ();
  2129. Update_Emitters_List ();
  2130. return ;
  2131. }
  2132. ////////////////////////////////////////////////////////////////////////////
  2133. //
  2134. // OnSaveAggregate
  2135. //
  2136. ////////////////////////////////////////////////////////////////////////////
  2137. void
  2138. CMainFrame::OnSaveAggregate (void)
  2139. {
  2140. ((CW3DViewDoc *)GetActiveDocument ())->Save_Selected_Aggregate ();
  2141. return ;
  2142. }
  2143. ////////////////////////////////////////////////////////////////////////////
  2144. //
  2145. // OnCameraAnimate
  2146. //
  2147. ////////////////////////////////////////////////////////////////////////////
  2148. void
  2149. CMainFrame::OnCameraAnimate (void)
  2150. {
  2151. // Toggel the animated state
  2152. bool banimated = ((CW3DViewDoc *)GetActiveDocument ())->Is_Camera_Animated ();
  2153. ((CW3DViewDoc *)GetActiveDocument ())->Animate_Camera (banimated == false);
  2154. return ;
  2155. }
  2156. ////////////////////////////////////////////////////////////////////////////
  2157. //
  2158. // OnSaveAggregate
  2159. //
  2160. ////////////////////////////////////////////////////////////////////////////
  2161. void
  2162. CMainFrame::OnUpdateCameraAnimate (CCmdUI *pCmdUI)
  2163. {
  2164. pCmdUI->SetCheck (((CW3DViewDoc *)GetActiveDocument ())->Is_Camera_Animated ());
  2165. return ;
  2166. }
  2167. ////////////////////////////////////////////////////////////////////////////
  2168. //
  2169. // OnUpdateLodSave
  2170. //
  2171. ////////////////////////////////////////////////////////////////////////////
  2172. void
  2173. CMainFrame::OnUpdateLodSave (CCmdUI *pCmdUI)
  2174. {
  2175. pCmdUI->Enable (m_currentAssetType == TypeLOD);
  2176. return ;
  2177. }
  2178. ////////////////////////////////////////////////////////////////////////////
  2179. //
  2180. // OnUpdateSaveAggregate
  2181. //
  2182. ////////////////////////////////////////////////////////////////////////////
  2183. void
  2184. CMainFrame::OnUpdateSaveAggregate (CCmdUI *pCmdUI)
  2185. {
  2186. pCmdUI->Enable (m_currentAssetType == TypeAggregate);
  2187. return ;
  2188. }
  2189. ////////////////////////////////////////////////////////////////////////////
  2190. //
  2191. // OnCameraResetOnLoad
  2192. //
  2193. ////////////////////////////////////////////////////////////////////////////
  2194. void
  2195. CMainFrame::OnCameraResetOnLoad (void)
  2196. {
  2197. // Toggle the auto reset state of the menu option
  2198. CW3DViewDoc *pdoc = (CW3DViewDoc *)GetActiveDocument ();
  2199. pdoc->Turn_Camera_Auto_Reset_On ((pdoc->Is_Camera_Auto_Reset_On () == false));
  2200. return ;
  2201. }
  2202. ////////////////////////////////////////////////////////////////////////////
  2203. //
  2204. // OnUpdateCameraResetOnLoad
  2205. //
  2206. ////////////////////////////////////////////////////////////////////////////
  2207. void
  2208. CMainFrame::OnUpdateCameraResetOnLoad (CCmdUI *pCmdUI)
  2209. {
  2210. CW3DViewDoc *pdoc = (CW3DViewDoc *)GetActiveDocument ();
  2211. pCmdUI->SetCheck (pdoc->Is_Camera_Auto_Reset_On ());
  2212. return ;
  2213. }
  2214. ////////////////////////////////////////////////////////////////////////////
  2215. //
  2216. // OnObjectRotateYBack
  2217. //
  2218. ////////////////////////////////////////////////////////////////////////////
  2219. void
  2220. CMainFrame::OnObjectRotateYBack (void)
  2221. {
  2222. CGraphicView *pgraphic_view = (CGraphicView *)m_wndSplitter.GetPane (0, 1);
  2223. ASSERT (pgraphic_view != NULL);
  2224. if (pgraphic_view != NULL) {
  2225. // Start or stop the rotation around Y
  2226. int rotation = (pgraphic_view->GetObjectRotation () ^ (CGraphicView::RotateYBack));
  2227. rotation &= ~CGraphicView::RotateY;
  2228. pgraphic_view->RotateObject ((CGraphicView::OBJECT_ROTATION)rotation);
  2229. }
  2230. return;
  2231. }
  2232. ////////////////////////////////////////////////////////////////////////////
  2233. //
  2234. // OnObjectRotateZBack
  2235. //
  2236. ////////////////////////////////////////////////////////////////////////////
  2237. void
  2238. CMainFrame::OnObjectRotateZBack (void)
  2239. {
  2240. CGraphicView *pgraphic_view = (CGraphicView *)m_wndSplitter.GetPane (0, 1);
  2241. ASSERT (pgraphic_view != NULL);
  2242. if (pgraphic_view != NULL) {
  2243. // Start or stop the rotation around Z
  2244. int rotation = (pgraphic_view->GetObjectRotation () ^ (CGraphicView::RotateZBack));
  2245. rotation &= ~CGraphicView::RotateZ;
  2246. pgraphic_view->RotateObject ((CGraphicView::OBJECT_ROTATION)rotation);
  2247. }
  2248. return;
  2249. }
  2250. ////////////////////////////////////////////////////////////////////////////
  2251. //
  2252. // OnObjectRotateZBack
  2253. //
  2254. ////////////////////////////////////////////////////////////////////////////
  2255. void
  2256. CMainFrame::OnLightRotateY (void)
  2257. {
  2258. CGraphicView *pgraphic_view = (CGraphicView *)m_wndSplitter.GetPane (0, 1);
  2259. ASSERT (pgraphic_view != NULL);
  2260. if (pgraphic_view != NULL) {
  2261. // Start or stop the rotation around Y
  2262. int rotation = (pgraphic_view->Get_Light_Rotation () ^ (CGraphicView::RotateY));
  2263. rotation &= ~CGraphicView::RotateYBack;
  2264. pgraphic_view->Rotate_Light ((CGraphicView::OBJECT_ROTATION)rotation);
  2265. }
  2266. return ;
  2267. }
  2268. ////////////////////////////////////////////////////////////////////////////
  2269. //
  2270. // OnLightRotateYBack
  2271. //
  2272. ////////////////////////////////////////////////////////////////////////////
  2273. void
  2274. CMainFrame::OnLightRotateYBack (void)
  2275. {
  2276. CGraphicView *pgraphic_view = (CGraphicView *)m_wndSplitter.GetPane (0, 1);
  2277. ASSERT (pgraphic_view != NULL);
  2278. if (pgraphic_view != NULL) {
  2279. // Start or stop the rotation around Y
  2280. int rotation = (pgraphic_view->Get_Light_Rotation () ^ (CGraphicView::RotateYBack));
  2281. rotation &= ~CGraphicView::RotateY;
  2282. pgraphic_view->Rotate_Light ((CGraphicView::OBJECT_ROTATION)rotation);
  2283. }
  2284. return ;
  2285. }
  2286. ////////////////////////////////////////////////////////////////////////////
  2287. //
  2288. // OnLightRotateZ
  2289. //
  2290. ////////////////////////////////////////////////////////////////////////////
  2291. void
  2292. CMainFrame::OnLightRotateZ (void)
  2293. {
  2294. CGraphicView *pgraphic_view = (CGraphicView *)m_wndSplitter.GetPane (0, 1);
  2295. ASSERT (pgraphic_view != NULL);
  2296. if (pgraphic_view != NULL) {
  2297. // Start or stop the rotation around Z
  2298. int rotation = (pgraphic_view->Get_Light_Rotation () ^ (CGraphicView::RotateZ));
  2299. rotation &= ~CGraphicView::RotateZBack;
  2300. pgraphic_view->Rotate_Light ((CGraphicView::OBJECT_ROTATION)rotation);
  2301. }
  2302. return ;
  2303. }
  2304. ////////////////////////////////////////////////////////////////////////////
  2305. //
  2306. // OnLightRotateZBack
  2307. //
  2308. ////////////////////////////////////////////////////////////////////////////
  2309. void
  2310. CMainFrame::OnLightRotateZBack (void)
  2311. {
  2312. CGraphicView *pgraphic_view = (CGraphicView *)m_wndSplitter.GetPane (0, 1);
  2313. ASSERT (pgraphic_view != NULL);
  2314. if (pgraphic_view != NULL) {
  2315. // Start or stop the rotation around Y
  2316. int rotation = (pgraphic_view->Get_Light_Rotation () ^ (CGraphicView::RotateZBack));
  2317. rotation &= ~CGraphicView::RotateZ;
  2318. pgraphic_view->Rotate_Light ((CGraphicView::OBJECT_ROTATION)rotation);
  2319. }
  2320. return ;
  2321. }
  2322. ////////////////////////////////////////////////////////////////////////////
  2323. //
  2324. // OnDestroy
  2325. //
  2326. ////////////////////////////////////////////////////////////////////////////
  2327. void
  2328. CMainFrame::OnDestroy (void)
  2329. {
  2330. CRect rect;
  2331. WINDOWPLACEMENT wnd_info = { sizeof (WINDOWPLACEMENT), 0 };
  2332. ::GetWindowPlacement (m_hWnd, &wnd_info);
  2333. ::GetWindowRect (m_hWnd, &rect);
  2334. //
  2335. // Cache this information in the registry
  2336. //
  2337. theApp.WriteProfileInt ("Window", "Left", rect.left);
  2338. theApp.WriteProfileInt ("Window", "Right", rect.right);
  2339. theApp.WriteProfileInt ("Window", "Top", rect.top);
  2340. theApp.WriteProfileInt ("Window", "Bottom", rect.bottom);
  2341. theApp.WriteProfileInt ("Window", "Maximized", int(wnd_info.showCmd == SW_SHOWMAXIMIZED));
  2342. // Cache this information in the registry
  2343. theApp.WriteProfileInt ("Config",
  2344. "AnimateCamera",
  2345. (int)((CW3DViewDoc *)GetActiveDocument ())->Is_Camera_Animated ());
  2346. // Cache this information in the registry
  2347. theApp.WriteProfileInt ("Config",
  2348. "ResetCamera",
  2349. (int)((CW3DViewDoc *)GetActiveDocument ())->Is_Camera_Auto_Reset_On ());
  2350. CFrameWnd::OnDestroy ();
  2351. return ;
  2352. }
  2353. ////////////////////////////////////////////////////////////////////////////
  2354. //
  2355. // OnDecLight
  2356. //
  2357. ////////////////////////////////////////////////////////////////////////////
  2358. void
  2359. CMainFrame::OnDecLight (void)
  2360. {
  2361. CW3DViewDoc *pdoc = ::GetCurrentDocument ();
  2362. LightClass *plight = pdoc->GetSceneLight ();
  2363. if (plight != NULL) {
  2364. // Get the current light settings
  2365. Vector3 diffuse;
  2366. Vector3 specular;
  2367. plight->Get_Diffuse (&diffuse);
  2368. plight->Get_Specular (&specular);
  2369. // Decrement the intensity and pass it back to the light
  2370. Adjust_Light_Intensity (diffuse, -0.05F);
  2371. Adjust_Light_Intensity (specular, -0.05F);
  2372. plight->Set_Diffuse (diffuse);
  2373. plight->Set_Specular (specular);
  2374. }
  2375. return ;
  2376. }
  2377. ////////////////////////////////////////////////////////////////////////////
  2378. //
  2379. // OnIncLight
  2380. //
  2381. ////////////////////////////////////////////////////////////////////////////
  2382. void
  2383. CMainFrame::OnIncLight (void)
  2384. {
  2385. CW3DViewDoc *pdoc = ::GetCurrentDocument ();
  2386. LightClass *plight = pdoc->GetSceneLight ();
  2387. if (plight != NULL) {
  2388. // Get the current light settings
  2389. Vector3 diffuse;
  2390. Vector3 specular;
  2391. plight->Get_Diffuse (&diffuse);
  2392. plight->Get_Specular (&specular);
  2393. // Increment the intensity and pass it back to the light
  2394. Adjust_Light_Intensity (diffuse, 0.05F);
  2395. Adjust_Light_Intensity (specular, 0.05F);
  2396. plight->Set_Diffuse (diffuse);
  2397. plight->Set_Specular (specular);
  2398. }
  2399. return ;
  2400. }
  2401. ////////////////////////////////////////////////////////////////////////////
  2402. //
  2403. // OnDecAmbientLight
  2404. //
  2405. ////////////////////////////////////////////////////////////////////////////
  2406. void
  2407. CMainFrame::OnDecAmbientLight (void)
  2408. {
  2409. CW3DViewDoc *pdoc = ::GetCurrentDocument ();
  2410. if (pdoc->GetScene () != NULL) {
  2411. // Get the current ambient light settings
  2412. Vector3 color = pdoc->GetScene ()->Get_Ambient_Light ();
  2413. // Decrement the intensity and pass it back to the light
  2414. Adjust_Light_Intensity (color, -0.05F);
  2415. pdoc->GetScene ()->Set_Ambient_Light (color);
  2416. }
  2417. return ;
  2418. }
  2419. ////////////////////////////////////////////////////////////////////////////
  2420. //
  2421. // OnIncAmbientLight
  2422. //
  2423. ////////////////////////////////////////////////////////////////////////////
  2424. void
  2425. CMainFrame::OnIncAmbientLight (void)
  2426. {
  2427. CW3DViewDoc *pdoc = ::GetCurrentDocument ();
  2428. if (pdoc->GetScene () != NULL) {
  2429. // Get the current ambient light settings
  2430. Vector3 color = pdoc->GetScene ()->Get_Ambient_Light ();
  2431. // Increment the intensity and pass it back to the light
  2432. Adjust_Light_Intensity (color, 0.05F);
  2433. pdoc->GetScene ()->Set_Ambient_Light (color);
  2434. }
  2435. return ;
  2436. }
  2437. void CMainFrame::OnLightingExpose()
  2438. {
  2439. // Toggle.
  2440. WW3D::Expose_Prelit (!WW3D::Expose_Prelit());
  2441. }
  2442. void CMainFrame::OnUpdateLightingExpose (CCmdUI *pcmdui)
  2443. {
  2444. pcmdui->SetCheck (WW3D::Expose_Prelit());
  2445. }
  2446. ////////////////////////////////////////////////////////////////////////////
  2447. //
  2448. // OnMakeAggregate
  2449. //
  2450. ////////////////////////////////////////////////////////////////////////////
  2451. void
  2452. CMainFrame::OnMakeAggregate (void)
  2453. {
  2454. // Show the name dialog to the user
  2455. AggregateNameDialogClass dialog (this);
  2456. if (dialog.DoModal () == IDOK) {
  2457. CDataTreeView *pdata_tree = (CDataTreeView *)m_wndSplitter.GetPane (0, 0);
  2458. RenderObjClass *prender_obj = ::GetCurrentDocument ()->GetDisplayedObject ();
  2459. if (prender_obj != NULL) {
  2460. // Build a definition object from the hierarchy
  2461. AggregateDefClass *pdefinition = new AggregateDefClass (*prender_obj);
  2462. AggregatePrototypeClass *pprototype = new AggregatePrototypeClass (pdefinition);
  2463. pdefinition->Set_Name (dialog.Get_Name ());
  2464. // Add this prototype to the asset manager
  2465. WW3DAssetManager::Get_Instance ()->Remove_Prototype (dialog.Get_Name ());
  2466. WW3DAssetManager::Get_Instance ()->Add_Prototype (pprototype);
  2467. // Add an entry for this aggregate in the tree control
  2468. pdata_tree->Add_Asset_To_Tree (dialog.Get_Name (), TypeAggregate, true);
  2469. }
  2470. }
  2471. return ;
  2472. }
  2473. ////////////////////////////////////////////////////////////////////////////
  2474. //
  2475. // OnRenameAggregate
  2476. //
  2477. ////////////////////////////////////////////////////////////////////////////
  2478. void
  2479. CMainFrame::OnRenameAggregate (void)
  2480. {
  2481. // Get a pointer to the current aggregate
  2482. RenderObjClass *prender_obj = (::GetCurrentDocument ())->GetDisplayedObject ();
  2483. if (prender_obj != NULL) {
  2484. // Show the rename dialog to the user
  2485. const char *old_name = prender_obj->Get_Name ();
  2486. AggregateNameDialogClass dialog (IDD_RENAME_AGGREGATE, prender_obj->Get_Name (), this);
  2487. if (dialog.DoModal () == IDOK) {
  2488. // Rename the prototype
  2489. ::Rename_Aggregate_Prototype (old_name, dialog.Get_Name ());
  2490. // Refresh the UI
  2491. CDataTreeView *pdata_tree = (CDataTreeView *)m_wndSplitter.GetPane (0, 0);
  2492. pdata_tree->Refresh_Asset (dialog.Get_Name (), old_name, TypeAggregate);
  2493. // Now let the actual displayed render object know its new name...
  2494. prender_obj->Set_Name (dialog.Get_Name ());
  2495. }
  2496. }
  2497. return ;
  2498. }
  2499. ////////////////////////////////////////////////////////////////////////////
  2500. //
  2501. // OnCommand
  2502. //
  2503. ////////////////////////////////////////////////////////////////////////////
  2504. BOOL
  2505. CMainFrame::OnCommand
  2506. (
  2507. WPARAM wParam,
  2508. LPARAM lParam
  2509. )
  2510. {
  2511. if ((lParam == 0) &&
  2512. (LOWORD (wParam) >= 1000) &&
  2513. (LOWORD (wParam) < 1100)) {
  2514. MENUITEMINFO info = { sizeof (MENUITEMINFO), MIIM_DATA | MIIM_TYPE, 0 };
  2515. TCHAR emitter_name[200];
  2516. info.dwTypeData = emitter_name;
  2517. info.cch = sizeof (emitter_name);
  2518. if (::GetMenuItemInfo (m_hEmittersSubMenu, LOWORD (wParam), FALSE, &info)) {
  2519. //
  2520. // Make a list of emitters with the given name
  2521. //
  2522. EmitterInstanceListClass *instance_list = new EmitterInstanceListClass;
  2523. ::GetCurrentDocument ()->Build_Emitter_List (instance_list, emitter_name);
  2524. //
  2525. // Show the emitter property sheet
  2526. //
  2527. EmitterPropertySheetClass prop_sheet (instance_list, IDS_EMITTER_PROP_TITLE, this);
  2528. prop_sheet.DoModal ();
  2529. }
  2530. }
  2531. // Allow the base class to process this message
  2532. return CFrameWnd::OnCommand (wParam, lParam);
  2533. }
  2534. ////////////////////////////////////////////////////////////////////////////
  2535. //
  2536. // OnCmdMsg
  2537. //
  2538. ////////////////////////////////////////////////////////////////////////////
  2539. BOOL
  2540. CMainFrame::OnCmdMsg
  2541. (
  2542. UINT nID,
  2543. int nCode,
  2544. void *pExtra,
  2545. AFX_CMDHANDLERINFO* pHandlerInfo
  2546. )
  2547. {
  2548. // Hack to get MFC to enable the 'Editable Emitters List' submenu...
  2549. if (nCode == CN_UPDATE_COMMAND_UI) {
  2550. CCmdUI *pCmdUI = (CCmdUI *)pExtra;
  2551. if (pCmdUI != NULL && (pCmdUI->m_nID >= 1000) && (pCmdUI->m_nID < 1100)) {
  2552. pCmdUI->Enable (TRUE);
  2553. return TRUE;
  2554. }
  2555. }
  2556. // Allow the base class to process this message
  2557. return CFrameWnd::OnCmdMsg (nID, nCode, pExtra, pHandlerInfo);
  2558. }
  2559. ////////////////////////////////////////////////////////////////////////////
  2560. //
  2561. // OnCrashApp
  2562. //
  2563. ////////////////////////////////////////////////////////////////////////////
  2564. void
  2565. CMainFrame::OnCrashApp (void)
  2566. {
  2567. // Usefull HACK to get the program to crash when needed...
  2568. LPTSTR hack = 0;
  2569. (*hack) = 0;
  2570. return ;
  2571. }
  2572. ////////////////////////////////////////////////////////////////////////////
  2573. //
  2574. // OnLODRecordScreenArea
  2575. //
  2576. ////////////////////////////////////////////////////////////////////////////
  2577. void
  2578. CMainFrame::OnLODRecordScreenArea (void)
  2579. {
  2580. // Make sure the current object is an LOD
  2581. RenderObjClass *prender_obj = ::GetCurrentDocument ()->GetDisplayedObject ();
  2582. if ((prender_obj != NULL) &&
  2583. (prender_obj->Class_ID () == RenderObjClass::CLASSID_HLOD)) {
  2584. CGraphicView *graphic_view = (CGraphicView *)m_wndSplitter.GetPane (0, 1);
  2585. //
  2586. // TODO - Calculate the real screen size of the LOD and pass it onto
  2587. // the object.
  2588. //
  2589. CameraClass *pcamera = graphic_view->GetCamera ();
  2590. float screen_size = prender_obj->Get_Screen_Size (*pcamera);
  2591. // Let the LOD know what its new clamp is.
  2592. int index = ((HLodClass *)prender_obj)->Get_LOD_Level ();
  2593. ((HLodClass *)prender_obj)->Set_Max_Screen_Size (index, screen_size);
  2594. // Update the prototype for this lod to reflect the changes
  2595. ::GetCurrentDocument ()->Update_LOD_Prototype (*((HLodClass *)prender_obj));
  2596. }
  2597. return ;
  2598. }
  2599. ////////////////////////////////////////////////////////////////////////////
  2600. //
  2601. // OnLODIncludeNull
  2602. //
  2603. ////////////////////////////////////////////////////////////////////////////
  2604. void
  2605. CMainFrame::OnLODIncludeNull (void)
  2606. {
  2607. // Make sure the current object is an LOD
  2608. RenderObjClass *prender_obj = ::GetCurrentDocument ()->GetDisplayedObject ();
  2609. if ((prender_obj != NULL) &&
  2610. (prender_obj->Class_ID () == RenderObjClass::CLASSID_HLOD)) {
  2611. // Toggle the NULL lod
  2612. bool include = ((HLodClass *)prender_obj)->Is_NULL_Lod_Included ();
  2613. ((HLodClass *)prender_obj)->Include_NULL_Lod (!include);
  2614. // Update the prototype for this lod to reflect the changes
  2615. ::GetCurrentDocument ()->Update_LOD_Prototype (*((HLodClass *)prender_obj));
  2616. }
  2617. return ;
  2618. }
  2619. ////////////////////////////////////////////////////////////////////////////
  2620. //
  2621. // OnUpdateLODIncludeNull
  2622. //
  2623. ////////////////////////////////////////////////////////////////////////////
  2624. void
  2625. CMainFrame::OnUpdateLODIncludeNull (CCmdUI *pCmdUI)
  2626. {
  2627. // Make sure the current object is an LOD
  2628. RenderObjClass *prender_obj = (::GetCurrentDocument ())->GetDisplayedObject ();
  2629. if ((prender_obj != NULL) &&
  2630. (prender_obj->Class_ID () == RenderObjClass::CLASSID_HLOD)) {
  2631. // Check or uncheck the menu option depending on the state of the LOD
  2632. bool check = ((HLodClass *)prender_obj)->Is_NULL_Lod_Included ();
  2633. pCmdUI->SetCheck (check);
  2634. }
  2635. return ;
  2636. }
  2637. ////////////////////////////////////////////////////////////////////////////
  2638. //
  2639. // OnLodPrevLevel
  2640. //
  2641. ////////////////////////////////////////////////////////////////////////////
  2642. void
  2643. CMainFrame::OnLodPrevLevel (void)
  2644. {
  2645. ::GetCurrentDocument ()->Switch_LOD (-1);
  2646. return ;
  2647. }
  2648. ////////////////////////////////////////////////////////////////////////////
  2649. //
  2650. // OnUpdateLodPrevLevel
  2651. //
  2652. ////////////////////////////////////////////////////////////////////////////
  2653. void
  2654. CMainFrame::OnUpdateLodPrevLevel (CCmdUI *pCmdUI)
  2655. {
  2656. // Make sure the current object is an LOD
  2657. RenderObjClass *prender_obj = (::GetCurrentDocument ())->GetDisplayedObject ();
  2658. if ((prender_obj != NULL) &&
  2659. (prender_obj->Class_ID () == RenderObjClass::CLASSID_HLOD)) {
  2660. // Enable the menu option if there is a previous lod to display
  2661. int current_lod = ((HLodClass *)prender_obj)->Get_LOD_Level ();
  2662. pCmdUI->Enable (current_lod > 0);
  2663. }
  2664. return ;
  2665. }
  2666. ////////////////////////////////////////////////////////////////////////////
  2667. //
  2668. // OnLodNextLevel
  2669. //
  2670. ////////////////////////////////////////////////////////////////////////////
  2671. void
  2672. CMainFrame::OnLodNextLevel (void)
  2673. {
  2674. ::GetCurrentDocument ()->Switch_LOD (1);
  2675. return ;
  2676. }
  2677. ////////////////////////////////////////////////////////////////////////////
  2678. //
  2679. // OnUpdateLodNextLevel
  2680. //
  2681. ////////////////////////////////////////////////////////////////////////////
  2682. void
  2683. CMainFrame::OnUpdateLodNextLevel (CCmdUI *pCmdUI)
  2684. {
  2685. // Make sure the current object is an LOD
  2686. RenderObjClass *prender_obj = (::GetCurrentDocument ())->GetDisplayedObject ();
  2687. if ((prender_obj != NULL) &&
  2688. (prender_obj->Class_ID () == RenderObjClass::CLASSID_HLOD)) {
  2689. // Enable the menu option if there is another lod to display
  2690. int current_lod = ((HLodClass *)prender_obj)->Get_LOD_Level ();
  2691. int lod_count = ((HLodClass *)prender_obj)->Get_LOD_Count ();
  2692. pCmdUI->Enable ((current_lod + 1) < lod_count);
  2693. }
  2694. return ;
  2695. }
  2696. ////////////////////////////////////////////////////////////////////////////
  2697. //
  2698. // OnLodAutoswitch
  2699. //
  2700. ////////////////////////////////////////////////////////////////////////////
  2701. void
  2702. CMainFrame::OnLodAutoswitch (void)
  2703. {
  2704. // Toggle the autoswitch setting
  2705. ViewerSceneClass *pscene = ::GetCurrentDocument ()->GetScene ();
  2706. pscene->Allow_LOD_Switching (!pscene->Are_LODs_Switching ());
  2707. return ;
  2708. }
  2709. ////////////////////////////////////////////////////////////////////////////
  2710. //
  2711. // OnUpdateLodAutoswitch
  2712. //
  2713. ////////////////////////////////////////////////////////////////////////////
  2714. void
  2715. CMainFrame::OnUpdateLodAutoswitch (CCmdUI *pCmdUI)
  2716. {
  2717. ViewerSceneClass *pscene = ::GetCurrentDocument ()->GetScene ();
  2718. pCmdUI->SetCheck (pscene->Are_LODs_Switching ());
  2719. return ;
  2720. }
  2721. ////////////////////////////////////////////////////////////////////////////
  2722. //
  2723. // OnUpdateMakeMovie
  2724. //
  2725. ////////////////////////////////////////////////////////////////////////////
  2726. void
  2727. CMainFrame::OnUpdateMakeMovie (CCmdUI *pCmdUI)
  2728. {
  2729. // Enable the 'movie' option if this is an animation
  2730. CDataTreeView *pCDataTreeView = (CDataTreeView *)m_wndSplitter.GetPane (0, 0);
  2731. int atype = pCDataTreeView->GetCurrentSelectionType();
  2732. bool enabled = ((atype == TypeAnimation) || (atype == TypeCompressedAnimation));
  2733. pCmdUI->Enable ( enabled );
  2734. return ;
  2735. }
  2736. ////////////////////////////////////////////////////////////////////////////
  2737. //
  2738. // OnMakeMovie
  2739. //
  2740. ////////////////////////////////////////////////////////////////////////////
  2741. void
  2742. CMainFrame::OnMakeMovie (void)
  2743. {
  2744. // Force a resolution change
  2745. //WW3D::Set_Resolution (800, 600, g_iBitsPerPixel, 0);
  2746. ::GetCurrentDocument ()->Make_Movie ();
  2747. return ;
  2748. }
  2749. ////////////////////////////////////////////////////////////////////////////
  2750. //
  2751. // OnSaveScreenshot
  2752. //
  2753. ////////////////////////////////////////////////////////////////////////////
  2754. void
  2755. CMainFrame::OnSaveScreenshot (void)
  2756. {
  2757. // Get the directory where this executable was run from
  2758. TCHAR filename[MAX_PATH];
  2759. ::GetModuleFileName (NULL, filename, sizeof (filename));
  2760. //
  2761. // Strip the filename from the path
  2762. //
  2763. LPTSTR ppath = ::strrchr (filename, '\\');
  2764. if (ppath != NULL) {
  2765. ppath[0] = 0;
  2766. }
  2767. //
  2768. // Tag the default filename base onto the end of the path
  2769. //
  2770. Delimit_Path (filename);
  2771. StringClass full_path = filename;
  2772. full_path += "ScreenShot";
  2773. //
  2774. // Take the actual screen shot
  2775. //
  2776. bool cursor_shown = GetCurrentDocument ()->Is_Cursor_Shown ();
  2777. GetCurrentDocument ()->Show_Cursor (false);
  2778. Get_Graphic_View ()->RepaintView ();
  2779. WW3D::Make_Screen_Shot (full_path);
  2780. GetCurrentDocument ()->Show_Cursor (cursor_shown);
  2781. return ;
  2782. }
  2783. ////////////////////////////////////////////////////////////////////////////
  2784. //
  2785. // Update_Emitters_List
  2786. //
  2787. ////////////////////////////////////////////////////////////////////////////
  2788. void
  2789. CMainFrame::Update_Emitters_List (void)
  2790. {
  2791. ::EnableMenuItem (::GetSubMenu (::GetMenu (m_hWnd), 3), 3, MF_BYPOSITION | MF_ENABLED);
  2792. HMENU hsub_menu = Get_Emitters_List_Menu ();
  2793. int index = 0;
  2794. while (::RemoveMenu (hsub_menu, 0, MF_BYPOSITION)) {
  2795. //index ++;
  2796. }
  2797. RenderObjClass *prender_obj = GetCurrentDocument ()->GetDisplayedObject ();
  2798. if (prender_obj != NULL) {
  2799. DynamicVectorClass<CString> list;
  2800. Build_Emitter_List (*prender_obj, list);
  2801. for (int index = 0; index < list.Count (); index ++) {
  2802. MENUITEMINFO info = { sizeof (MENUITEMINFO), 0 };
  2803. info.fMask = MIIM_TYPE | MIIM_DATA | MIIM_ID;
  2804. info.fType = MFT_STRING;
  2805. info.dwTypeData = (char *)(LPCTSTR)list[index];
  2806. info.wID = 1000 + index;
  2807. ::InsertMenuItem (hsub_menu, index, TRUE, &info);
  2808. }
  2809. }
  2810. return ;
  2811. }
  2812. ////////////////////////////////////////////////////////////////////////////
  2813. //
  2814. // OnSlideshowDown
  2815. //
  2816. ////////////////////////////////////////////////////////////////////////////
  2817. void
  2818. CMainFrame::OnSlideshowDown (void)
  2819. {
  2820. CDataTreeView *data_tree = (CDataTreeView *)m_wndSplitter.GetPane (0, 0);
  2821. if (data_tree != NULL) {
  2822. data_tree->Select_Next ();
  2823. }
  2824. return ;
  2825. }
  2826. ////////////////////////////////////////////////////////////////////////////
  2827. //
  2828. // OnSlideshowUp
  2829. //
  2830. ////////////////////////////////////////////////////////////////////////////
  2831. void
  2832. CMainFrame::OnSlideshowUp (void)
  2833. {
  2834. CDataTreeView *data_tree = (CDataTreeView *)m_wndSplitter.GetPane (0, 0);
  2835. if (data_tree != NULL) {
  2836. data_tree->Select_Prev ();
  2837. }
  2838. return ;
  2839. }
  2840. ////////////////////////////////////////////////////////////////////////////
  2841. //
  2842. // OnAdvancedAnim
  2843. //
  2844. ////////////////////////////////////////////////////////////////////////////
  2845. void
  2846. CMainFrame::OnAdvancedAnim()
  2847. {
  2848. // Display the advanced animation control dialog and render the object
  2849. // with the mix of animations the user specified.
  2850. CAdvancedAnimSheet dlg;
  2851. dlg.DoModal();
  2852. }
  2853. ////////////////////////////////////////////////////////////////////////////
  2854. //
  2855. // OnUpdateAdvancedAnim
  2856. //
  2857. ////////////////////////////////////////////////////////////////////////////
  2858. void
  2859. CMainFrame::OnUpdateAdvancedAnim(CCmdUI* pCmdUI)
  2860. {
  2861. // Enable the menu item if the selected hierarchy has at least one
  2862. // animation we can apply.
  2863. RenderObjClass *prender_obj = ::GetCurrentDocument()->GetDisplayedObject();
  2864. }
  2865. ////////////////////////////////////////////////////////////////////////////
  2866. //
  2867. // OnCameraSettings
  2868. //
  2869. ////////////////////////////////////////////////////////////////////////////
  2870. void
  2871. CMainFrame::OnCameraSettings (void)
  2872. {
  2873. CameraSettingsDialogClass dialog (this);
  2874. dialog.DoModal ();
  2875. return ;
  2876. }
  2877. ////////////////////////////////////////////////////////////////////////////
  2878. //
  2879. // OnCopyScreenSize
  2880. //
  2881. ////////////////////////////////////////////////////////////////////////////
  2882. void
  2883. CMainFrame::OnCopyScreenSize (void)
  2884. {
  2885. //
  2886. // Determine the current screen size of the displayed object
  2887. //
  2888. CGraphicView *graphic_view = (CGraphicView *)m_wndSplitter.GetPane (0, 1);
  2889. CameraClass *camera = graphic_view->GetCamera ();
  2890. RenderObjClass *render_obj = ::GetCurrentDocument ()->GetDisplayedObject ();
  2891. float screen_size = render_obj->Get_Screen_Size (*camera);
  2892. //
  2893. // Convert the float to a string
  2894. //
  2895. CString size_string;
  2896. size_string.Format ("MaxScreenSize=%f", screen_size);
  2897. int len = size_string.GetLength () + 1;
  2898. //
  2899. // Allocate a chunk of clipboard-safe memory, and
  2900. // copy the string to it.
  2901. //
  2902. HGLOBAL global_mem = ::GlobalAlloc (GHND, len);
  2903. LPTSTR global_ptr = (LPTSTR)::GlobalLock (global_mem);
  2904. ::memcpy (global_ptr, size_string, len);
  2905. ::GlobalUnlock (global_mem);
  2906. //
  2907. // Copy the string to the clipboard
  2908. //
  2909. OpenClipboard ();
  2910. ::EmptyClipboard ();
  2911. ::SetClipboardData (CF_TEXT, global_mem);
  2912. CloseClipboard ();
  2913. return ;
  2914. }
  2915. ////////////////////////////////////////////////////////////////////////////
  2916. //
  2917. // OnListMissingTextures
  2918. //
  2919. ////////////////////////////////////////////////////////////////////////////
  2920. void
  2921. CMainFrame::OnListMissingTextures (void)
  2922. {
  2923. //
  2924. // Get the list of missing textures and preset it to the user
  2925. //
  2926. DynamicVectorClass<CString> texture_list = _TheAssetMgr->Get_Missing_Texture_List ();
  2927. if (texture_list.Count () > 0) {
  2928. CString message ("Warning! The following textures are missing:\r\n\r\n");
  2929. for (int index = 0; index < texture_list.Count (); index ++) {
  2930. message += texture_list[index];
  2931. message += "\r\n";
  2932. }
  2933. ::MessageBox (::AfxGetMainWnd ()->m_hWnd, message, "Missing Textures", MB_ICONEXCLAMATION | MB_OK);
  2934. } else {
  2935. ::MessageBox (::AfxGetMainWnd ()->m_hWnd, "No Missing Textures!", "Texture Info", MB_ICONEXCLAMATION | MB_OK);
  2936. }
  2937. return ;
  2938. }
  2939. ////////////////////////////////////////////////////////////////////////////
  2940. //
  2941. // OnCopyAssets
  2942. //
  2943. ////////////////////////////////////////////////////////////////////////////
  2944. void
  2945. CMainFrame::OnCopyAssets (void)
  2946. {
  2947. CString path;
  2948. if (::Browse_For_Folder (m_hWnd, NULL, path)) {
  2949. //
  2950. // Copy all dependent asset files to the selected directory
  2951. //
  2952. CW3DViewDoc *doc = ::GetCurrentDocument ();
  2953. if (doc != NULL) {
  2954. doc->Copy_Assets_To_Dir (path);
  2955. }
  2956. }
  2957. return ;
  2958. }
  2959. ////////////////////////////////////////////////////////////////////////////
  2960. //
  2961. // OnUpdateCopyAssets
  2962. //
  2963. ////////////////////////////////////////////////////////////////////////////
  2964. void
  2965. CMainFrame::OnUpdateCopyAssets (CCmdUI *pCmdUI)
  2966. {
  2967. CW3DViewDoc *doc = ::GetCurrentDocument ();
  2968. if (doc != NULL) {
  2969. //
  2970. // Only enable this option if we are viewing an object
  2971. //
  2972. pCmdUI->Enable (doc->GetDisplayedObject () != NULL);
  2973. }
  2974. return ;
  2975. }
  2976. ////////////////////////////////////////////////////////////////////////////
  2977. //
  2978. // OnTexturePath
  2979. //
  2980. ////////////////////////////////////////////////////////////////////////////
  2981. void
  2982. CMainFrame::OnTexturePath (void)
  2983. {
  2984. TexturePathDialogClass dialog (this);
  2985. dialog.DoModal ();
  2986. return ;
  2987. }
  2988. ////////////////////////////////////////////////////////////////////////////
  2989. //
  2990. // OnChangeResolution
  2991. //
  2992. ////////////////////////////////////////////////////////////////////////////
  2993. void
  2994. CMainFrame::OnChangeResolution (void)
  2995. {
  2996. #ifdef WW3D_DX8
  2997. ResolutionDialogClass dialog (this);
  2998. dialog.DoModal ();
  2999. #else
  3000. ::MessageBox(m_hWnd,"Feature removed during conversion to DX8.","Unsupported Feature",MB_OK|MB_ICONEXCLAMATION);
  3001. #endif
  3002. return ;
  3003. }
  3004. ////////////////////////////////////////////////////////////////////////////
  3005. //
  3006. // OnCreateSphere
  3007. //
  3008. ////////////////////////////////////////////////////////////////////////////
  3009. void
  3010. CMainFrame::OnCreateSphere (void)
  3011. {
  3012. // Clear the current display
  3013. CW3DViewDoc *doc = (CW3DViewDoc *)GetActiveDocument ();
  3014. if (doc) {
  3015. doc->DisplayObject ((RenderObjClass *)NULL);
  3016. }
  3017. //
  3018. // Display the sphere property sheet
  3019. //
  3020. SpherePropertySheetClass dialog (NULL, IDS_SPHERE_PROP_TITLE, this);
  3021. dialog.DoModal ();
  3022. return ;
  3023. }
  3024. ////////////////////////////////////////////////////////////////////////////
  3025. //
  3026. // OnCreateRing
  3027. //
  3028. ////////////////////////////////////////////////////////////////////////////
  3029. void
  3030. CMainFrame::OnCreateRing (void)
  3031. {
  3032. // Clear the current display
  3033. CW3DViewDoc *doc = (CW3DViewDoc *)GetActiveDocument ();
  3034. if (doc) {
  3035. doc->DisplayObject ((RenderObjClass *)NULL);
  3036. }
  3037. //
  3038. // Display the ring property sheet
  3039. //
  3040. RingPropertySheetClass dialog (NULL, IDS_RING_PROP_TITLE, this);
  3041. dialog.DoModal ();
  3042. return ;
  3043. }
  3044. ////////////////////////////////////////////////////////////////////////////
  3045. //
  3046. // OnEditPrimitive
  3047. //
  3048. ////////////////////////////////////////////////////////////////////////////
  3049. void
  3050. CMainFrame::OnEditPrimitive (void)
  3051. {
  3052. // Get a pointer to the doc object
  3053. CW3DViewDoc *doc = (CW3DViewDoc *)GetActiveDocument ();
  3054. if (doc != NULL) {
  3055. //
  3056. // Make a list of emitters containing the currently displayed emitter
  3057. //
  3058. RenderObjClass *render_obj = doc->GetDisplayedObject ();
  3059. if (render_obj != NULL) {
  3060. if (render_obj->Class_ID () == RenderObjClass::CLASSID_SPHERE) {
  3061. //
  3062. // Display the sphere property sheet
  3063. //
  3064. SpherePropertySheetClass dialog ((SphereRenderObjClass *)render_obj, IDS_SPHERE_PROP_TITLE, this);
  3065. dialog.DoModal ();
  3066. } else if (render_obj->Class_ID () == RenderObjClass::CLASSID_RING) {
  3067. //
  3068. // Display the ring property sheet
  3069. //
  3070. RingPropertySheetClass dialog ((RingRenderObjClass *)render_obj, IDS_RING_PROP_TITLE, this);
  3071. dialog.DoModal ();
  3072. }
  3073. }
  3074. }
  3075. return ;
  3076. }
  3077. ////////////////////////////////////////////////////////////////////////////
  3078. //
  3079. // OnUpdateEditPrimitive
  3080. //
  3081. ////////////////////////////////////////////////////////////////////////////
  3082. void
  3083. CMainFrame::OnUpdateEditPrimitive (CCmdUI *pCmdUI)
  3084. {
  3085. CDataTreeView *data_tree = (CDataTreeView *)m_wndSplitter.GetPane (0, 0);
  3086. if (data_tree != NULL && data_tree->GetCurrentSelectionType () == TypePrimitives) {
  3087. pCmdUI->Enable (true);
  3088. } else {
  3089. pCmdUI->Enable (false);
  3090. }
  3091. return ;
  3092. }
  3093. ////////////////////////////////////////////////////////////////////////////
  3094. //
  3095. // OnExportPrimitive
  3096. //
  3097. ////////////////////////////////////////////////////////////////////////////
  3098. void
  3099. CMainFrame::OnExportPrimitive (void)
  3100. {
  3101. ((CW3DViewDoc *)GetActiveDocument ())->Save_Selected_Primitive ();
  3102. return ;
  3103. }
  3104. ////////////////////////////////////////////////////////////////////////////
  3105. //
  3106. // OnUpdateExportPrimitive
  3107. //
  3108. ////////////////////////////////////////////////////////////////////////////
  3109. void
  3110. CMainFrame::OnUpdateExportPrimitive (CCmdUI *pCmdUI)
  3111. {
  3112. pCmdUI->Enable (m_currentAssetType == TypePrimitives);
  3113. return ;
  3114. }
  3115. ////////////////////////////////////////////////////////////////////////////
  3116. //
  3117. // OnKillSceneLight
  3118. //
  3119. ////////////////////////////////////////////////////////////////////////////
  3120. void CMainFrame::OnKillSceneLight()
  3121. {
  3122. CW3DViewDoc *pdoc = ::GetCurrentDocument();
  3123. LightClass *plight = pdoc->GetSceneLight ();
  3124. if (plight != NULL) {
  3125. const Vector3 black (0.0f, 0.0f, 0.0f);
  3126. plight->Set_Diffuse (black);
  3127. plight->Set_Specular (black);
  3128. }
  3129. }
  3130. //////////////////////////////////////////////////////////////////////////
  3131. //
  3132. // OnPrelitMultipass
  3133. //
  3134. //////////////////////////////////////////////////////////////////////////
  3135. void
  3136. CMainFrame::OnPrelitMultipass (void)
  3137. {
  3138. if (WW3D::Get_Prelit_Mode () != WW3D::PRELIT_MODE_LIGHTMAP_MULTI_PASS) {
  3139. //
  3140. // Change the loading mode
  3141. //
  3142. WW3D::Set_Prelit_Mode (WW3D::PRELIT_MODE_LIGHTMAP_MULTI_PASS);
  3143. //
  3144. // Reload the lightmap models
  3145. //
  3146. CDataTreeView *data_tree = (CDataTreeView *)m_wndSplitter.GetPane (0, 0);
  3147. data_tree->Reload_Lightmap_Models ();
  3148. ::GetCurrentDocument ()->Reload_Displayed_Object ();
  3149. }
  3150. return ;
  3151. }
  3152. //////////////////////////////////////////////////////////////////////////
  3153. //
  3154. // OnUpdatePrelitMultipass
  3155. //
  3156. //////////////////////////////////////////////////////////////////////////
  3157. void
  3158. CMainFrame::OnUpdatePrelitMultipass (CCmdUI *pCmdUI)
  3159. {
  3160. bool enable = (WW3D::Get_Prelit_Mode () == WW3D::PRELIT_MODE_LIGHTMAP_MULTI_PASS);
  3161. pCmdUI->SetRadio (enable);
  3162. return ;
  3163. }
  3164. //////////////////////////////////////////////////////////////////////////
  3165. //
  3166. // OnPrelitMultitex
  3167. //
  3168. //////////////////////////////////////////////////////////////////////////
  3169. void
  3170. CMainFrame::OnPrelitMultitex (void)
  3171. {
  3172. if (WW3D::Get_Prelit_Mode () != WW3D::PRELIT_MODE_LIGHTMAP_MULTI_TEXTURE) {
  3173. //
  3174. // Change the loading mode
  3175. //
  3176. WW3D::Set_Prelit_Mode (WW3D::PRELIT_MODE_LIGHTMAP_MULTI_TEXTURE);
  3177. //
  3178. // Reload the lightmap models
  3179. //
  3180. CDataTreeView *data_tree = (CDataTreeView *)m_wndSplitter.GetPane (0, 0);
  3181. data_tree->Reload_Lightmap_Models ();
  3182. ::GetCurrentDocument ()->Reload_Displayed_Object ();
  3183. }
  3184. return ;
  3185. }
  3186. //////////////////////////////////////////////////////////////////////////
  3187. //
  3188. // OnUpdatePrelitMultitex
  3189. //
  3190. //////////////////////////////////////////////////////////////////////////
  3191. void
  3192. CMainFrame::OnUpdatePrelitMultitex (CCmdUI *pCmdUI)
  3193. {
  3194. bool enable = (WW3D::Get_Prelit_Mode () == WW3D::PRELIT_MODE_LIGHTMAP_MULTI_TEXTURE);
  3195. pCmdUI->SetRadio (enable);
  3196. return ;
  3197. }
  3198. //////////////////////////////////////////////////////////////////////////
  3199. //
  3200. // OnPrelitVertex
  3201. //
  3202. //////////////////////////////////////////////////////////////////////////
  3203. void
  3204. CMainFrame::OnPrelitVertex (void)
  3205. {
  3206. if (WW3D::Get_Prelit_Mode () != WW3D::PRELIT_MODE_VERTEX) {
  3207. //
  3208. // Change the loading mode
  3209. //
  3210. WW3D::Set_Prelit_Mode (WW3D::PRELIT_MODE_VERTEX);
  3211. //
  3212. // Reload the lightmap models
  3213. //
  3214. CDataTreeView *data_tree = (CDataTreeView *)m_wndSplitter.GetPane (0, 0);
  3215. data_tree->Reload_Lightmap_Models ();
  3216. ::GetCurrentDocument ()->Reload_Displayed_Object ();
  3217. }
  3218. return ;
  3219. }
  3220. //////////////////////////////////////////////////////////////////////////
  3221. //
  3222. // OnUpdatePrelitVertex
  3223. //
  3224. //////////////////////////////////////////////////////////////////////////
  3225. void
  3226. CMainFrame::OnUpdatePrelitVertex (CCmdUI *pCmdUI)
  3227. {
  3228. bool enable = (WW3D::Get_Prelit_Mode () == WW3D::PRELIT_MODE_VERTEX);
  3229. pCmdUI->SetRadio (enable);
  3230. return ;
  3231. }
  3232. //////////////////////////////////////////////////////////////////////////
  3233. //
  3234. // OnAddToLineup
  3235. //
  3236. //////////////////////////////////////////////////////////////////////////
  3237. void
  3238. CMainFrame::OnAddToLineup (void)
  3239. {
  3240. // Display a dialog that will let the user choose a render object
  3241. // to add to the current scene. The reason I call it a lineup is
  3242. // that the objects we add in this manner are stacked in a horizontal
  3243. // row, just like a lineup.
  3244. CW3DViewDoc *pDoc = (CW3DViewDoc*)GetActiveDocument();
  3245. ViewerSceneClass *pScene = NULL;
  3246. if (pDoc)
  3247. pScene = pDoc->GetScene();
  3248. CAddToLineupDialog dlg(pScene, this);
  3249. if (dlg.DoModal() == IDOK)
  3250. {
  3251. // Create the named render object.
  3252. RenderObjClass *obj = WW3DAssetManager::Get_Instance()->Create_Render_Obj(dlg.m_Object);
  3253. if (obj)
  3254. {
  3255. // Set the render object to it's highest LOD.
  3256. Set_Highest_LOD(obj);
  3257. // Add the object to the scene's lineup.
  3258. pScene->Add_To_Lineup(obj);
  3259. }
  3260. else
  3261. {
  3262. // Tell the user that the render object could not be created.
  3263. CString msg;
  3264. msg.Format("Unable to create render object '%s'!", dlg.m_Object);
  3265. ::AfxMessageBox(msg, MB_OK | MB_ICONINFORMATION);
  3266. }
  3267. }
  3268. }
  3269. //////////////////////////////////////////////////////////////////////////
  3270. //
  3271. // OnUpdateAddToLineup
  3272. //
  3273. //////////////////////////////////////////////////////////////////////////
  3274. void CMainFrame::OnUpdateAddToLineup(CCmdUI* pCmdUI)
  3275. {
  3276. bool enable = false;
  3277. // The button should only be enabled if there is a valid scene,
  3278. // and there is a valid current render object, and that render
  3279. // object is an object that can be lined up.
  3280. CW3DViewDoc *pDoc = (CW3DViewDoc*)GetActiveDocument();
  3281. if (pDoc)
  3282. {
  3283. ViewerSceneClass *pScene = pDoc->GetScene();
  3284. RenderObjClass *pObj = pDoc->GetDisplayedObject();
  3285. if (pScene && pObj)
  3286. {
  3287. if (pScene->Can_Line_Up(pObj))
  3288. enable = true;
  3289. }
  3290. }
  3291. pCmdUI->Enable(enable);
  3292. return ;
  3293. }
  3294. //////////////////////////////////////////////////////////////////////////
  3295. //
  3296. // OnImportFacialAnims
  3297. //
  3298. //////////////////////////////////////////////////////////////////////////
  3299. void
  3300. CMainFrame::OnImportFacialAnims (void)
  3301. {
  3302. //
  3303. // Look up the currently selected hierarchy
  3304. //
  3305. CW3DViewDoc *doc = ::GetCurrentDocument ();
  3306. const HTreeClass *htree = doc->Get_Current_HTree ();
  3307. ASSERT (htree != NULL);
  3308. if (htree != NULL) {
  3309. CFileDialog dialog ( TRUE,
  3310. ".txt",
  3311. NULL,
  3312. OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_ALLOWMULTISELECT | OFN_EXPLORER,
  3313. "Animation Description (*.txt)|*.txt||",
  3314. this);
  3315. TCHAR filename_list[MAX_PATH * 20] = { 0 };
  3316. dialog.m_ofn.lpstrFile = filename_list;
  3317. dialog.m_ofn.nMaxFile = sizeof (filename_list);
  3318. //
  3319. // Ask the user what files they want to import
  3320. //
  3321. if (dialog.DoModal () == IDOK) {
  3322. CWaitCursor wait_cursor;
  3323. //
  3324. // Loop over all the selected files
  3325. //
  3326. POSITION pos = dialog.GetStartPosition ();
  3327. while (pos != NULL) {
  3328. // Ask the doc to load the assets from this file into memory
  3329. CString filename = dialog.GetNextPathName (pos);
  3330. doc->Import_Facial_Animation (htree->Get_Name (), filename);
  3331. }
  3332. //
  3333. // Re-load the data list to include all new assets
  3334. //
  3335. CDataTreeView *data_tree = doc->GetDataTreeView ();
  3336. if (data_tree != NULL) {
  3337. data_tree->LoadAssetsIntoTree ();
  3338. }
  3339. }
  3340. }
  3341. return ;
  3342. }
  3343. //////////////////////////////////////////////////////////////////////////
  3344. //
  3345. // OnUpdateImportFacialAnims
  3346. //
  3347. //////////////////////////////////////////////////////////////////////////
  3348. void
  3349. CMainFrame::OnUpdateImportFacialAnims (CCmdUI *pCmdUI)
  3350. {
  3351. CW3DViewDoc *doc = ::GetCurrentDocument ();
  3352. if (doc != NULL) {
  3353. //
  3354. // Enable this command only if the user has an htree
  3355. // currently selected
  3356. //
  3357. const HTreeClass *htree = doc->Get_Current_HTree ();
  3358. pCmdUI->Enable (htree != NULL);
  3359. }
  3360. return ;
  3361. }
  3362. //////////////////////////////////////////////////////////////////////////
  3363. //
  3364. // OnRestrictAnims
  3365. //
  3366. //////////////////////////////////////////////////////////////////////////
  3367. void
  3368. CMainFrame::OnRestrictAnims (void)
  3369. {
  3370. CDataTreeView *data_tree = ::GetCurrentDocument ()->GetDataTreeView ();
  3371. if (data_tree != NULL) {
  3372. bool enabled = data_tree->Are_Anims_Restricted ();
  3373. data_tree->Restrict_Anims (!enabled);
  3374. }
  3375. return ;
  3376. }
  3377. //////////////////////////////////////////////////////////////////////////
  3378. //
  3379. // OnUpdateRestrictAnims
  3380. //
  3381. //////////////////////////////////////////////////////////////////////////
  3382. void
  3383. CMainFrame::OnUpdateRestrictAnims (CCmdUI *pCmdUI)
  3384. {
  3385. bool check = true;
  3386. CDataTreeView *data_tree = ::GetCurrentDocument ()->GetDataTreeView ();
  3387. if (data_tree != NULL) {
  3388. check = data_tree->Are_Anims_Restricted ();
  3389. }
  3390. pCmdUI->SetCheck (check);
  3391. return ;
  3392. }
  3393. //////////////////////////////////////////////////////////////////////////
  3394. //
  3395. // OnBindSubobjectLod
  3396. //
  3397. //////////////////////////////////////////////////////////////////////////
  3398. void
  3399. CMainFrame::OnBindSubobjectLod (void)
  3400. {
  3401. CW3DViewDoc *doc = (CW3DViewDoc *)GetActiveDocument ();
  3402. if (doc != NULL && doc->GetDisplayedObject () != NULL) {
  3403. //
  3404. // Toggle the state of the currently displayed object
  3405. //
  3406. RenderObjClass *render_obj = doc->GetDisplayedObject ();
  3407. bool is_enabled = (render_obj->Is_Sub_Objects_Match_LOD_Enabled () != 0);
  3408. render_obj->Set_Sub_Objects_Match_LOD (!is_enabled);
  3409. doc->Update_Aggregate_Prototype (*render_obj);
  3410. }
  3411. return ;
  3412. }
  3413. //////////////////////////////////////////////////////////////////////////
  3414. //
  3415. // OnUpdateBindSubobjectLod
  3416. //
  3417. //////////////////////////////////////////////////////////////////////////
  3418. void
  3419. CMainFrame::OnUpdateBindSubobjectLod (CCmdUI *pCmdUI)
  3420. {
  3421. CW3DViewDoc *doc = (CW3DViewDoc *)GetActiveDocument ();
  3422. if (doc != NULL && doc->GetDisplayedObject () != NULL) {
  3423. //
  3424. // Set the check if we are currenly forcing sub object matching
  3425. //
  3426. RenderObjClass *render_obj = doc->GetDisplayedObject ();
  3427. bool is_enabled = (render_obj->Is_Sub_Objects_Match_LOD_Enabled () != 0);
  3428. pCmdUI->SetCheck (is_enabled);
  3429. }
  3430. return ;
  3431. }
  3432. //////////////////////////////////////////////////////////////////////////
  3433. //
  3434. // OnSetCameraDistance
  3435. //
  3436. //////////////////////////////////////////////////////////////////////////
  3437. void
  3438. CMainFrame::OnSetCameraDistance (void)
  3439. {
  3440. CameraDistanceDialogClass dialog (this);
  3441. dialog.DoModal ();
  3442. return ;
  3443. }
  3444. //////////////////////////////////////////////////////////////////////////
  3445. //
  3446. // OnObjectAlternateMaterials
  3447. //
  3448. //////////////////////////////////////////////////////////////////////////
  3449. void
  3450. CMainFrame::OnObjectAlternateMaterials (void)
  3451. {
  3452. ::GetCurrentDocument ()->Toggle_Alternate_Materials ();
  3453. return ;
  3454. }
  3455. //////////////////////////////////////////////////////////////////////////
  3456. //
  3457. // OnCreateSoundObject
  3458. //
  3459. //////////////////////////////////////////////////////////////////////////
  3460. void
  3461. CMainFrame::OnCreateSoundObject (void)
  3462. {
  3463. SoundEditDialogClass dialog (this);
  3464. dialog.DoModal ();
  3465. return ;
  3466. }
  3467. //////////////////////////////////////////////////////////////////////////
  3468. //
  3469. // OnEditSoundObject
  3470. //
  3471. //////////////////////////////////////////////////////////////////////////
  3472. void
  3473. CMainFrame::OnEditSoundObject (void)
  3474. {
  3475. //
  3476. // Get a pointer to the doc object
  3477. //
  3478. CW3DViewDoc *doc = (CW3DViewDoc *)GetActiveDocument ();
  3479. if (doc != NULL) {
  3480. //
  3481. // Get a pointer to the currently displayed sound object
  3482. //
  3483. SoundRenderObjClass *sound_obj = (SoundRenderObjClass *)doc->GetDisplayedObject ();
  3484. if (sound_obj != NULL) {
  3485. //
  3486. // Display the sound edit dialog
  3487. //
  3488. SoundEditDialogClass dialog (this);
  3489. dialog.Set_Sound (sound_obj);
  3490. dialog.DoModal ();
  3491. }
  3492. }
  3493. return ;
  3494. }
  3495. //////////////////////////////////////////////////////////////////////////
  3496. //
  3497. // OnUpdateEditSoundObject
  3498. //
  3499. //////////////////////////////////////////////////////////////////////////
  3500. void
  3501. CMainFrame::OnUpdateEditSoundObject (CCmdUI *pCmdUI)
  3502. {
  3503. pCmdUI->Enable (m_currentAssetType == TypeSound);
  3504. return ;
  3505. }
  3506. //////////////////////////////////////////////////////////////////////////
  3507. //
  3508. // OnExportSoundObj
  3509. //
  3510. //////////////////////////////////////////////////////////////////////////
  3511. void
  3512. CMainFrame::OnExportSoundObj (void)
  3513. {
  3514. ((CW3DViewDoc *)GetActiveDocument ())->Save_Selected_Sound_Object ();
  3515. return ;
  3516. }
  3517. //////////////////////////////////////////////////////////////////////////
  3518. //
  3519. // OnUpdateExportSoundObj
  3520. //
  3521. //////////////////////////////////////////////////////////////////////////
  3522. void
  3523. CMainFrame::OnUpdateExportSoundObj (CCmdUI *pCmdUI)
  3524. {
  3525. pCmdUI->Enable (m_currentAssetType == TypeSound);
  3526. return ;
  3527. }
  3528. //////////////////////////////////////////////////////////////////////////
  3529. //
  3530. // OnWireframeMode
  3531. //
  3532. //////////////////////////////////////////////////////////////////////////
  3533. void
  3534. CMainFrame::OnWireframeMode (void)
  3535. {
  3536. ViewerSceneClass *scene = ::GetCurrentDocument ()->GetScene ();
  3537. bool enable = (scene->Get_Polygon_Mode () != SceneClass::LINE);
  3538. scene->Set_Polygon_Mode (enable ? SceneClass::LINE : SceneClass::FILL);
  3539. return ;
  3540. }
  3541. //////////////////////////////////////////////////////////////////////////
  3542. //
  3543. // OnUpdateWireframeMode
  3544. //
  3545. //////////////////////////////////////////////////////////////////////////
  3546. void
  3547. CMainFrame::OnUpdateWireframeMode (CCmdUI *pCmdUI)
  3548. {
  3549. ViewerSceneClass *scene = ::GetCurrentDocument ()->GetScene ();
  3550. pCmdUI->SetCheck (scene->Get_Polygon_Mode () == SceneClass::LINE);
  3551. return ;
  3552. }
  3553. //////////////////////////////////////////////////////////////////////////
  3554. //
  3555. // OnToggleSorting
  3556. //
  3557. //////////////////////////////////////////////////////////////////////////
  3558. void
  3559. CMainFrame::OnToggleSorting()
  3560. {
  3561. // Toggle the polygon sorting state.
  3562. bool sorting=!WW3D::Is_Sorting_Enabled();
  3563. WW3D::_Invalidate_Mesh_Cache();
  3564. WW3D::Enable_Sorting(sorting);
  3565. // Save the new value in the registry.
  3566. ::AfxGetApp()->WriteProfileInt("Config", "EnableSorting",sorting?1:0);
  3567. }
  3568. //////////////////////////////////////////////////////////////////////////
  3569. //
  3570. // OnUpdateToggleSorting
  3571. //
  3572. //////////////////////////////////////////////////////////////////////////
  3573. void
  3574. CMainFrame::OnUpdateToggleSorting(CCmdUI* pCmdUI)
  3575. {
  3576. // Check the menu item if sorting is enabled, clear it otherwise.
  3577. pCmdUI->SetCheck(WW3D::Is_Sorting_Enabled() ? 1 : 0);
  3578. }
  3579. //////////////////////////////////////////////////////////////////////////
  3580. //
  3581. // OnCameraBonePosX
  3582. //
  3583. //////////////////////////////////////////////////////////////////////////
  3584. void
  3585. CMainFrame::OnCameraBonePosX()
  3586. {
  3587. CGraphicView *pCGraphicView = (CGraphicView *)m_wndSplitter.GetPane (0, 1);
  3588. if (pCGraphicView != NULL) {
  3589. pCGraphicView->Set_Camera_Bone_Pos_X(!pCGraphicView->Is_Camera_Bone_Pos_X());
  3590. }
  3591. }
  3592. //////////////////////////////////////////////////////////////////////////
  3593. //
  3594. // OnUpdateCameraBonePosX
  3595. //
  3596. //////////////////////////////////////////////////////////////////////////
  3597. void
  3598. CMainFrame::OnUpdateCameraBonePosX(CCmdUI* pCmdUI)
  3599. {
  3600. CGraphicView *pCGraphicView = (CGraphicView *)m_wndSplitter.GetPane (0, 1);
  3601. if (pCGraphicView != NULL) {
  3602. pCmdUI->SetCheck(pCGraphicView->Is_Camera_Bone_Pos_X());
  3603. }
  3604. }
  3605. void CMainFrame::OnViewPatchGapFill()
  3606. {
  3607. // If gap-filling is on, turn it off. Otherwise turn it on.
  3608. if (WW3D::Get_NPatches_Gap_Filling_Mode() == WW3D::NPATCHES_GAP_FILLING_ENABLED)
  3609. {
  3610. WW3D::Set_NPatches_Gap_Filling_Mode(WW3D::NPATCHES_GAP_FILLING_DISABLED);
  3611. ::AfxGetApp()->WriteProfileInt("Config", "NPatchesGapFilling", 0);
  3612. }
  3613. else
  3614. {
  3615. WW3D::Set_NPatches_Gap_Filling_Mode(WW3D::NPATCHES_GAP_FILLING_ENABLED);
  3616. ::AfxGetApp()->WriteProfileInt("Config", "NPatchesGapFilling", 1);
  3617. }
  3618. }
  3619. void CMainFrame::OnUpdateViewPatchGapFill(CCmdUI* pCmdUI)
  3620. {
  3621. // Check the menu item if gap-filling is turned on.
  3622. bool enabled = (WW3D::Get_NPatches_Gap_Filling_Mode() == WW3D::NPATCHES_GAP_FILLING_ENABLED);
  3623. pCmdUI->SetCheck((int)enabled);
  3624. }
  3625. void CMainFrame::OnViewSubdivision1()
  3626. {
  3627. // Set the N-Patches Subdivision Level to 1.
  3628. WW3D::Set_NPatches_Level(1);
  3629. // Save the new value in the registry.
  3630. ::AfxGetApp()->WriteProfileInt("Config", "NPatchesSubdivision", 1);
  3631. }
  3632. void CMainFrame::OnUpdateViewSubdivision1(CCmdUI* pCmdUI)
  3633. {
  3634. // Check the menu item if the current N-Patch Subdivision Level is 1.
  3635. bool checked = (WW3D::Get_NPatches_Level() == 1);
  3636. pCmdUI->SetCheck((int)checked);
  3637. }
  3638. void CMainFrame::OnViewSubdivision2()
  3639. {
  3640. // Set the N-Patches Subdivision Level to 2.
  3641. WW3D::Set_NPatches_Level(2);
  3642. // Save the new value in the registry.
  3643. ::AfxGetApp()->WriteProfileInt("Config", "NPatchesSubdivision", 2);
  3644. }
  3645. void CMainFrame::OnUpdateViewSubdivision2(CCmdUI* pCmdUI)
  3646. {
  3647. // Check the menu item if the current N-Patch Subdivision Level is 2.
  3648. bool checked = (WW3D::Get_NPatches_Level() == 2);
  3649. pCmdUI->SetCheck((int)checked);
  3650. }
  3651. void CMainFrame::OnViewSubdivision3()
  3652. {
  3653. // Set the N-Patches Subdivision Level to 3.
  3654. WW3D::Set_NPatches_Level(3);
  3655. // Save the new value in the registry.
  3656. ::AfxGetApp()->WriteProfileInt("Config", "NPatchesSubdivision", 3);
  3657. }
  3658. void CMainFrame::OnUpdateViewSubdivision3(CCmdUI* pCmdUI)
  3659. {
  3660. // Check the menu item if the current N-Patch Subdivision Level is 3.
  3661. bool checked = (WW3D::Get_NPatches_Level() == 3);
  3662. pCmdUI->SetCheck((int)checked);
  3663. }
  3664. void CMainFrame::OnViewSubdivision4()
  3665. {
  3666. // Set the N-Patches Subdivision Level to 4.
  3667. WW3D::Set_NPatches_Level(4);
  3668. // Save the new value in the registry.
  3669. ::AfxGetApp()->WriteProfileInt("Config", "NPatchesSubdivision", 4);
  3670. }
  3671. void CMainFrame::OnUpdateViewSubdivision4(CCmdUI* pCmdUI)
  3672. {
  3673. // Check the menu item if the current N-Patch Subdivision Level is 4.
  3674. bool checked = (WW3D::Get_NPatches_Level() == 4);
  3675. pCmdUI->SetCheck((int)checked);
  3676. }
  3677. void CMainFrame::OnViewSubdivision5()
  3678. {
  3679. // Set the N-Patches Subdivision Level to 5.
  3680. WW3D::Set_NPatches_Level(5);
  3681. // Save the new value in the registry.
  3682. ::AfxGetApp()->WriteProfileInt("Config", "NPatchesSubdivision", 5);
  3683. }
  3684. void CMainFrame::OnUpdateViewSubdivision5(CCmdUI* pCmdUI)
  3685. {
  3686. // Check the menu item if the current N-Patch Subdivision Level is 5.
  3687. bool checked = (WW3D::Get_NPatches_Level() == 5);
  3688. pCmdUI->SetCheck((int)checked);
  3689. }
  3690. void CMainFrame::OnViewSubdivision6()
  3691. {
  3692. // Set the N-Patches Subdivision Level to 6.
  3693. WW3D::Set_NPatches_Level(6);
  3694. // Save the new value in the registry.
  3695. ::AfxGetApp()->WriteProfileInt("Config", "NPatchesSubdivision", 6);
  3696. }
  3697. void CMainFrame::OnUpdateViewSubdivision6(CCmdUI* pCmdUI)
  3698. {
  3699. // Check the menu item if the current N-Patch Subdivision Level is 6.
  3700. bool checked = (WW3D::Get_NPatches_Level() == 6);
  3701. pCmdUI->SetCheck((int)checked);
  3702. }
  3703. void CMainFrame::OnViewSubdivision7()
  3704. {
  3705. // Set the N-Patches Subdivision Level to 7.
  3706. WW3D::Set_NPatches_Level(7);
  3707. // Save the new value in the registry.
  3708. ::AfxGetApp()->WriteProfileInt("Config", "NPatchesSubdivision", 7);
  3709. }
  3710. void CMainFrame::OnUpdateViewSubdivision7(CCmdUI* pCmdUI)
  3711. {
  3712. // Check the menu item if the current N-Patch Subdivision Level is 7.
  3713. bool checked = (WW3D::Get_NPatches_Level() == 7);
  3714. pCmdUI->SetCheck((int)checked);
  3715. }
  3716. void CMainFrame::OnViewSubdivision8()
  3717. {
  3718. // Set the N-Patches Subdivision Level to 8.
  3719. WW3D::Set_NPatches_Level(8);
  3720. // Save the new value in the registry.
  3721. ::AfxGetApp()->WriteProfileInt("Config", "NPatchesSubdivision", 8);
  3722. }
  3723. void CMainFrame::OnUpdateViewSubdivision8(CCmdUI* pCmdUI)
  3724. {
  3725. // Check the menu item if the current N-Patch Subdivision Level is 8.
  3726. bool checked = (WW3D::Get_NPatches_Level() == 8);
  3727. pCmdUI->SetCheck((int)checked);
  3728. }
  3729. void CMainFrame::OnMungeSortOnLoad()
  3730. {
  3731. bool setting=!WW3D::Is_Munge_Sort_On_Load_Enabled();
  3732. WW3D::Enable_Munge_Sort_On_Load(setting);
  3733. // Save the new value in the registry.
  3734. ::AfxGetApp()->WriteProfileInt("Config", "MungeSortOnLoad", setting?1:0);
  3735. }
  3736. void CMainFrame::OnUpdateMungeSortOnLoad(CCmdUI* pCmdUI)
  3737. {
  3738. pCmdUI->SetCheck(WW3D::Is_Munge_Sort_On_Load_Enabled() ? 1 : 0);
  3739. }
  3740. void CMainFrame::OnEnableGammaCorrection()
  3741. {
  3742. int setting=::AfxGetApp()->GetProfileInt("Config","EnableGamma",0);
  3743. bool enable_gamma=(setting?true:false);
  3744. enable_gamma=!enable_gamma;
  3745. ::AfxGetApp()->WriteProfileInt("Config", "EnableGamma", enable_gamma?1:0);
  3746. if (enable_gamma) {
  3747. float gamma=::AfxGetApp()->GetProfileInt("Config","Gamma",10);
  3748. gamma=gamma/10.0f;
  3749. if (gamma<1.0) gamma=1.0;
  3750. if (gamma>3.0) gamma=3.0;
  3751. DX8Wrapper::Set_Gamma(gamma,0.0f,1.0f);
  3752. } else {
  3753. DX8Wrapper::Set_Gamma(1.0,0.0f,1.0f);
  3754. }
  3755. }
  3756. void CMainFrame::OnUpdateEnableGammaCorrection(CCmdUI* pCmdUI)
  3757. {
  3758. int setting=::AfxGetApp()->GetProfileInt("Config","EnableGamma",0);
  3759. pCmdUI->SetCheck(setting);
  3760. }
  3761. void CMainFrame::OnSetGamma()
  3762. {
  3763. int setting=::AfxGetApp()->GetProfileInt("Config","EnableGamma",0);
  3764. if (setting) {
  3765. GammaDialogClass gammadialog;
  3766. gammadialog.DoModal();
  3767. } else {
  3768. MessageBox("Gamma is disabled.\nEnable in File Menu.","Warning");
  3769. }
  3770. }
  3771. //////////////////////////////////////////////////////////////////////////
  3772. //
  3773. // OnEditAnimatedSoundsOptions
  3774. //
  3775. //////////////////////////////////////////////////////////////////////////
  3776. void
  3777. CMainFrame::OnEditAnimatedSoundsOptions (void)
  3778. {
  3779. AnimatedSoundOptionsDialogClass dialog (this);
  3780. dialog.DoModal ();
  3781. return ;
  3782. }