Billboards.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // Copyright (c) 2008-2023 the Urho3D project
  2. // License: MIT
  3. #pragma once
  4. #include "Sample.h"
  5. namespace Urho3D
  6. {
  7. class Node;
  8. class Scene;
  9. }
  10. /// Billboard example.
  11. /// This sample demonstrates:
  12. /// - Populating a 3D scene with billboard sets and several shadow casting spotlights
  13. /// - Parenting scene nodes to allow more intuitive creation of groups of objects
  14. /// - Examining rendering performance with a somewhat large object and light count
  15. class Billboards : public Sample
  16. {
  17. URHO3D_OBJECT(Billboards, Sample);
  18. public:
  19. /// Construct.
  20. explicit Billboards(Context* context);
  21. /// Setup after engine initialization and before running the main loop.
  22. void Start() override;
  23. protected:
  24. /// Return XML patch instructions for screen joystick layout for a specific sample app, if any.
  25. String GetScreenJoystickPatchString() const override { return
  26. "<patch>"
  27. " <remove sel=\"/element/element[./attribute[@name='Name' and @value='Button1']]/attribute[@name='Is Visible']\" />"
  28. " <replace sel=\"/element/element[./attribute[@name='Name' and @value='Button1']]/element[./attribute[@name='Name' and @value='Label']]/attribute[@name='Text']/@value\">Debug</replace>"
  29. " <add sel=\"/element/element[./attribute[@name='Name' and @value='Button1']]\">"
  30. " <element type=\"Text\">"
  31. " <attribute name=\"Name\" value=\"KeyBinding\" />"
  32. " <attribute name=\"Text\" value=\"SPACE\" />"
  33. " </element>"
  34. " </add>"
  35. "</patch>";
  36. }
  37. private:
  38. /// Construct the scene content.
  39. void CreateScene();
  40. /// Construct an instruction text to the UI.
  41. void CreateInstructions();
  42. /// Set up a viewport for displaying the scene.
  43. void SetupViewport();
  44. /// Subscribe to application-wide logic update and post-render update events.
  45. void SubscribeToEvents();
  46. /// Read input and moves the camera.
  47. void MoveCamera(float timeStep);
  48. /// Animate the scene.
  49. void AnimateScene(float timeStep);
  50. /// Handle the logic update event.
  51. void HandleUpdate(StringHash eventType, VariantMap& eventData);
  52. /// Handle the post-render update event.
  53. void HandlePostRenderUpdate(StringHash eventType, VariantMap& eventData);
  54. /// Flag for drawing debug geometry.
  55. bool drawDebug_;
  56. };