Advertisement
WaveEngine

Lighting demo source code

Feb 13th, 2013
209
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.84 KB | None
  1. // Copyright (C) 2012-2013 Weekend Game Studio
  2. //
  3. // Permission is hereby granted, free of charge, to any person obtaining a copy
  4. // of this software and associated documentation files (the "Software"), to
  5. // deal in the Software without restriction, including without limitation the
  6. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  7. // sell copies of the Software, and to permit persons to whom the Software is
  8. // furnished to do so, subject to the following conditions:
  9. //
  10. // The above copyright notice and this permission notice shall be included in
  11. // all copies or substantial portions of the Software.
  12. //
  13. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  16. // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  18. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  19. // IN THE SOFTWARE.
  20.  
  21. #region Using Statements
  22. using System;
  23. using WaveEngine.Common;
  24. using WaveEngine.Common.Graphics;
  25. using WaveEngine.Common.Math;
  26. using WaveEngine.Components;
  27. using WaveEngine.Components.Cameras;
  28. using WaveEngine.Components.Graphics3D;
  29. using WaveEngine.Framework;
  30. using WaveEngine.Framework.Graphics;
  31. using WaveEngine.Framework.Services;
  32. using WaveEngine.Materials;
  33. #endregion
  34.  
  35. namespace LightingProject
  36. {
  37.     public class Game : WaveEngine.Framework.Game
  38.     {
  39.         public override void Initialize(IAdapter adapter)
  40.         {
  41.             base.Initialize(adapter);
  42.  
  43.             ScreenLayers screenLayers = WaveServices.ScreenLayers;
  44.             screenLayers.AddScene<MyScene>();
  45.             screenLayers.Apply();
  46.         }
  47.     }
  48.  
  49.     public class MyScene : Scene
  50.     {
  51.         protected override void CreateScene()
  52.         {
  53.             RenderManager.BackgroundColor = Color.CornflowerBlue;
  54.             RenderManager.DebugLines = true;
  55.  
  56.             FreeCamera camera = new FreeCamera("MainCamera", new Vector3(0, 20, 30), Vector3.Zero);
  57.             EntityManager.Add(camera.Entity);
  58.  
  59.  
  60.             DirectionalLight skylight = new DirectionalLight("SkyLight", new Vector3(1));
  61.             EntityManager.Add(skylight);
  62.  
  63.             Entity sphere = new Entity("Sphere")
  64.                 .AddComponent(new Transform3D() { Scale = new Vector3(10f) })
  65.                 .AddComponent(new Spinner() { AxisTotalIncreases = new Vector3(0, 1, 0) })
  66.                 .AddComponent(Model.CreateSphere())
  67.                 .AddComponent(new MaterialsMap(new BasicMaterial("Content/tile1.wpk") { LightingEnabled = true}))
  68.                 .AddComponent(new ModelRenderer());
  69.  
  70.             EntityManager.Add(sphere);
  71.         }
  72.     }
  73. }
Advertisement
RAW Paste Data Copied
Advertisement