ModelImporter.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. }
  13. using namespace Atomic;
  14. namespace ToolCore
  15. {
  16. class AnimationImportInfo : public Object
  17. {
  18. friend class ModelImporter;
  19. public:
  20. OBJECT(AnimationImportInfo);
  21. AnimationImportInfo(Context* context) : Object(context), startTime_(-1.0f), endTime_(-1.0f)
  22. {
  23. }
  24. const String& GetName() const { return name_; }
  25. float GetStartTime() const { return startTime_; }
  26. float GetEndTime() const { return endTime_; }
  27. void SetName(const String& name) { name_ = name; }
  28. void SetStartTime(float time) { startTime_ = time; }
  29. void SetEndTime(float time) { endTime_ = time; }
  30. private:
  31. String name_;
  32. float startTime_;
  33. float endTime_;
  34. };
  35. class ModelImporter : public AssetImporter
  36. {
  37. OBJECT(ModelImporter);
  38. public:
  39. /// Construct.
  40. ModelImporter(Context* context, Asset* asset);
  41. virtual ~ModelImporter();
  42. virtual void SetDefaults();
  43. double GetScale() { return scale_; }
  44. void SetScale(double scale) {scale_ = scale; }
  45. bool GetImportAnimations() { return importAnimations_; }
  46. void SetImportAnimations(bool importAnimations) { importAnimations_ = importAnimations; }
  47. unsigned GetAnimationCount();
  48. void SetAnimationCount(unsigned count);
  49. Resource* GetResource(const String& typeName = String::EMPTY);
  50. AnimationImportInfo* GetAnimationInfo(unsigned index) { return animationInfo_[index]; }
  51. /// Instantiate a node from the asset
  52. Node* InstantiateNode(Node* parent, const String& name);
  53. protected:
  54. bool Import();
  55. bool ImportModel();
  56. bool ImportAnimations();
  57. bool ImportAnimation(const String &filename, const String& name, float startTime=-1.0f, float endTime=-1.0f);
  58. virtual bool LoadSettingsInternal(JSONValue& jsonRoot);
  59. virtual bool SaveSettingsInternal(JSONValue& jsonRoot);
  60. double scale_;
  61. bool importAnimations_;
  62. Vector<SharedPtr<AnimationImportInfo>> animationInfo_;
  63. SharedPtr<Node> importNode_;
  64. };
  65. }