ModelImporter.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. //
  2. // Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
  3. // LICENSE: Atomic Game Engine Editor and Tools EULA
  4. // Please see LICENSE_ATOMIC_EDITOR_AND_TOOLS.md in repository root for
  5. // license information: https://github.com/AtomicGameEngine/AtomicGameEngine
  6. //
  7. #pragma once
  8. #include "AssetImporter.h"
  9. namespace Atomic
  10. {
  11. class Node;
  12. class Animation;
  13. }
  14. using namespace Atomic;
  15. namespace ToolCore
  16. {
  17. class AnimationImportInfo : public Object
  18. {
  19. friend class ModelImporter;
  20. public:
  21. OBJECT(AnimationImportInfo);
  22. AnimationImportInfo(Context* context) : Object(context), startTime_(-1.0f), endTime_(-1.0f)
  23. {
  24. }
  25. const String& GetName() const { return name_; }
  26. float GetStartTime() const { return startTime_; }
  27. float GetEndTime() const { return endTime_; }
  28. void SetName(const String& name) { name_ = name; }
  29. void SetStartTime(float time) { startTime_ = time; }
  30. void SetEndTime(float time) { endTime_ = time; }
  31. private:
  32. String name_;
  33. float startTime_;
  34. float endTime_;
  35. };
  36. class ModelImporter : public AssetImporter
  37. {
  38. OBJECT(ModelImporter);
  39. public:
  40. /// Construct.
  41. ModelImporter(Context* context, Asset* asset);
  42. virtual ~ModelImporter();
  43. virtual void SetDefaults();
  44. double GetScale() { return scale_; }
  45. void SetScale(double scale) {scale_ = scale; }
  46. bool GetImportAnimations() { return importAnimations_; }
  47. void SetImportAnimations(bool importAnimations) { importAnimations_ = importAnimations; }
  48. unsigned GetAnimationCount();
  49. void SetAnimationCount(unsigned count);
  50. Resource* GetResource(const String& typeName = String::EMPTY);
  51. void GetAnimations(PODVector<Atomic::Animation *>& animations);
  52. AnimationImportInfo* GetAnimationInfo(unsigned index) { return animationInfo_[index]; }
  53. /// Instantiate a node from the asset
  54. Node* InstantiateNode(Node* parent, const String& name);
  55. protected:
  56. bool Import();
  57. bool ImportModel();
  58. bool ImportAnimations();
  59. bool ImportAnimation(const String &filename, const String& name, float startTime=-1.0f, float endTime=-1.0f);
  60. virtual bool LoadSettingsInternal(JSONValue& jsonRoot);
  61. virtual bool SaveSettingsInternal(JSONValue& jsonRoot);
  62. double scale_;
  63. bool importAnimations_;
  64. Vector<SharedPtr<AnimationImportInfo>> animationInfo_;
  65. SharedPtr<Node> importNode_;
  66. };
  67. }