BoxComponent.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. // ----------------------------------------------------------------
  2. // From Game Programming in C++ by Sanjay Madhav
  3. // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
  4. //
  5. // Released under the BSD License
  6. // See LICENSE in root directory for full details.
  7. // ----------------------------------------------------------------
  8. #pragma once
  9. #include "Component.h"
  10. #include "Collision.h"
  11. class BoxComponent : public Component
  12. {
  13. public:
  14. BoxComponent(class Actor* owner, int updateOrder = 100);
  15. ~BoxComponent();
  16. void OnUpdateWorldTransform() override;
  17. void SetObjectBox(const AABB& model) { mObjectBox = model; }
  18. const AABB& GetWorldBox() const { return mWorldBox; }
  19. TypeID GetType() const override { return TBoxComponent; }
  20. void LoadProperties(const rapidjson::Value& inObj) override;
  21. void SaveProperties(rapidjson::Document::AllocatorType& alloc,
  22. rapidjson::Value& inObj) const override;
  23. void SetShouldRotate(bool value) { mShouldRotate = value; }
  24. private:
  25. AABB mObjectBox;
  26. AABB mWorldBox;
  27. bool mShouldRotate;
  28. };