SimpleApp.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Urho;
  7. using Urho.Shapes;
  8. namespace Playgrounds.Console
  9. {
  10. public class SimpleApp : Application
  11. {
  12. public SimpleApp(ApplicationOptions options) : base(options)
  13. {
  14. }
  15. public static void RunApp()
  16. {
  17. var app = new SimpleApp(new ApplicationOptions("Data"));
  18. app.Run();
  19. }
  20. protected override void Start()
  21. {
  22. var scene = new Scene();
  23. scene.CreateComponent<Octree>();
  24. scene.CreateComponent<Zone>().AmbientColor = new Color(0.3f, 0.3f, 0.3f);
  25. var lightNode = scene.CreateChild();
  26. lightNode.SetDirection(new Vector3(0.6f, -1.0f, 0.8f));
  27. var light = lightNode.CreateComponent<Light>();
  28. light.LightType = LightType.Directional;
  29. var child = scene.CreateChild();
  30. var box = child.CreateComponent<Box>();
  31. child.Position = new Vector3(0, 0, 5);
  32. var cloned = child.Clone(CreateMode.Replicated);
  33. cloned.Position = new Vector3(1, 0, 5);
  34. var bb = cloned.GetComponent<Box>();
  35. var leftEyeNode = scene.CreateChild();
  36. var leftEye = leftEyeNode.CreateComponent<Camera>();
  37. var leftVp = new Viewport(Context, scene, leftEye, null);
  38. Renderer.SetViewport(0, leftVp);
  39. }
  40. }
  41. }