ModelNode.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Copyright (C) 2009-2016, Panagiotis Christopoulos Charitos.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #pragma once
  6. #include <anki/scene/SceneNode.h>
  7. #include <anki/scene/RenderComponent.h>
  8. #include <anki/scene/MoveComponent.h>
  9. #include <anki/scene/SpatialComponent.h>
  10. #include <anki/resource/Model.h>
  11. #include <anki/collision/Obb.h>
  12. namespace anki
  13. {
  14. // Forward
  15. class ObbSpatialComponent;
  16. class BodyComponent;
  17. /// @addtogroup scene
  18. /// @{
  19. /// A fragment of the ModelNode
  20. class ModelPatchNode : public SceneNode
  21. {
  22. friend class ModelNode;
  23. friend class ModelPatchRenderComponent;
  24. public:
  25. ModelPatchNode(SceneGraph* scene);
  26. ~ModelPatchNode();
  27. ANKI_USE_RESULT Error create(
  28. const CString& name, const ModelPatch* modelPatch);
  29. private:
  30. Obb m_obb; ///< In world space. ModelNode will update it.
  31. const ModelPatch* m_modelPatch = nullptr; ///< The resource
  32. ANKI_USE_RESULT Error buildRendering(RenderingBuildInfo& data) const;
  33. };
  34. /// The model scene node
  35. class ModelNode : public SceneNode
  36. {
  37. friend class ModelPatchNode;
  38. friend class ModelMoveFeedbackComponent;
  39. public:
  40. ModelNode(SceneGraph* scene);
  41. ~ModelNode();
  42. ANKI_USE_RESULT Error create(
  43. const CString& name, const CString& modelFname);
  44. const Model& getModel() const
  45. {
  46. return *m_model;
  47. }
  48. private:
  49. ModelResourcePtr m_model; ///< The resource
  50. DArray<ModelPatchNode*> m_modelPatches;
  51. void onMoveComponentUpdate(MoveComponent& move);
  52. };
  53. /// @}
  54. } // end namespace anki