| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311 |
- //
- // Copyright (c) 2008-2017 the Urho3D project.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a copy
- // of this software and associated documentation files (the "Software"), to deal
- // in the Software without restriction, including without limitation the rights
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- // copies of the Software, and to permit persons to whom the Software is
- // furnished to do so, subject to the following conditions:
- //
- // The above copyright notice and this permission notice shall be included in
- // all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- // THE SOFTWARE.
- //
- #pragma once
- namespace pugi
- {
- class xml_node;
- }
- namespace Atomic
- {
- namespace Spriter
- {
- struct Animation;
- struct BoneTimelineKey;
- struct CharacterMap;
- struct Entity;
- struct File;
- struct Folder;
- struct MainlineKey;
- struct MapInstruction;
- struct Ref;
- struct SpatialInfo;
- struct SpatialTimelineKey;
- struct SpriterData;
- struct SpriteTimelineKey;
- struct Timeline;
- struct TimelineKey;
- /// Spriter data.
- struct SpriterData
- {
- SpriterData();
- ~SpriterData();
- void Reset();
- bool Load(const pugi::xml_node& node);
- bool Load(const void* data, size_t size);
- int scmlVersion_;
- String generator_;
- String generatorVersion_;
- PODVector<Folder*> folders_;
- PODVector<Entity*> entities_;
- };
- /// Folder.
- struct Folder
- {
- Folder();
- ~Folder();
- void Reset();
- bool Load(const pugi::xml_node& node);
- int id_;
- String name_;
- PODVector<File*> files_;
- };
- /// File.
- struct File
- {
- File(Folder* folder);
- ~File();
- bool Load(const pugi::xml_node& node);
- Folder* folder_;
- int id_;
- String name_;
- float width_;
- float height_;
- float pivotX_;
- float pivotY_;
- };
- /// Entity.
- struct Entity
- {
- Entity();
- ~Entity();
- void Reset();
- bool Load(const pugi::xml_node& node);
- int id_;
- String name_;
- PODVector<CharacterMap*> characterMaps_;
- PODVector<Animation*> animations_;
- };
- /// Character map.
- struct CharacterMap
- {
- CharacterMap();
- ~CharacterMap();
- void Reset();
- bool Load(const pugi::xml_node& node);
- int id_;
- String name_;
- PODVector<MapInstruction*> maps_;
- };
- /// Map instruction.
- struct MapInstruction
- {
- MapInstruction();
- ~MapInstruction();
- bool Load(const pugi::xml_node& node);
- int folder_;
- int file_;
- int targetFolder_;
- int targetFile_;
- };
- /// Animation.
- struct Animation
- {
- Animation();
- ~Animation();
- void Reset();
- bool Load(const pugi::xml_node& node);
- int id_;
- String name_;
- float length_;
- bool looping_;
- PODVector<MainlineKey*> mainlineKeys_;
- PODVector<Timeline*> timelines_;
- };
- /// Mainline key.
- struct MainlineKey
- {
- MainlineKey();
- ~MainlineKey();
- void Reset();
- bool Load(const pugi::xml_node& node);
- int id_;
- float time_;
- PODVector<Ref*> boneRefs_;
- PODVector<Ref*> objectRefs_;
- };
- /// Ref.
- struct Ref
- {
- Ref();
- ~Ref();
- bool Load(const pugi::xml_node& node);
- int id_;
- int parent_;
- int timeline_;
- int key_;
- int zIndex_;
- };
- /// Object type.
- enum ObjectType
- {
- BONE = 0,
- SPRITE
- };
- /// Timeline.
- struct Timeline
- {
- Timeline();
- ~Timeline();
- void Reset();
- bool Load(const pugi::xml_node& node);
- int id_;
- String name_;
- ObjectType objectType_;
- PODVector<SpatialTimelineKey*> keys_;
- };
- /// Curve type.
- enum CurveType
- {
- INSTANT = 0,
- LINEAR,
- QUADRATIC,
- CUBIC
- };
- /// Timeline key.
- struct TimelineKey
- {
- TimelineKey(Timeline* timeline);
- virtual ~TimelineKey();
- virtual ObjectType GetObjectType() const = 0;
- virtual TimelineKey* Clone() const = 0;
- virtual bool Load(const pugi::xml_node& node);
- virtual void Interpolate(const TimelineKey& other, float t) = 0;
- TimelineKey& operator=(const TimelineKey& rhs);
- float GetTByCurveType(float currentTime, float nextTimelineTime) const;
- Timeline* timeline_;
- int id_;
- float time_;
- CurveType curveType_;
- float c1_;
- float c2_;
- };
- /// Spatial info.
- struct SpatialInfo
- {
- float x_;
- float y_;
- float angle_;
- float scaleX_;
- float scaleY_;
- float alpha_;
- int spin;
- SpatialInfo(float x = 0.0f, float y = 0.0f, float angle = 0.0f, float scale_x = 1, float scale_y = 1, float a = 1, int spin = 1);
- SpatialInfo UnmapFromParent(const SpatialInfo& parentInfo) const;
- void Interpolate(const SpatialInfo& other, float t);
- };
- /// Spatial timeline key.
- struct SpatialTimelineKey : TimelineKey
- {
- SpatialInfo info_;
- SpatialTimelineKey(Timeline* timeline);
- virtual ~SpatialTimelineKey();
- virtual bool Load(const pugi::xml_node& node);
- virtual void Interpolate(const TimelineKey& other, float t);
- SpatialTimelineKey& operator=(const SpatialTimelineKey& rhs);
- };
- /// Bone timeline key.
- struct BoneTimelineKey : SpatialTimelineKey
- {
- float length_;
- float width_;
- BoneTimelineKey(Timeline* timeline);
- virtual ~BoneTimelineKey();
- virtual ObjectType GetObjectType() const { return BONE; }
- virtual TimelineKey* Clone() const;
- virtual bool Load(const pugi::xml_node& node);
- virtual void Interpolate(const TimelineKey& other, float t);
- BoneTimelineKey& operator=(const BoneTimelineKey& rhs);
- };
- /// Sprite timeline key.
- struct SpriteTimelineKey : SpatialTimelineKey
- {
- int folderId_;
- int fileId_;
- bool useDefaultPivot_;
- float pivotX_;
- float pivotY_;
- /// Run time data.
- int zIndex_;
- SpriteTimelineKey(Timeline* timeline);
- virtual ~SpriteTimelineKey();
- virtual ObjectType GetObjectType() const { return SPRITE; }
- virtual TimelineKey* Clone() const;
- virtual bool Load(const pugi::xml_node& node);
- virtual void Interpolate(const TimelineKey& other, float t);
- SpriteTimelineKey& operator=(const SpriteTimelineKey& rhs);
- };
- }
- }
|