VehicleDemo.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 a physical vehicle with rigid bodies for the hull and the wheels, joined with constraints
  15. /// - Defining attributes (including node and component references) of a custom component so that it can be saved and loaded
  16. class VehicleDemo : public Sample
  17. {
  18. URHO3D_OBJECT(VehicleDemo, Sample);
  19. public:
  20. /// Construct.
  21. explicit VehicleDemo(Context* context);
  22. /// Setup after engine initialization and before running the main loop.
  23. void Start() override;
  24. private:
  25. /// Create static scene content.
  26. void CreateScene();
  27. /// Create the vehicle.
  28. void CreateVehicle();
  29. /// Construct an instruction text to the UI.
  30. void CreateInstructions();
  31. /// Subscribe to necessary events.
  32. void SubscribeToEvents();
  33. /// Handle application update. Set controls to vehicle.
  34. void HandleUpdate(StringHash eventType, VariantMap& eventData);
  35. /// Handle application post-update. Update camera position after vehicle has moved.
  36. void HandlePostUpdate(StringHash eventType, VariantMap& eventData);
  37. /// The controllable vehicle component.
  38. WeakPtr<Vehicle> vehicle_;
  39. };