Decals.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. //
  2. // Copyright (c) 2008-2016 the Urho3D project.
  3. // Copyright (c) 2014-2016, THUNDERBEAST GAMES LLC All rights reserved
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to deal
  7. // in the Software without restriction, including without limitation the rights
  8. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. // copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. // THE SOFTWARE.
  22. //
  23. #pragma once
  24. #include "Sample.h"
  25. namespace Atomic
  26. {
  27. class Drawable;
  28. class Node;
  29. class Scene;
  30. }
  31. /// Decals example.
  32. /// This sample demonstrates:
  33. /// - Performing a raycast to the octree and adding a decal to the hit location
  34. /// - Defining a Cursor UI element which stays inside the window and can be shown/hidden
  35. /// - Marking suitable (large) objects as occluders for occlusion culling
  36. /// - Displaying renderer debug geometry to see the effect of occlusion
  37. class Decals : public Sample
  38. {
  39. ATOMIC_OBJECT(Decals, Sample)
  40. public:
  41. /// Construct.
  42. Decals(Context* context);
  43. /// Setup after engine initialization and before running the main loop.
  44. virtual void Start();
  45. protected:
  46. private:
  47. /// Construct the scene content.
  48. void CreateScene();
  49. /// Construct user interface elements.
  50. void CreateUI();
  51. /// Set up a viewport for displaying the scene.
  52. void SetupViewport();
  53. /// Subscribe to application-wide logic update and post-render update events.
  54. void SubscribeToEvents();
  55. /// Reads input and moves the camera.
  56. void MoveCamera(float timeStep);
  57. /// Paint a decal using a ray cast from the mouse cursor.
  58. void PaintDecal();
  59. /// Utility function to raycast to the cursor position. Return true if hit
  60. bool Raycast(float maxDistance, Vector3& hitPos, Drawable*& hitDrawable);
  61. /// Handle the logic update event.
  62. void HandleUpdate(StringHash eventType, VariantMap& eventData);
  63. /// Handle the post-render update event.
  64. void HandlePostRenderUpdate(StringHash eventType, VariantMap& eventData);
  65. /// Flag for drawing debug geometry.
  66. bool drawDebug_;
  67. };