RaycastVehicleDemo.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. class Vehicle;
  11. /// Vehicle example.
  12. /// This sample demonstrates:
  13. /// - Creating a heightmap terrain with collision
  14. /// - Constructing 100 raycast vehicles
  15. /// - Defining attributes (including node and component references) of a custom component
  16. /// (Saving and loading is broken now)
  17. class RaycastVehicleDemo : public Sample
  18. {
  19. URHO3D_OBJECT(RaycastVehicleDemo, Sample);
  20. public:
  21. /// Construct.
  22. explicit RaycastVehicleDemo(Context* context);
  23. /// Setup after engine initialization and before running the main loop.
  24. void Start() override;
  25. private:
  26. /// Create static scene content.
  27. void CreateScene();
  28. /// Create the vehicle.
  29. void CreateVehicle();
  30. /// Construct an instruction text to the UI.
  31. void CreateInstructions();
  32. /// Subscribe to necessary events.
  33. void SubscribeToEvents();
  34. /// Handle application update. Set controls to vehicle.
  35. void HandleUpdate(StringHash eventType, VariantMap& eventData);
  36. /// Handle application post-update. Update camera position after vehicle has moved.
  37. void HandlePostUpdate(StringHash eventType, VariantMap& eventData);
  38. /// The controllable vehicle component.
  39. WeakPtr<Vehicle> vehicle_;
  40. };