MeshComponent.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #include <AnKi/Scene/Components/MeshComponent.h>
  6. #include <AnKi/Resource/ResourceManager.h>
  7. #include <AnKi/Resource/MeshResource.h>
  8. namespace anki {
  9. MeshComponent::MeshComponent(SceneNode* node)
  10. : SceneComponent(node, kClassType)
  11. {
  12. }
  13. MeshComponent::~MeshComponent()
  14. {
  15. }
  16. MeshComponent& MeshComponent::setMeshFilename(CString fname)
  17. {
  18. MeshResourcePtr newRsrc;
  19. const Error err = ResourceManager::getSingleton().loadResource(fname, newRsrc);
  20. if(err)
  21. {
  22. ANKI_SCENE_LOGE("Failed to load resource: %s", fname.cstr());
  23. }
  24. else
  25. {
  26. m_resource = newRsrc;
  27. m_resourceDirty = true;
  28. }
  29. return *this;
  30. }
  31. CString MeshComponent::getMeshFilename() const
  32. {
  33. return (m_resource) ? m_resource->getFilename() : "*Error*";
  34. }
  35. void MeshComponent::update([[maybe_unused]] SceneComponentUpdateInfo& info, Bool& updated)
  36. {
  37. updated = m_resourceDirty;
  38. m_resourceDirty = false;
  39. }
  40. } // end namespace anki