SkeletalAnimation.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. /// Skeletal animation example.
  11. /// This sample demonstrates:
  12. /// - Populating a 3D scene with skeletally animated AnimatedModel components;
  13. /// - Moving the animated models and advancing their animation using a custom component
  14. /// - Enabling a cascaded shadow map on a directional light, which allows high-quality shadows
  15. /// over a large area (typically used in outdoor scenes for shadows cast by sunlight)
  16. /// - Displaying renderer debug geometry
  17. class SkeletalAnimation : public Sample
  18. {
  19. URHO3D_OBJECT(SkeletalAnimation, Sample);
  20. public:
  21. /// Construct.
  22. explicit SkeletalAnimation(Context* context);
  23. /// Setup after engine initialization and before running the main loop.
  24. void Start() override;
  25. protected:
  26. /// Return XML patch instructions for screen joystick layout for a specific sample app, if any.
  27. String GetScreenJoystickPatchString() const override { return
  28. "<patch>"
  29. " <remove sel=\"/element/element[./attribute[@name='Name' and @value='Button1']]/attribute[@name='Is Visible']\" />"
  30. " <replace sel=\"/element/element[./attribute[@name='Name' and @value='Button1']]/element[./attribute[@name='Name' and @value='Label']]/attribute[@name='Text']/@value\">Debug</replace>"
  31. " <add sel=\"/element/element[./attribute[@name='Name' and @value='Button1']]\">"
  32. " <element type=\"Text\">"
  33. " <attribute name=\"Name\" value=\"KeyBinding\" />"
  34. " <attribute name=\"Text\" value=\"SPACE\" />"
  35. " </element>"
  36. " </add>"
  37. "</patch>";
  38. }
  39. private:
  40. /// Construct the scene content.
  41. void CreateScene();
  42. /// Construct an instruction text to the UI.
  43. void CreateInstructions();
  44. #ifdef URHO3D_GLES3
  45. /// Create additional lights fo scene
  46. void CreateLights();
  47. #endif
  48. /// Set up a viewport for displaying the scene.
  49. void SetupViewport();
  50. /// Subscribe to application-wide logic update and post-render update events.
  51. void SubscribeToEvents();
  52. /// Read input and moves the camera.
  53. void MoveCamera(float timeStep);
  54. /// Handle the logic update event.
  55. void HandleUpdate(StringHash eventType, VariantMap& eventData);
  56. /// Handle the post-render update event.
  57. void HandlePostRenderUpdate(StringHash eventType, VariantMap& eventData);
  58. /// Flag for drawing debug geometry.
  59. bool drawDebug_;
  60. };