OffMeshConnection.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. //
  2. // Copyright (c) 2008-2017 the Urho3D project.
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. #pragma once
  23. #include "../Scene/Component.h"
  24. namespace Urho3D
  25. {
  26. /// A link between otherwise unconnected regions of the navigation mesh.
  27. class URHO3D_API OffMeshConnection : public Component
  28. {
  29. URHO3D_OBJECT(OffMeshConnection, Component);
  30. public:
  31. /// Construct.
  32. OffMeshConnection(Context* context);
  33. /// Destruct.
  34. virtual ~OffMeshConnection();
  35. /// Register object factory.
  36. static void RegisterObject(Context* context);
  37. /// Handle attribute write access.
  38. virtual void OnSetAttribute(const AttributeInfo& attr, const Variant& src);
  39. /// Apply attribute changes that can not be applied immediately. Called after scene load or a network update.
  40. virtual void ApplyAttributes();
  41. /// Visualize the component as debug geometry.
  42. virtual void DrawDebugGeometry(DebugRenderer* debug, bool depthTest);
  43. /// Set endpoint node.
  44. void SetEndPoint(Node* node);
  45. /// Set radius.
  46. void SetRadius(float radius);
  47. /// Set bidirectional flag. Default true.
  48. void SetBidirectional(bool enabled);
  49. /// Set a user assigned mask
  50. void SetMask(unsigned newMask);
  51. /// Sets the assigned area Id for the connection
  52. void SetAreaID(unsigned newAreaID);
  53. /// Return endpoint node.
  54. Node* GetEndPoint() const;
  55. /// Return radius.
  56. float GetRadius() const { return radius_; }
  57. /// Return whether is bidirectional.
  58. bool IsBidirectional() const { return bidirectional_; }
  59. /// Return the user assigned mask
  60. unsigned GetMask() const { return mask_; }
  61. /// Return the user assigned area ID
  62. unsigned GetAreaID() const { return areaId_; }
  63. private:
  64. /// Endpoint node.
  65. WeakPtr<Node> endPoint_;
  66. /// Endpoint node ID.
  67. unsigned endPointID_;
  68. /// Radius.
  69. float radius_;
  70. /// Bidirectional flag.
  71. bool bidirectional_;
  72. /// Endpoint changed flag.
  73. bool endPointDirty_;
  74. /// Flags mask to represent properties of this mesh
  75. unsigned mask_;
  76. /// Area id to be used for this off mesh connection's internal poly
  77. unsigned areaId_;
  78. };
  79. }