MeshComponent.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. class MeshComponent : public Component
  11. {
  12. public:
  13. MeshComponent(class Actor* owner, bool isSkeletal = false);
  14. ~MeshComponent();
  15. // Draw this mesh component
  16. virtual void Draw(class Shader* shader);
  17. // Set the mesh/texture index used by mesh component
  18. virtual void SetMesh(class Mesh* mesh) { mMesh = mesh; }
  19. void SetTextureIndex(size_t index) { mTextureIndex = index; }
  20. void SetVisible(bool visible) { mVisible = visible; }
  21. bool GetVisible() const { return mVisible; }
  22. bool GetIsSkeletal() const { return mIsSkeletal; }
  23. TypeID GetType() const override { return TMeshComponent; }
  24. void LoadProperties(const rapidjson::Value& inObj) override;
  25. void SaveProperties(rapidjson::Document::AllocatorType& alloc,
  26. rapidjson::Value& inObj) const override;
  27. protected:
  28. class Mesh* mMesh;
  29. size_t mTextureIndex;
  30. bool mVisible;
  31. bool mIsSkeletal;
  32. };