ModelImporter.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #pragma once
  2. #include "AssetImporter.h"
  3. namespace Atomic
  4. {
  5. class Node;
  6. }
  7. using namespace Atomic;
  8. namespace ToolCore
  9. {
  10. class AnimationImportInfo : public Object
  11. {
  12. friend class ModelImporter;
  13. public:
  14. OBJECT(AnimationImportInfo);
  15. AnimationImportInfo(Context* context) : Object(context), startTime_(-1.0f), endTime_(-1.0f)
  16. {
  17. }
  18. const String& GetName() const { return name_; }
  19. float GetStartTime() const { return startTime_; }
  20. float GetEndTime() const { return endTime_; }
  21. void SetName(const String& name) { name_ = name; }
  22. void SetStartTime(float time) { startTime_ = time; }
  23. void SetEndTime(float time) { endTime_ = time; }
  24. private:
  25. String name_;
  26. float startTime_;
  27. float endTime_;
  28. };
  29. class ModelImporter : public AssetImporter
  30. {
  31. OBJECT(ModelImporter);
  32. public:
  33. /// Construct.
  34. ModelImporter(Context* context, Asset* asset);
  35. virtual ~ModelImporter();
  36. virtual void SetDefaults();
  37. float GetScale() { return scale_; }
  38. void SetScale(float scale) {scale_ = scale; }
  39. bool GetImportAnimations() { return importAnimations_; }
  40. void SetImportAnimations(bool importAnimations) { importAnimations_ = importAnimations; }
  41. unsigned GetAnimationCount();
  42. void SetAnimationCount(unsigned count);
  43. AnimationImportInfo* GetAnimationInfo(unsigned index) { return animationInfo_[index]; }
  44. protected:
  45. bool Import();
  46. bool ImportModel();
  47. bool ImportAnimations();
  48. bool ImportAnimation(const String &filename, const String& name, float startTime=-1.0f, float endTime=-1.0f);
  49. virtual bool LoadSettingsInternal();
  50. virtual bool SaveSettingsInternal();
  51. float scale_;
  52. bool importAnimations_;
  53. Vector<SharedPtr<AnimationImportInfo>> animationInfo_;
  54. SharedPtr<Node> importNode_;
  55. };
  56. }