PageRenderTime 48ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/Rendering/EffectTests/Effect3DTests.cs

#
C# | 744 lines | 554 code | 55 blank | 135 comment | 13 complexity | 901cd155e19ef150f653808a68145117 MD5 | raw file
Possible License(s): Apache-2.0
  1. using Delta.ContentSystem.Rendering;
  2. using Delta.ContentSystem.Rendering.Helpers;
  3. using Delta.Engine;
  4. using Delta.InputSystem;
  5. using Delta.Rendering.Basics.Drawing;
  6. using Delta.Rendering.Basics.Fonts;
  7. using Delta.Rendering.Cameras;
  8. using Delta.Rendering.Effects;
  9. using Delta.Rendering.Effects.Modifiers;
  10. using Delta.Rendering.Enums;
  11. using Delta.Rendering.Models;
  12. using Delta.Utilities.Datatypes;
  13. using Delta.Utilities.Helpers;
  14. using Delta.Utilities.Math;
  15. using NUnit.Framework;
  16. namespace Delta.Rendering.EffectTests
  17. {
  18. /// <summary>
  19. /// Effect test in 3D space.
  20. /// </summary>
  21. [Category("Visual")]
  22. internal class Effect3DTests
  23. {
  24. #region Helpers
  25. /// <summary>
  26. /// The default 3d material modifier, so we don't have to write the code
  27. /// in every test again.
  28. /// </summary>
  29. public static readonly MaterialModifier Default3DMaterialModifier =
  30. new MaterialModifier
  31. {
  32. Material = new MaterialColored("DeltaEngineLogo")
  33. {
  34. DrawLayer = RenderLayer.Normal,
  35. BlendColor = Color.White,
  36. },
  37. BillboardMode = BillboardMode.CameraFacingPrecise,
  38. };
  39. #endregion
  40. #region SimpleEffect3D (Static)
  41. /// <summary>
  42. /// Spawn simple effect
  43. /// </summary>
  44. [Test]
  45. public static void SimpleEffect3D()
  46. {
  47. // Create a default camera.
  48. LookAtCamera cam = new LookAtCamera(new Vector(1, -5, 3));
  49. // Create a new template.
  50. EffectData data = EffectData.Get("<SimpleEffect3D>");
  51. // Add one emitter and some modifiers.
  52. EmitterData emitter = new EmitterData();
  53. emitter.Modifiers.Add(new AlwaysSpawnModifier());
  54. emitter.Modifiers.Add(Default3DMaterialModifier);
  55. emitter.Modifiers.Add(new RotationModifier
  56. {
  57. Rotation = new Range(0.0f, 360.0f),
  58. });
  59. emitter.Modifiers.Add(new VelocityModifier
  60. {
  61. Velocity = new Vector(0f, 0f, 1f)
  62. });
  63. emitter.Modifiers.Add(new SizeModifier
  64. {
  65. WidthRange = new Range(0.2f, 4f),
  66. HeightRange = new Range(0.1f, 2f),
  67. });
  68. data.Emitters.Add(emitter);
  69. // Spawn the effect.
  70. int effectId = Effect.Spawn(data, Vector.Zero);
  71. // Start the application.
  72. Application.Start(delegate
  73. {
  74. // Draw a grid for orientation.
  75. Grid.Draw();
  76. if (Input.Keyboard.EnterReleased ||
  77. Input.Touch.TouchReleased)
  78. {
  79. if (effectId == MathHelper.InvalidIndex)
  80. {
  81. effectId = Effect.Spawn(data, Vector.Zero);
  82. }
  83. else
  84. {
  85. Effect.Stop(effectId);
  86. effectId = MathHelper.InvalidIndex;
  87. }
  88. }
  89. });
  90. }
  91. #endregion
  92. #region ElapsingEffect3D (Static)
  93. /// <summary>
  94. /// Spawn elapsing effect 3d
  95. /// </summary>
  96. [Test]
  97. public static void ElapsingEffect3D()
  98. {
  99. // Create a default camera.
  100. LookAtCamera cam = new LookAtCamera(new Vector(1, -5, 3));
  101. // Create a new template.
  102. EffectData data = EffectData.Get("<ElapsingEffect3D>");
  103. // Add an emitter and modifiers.
  104. EmitterData emitter = new EmitterData();
  105. emitter.Modifiers.Add(new AlwaysSpawnModifier());
  106. emitter.Modifiers.Add(Default3DMaterialModifier);
  107. emitter.Modifiers.Add(new VelocityModifier
  108. {
  109. Velocity = new Vector(0f, 0f, 1f)
  110. });
  111. emitter.Modifiers.Add(new TimeRangeModifier
  112. {
  113. TimeRange = new Range(0f, 5f),
  114. });
  115. data.Emitters.Add(emitter);
  116. int effectId = Effect.Spawn(data, Vector.Zero);
  117. // Start the application.
  118. Application.Start(delegate
  119. {
  120. // Draw a grid for orientation.
  121. Grid.Draw();
  122. });
  123. }
  124. #endregion
  125. #region BillboardModeTest (Static)
  126. /// <summary>
  127. /// Test all the billboard modes.
  128. /// </summary>
  129. [Test]
  130. public static void BillboardModeTest()
  131. {
  132. // Create a default camera.
  133. LookAtCamera cam = new LookAtCamera(new Vector(1, -5, 3));
  134. BillboardMode currentMode = BillboardMode.CameraFacing;
  135. // Create the new effect template with the first billboard mode.
  136. EffectData data = EffectData.Get("<BillboardModeTest>");
  137. // Add an emitter and modifiers.
  138. EmitterData emitter = new EmitterData();
  139. emitter.Modifiers.Add(new AlwaysSpawnModifier());
  140. emitter.Modifiers.Add(new SizeModifier
  141. {
  142. HeightRange = new Range(10),
  143. WidthRange = new Range(15),
  144. });
  145. MaterialModifier materialModifier = Default3DMaterialModifier;
  146. materialModifier.BillboardMode = currentMode;
  147. emitter.Modifiers.Add(materialModifier);
  148. data.Emitters.Add(emitter);
  149. int effectId = Effect.Spawn(data, Vector.Zero);
  150. // Start the application.
  151. Application.Start(delegate
  152. {
  153. // Draw a grid for orientation.
  154. Grid.Draw();
  155. // Show which mode we're currently using.
  156. Font.Default.Draw("currentMode=" + currentMode,
  157. new Rectangle(0.0f, ScreenSpace.DrawArea.Top, 1.0f,
  158. Font.Default.LineHeight));
  159. // Every time we hit enter or release a touch we want to go to the
  160. // next billboard mode for easy debugging of all modes.
  161. if (Input.Keyboard.EnterReleased ||
  162. Input.Touch.TouchReleased)
  163. {
  164. // Go to the next mode
  165. currentMode = (BillboardMode)currentMode.Next();
  166. // Skip the only2D mode cause this is working in all the 2d tests
  167. // anyways.
  168. if (currentMode == BillboardMode.Only2D)
  169. {
  170. currentMode = (BillboardMode)currentMode.Next();
  171. }
  172. // Kill the previous effect if it exists.
  173. if (effectId != MathHelper.InvalidIndex)
  174. {
  175. Effect.Kill(effectId);
  176. }
  177. // Set the current mode and then spawn the new effect.
  178. materialModifier.BillboardMode = currentMode;
  179. effectId = Effect.Spawn(data, Vector.Zero);
  180. }
  181. });
  182. }
  183. #endregion
  184. #region BillboardModeTestDirect (Static)
  185. /// <summary>
  186. /// Test all the billboard modes directly over the BillboardManager
  187. /// without spawning an effect.
  188. /// </summary>
  189. [Test]
  190. public static void BillboardModeTestDirect()
  191. {
  192. // Create a default camera.
  193. LookAtCamera cam = new LookAtCamera(new Vector(1, -5, 3));
  194. BillboardMode currentMode = BillboardMode.CameraFacing;
  195. MaterialColored material = new MaterialColored("DeltaEngineLogo")
  196. {
  197. DrawLayer = RenderLayer.Normal,
  198. BlendColor = Color.White,
  199. billboardMode = currentMode,
  200. };
  201. // Start the application.
  202. Application.Start(delegate
  203. {
  204. // Draw a grid for orientation.
  205. Grid.Draw();
  206. Application.Window.Title = "currentMode=" + currentMode;
  207. // Every time we hit enter or release a touch we want to go to the
  208. // next billboard mode for easy debugging of all modes.
  209. if (Input.Keyboard.EnterReleased ||
  210. Input.Touch.TouchReleased)
  211. {
  212. // Go to the next mode
  213. currentMode = (BillboardMode)currentMode.Next();
  214. // Skip the only2D mode cause this is working in all the 2d tests
  215. // anyways.
  216. if (currentMode == BillboardMode.Only2D)
  217. {
  218. currentMode = (BillboardMode)currentMode.Next();
  219. }
  220. material.billboardMode = currentMode;
  221. }
  222. BillboardManager.Instance.Draw(material, Vector.Zero,
  223. new Size(5, 2.5f), 0f);
  224. BillboardManager.Instance.Draw(material, new Vector(0f, -10f, 0f),
  225. new Size(5, 2.5f), 0f);
  226. BillboardManager.Instance.Draw(material, new Vector(0f, 10f, 0f),
  227. new Size(5, 2.5f), 0f);
  228. });
  229. }
  230. #endregion
  231. #region FountainEffect3D (Static)
  232. /// <summary>
  233. /// Fountain effect 3D
  234. ///
  235. /// </summary>
  236. [Test]
  237. public static void FountainEffect3D()
  238. {
  239. // Set up camera
  240. LookAtCamera cam = new LookAtCamera(new Vector(1, -5, 3));
  241. // Create a new template.
  242. EffectData data = EffectData.Get("<FountainEffect3D>");
  243. // Add the emitters and modifiers.
  244. #region HeadEmitter
  245. EmitterData headEmitter = new EmitterData();
  246. headEmitter.Modifiers.AddRange(
  247. new IEffectModifier[]
  248. {
  249. new AlwaysSpawnModifier(),
  250. new SpawnIntervalModifier
  251. {
  252. SpawnInterval = 0.4f,
  253. },
  254. new VelocityModifier
  255. {
  256. Velocity = new VectorRange(Vector.UnitZ, -Vector.UnitZ),
  257. },
  258. new SizeModifier
  259. {
  260. WidthRange = 20f,
  261. HeightRange = 20f,
  262. },
  263. new ParticleLifetimeModifier
  264. {
  265. ParticleLifetime = 4f,
  266. },
  267. new RotationModifier
  268. {
  269. Rotation = new Range(0f, 360f),
  270. },
  271. new MaterialModifier
  272. {
  273. Material = new MaterialColored("SmokeSmallAdditive")
  274. {
  275. BlendColor = new Color(0.3f, 0.4f, 0.8f),
  276. },
  277. BillboardMode = BillboardMode.CameraFacingPrecise,
  278. },
  279. });
  280. data.Emitters.Add(headEmitter);
  281. #endregion
  282. #region MiddleSurfaceEmitter
  283. EmitterData middleSurfaceEmitter = new EmitterData();
  284. middleSurfaceEmitter.Modifiers.AddRange(
  285. new IEffectModifier[]
  286. {
  287. new AlwaysSpawnModifier(),
  288. new SpawnIntervalModifier
  289. {
  290. SpawnInterval = 0.3333f,
  291. },
  292. new SizeModifier
  293. {
  294. WidthRange = 60f,
  295. HeightRange = 60f,
  296. },
  297. new EmitterOffsetModifier
  298. {
  299. Offset = new Vector(0f, 0f, -1f),
  300. },
  301. new MaterialModifier
  302. {
  303. Material = new MaterialColored("SmokeSmallAdditive")
  304. {
  305. BlendColor = new Color(0.3f, 0.4f, 0.8f),
  306. },
  307. BillboardMode = BillboardMode.Ground,
  308. },
  309. });
  310. data.Emitters.Add(middleSurfaceEmitter);
  311. #endregion
  312. #region BottomSurfaceEmitter
  313. EmitterData bottomSurfaceEmitter = new EmitterData();
  314. bottomSurfaceEmitter.Modifiers.AddRange(
  315. new IEffectModifier[]
  316. {
  317. new AlwaysSpawnModifier(),
  318. new SpawnIntervalModifier
  319. {
  320. SpawnInterval = 0.3333f,
  321. },
  322. new SizeModifier
  323. {
  324. WidthRange = 150f,
  325. HeightRange = 150f,
  326. },
  327. new EmitterOffsetModifier
  328. {
  329. Offset = new Vector(0f, 0f, -4f),
  330. },
  331. new MaterialModifier
  332. {
  333. Material = new MaterialColored("SmokeSmallAdditive")
  334. {
  335. BlendColor = new Color(0.3f, 0.4f, 0.8f),
  336. },
  337. BillboardMode = BillboardMode.Ground,
  338. },
  339. });
  340. data.Emitters.Add(bottomSurfaceEmitter);
  341. #endregion
  342. Effect.Spawn(data, new Vector(0.0f, 0.0f, 4.5f));
  343. Matrix mat = Matrix.CreateScale(0.45f);
  344. Application.BackgroundColor = Color.Black;
  345. // Start the application.
  346. Application.Start(delegate
  347. {
  348. // Draw a grid for orientation and the fountain for the visual.
  349. Grid.Draw();
  350. });
  351. }
  352. #endregion
  353. #region SmokeEffect3D (Static)
  354. /// <summary>
  355. /// Smoke effect 3D
  356. /// </summary>
  357. [Test]
  358. public static void SmokeEffect3D()
  359. {
  360. // Set up camera
  361. LookAtCamera cam = new LookAtCamera(new Vector(1, -5, 3));
  362. // Create a new template.
  363. EffectData data = EffectData.Get("<SmokeEffect3D>");
  364. // Add an emitter and modifiers.
  365. EmitterData emitter = new EmitterData();
  366. emitter.Modifiers.Add(new SpawnIntervalModifier
  367. {
  368. SpawnInterval = 0.05f,
  369. });
  370. emitter.Modifiers.Add(new ParticleLifetimeModifier
  371. {
  372. ParticleLifetime = 7f
  373. });
  374. emitter.Modifiers.Add(new TimeRangeModifier
  375. {
  376. TimeRange = new Range(0f, float.PositiveInfinity),
  377. });
  378. Graph alphaGraph = new Graph();
  379. alphaGraph.Add(0f, 0f);
  380. alphaGraph.Add(0.2f, 1f);
  381. alphaGraph.Add(0.8f, 1f);
  382. alphaGraph.Add(1f, 0f);
  383. emitter.Modifiers.Add(new FadeModifier
  384. {
  385. AdvancedAlphaFade = alphaGraph,
  386. });
  387. emitter.Modifiers.Add(new MaterialModifier
  388. {
  389. Material = new MaterialColored("SmokeAdditive"),
  390. BillboardMode = BillboardMode.CameraFacingPrecise
  391. });
  392. emitter.Modifiers.Add(new SizeModifier
  393. {
  394. WidthRange = new Range(10f, 12f),
  395. HeightRange = new Range(10f, 12f),
  396. });
  397. emitter.Modifiers.Add(new RandomVelocityModifier
  398. {
  399. MinVelocity = new Vector(-0.1f, -0.3f, 0.4f),
  400. MaxVelocity = new Vector(0.3f, 0.3f, 0.4f),
  401. });
  402. data.Emitters.Add(emitter);
  403. Effect.Spawn(data, Vector.Zero);
  404. // Start the application.
  405. Application.Start(delegate
  406. {
  407. // Draw a grid for orientation.
  408. Grid.Draw();
  409. });
  410. }
  411. #endregion
  412. #region GroundMistEffect3D (Static)
  413. /// <summary>
  414. /// Mist effect 3D
  415. /// </summary>
  416. [Test]
  417. public static void GroundMistEffect3D()
  418. {
  419. // Set up camera
  420. LookAtCamera cam = new LookAtCamera(new Vector(1, -5, 3));
  421. // Create a new template.
  422. EffectData data = EffectData.Get("<GroundMistEffect3D>");
  423. // Add an emitter and modifiers.
  424. EmitterData emitter = new EmitterData();
  425. emitter.Modifiers.Add(new SpawnIntervalModifier
  426. {
  427. SpawnInterval = 0.1f,
  428. });
  429. emitter.Modifiers.Add(new ParticleLifetimeModifier
  430. {
  431. ParticleLifetime = 5f,
  432. });
  433. emitter.Modifiers.Add(new TimeRangeModifier
  434. {
  435. TimeRange = new Range(0f, float.PositiveInfinity),
  436. });
  437. Graph alphaGraph = new Graph();
  438. alphaGraph.Add(0f, 0f);
  439. alphaGraph.Add(0.5f, 0.4f);
  440. alphaGraph.Add(1f, 0f);
  441. emitter.Modifiers.Add(new FadeModifier
  442. {
  443. AdvancedAlphaFade = alphaGraph,
  444. });
  445. emitter.Modifiers.Add(new MaterialModifier
  446. {
  447. Material = new MaterialColored("SmokeAdditive")
  448. {
  449. BlendColor = new Color(1f, 1f, 1f),
  450. },
  451. BillboardMode = BillboardMode.Ground,
  452. });
  453. emitter.Modifiers.Add(new RandomVelocityModifier
  454. {
  455. MinVelocity = new Vector(-0.2f, -0.2f, 0f),
  456. MaxVelocity = new Vector(0.2f, 0.2f, 0f),
  457. });
  458. emitter.Modifiers.Add(new RandomSpawnOffsetModifier
  459. {
  460. MinOffset = new Vector(-5f, -5f, -0.1f),
  461. MaxOffset = new Vector(5f, 5f, 0.1f),
  462. });
  463. emitter.Modifiers.Add(new SizeModifier
  464. {
  465. WidthRange = new Range(20f, 25f),
  466. HeightRange = new Range(20f, 25f),
  467. });
  468. data.Emitters.Add(emitter);
  469. Effect.Spawn(data, new Vector(0.0f, 0.0f, 0.2f));
  470. MaterialColored planeMat = new MaterialColored(
  471. "InnerGroundBestHighMediumLowDiffuse");
  472. // Start the application.
  473. Application.Start(delegate
  474. {
  475. // Draw a sky and a plane for orientation.
  476. Sky.Draw();
  477. BillboardManager.Instance.DrawPlane(planeMat);
  478. });
  479. }
  480. #endregion
  481. #region SwordClashEffect3D (Static)
  482. /// <summary>
  483. /// Sword clash effect 3D
  484. /// </summary>
  485. [Test]
  486. public static void SwordClashEffect3D()
  487. {
  488. // Set up camera
  489. LookAtCamera cam = new LookAtCamera(new Vector(1, -5, 3));
  490. // Create a new template.
  491. EffectData data = EffectData.Get("<SwordClashEffect3D>");
  492. // Add an emitter and modifiers.
  493. EmitterData emitter = new EmitterData();
  494. emitter.Modifiers.Add(new SpawnOnceModifier());
  495. emitter.Modifiers.Add(new ParticleLifetimeModifier
  496. {
  497. ParticleLifetime = 0.1f,
  498. });
  499. emitter.Modifiers.Add(new MaterialModifier
  500. {
  501. Material = new MaterialColored("WaterSplatterAdditive")
  502. {
  503. BlendColor = new Color(0.6f, 0.6f, 0.2f),
  504. },
  505. BillboardMode = BillboardMode.CameraFacingPrecise,
  506. });
  507. emitter.Modifiers.Add(new VelocityModifier
  508. {
  509. Velocity = new VectorRange(new Vector(-0.5f, -0.5f, 0f),
  510. new Vector(0.5f, 0.5f, 0f)),
  511. });
  512. emitter.Modifiers.Add(new SizeModifier
  513. {
  514. WidthRange = new Range(3f, 10f),
  515. HeightRange = new Range(3f, 10f),
  516. });
  517. emitter.Modifiers.Add(new RotationModifier
  518. {
  519. Rotation = new Range(0f, 360f),
  520. });
  521. data.Emitters.Add(emitter);
  522. // Start the application.
  523. Application.Start(delegate
  524. {
  525. // Draw a grid for orientation.
  526. Grid.Draw();
  527. if (Input.Keyboard.EnterReleased)
  528. {
  529. Effect.Spawn(data, new Vector(0.0f, 0.0f, 0.1f));
  530. }
  531. });
  532. }
  533. #endregion
  534. #region FireEffect3D (Static)
  535. /// <summary>
  536. /// Fire effect 3D
  537. /// </summary>
  538. [Test]
  539. public static void FireEffect3D()
  540. {
  541. // Set up camera
  542. LookAtCamera cam = new LookAtCamera(new Vector(1, -5, 3));
  543. // Create a new template.
  544. EffectData data = EffectData.Get("<FireEffect3D>");
  545. // Add emitters and modifiers.
  546. EmitterData emitter = new EmitterData();
  547. emitter.Modifiers.Add(new SpawnIntervalModifier
  548. {
  549. SpawnInterval = 0.05f,
  550. });
  551. emitter.Modifiers.Add(new ParticleLifetimeModifier
  552. {
  553. ParticleLifetime = 1.2f
  554. });
  555. emitter.Modifiers.Add(new TimeRangeModifier
  556. {
  557. TimeRange = new Range(0f, float.PositiveInfinity),
  558. });
  559. Graph alphaFade = new Graph();
  560. alphaFade.Add(0f, 0f);
  561. alphaFade.Add(0.2f, 1f);
  562. alphaFade.Add(0.8f, 1f);
  563. alphaFade.Add(1f, 0f);
  564. emitter.Modifiers.Add(new FadeModifier
  565. {
  566. AdvancedAlphaFade = alphaFade,
  567. });
  568. emitter.Modifiers.Add(new SizeModifier
  569. {
  570. WidthRange = new Range(10f, 0.05f),
  571. HeightRange = new Range(10f, 0.05f),
  572. });
  573. emitter.Modifiers.Add(new MaterialModifier
  574. {
  575. Material = new MaterialColored("SmokeAdditive")
  576. {
  577. BlendColor = new Color(0.6f, 0.3f, 0f),
  578. },
  579. BillboardMode = BillboardMode.CameraFacingPrecise,
  580. });
  581. emitter.Modifiers.Add(new RandomSpawnOffsetModifier
  582. {
  583. MinOffset = new Vector(-0.05f, -0.05f, 0f),
  584. MaxOffset = new Vector(0.05f, 0.05f, 0f),
  585. });
  586. emitter.Modifiers.Add(new RandomVelocityModifier
  587. {
  588. MinVelocity = new Vector(-0.1f, -0.1f, 1f),
  589. MaxVelocity = new Vector(0.1f, 0.1f, 1f),
  590. });
  591. data.Emitters.Add(emitter);
  592. Effect.Spawn(data, Vector.Zero);
  593. // Start the application.
  594. Application.Start(delegate
  595. {
  596. // Draw a grid for orientation.
  597. Grid.Draw();
  598. });
  599. }
  600. #endregion
  601. #region BloodSplatterEffect3D (Static)
  602. /// <summary>
  603. /// Blood splatter effect 3D
  604. /// </summary>
  605. [Test]
  606. public static void BloodSplatterEffect3D()
  607. {
  608. // Set up camera
  609. LookAtCamera cam = new LookAtCamera(new Vector(1, -5, 3));
  610. // Create a new template.
  611. EffectData data = EffectData.Get("<BloodSplatterEffect3D>");
  612. // Add an emitter and modifiers.
  613. EmitterData emitter = new EmitterData();
  614. emitter.Modifiers.Add(new SpawnOnceModifier());
  615. emitter.Modifiers.Add(new ParticleLifetimeModifier
  616. {
  617. ParticleLifetime = 0.5f,
  618. });
  619. emitter.Modifiers.Add(new MaterialModifier
  620. {
  621. Material = new MaterialColored("BloodPoints")
  622. {
  623. BlendColor = new Color(0.6f, 0.6f, 0.2f),
  624. },
  625. BillboardMode = BillboardMode.CameraFacingPrecise,
  626. });
  627. emitter.Modifiers.Add(new VelocityModifier
  628. {
  629. Velocity = new VectorRange(new Vector(-0.5f, -0.5f, 0f),
  630. new Vector(0.5f, 0.5f, 0f)),
  631. });
  632. emitter.Modifiers.Add(new SizeModifier
  633. {
  634. WidthRange = new Range(3f, 10f),
  635. HeightRange = new Range(3f, 10f),
  636. });
  637. emitter.Modifiers.Add(new RotationModifier
  638. {
  639. Rotation = new Range(0f, 180f),
  640. });
  641. data.Emitters.Add(emitter);
  642. // Start the application.
  643. Application.Start(delegate
  644. {
  645. // Draw a grid for orientation.
  646. Grid.Draw();
  647. if (Input.Keyboard.EnterReleased)
  648. {
  649. // Spawn the effect.
  650. Effect.Spawn(data, new Vector(0.0f, 0.0f, 0.1f));
  651. }
  652. });
  653. }
  654. #endregion
  655. ///// <summary>
  656. ///// Lens flare effect 3D, together with a sun
  657. ///// </summary>
  658. //public static void LensFlareEffect3D()
  659. //{
  660. // // Set up camera
  661. // LookAtCamera cam = new LookAtCamera(new Vector(-2, -5, -5));
  662. // // Sun position taken from max scene.
  663. // // Skydome needs to be changed to fit it. Note: Is changed now!
  664. // Light.Direction = Light.SoulcraftTechDemoLightDirection;
  665. // Light.Direction.Normalize();
  666. // // Setup Lens Flare effect
  667. // LensFlareEffect effect = new LensFlareEffect("LensFlareEffect",
  668. // new Material2DColored("PentagonAdditive"),
  669. // new Material2DColored("LensflareETransparency"));
  670. // // Setup Glare effect
  671. // effect.GlareMaterial = new Material2DColored("SunBlendAdditive");
  672. // // And activate it
  673. // effect.Activate();
  674. // Application.Start(delegate
  675. // {
  676. // Sky.Draw();
  677. // Grid.Draw();
  678. // // Calculate positions for debug (same math as in LensFlareEffect)
  679. // Vector sunPosition =
  680. // Light.GetLightPosition(ScreenSpace.ViewInverse.Translation, 50.0f);
  681. // Vector sunScreenPosition = ScreenSpace.Project(sunPosition);
  682. // Font infoFont = Font.Default;
  683. // float yPos = ScreenSpace.Area.Top + infoFont.LineHeight;
  684. // infoFont.Write(new Point(0.5f, yPos),
  685. // "SunScreenPosition= " + sunScreenPosition);
  686. // });
  687. //}
  688. }
  689. }