mdledit.cpp 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // MDL Editor
  4. //
  5. //////////////////////////////////////////////////////////////////////////////
  6. #include "pch.h"
  7. //////////////////////////////////////////////////////////////////////////////
  8. //
  9. // The main entry point
  10. //
  11. //////////////////////////////////////////////////////////////////////////////
  12. #include "main.h"
  13. //////////////////////////////////////////////////////////////////////////////
  14. //
  15. // Network
  16. //
  17. //////////////////////////////////////////////////////////////////////////////
  18. /*
  19. #include "network.h"
  20. #include "network.cpp"
  21. */
  22. //////////////////////////////////////////////////////////////////////////////
  23. //
  24. //
  25. //
  26. //////////////////////////////////////////////////////////////////////////////
  27. /*
  28. class WaveDeformation : public Deformation {
  29. private:
  30. float m_frequency;
  31. float m_amplitude;
  32. float m_phase;
  33. public:
  34. WaveDeformation(
  35. float wavelength,
  36. float amplitude
  37. ) :
  38. m_frequency(2.0f * pi / wavelength),
  39. m_amplitude(amplitude),
  40. m_phase(0)
  41. {
  42. }
  43. void SetWavelength(float wavelength)
  44. {
  45. m_frequency = 2.0f * pi / wavelength;
  46. }
  47. void SetAmplitude(float amplitude)
  48. {
  49. m_amplitude = amplitude;
  50. }
  51. void SetPhase(float phase)
  52. {
  53. m_phase = phase;
  54. }
  55. Vector Deform(const Vector& vec)
  56. {
  57. return
  58. Vector(
  59. vec.x,
  60. vec.y + m_amplitude * sin(m_frequency * vec.x + m_phase),
  61. vec.z
  62. //min(0, vec.z * max(1, vec.x * 0.25f))
  63. );
  64. }
  65. };
  66. */
  67. //////////////////////////////////////////////////////////////////////////////
  68. //
  69. //
  70. //
  71. //////////////////////////////////////////////////////////////////////////////
  72. class MDLEditWindow :
  73. public EffectWindow,
  74. public IIntegerEventSink,
  75. //public IEventSink,
  76. public IMenuCommandSink,
  77. public ISubmenuEventSink
  78. /*,
  79. public NetworkSite,
  80. public SocketSite*/
  81. {
  82. public:
  83. //////////////////////////////////////////////////////////////////////////////
  84. //
  85. //
  86. //
  87. //////////////////////////////////////////////////////////////////////////////
  88. float m_angle;
  89. class TestGeo : public WrapGeo {
  90. private:
  91. //TRef<WaveDeformation> m_pdeform;
  92. TRef<Modeler> m_pmodeler;
  93. TRef<Surface> m_psurface;
  94. TRef<ThingGeo> m_pgeo;
  95. TRef<GroupGeo> m_pgroupGeo;
  96. MDLEditWindow* m_pwindow;
  97. int m_test;
  98. VertexL vertices[4 * 100];
  99. WORD indices[6 * 100];
  100. float GetTime() { return Number::Cast(GetChild(1))->GetValue(); }
  101. public:
  102. TestGeo(Modeler* pmodeler, MDLEditWindow* pwindow, Number* ptime, int initialTest) :
  103. WrapGeo(Geo::GetEmpty(), ptime),
  104. m_pmodeler(pmodeler),
  105. m_pwindow(pwindow),
  106. m_test(initialTest)
  107. {
  108. //m_pdeform = new WaveDeformation(1.0f, 0.25f);
  109. m_pwindow->ToggleShowFPS();
  110. InitializePolyTest();
  111. InitializeGeoTest();
  112. InitializeRingTest();
  113. SetTest(initialTest);
  114. }
  115. void InitPoly(int qindex)
  116. {
  117. int index = qindex * 6;
  118. int vindex = qindex * 4;
  119. //float z = -0.1f * float(2 * qindex - qindex); // front to back
  120. float z = -0.1f * float(99 - qindex); // back to front
  121. //float z = 0;
  122. //vertices[vindex + 0] = Vertex(-1, 1, z, 0, 0, 1, 0, 0);
  123. //vertices[vindex + 1] = Vertex(-1, -1, z, 0, 0, 1, 0, 1);
  124. //vertices[vindex + 2] = Vertex( 1, -1, z, 0, 0, 1, 1, 1);
  125. //vertices[vindex + 3] = Vertex( 1, 1, z, 0, 0, 1, 1, 0);
  126. float a = 1.0f;
  127. float r = 1.0f * a;
  128. float g = 0.5f * a;
  129. float b = 0.25f * a;
  130. vertices[vindex + 0] = VertexL(-1, 1, z, r, g, b, a, 0, 0);
  131. vertices[vindex + 1] = VertexL(-1, -1, z, r, g, b, a, 0, 1);
  132. vertices[vindex + 2] = VertexL( 1, -1, z, r, g, b, a, 1, 1);
  133. vertices[vindex + 3] = VertexL( 1, 1, z, r, g, b, a, 1, 0);
  134. indices[index + 0] = vindex + 0; // cw
  135. indices[index + 1] = vindex + 2;
  136. indices[index + 2] = vindex + 1;
  137. indices[index + 3] = vindex + 0; // ccw
  138. indices[index + 4] = vindex + 3;
  139. indices[index + 5] = vindex + 2;
  140. }
  141. void InitializePolyTest()
  142. {
  143. m_pwindow->m_angle = 0;
  144. m_psurface = m_pmodeler->LoadSurface("testtexturebmp", false);
  145. //m_psurface = m_pmodeler->LoadSurface("fig04bmp", false);
  146. //m_psurface = m_pmodeler->LoadSurface("f101bmp", false);
  147. m_psurface->SetColorKey(Color::Black());
  148. for (int qindex = 0; qindex < 100; qindex++) {
  149. InitPoly(qindex);
  150. }
  151. }
  152. void InitializeGeoTest()
  153. {
  154. m_pgeo = m_pwindow->CreateThingGeo("bom01a", Vector(0, 0, 0));
  155. }
  156. /*
  157. Matrix mat;
  158. float y = (value - 0.5f) * 10;
  159. float radius = 10;
  160. float angle = value * 4 * pi;
  161. float z = radius * cos(angle);
  162. float x = radius * sin(angle);
  163. Vector center(0, 0, -20);
  164. mat.SetRotate(Vector(0, 1, 0), - pi / 2);
  165. mat.Translate(center + Vector(x, y, z));
  166. m_pgroupGeo->AddGeo(
  167. new TransformGeo(
  168. new CullGeo(pgeo),
  169. new MatrixTransform(mat)
  170. )
  171. );
  172. */
  173. void InitializeRingTest()
  174. {
  175. m_pgroupGeo = GroupGeo::Create();
  176. float max = 32.0f;
  177. float radius = 50.0f;
  178. for (float value = 0.0f; value < max; value++) {
  179. TRef<ThingGeo> pthing =
  180. m_pwindow->CreateThingGeo(
  181. "bom01a",
  182. Vector::RandomPosition(radius) + Vector(0, 0, -3.0f * radius)
  183. );
  184. m_pgroupGeo->AddGeo(pthing->GetGeo());
  185. }
  186. }
  187. void SetTest(int test)
  188. {
  189. m_test = test;
  190. switch (m_test) {
  191. case 2:
  192. ThingGeo::SetShowLights(true);
  193. SetGeo(m_pgeo->GetGeo());
  194. break;
  195. case 3:
  196. ThingGeo::SetShowLights(false);
  197. SetGeo(m_pgroupGeo);
  198. break;
  199. default: SetGeo(Geo::GetEmpty()); break;
  200. }
  201. }
  202. void NextTest()
  203. {
  204. m_test++;
  205. if (m_test > 3) {
  206. m_test = 0;
  207. }
  208. SetTest(m_test);
  209. }
  210. void SetMode(Context* pcontext)
  211. {
  212. pcontext->SetColorKey(false);
  213. pcontext->SetCullMode(CullModeNone);
  214. pcontext->SetZWrite(true);
  215. pcontext->SetZTest(true);
  216. //pcontext->SetShadeMode(ShadeModeCopy);
  217. pcontext->SetShadeMode(ShadeModeFlat);
  218. //pcontext->SetShadeMode(ShadeModeGouraud);
  219. pcontext->SetBlendMode(BlendModeSource);
  220. //pcontext->SetBlendMode(BlendModeAdd);
  221. //pcontext->SetBlendMode(BlendModeSourceAlpha);
  222. //pcontext->SetTexture(NULL);
  223. pcontext->SetTexture(m_psurface);
  224. //m_pdeform->SetPhase(4.0f * GetTime());
  225. //pcontext->SetDeformation(m_pdeform);
  226. }
  227. void DrawTriangles(Context* pcontext, int count, float scale)
  228. {
  229. pcontext->PushState();
  230. pcontext->Scale(Vector(scale, scale, 1));
  231. pcontext->DrawTriangles(vertices, 4 * count, indices, 6 * count);
  232. //pcontext->DrawTriangles(vertices, 4, indices, 3);
  233. pcontext->PopState();
  234. }
  235. void Test0(Context* pcontext)
  236. {
  237. SetMode(pcontext);
  238. pcontext->Rotate(Vector(0, 0, 1), m_pwindow->m_angle);
  239. //pcontext->Rotate(Vector(0, 0, 1), 0.25f * pi);
  240. DrawTriangles(pcontext, 1, 1.0f);
  241. }
  242. void Test1(Context* pcontext)
  243. {
  244. SetMode(pcontext);
  245. pcontext->SetShadeMode(ShadeModeNone);
  246. pcontext->Rotate(Vector(0, 1, 0), m_pwindow->m_angle);
  247. pcontext->Rotate(Vector(0, 0, 1), 1.0f);
  248. for(int index = 0; index < 400; index++) {
  249. DrawTriangles(pcontext, 100, 0.01f);
  250. }
  251. }
  252. void DefaultRender(Context* pcontext)
  253. {
  254. SetMode(pcontext);
  255. WrapGeo::Render(pcontext);
  256. }
  257. void Render(Context* pcontext)
  258. {
  259. switch (m_test) {
  260. case 0: Test0(pcontext); break;
  261. case 1: Test1(pcontext); break;
  262. default: DefaultRender(pcontext); break;
  263. }
  264. }
  265. };
  266. //////////////////////////////////////////////////////////////////////////////
  267. //
  268. //
  269. //
  270. //////////////////////////////////////////////////////////////////////////////
  271. class TestImage : public Image {
  272. public:
  273. TRef<Modeler> m_pmodeler;
  274. MDLEditWindow* m_pwindow;
  275. TRef<Surface> m_psurfaceIcon;
  276. float GetTime() { return Number::Cast(GetChild(0))->GetValue(); }
  277. //////////////////////////////////////////////////////////////////////////////
  278. //
  279. // constructor
  280. //
  281. //////////////////////////////////////////////////////////////////////////////
  282. TestImage(Modeler* pmodeler, MDLEditWindow* pwindow, Number* ptime) :
  283. Image(ptime),
  284. m_pmodeler(pmodeler),
  285. m_pwindow(pwindow)
  286. {
  287. m_pwindow->m_angle = 0;
  288. m_psurfaceIcon = m_pmodeler->LoadSurface("fighterbmp", true);
  289. }
  290. //////////////////////////////////////////////////////////////////////////////
  291. //
  292. // Image methods
  293. //
  294. //////////////////////////////////////////////////////////////////////////////
  295. void Render(Context* pcontext)
  296. {
  297. /*
  298. float angle = m_pwindow->m_angle;//GetTime();
  299. VertexScreen pvertex[3];
  300. MeshIndex pindex[4] = { 0, 1, 1, 2 };
  301. pvertex[0].x = 100.5f;
  302. pvertex[0].y = 100.5f;
  303. pvertex[0].z = 0;
  304. pvertex[0].qw = 1;
  305. pvertex[0].color = MakeD3DCOLOR(Color(1, 1, 1));
  306. pvertex[0].specular = 0;
  307. pvertex[0].u = 0;
  308. pvertex[0].v = 0;
  309. pvertex[1].x = 100.5f + 20 * cos(angle);
  310. pvertex[1].y = 100.5f + 20 * sin(angle);
  311. pvertex[1].z = 0;
  312. pvertex[1].qw = 1;
  313. pvertex[1].color = MakeD3DCOLOR(Color(1, 1, 1));
  314. pvertex[1].specular = 0;
  315. pvertex[1].u = 0;
  316. pvertex[1].v = 0;
  317. pvertex[2].x = 30;
  318. pvertex[2].y = 20;
  319. pvertex[2].z = 0;
  320. pvertex[2].qw = 1;
  321. pvertex[2].color = MakeD3DCOLOR(Color(1, 1, 1));
  322. pvertex[2].specular = 0;
  323. pvertex[2].u = 0;
  324. pvertex[2].v = 0;
  325. pvertex[1].color = MakeD3DCOLOR(Color(1, 0, 0));
  326. pcontext->DrawPoints(pvertex + 1, 1);
  327. pvertex[1].color = MakeD3DCOLOR(Color(1, 1, 1));
  328. pcontext->DrawLines(pvertex, 2, pindex, 2);
  329. */
  330. pcontext->Translate(Point(50, 50));
  331. pcontext->SetBlendMode(BlendModeSourceAlpha);
  332. pcontext->DrawImage3D(m_psurfaceIcon, Color(1, 0.5f, 0.5f), true);
  333. }
  334. //////////////////////////////////////////////////////////////////////////////
  335. //
  336. // IMouseInput methods
  337. //
  338. //////////////////////////////////////////////////////////////////////////////
  339. MouseResult HitTest(IInputProvider* pprovider, const Point& point, bool bCaptured)
  340. {
  341. return MouseResult();
  342. }
  343. };
  344. //////////////////////////////////////////////////////////////////////////////
  345. //
  346. //
  347. //
  348. //////////////////////////////////////////////////////////////////////////////
  349. class CursorSurfaceSite : public SurfaceSite {
  350. public:
  351. void UpdateSurface(Surface* psurface)
  352. {
  353. const Color& color = Color::White();
  354. const WinPoint& size = psurface->GetSize();
  355. int x = size.X();
  356. int y = size.Y();
  357. psurface->FillSurface(Color::Black());
  358. psurface->FillRect(WinRect( 0, y / 2 - 1, x / 2 - 2, y / 2 + 1), color);
  359. psurface->FillRect(WinRect(x / 2 + 2, y / 2 - 1, x, y / 2 + 1), color);
  360. psurface->FillRect(WinRect(x / 2 - 1, 0, x / 2 + 1, y / 2 - 2), color);
  361. psurface->FillRect(WinRect(x / 2 - 1, y / 2 + 2, x / 2 + 1, y), color);
  362. }
  363. };
  364. //////////////////////////////////////////////////////////////////////////////
  365. //
  366. //
  367. //
  368. //////////////////////////////////////////////////////////////////////////////
  369. //TRef<SoundEngine> m_psoundEngine;
  370. TRef<Camera> m_pcamera;
  371. TRef<Viewport> m_pviewport;
  372. TRef<GroupGeo> m_pgroupGeo;
  373. TRef<GroupImage> m_pgroupImage;
  374. TRef<GeoImage> m_pgeoImage;
  375. TRef<WrapImage> m_pwrapImageInput;
  376. TRef<Image> m_pimageCursor;
  377. TRef<ModifiableColorValue> m_pcolorBackground;
  378. //
  379. // LOD scroll bar
  380. //
  381. TRef<ScrollPane> m_pscrollPane;
  382. TRef<IIntegerEventSource> m_peventLOD;
  383. TRef<ModifiableBoolean> m_pbooleanVisibleLOD;
  384. //
  385. // ThingGeo
  386. //
  387. TRef<ThingGeo> m_pthing;
  388. TRef<ModifiableNumber> m_pnumberFrame;
  389. TRef<ParticleGeo> m_pParticleGeo;
  390. TRef<BitsGeo> m_pbitsGeo;
  391. bool m_bAnimate;
  392. bool m_bGlow;
  393. bool m_bClearColor;
  394. //
  395. // Tests
  396. //
  397. TRef<TestGeo> m_ptestGeo;
  398. //////////////////////////////////////////////////////////////////////////////
  399. //
  400. //
  401. //
  402. //////////////////////////////////////////////////////////////////////////////
  403. MDLEditWindow(
  404. EffectApp* papp,
  405. const ZString& strCommandLine,
  406. bool bImageTest,
  407. bool bTest,
  408. int initialTest
  409. ) :
  410. EffectWindow(
  411. papp,
  412. strCommandLine,
  413. "MDLEdit",
  414. false,
  415. WinRect(0, 0, 256, 256)
  416. ),
  417. m_bAnimate(false),
  418. m_bGlow(false),
  419. m_bClearColor(false)
  420. {
  421. SetEffectWindow(this);
  422. //
  423. // This app runs in Game Mode
  424. //
  425. //SetFullscreen(true);
  426. //GetEngine()->SetDebugFullscreen(true);
  427. GetEngine()->Set3DAccelerationImportant(true);
  428. SetShowFPS(false);
  429. //
  430. // Create the sound engine
  431. //
  432. //m_psoundEngine = CreateSoundEngine(GetHWND());
  433. //
  434. // Create the image hierarchy
  435. //
  436. m_pgroupImage = new GroupImage();
  437. SetImage(m_pgroupImage);
  438. m_pgroupImage->AddImage(papp->GetPopupContainer()->GetImage());
  439. AddLODScrollBar();
  440. m_pgroupImage->AddImage(
  441. m_pwrapImageInput = new WrapImage(Image::GetEmpty())
  442. );
  443. //
  444. // The Camera
  445. //
  446. TRef<Image> pimageCamera;
  447. TRef<IKeyboardInput> pkeyboardInput;
  448. Vector cameraPosition(0, 0, 10);
  449. m_pcamera =
  450. CreateMotionCamera(
  451. cameraPosition,
  452. GetTime(),
  453. pimageCamera,
  454. pkeyboardInput
  455. );
  456. AddKeyboardInputFilter(pkeyboardInput);
  457. m_pgroupImage->AddImage(pimageCamera);
  458. m_pcamera->SetZClip(1, 10000);
  459. //m_pcamera->SetFOV(RadiansFromDegrees(65));
  460. m_pcamera->SetPerspective(4.0f);
  461. //
  462. // The viewport
  463. //
  464. m_pviewport = new Viewport(m_pcamera, GetRenderRectValue());
  465. //
  466. // Geometry
  467. //
  468. m_pgroupGeo = GroupGeo::Create();
  469. m_pgeoImage = new GeoImage(m_pgroupGeo, m_pviewport, true);
  470. m_pgroupImage->AddImage(m_pgeoImage);
  471. Color color(0, 0.5f, 1.0f);
  472. m_pgeoImage->SetLight(Color(1, 0, 0), color);
  473. m_pgeoImage->SetAmbientLevel(0.5f);
  474. //
  475. // Image Layers
  476. //
  477. Add3DTests(bTest, initialTest);
  478. Add2DTests(bImageTest);
  479. //
  480. // Stars
  481. //
  482. m_pgroupImage->AddImage(StarImage::Create(m_pviewport, 1000));
  483. //
  484. // Background
  485. //
  486. m_pcolorBackground = new ModifiableColorValue(Color::Black());
  487. m_pgroupImage->AddImage(CreateColorImage(m_pcolorBackground));
  488. //
  489. // Popups
  490. //
  491. Window::AddKeyboardInputFilter(papp->GetPopupContainer());
  492. InitializeMenu();
  493. //
  494. // Cursor
  495. //
  496. volatile float size = 16;
  497. TRef<Surface> psurfaceCursor =
  498. GetEngine()->CreateSurface(
  499. WinPoint(int(size), int(size)),
  500. SurfaceType2D(),
  501. new CursorSurfaceSite()
  502. );
  503. psurfaceCursor->SetColorKey(Color::Black());
  504. m_pimageCursor =
  505. new TransformImage(
  506. new ConstantImage(
  507. psurfaceCursor,
  508. ZString("cursor")
  509. ),
  510. new TranslateTransform2(
  511. new PointValue(
  512. Point(-(size / 2), -(size / 2))
  513. )
  514. )
  515. );
  516. RestoreCursor();
  517. //
  518. // Test CreateMMLPopup
  519. //
  520. /*
  521. GetPopupContainer()->OpenPopup(
  522. CreateMMLPopup(
  523. GetModeler(),
  524. "hlp7a4.mml"
  525. )
  526. );
  527. */
  528. }
  529. //////////////////////////////////////////////////////////////////////////////
  530. //
  531. //
  532. //
  533. //////////////////////////////////////////////////////////////////////////////
  534. void Add2DTests(bool bTest)
  535. {
  536. if (bTest) {
  537. m_pgroupImage->AddImage(new TestImage(GetModeler(), this, GetTime()));
  538. }
  539. }
  540. //////////////////////////////////////////////////////////////////////////////
  541. //
  542. //
  543. //
  544. //////////////////////////////////////////////////////////////////////////////
  545. void Add3DTests(bool bTest, int initialTest)
  546. {
  547. if (bTest) {
  548. m_ptestGeo = new TestGeo(GetModeler(), this, GetTime(), initialTest);
  549. m_pgroupGeo->AddGeo(m_ptestGeo);
  550. }
  551. //AddDebris();
  552. //AddConeGeoTest();
  553. //AddIcosahedron();
  554. //AddLightening();
  555. //AddThingGeo();
  556. //AddSphere();
  557. }
  558. //////////////////////////////////////////////////////////////////////////////
  559. //
  560. //
  561. //
  562. //////////////////////////////////////////////////////////////////////////////
  563. TRef<MineFieldGeo> m_pmineFieldGeo;
  564. void AddMineFieldTest()
  565. {
  566. TRef<Surface> psurface = GetModeler()->LoadSurface("minebmp", true);
  567. for (int index = 0; index < 100; index++) {
  568. m_pmineFieldGeo = CreateMineFieldGeo(psurface, 1, 100);
  569. m_pgroupGeo->AddGeo(
  570. new TransformGeo(
  571. CreateCullGeo(m_pmineFieldGeo),
  572. new TranslateTransform(
  573. Vector::RandomPosition(1000)
  574. )
  575. )
  576. );
  577. }
  578. }
  579. //////////////////////////////////////////////////////////////////////////////
  580. //
  581. //
  582. //
  583. //////////////////////////////////////////////////////////////////////////////
  584. void AddBoltTest()
  585. {
  586. m_pgroupGeo->AddGeo(
  587. CreateBoltGeo(
  588. new VectorValue(Vector(-20, 0, 0)),
  589. new VectorValue(Vector( 20, 0, 0)),
  590. 0.125f,
  591. GetModeler()->LoadSurface("lightningbmp", true)
  592. )
  593. );
  594. }
  595. //////////////////////////////////////////////////////////////////////////////
  596. //
  597. //
  598. //
  599. //////////////////////////////////////////////////////////////////////////////
  600. class SweepNumber : public Number {
  601. private:
  602. float m_min;
  603. float m_max;
  604. float m_duration;
  605. float GetTime() { return Number::Cast(GetChild(0))->GetValue(); }
  606. public:
  607. SweepNumber(Number* ptime, float min, float max, float duration) :
  608. Number(ptime),
  609. m_min(min),
  610. m_max(max),
  611. m_duration(duration)
  612. {
  613. }
  614. void Evaluate()
  615. {
  616. GetValueInternal() =
  617. m_min + (sin(2 * pi * GetTime() / m_duration) + 1) * 0.5f * (m_max - m_min);
  618. }
  619. };
  620. TRef<Number> m_pnumberAngle;
  621. void AddConeGeoTest()
  622. {
  623. m_pnumberAngle =
  624. GetInputEngine()->GetJoystick(0)->GetValue(0);
  625. //new Number(pi * 0.25f);
  626. //new SweepNumber(GetTime(), 0.1f, 0.5f * pi, 5);
  627. m_pgroupGeo->AddGeo(
  628. new TransformGeo(
  629. new MaterialGeo(
  630. CreateConeGeo(m_pnumberAngle),
  631. CreateMaterial(Color(1.0, 1.0, 1.0))
  632. ),
  633. new AnimateRotateTransform(
  634. new VectorValue(Vector(0, 1, 0)),
  635. GetInputEngine()->GetJoystick(0)->GetValue(1)
  636. )
  637. )
  638. );
  639. }
  640. //////////////////////////////////////////////////////////////////////////////
  641. //
  642. //
  643. //
  644. //////////////////////////////////////////////////////////////////////////////
  645. ~MDLEditWindow()
  646. {
  647. m_pcamera = NULL;
  648. m_pgroupGeo = NULL;
  649. m_pgroupImage = NULL;
  650. m_pnumberFrame = NULL;
  651. }
  652. //////////////////////////////////////////////////////////////////////////////
  653. //
  654. //
  655. //
  656. //////////////////////////////////////////////////////////////////////////////
  657. bool IsValid()
  658. {
  659. return EngineWindow::IsValid();
  660. }
  661. void RestoreCursor()
  662. {
  663. SetCursorImage(m_pimageCursor);
  664. }
  665. TRef<Pane> CreateGeoPane(const Point& size)
  666. {
  667. TRef<Camera> m_pcamera = new Camera();
  668. m_pcamera->SetZClip(1, 10000);
  669. m_pcamera->SetFOV(RadiansFromDegrees(50));
  670. m_pcamera->SetPosition(Vector(0, 0, 10));
  671. TRef<Viewport> m_pviewport =
  672. new Viewport(
  673. m_pcamera,
  674. new RectValue(Rect(Point(0, 0), size))
  675. );
  676. TRef<GeoImage> pimage =
  677. new GeoImage(
  678. new TransformGeo(
  679. new TransformGeo(
  680. GetModeler()->LoadGeo("bom01a"),
  681. new AnimateRotateTransform(
  682. new VectorValue(Vector(0, 1, 0)),
  683. Multiply(GetTime(), new Number(1.0))
  684. )
  685. ),
  686. new RotateTransform(Vector(1, 0, 0), pi/8)
  687. ),
  688. m_pviewport,
  689. true
  690. );
  691. return new AnimatedImagePane(pimage);
  692. }
  693. //////////////////////////////////////////////////////////////////////////////
  694. //
  695. //
  696. //
  697. //////////////////////////////////////////////////////////////////////////////
  698. /*
  699. TRef<Network> m_pnetwork;
  700. bool m_bServer;
  701. int m_nmessage;
  702. TList<TRef<Socket> > m_listSockets;
  703. void Receive(Socket* psocket, const void* pbufArg, DWORD length)
  704. {
  705. BYTE* pbuf = (BYTE*)pbufArg;
  706. while (length > 0) {
  707. ZString str(pbuf);
  708. ZDebugOutput("Received " + str + "\n");
  709. pbuf += str.GetLength() + 1;
  710. length -= str.GetLength() + 1;
  711. }
  712. }
  713. void Disconnect(Socket* psocket)
  714. {
  715. m_listSockets.Remove(psocket);
  716. }
  717. TRef<SocketSite> Connect(Socket* psocket)
  718. {
  719. m_listSockets.PushFront(psocket);
  720. return this;
  721. }
  722. void StartServer()
  723. {
  724. m_nmessage = 0;
  725. m_bServer = true;
  726. m_bClient = false;
  727. m_pnetwork = CreateNetwork(this, 5000);
  728. }
  729. void ServerDoIdle()
  730. {
  731. m_pnetwork->Receive();
  732. //
  733. // Send some messages
  734. //
  735. {
  736. TList<TRef<Socket> >::Iterator iter(m_listSockets);
  737. while (!iter.End()) {
  738. Socket* psocket = iter.Value();
  739. psocket->Send("Hi client, message " + ZString(m_nmessage), true);
  740. m_nmessage++;
  741. iter.Next();
  742. }
  743. }
  744. Sleep(250);
  745. }
  746. //////////////////////////////////////////////////////////////////////////////
  747. //
  748. //
  749. //
  750. //////////////////////////////////////////////////////////////////////////////
  751. bool m_bClient;
  752. TRef<Socket> m_psocket;
  753. void StartClient()
  754. {
  755. m_nmessage = 0;
  756. m_bServer = false;
  757. m_bClient = true;
  758. m_pnetwork = CreateNetwork(NULL, 0);
  759. m_psocket = m_pnetwork->ConnectToServer("mikekehome", 5000, this);
  760. }
  761. void ClientDoIdle()
  762. {
  763. m_pnetwork->Receive();
  764. m_psocket->Send("Hi Server!" + ZString(m_nmessage), false);
  765. m_nmessage++;
  766. Sleep(100);
  767. }
  768. */
  769. /*
  770. class CullGeo : public WrapGeo {
  771. private:
  772. float m_radius;
  773. public:
  774. CullGeo(Geo* pgeo) :
  775. WrapGeo(pgeo)
  776. {
  777. m_radius = GetGeo()->GetRadius(Matrix::GetIdentity());
  778. }
  779. void Evaluate()
  780. {
  781. }
  782. void Render(Context* pcontext)
  783. {
  784. bool bNoClipping;
  785. if (!pcontext->IsCulled(Vector::GetZero(), m_radius, bNoClipping)) {
  786. if (bNoClipping) {
  787. pcontext->SetClipping(false);
  788. }
  789. //float screenRadius = pcontext->GetScreenRadius(Vector::GetZero(), m_radius);
  790. //pcontext->SetLOD(screenRadius * max(m_lodBiasMin, s_lodBias));
  791. GetGeo()->Render(pcontext);
  792. if (bNoClipping) {
  793. pcontext->SetClipping(true);
  794. }
  795. }
  796. }
  797. };
  798. */
  799. void AddDebris()
  800. {
  801. m_pgroupGeo->AddGeo(
  802. CreateDebrisGeo(
  803. GetModeler(),
  804. GetTime(),
  805. m_pviewport
  806. )
  807. );
  808. }
  809. void AddThingGeo()
  810. {
  811. //
  812. // Add a bits geo and a smoke geo
  813. //
  814. m_pParticleGeo = CreateParticleGeo(GetModeler(), GetTime());
  815. m_pgroupGeo->AddGeo(m_pParticleGeo);
  816. m_pbitsGeo = CreateBitsGeo(GetModeler(), GetTime());
  817. m_pgroupGeo->AddGeo(m_pbitsGeo);
  818. }
  819. void AddLODScrollBar()
  820. {
  821. //
  822. // Add the LOD scroll bar
  823. //
  824. TRef<Pane> ppane =
  825. CreateScrollPane(
  826. WinPoint(128, 10),
  827. 100, 10, 1, 90,
  828. m_pscrollPane,
  829. m_peventLOD
  830. );
  831. m_peventLOD->AddSink(IIntegerEventSink::CreateDelegate(this));
  832. m_pbooleanVisibleLOD = new ModifiableBoolean(false);
  833. m_pgroupImage->AddImage(
  834. CreateVisibleImage(
  835. CreatePaneImage(
  836. GetEngine(),
  837. SurfaceType2D(),
  838. false,
  839. ppane
  840. ),
  841. m_pbooleanVisibleLOD
  842. )
  843. );
  844. }
  845. void AddSphere()
  846. {
  847. /*
  848. m_pgroupGeo->AddGeo(
  849. new CullModeGeo(
  850. MakeSphere(1),
  851. CullModeNone
  852. )
  853. );
  854. */
  855. }
  856. bool OnEvent(IIntegerEventSource* pevent, int value)
  857. {
  858. if (pevent == m_peventLOD) {
  859. ThingGeo::SetLODBias(((float)value) / 100);
  860. //GetEngine()->SetClearColor(Color(0, 0, (float)value / 100));
  861. }
  862. return true;
  863. }
  864. void AddIcosahedron()
  865. {
  866. m_pgroupGeo->AddGeo(Geo::GetIcosahedron());
  867. }
  868. void OpenXFile(const ZString& strFilename)
  869. {
  870. m_pnumberFrame = new ModifiableNumber(0);
  871. bool bAnimation;
  872. TRef<Geo> pgeo = GetModeler()->LoadXFile(strFilename, m_pnumberFrame, bAnimation);
  873. if (pgeo == NULL) {
  874. if (bAnimation) {
  875. m_pnumberFrame = NULL;
  876. }
  877. } else {
  878. m_pgroupGeo->AddGeo(pgeo);
  879. }
  880. }
  881. TRef<INameSpace> OpenMDL(const ZString& strFilename)
  882. {
  883. m_pnumberFrame = NULL;
  884. TRef<INameSpace> pns = GetModeler()->GetNameSpace(strFilename);
  885. if (pns) {
  886. TRef<Geo> pgeo;
  887. CastTo( pgeo, pns->FindMember("object"));
  888. CastTo(m_pnumberFrame, pns->FindMember("frame"));
  889. m_pgroupGeo->AddGeo(pgeo);
  890. }
  891. return pns;
  892. }
  893. void OpenImage(const PathString& strPath)
  894. {
  895. TRef<INameSpace> pns = GetModeler()->GetNameSpace(strPath);
  896. if (pns) {
  897. TRef<Image> pimage; CastTo(pimage, (Value*)(pns->FindMember(strPath.GetName())));
  898. if (pimage) {
  899. m_pwrapImageInput->SetImage(pimage);
  900. }
  901. }
  902. }
  903. TRef<ThingGeo> CreateThingGeo(const ZString& strFilename, const Vector& vec)
  904. {
  905. TRef<INameSpace> pns = GetModeler()->GetNameSpace(strFilename);
  906. if (pns) {
  907. TRef<ThingGeo> pthing = ThingGeo::Create(GetModeler(), GetTime());
  908. pthing->LoadMDL(0, pns, NULL);
  909. pthing->SetPosition(vec);
  910. pthing->SetParticleGeo(m_pParticleGeo);
  911. pthing->SetBitsGeo(m_pbitsGeo);
  912. return pthing;
  913. }
  914. return NULL;
  915. }
  916. void OpenThingMDL(const ZString& strFilename, const Vector& vec)
  917. {
  918. m_pthing = CreateThingGeo(strFilename, vec);
  919. if (m_pthing) {
  920. {
  921. bool bAnimation;
  922. ZString str = strFilename + "_m.x";
  923. TRef<Geo> pgeo = GetModeler()->LoadXFile(str, new Number(0.0f), bAnimation, false);
  924. if (pgeo) {
  925. m_pthing->SetBoundsGeo(pgeo);
  926. }
  927. }
  928. m_pgroupGeo->AddGeo(m_pthing->GetGeo());
  929. }
  930. }
  931. void OnClose()
  932. {
  933. RemoveAllChildren();
  934. EngineWindow::OnClose();
  935. }
  936. void EvaluateFrame(Time ttime)
  937. {
  938. //m_psoundEngine->Update();
  939. //UpdateExplosions();
  940. /* network
  941. if (m_bClient) {
  942. ClientDoIdle();
  943. }
  944. if (m_bServer) {
  945. ServerDoIdle();
  946. }
  947. */
  948. float time = GetTime()->GetValue();
  949. if (m_pnumberFrame) {
  950. m_pnumberFrame->SetValue(mod((time) * 10, 100));
  951. }
  952. if (m_pthing) {
  953. Orientation orient;
  954. if (m_bAnimate) {
  955. m_pthing->SetPosition(
  956. Vector(5 * cos(time), 0, 5 * sin(time))
  957. );
  958. orient.Roll(time / pi);
  959. orient.Yaw(time);
  960. } else {
  961. m_pthing->SetPosition(Vector(0, 0, 0));
  962. }
  963. m_pthing->SetOrientation(orient);
  964. }
  965. }
  966. TRef<ISmoothPosition> m_psmoothPosition;
  967. void MoveCamera()
  968. {
  969. if (m_psmoothPosition == NULL) {
  970. m_psmoothPosition =
  971. CreateSmoothPosition(
  972. GetTime(),
  973. m_pcamera->GetPosition()
  974. );
  975. m_pcamera->SetPositionValue(m_psmoothPosition);
  976. m_pcamera->SetOrientationValue(
  977. CreateLookAtOrientation(
  978. new VectorValue(Vector(0, 0, 0)),
  979. m_psmoothPosition,
  980. new VectorValue(Vector(0, 1, 0))
  981. )
  982. );
  983. }
  984. m_psmoothPosition->Goto(
  985. m_pcamera->GetPosition() +
  986. Vector(
  987. random(-100, 100),
  988. random(-100, 100),
  989. random(-100, 100)
  990. ),
  991. 2
  992. );
  993. }
  994. class PopupImpl : public IPopup {
  995. private:
  996. IPopupContainer* m_pcontainer;
  997. IPopup* m_ppopupOwner;
  998. TRef<Pane> m_ppane;
  999. public:
  1000. PopupImpl(Modeler* pmodeler) :
  1001. m_pcontainer(NULL),
  1002. m_ppopupOwner(NULL)
  1003. {
  1004. m_ppane =
  1005. new ImagePane(
  1006. pmodeler->LoadImage("btncrimsonbmp", false)
  1007. );
  1008. }
  1009. //
  1010. // IKeyboardInput
  1011. //
  1012. bool OnChar(IInputProvider* pprovider, const KeyState& ks)
  1013. {
  1014. return true;
  1015. }
  1016. bool OnKey(IInputProvider* pprovider, const KeyState& ks, bool& fForceTranslate)
  1017. {
  1018. if (ks.vk == VK_RETURN) {
  1019. if (m_ppopupOwner) {
  1020. m_ppopupOwner->ClosePopup(this);
  1021. } else {
  1022. m_pcontainer->ClosePopup(this);
  1023. }
  1024. }
  1025. return true;
  1026. }
  1027. //
  1028. // IPopup methods
  1029. //
  1030. void SetContainer(IPopupContainer* pcontainer)
  1031. {
  1032. m_pcontainer = pcontainer;
  1033. }
  1034. void SetOwner(IPopup* ppopupOwner)
  1035. {
  1036. m_ppopupOwner = ppopupOwner;
  1037. }
  1038. void ClosePopup(IPopup* ppopup)
  1039. {
  1040. }
  1041. Pane* GetPane()
  1042. {
  1043. return m_ppane;
  1044. }
  1045. };
  1046. TRef<IMenu> m_pmenu;
  1047. TRef<IMenuCommandSink> m_pmenuCommandSink;
  1048. TRef<ISubmenuEventSink> m_psubmenuEventSink;
  1049. #define idmOptions 1
  1050. #define idmExit 2
  1051. void InitializeMenu()
  1052. {
  1053. m_pmenuCommandSink = IMenuCommandSink::CreateDelegate(this);
  1054. m_psubmenuEventSink = ISubmenuEventSink::CreateDelegate(this);
  1055. }
  1056. IEngineFont* GetFont()
  1057. {
  1058. return GetModeler()->GetNameSpace("model")->FindFont("defaultFont");
  1059. }
  1060. void ShowMenu()
  1061. {
  1062. m_pmenu =
  1063. CreateMenu(
  1064. GetModeler(),
  1065. GetFont(),
  1066. m_pmenuCommandSink
  1067. );
  1068. m_pmenu->AddMenuItem(idmOptions , "Engine Options", 0, m_psubmenuEventSink);
  1069. m_pmenu->AddMenuItem(idmExit , "Exit" );
  1070. Point point(10, 100);
  1071. GetPopupContainer()->OpenPopup(m_pmenu, Rect(point, point));
  1072. }
  1073. void CloseMenu()
  1074. {
  1075. GetPopupContainer()->ClosePopup(m_pmenu);
  1076. m_pmenu = NULL;
  1077. }
  1078. TRef<IPopup> GetSubMenu(IMenuItem* pitem)
  1079. {
  1080. TRef<IMenu> pmenu =
  1081. CreateMenu(
  1082. GetModeler(),
  1083. GetFont(),
  1084. m_pmenuCommandSink
  1085. );
  1086. switch (pitem->GetID()) {
  1087. case idmOptions:
  1088. return GetEngineMenu(GetFont());
  1089. break;
  1090. }
  1091. return pmenu;
  1092. }
  1093. void OnMenuCommand(IMenuItem* pitem)
  1094. {
  1095. switch (pitem->GetID()) {
  1096. case idmExit:
  1097. CloseMenu();
  1098. PostMessage(WM_CLOSE);
  1099. break;
  1100. }
  1101. }
  1102. //////////////////////////////////////////////////////////////////////////////
  1103. //
  1104. //
  1105. //
  1106. //////////////////////////////////////////////////////////////////////////////
  1107. bool OnKey(const KeyState& ks)
  1108. {
  1109. if (Window::OnKey(ks)) {
  1110. return true;
  1111. }
  1112. if (ks.bDown) {
  1113. switch(ks.vk) {
  1114. case 'B':
  1115. ThingGeo::SetShowBounds(!ThingGeo::GetShowBounds());
  1116. break;
  1117. case 'T':
  1118. ThingGeo::SetTransparentObjects(!ThingGeo::GetTransparentObjects());
  1119. break;
  1120. case 'O':
  1121. m_angle -= 0.1f;
  1122. break;
  1123. case 'P':
  1124. m_angle += 0.1f;
  1125. break;
  1126. case VK_ESCAPE:
  1127. ShowMenu();
  1128. return true;
  1129. case 'M':
  1130. m_bAnimate = !m_bAnimate;
  1131. break;
  1132. case 'N':
  1133. if (m_ptestGeo) {
  1134. m_ptestGeo->NextTest();
  1135. }
  1136. break;
  1137. case 'G':
  1138. m_bGlow = !m_bGlow;
  1139. if (m_pthing) {
  1140. if (m_bGlow) {
  1141. m_pthing->SetThrust(1);
  1142. } else {
  1143. m_pthing->SetThrust(0);
  1144. }
  1145. }
  1146. break;
  1147. case 'C':
  1148. m_bClearColor = !m_bClearColor;
  1149. if (m_bClearColor) {
  1150. m_pcolorBackground->SetValue(Color(0.25, 0, 0.25));
  1151. } else {
  1152. m_pcolorBackground->SetValue(Color(0.0, 0, 0.0));
  1153. }
  1154. break;
  1155. case 'X':
  1156. {
  1157. TRef<IMessageBox> pmsgBox = CreateMessageBox(this, GetModeler(), "Message Box", NULL, true, NULL, 0.0f);
  1158. GetPopupContainer()->OpenPopup(pmsgBox, false);
  1159. }
  1160. break;
  1161. case 'L':
  1162. m_pbooleanVisibleLOD->SetValue(
  1163. !m_pbooleanVisibleLOD->GetValue()
  1164. );
  1165. break;
  1166. }
  1167. }
  1168. if (m_pscrollPane) {
  1169. if (ks.bDown) {
  1170. switch(ks.vk) {
  1171. /*
  1172. case VK_SPACE:
  1173. {
  1174. GetPopupContainer()->OpenPopup(
  1175. new PopupImpl(GetModeler()),
  1176. Rect(20, 20, 20, 20),
  1177. false
  1178. );
  1179. m_pscrollPane->SetPos(0);
  1180. }
  1181. return true;
  1182. */
  1183. case 0xdb: // '['
  1184. m_pscrollPane->PageUp();
  1185. return true;
  1186. case 0xdd: // ']'
  1187. m_pscrollPane->PageDown();
  1188. return true;
  1189. }
  1190. }
  1191. }
  1192. return false;
  1193. }
  1194. };
  1195. //////////////////////////////////////////////////////////////////////////////
  1196. //
  1197. // ModelerSite
  1198. //
  1199. //////////////////////////////////////////////////////////////////////////////
  1200. class ModelerSiteImpl : public ModelerSite {
  1201. public:
  1202. void Error(const ZString& str)
  1203. {
  1204. ZError(str);
  1205. MessageBox(NULL, str, "Error", MB_OK);
  1206. _exit(0);
  1207. }
  1208. };
  1209. //////////////////////////////////////////////////////////////////////////////
  1210. //
  1211. // MDLEdit Application
  1212. //
  1213. //////////////////////////////////////////////////////////////////////////////
  1214. class MDLEdit : public EffectApp {
  1215. protected:
  1216. TRef<MDLEditWindow> m_pwindow;
  1217. public:
  1218. HRESULT Initialize(const ZString& strCommandLine)
  1219. {
  1220. EffectApp::Initialize(strCommandLine);
  1221. GetModeler()->SetSite(new ModelerSiteImpl());
  1222. //
  1223. // parse for -test
  1224. //
  1225. bool bTest = false;
  1226. bool bImageTest = false;
  1227. int initialTest = -1;
  1228. {
  1229. PCC pcc = strCommandLine;
  1230. CommandLineToken token(pcc, strCommandLine.GetLength());
  1231. while (token.MoreTokens()) {
  1232. ZString str;
  1233. if (token.IsMinus(str)) {
  1234. if (str == "test") {
  1235. bTest = true;
  1236. float value;
  1237. if (token.IsNumber(value)) {
  1238. initialTest = int(value);
  1239. }
  1240. break;
  1241. }
  1242. } else {
  1243. token.Skip();
  1244. }
  1245. }
  1246. }
  1247. //
  1248. // Create the window
  1249. //
  1250. m_pwindow = new MDLEditWindow(this, strCommandLine, bImageTest, bTest, initialTest);
  1251. //
  1252. // Parse the command line
  1253. //
  1254. {
  1255. PCC pcc = strCommandLine;
  1256. CommandLineToken token(pcc, strCommandLine.GetLength());
  1257. while (token.MoreTokens()) {
  1258. ZString strInput;
  1259. ZString str;
  1260. if (token.IsMinus(str)) {
  1261. if (str == "image") {
  1262. ZString strInput;
  1263. if (token.IsString(strInput)) {
  1264. m_pwindow->OpenImage(strInput);
  1265. return S_OK;
  1266. }
  1267. } else if (str == "test") {
  1268. float value;
  1269. if (token.IsNumber(value)) {
  1270. }
  1271. } else if (str == "imageTest") {
  1272. bImageTest = true;
  1273. }
  1274. /*
  1275. } else if (str == "client") {
  1276. m_pwindow->StartClient();
  1277. } else if (str == "server") {
  1278. m_pwindow->StartServer();
  1279. }
  1280. */
  1281. } else if (token.IsString(strInput)) {
  1282. PathString strPath(strInput);
  1283. if (strPath.GetExtension() == "x") {
  1284. m_pwindow->OpenXFile(strInput);
  1285. } else {
  1286. m_pwindow->OpenThingMDL(strInput, Vector(0, 0, 0));
  1287. }
  1288. return S_OK;
  1289. }
  1290. }
  1291. }
  1292. return S_OK;
  1293. }
  1294. void Terminate()
  1295. {
  1296. m_pwindow = NULL;
  1297. EffectApp::Terminate();
  1298. }
  1299. } g_app;