{"id":233027,"date":"2014-08-12T11:15:03","date_gmt":"2014-08-12T07:15:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=233027"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=233027","title":{"rendered":"<span class=\"post_title\">\u0412\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c Spine Generic Runtime \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 \u043d\u0430 \u0421++<\/span>"},"content":{"rendered":"<div class=\"content html_format\">     \t\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442! <\/p>\n<p>  \u041d\u0435\u0434\u0430\u0432\u043d\u043e \u043f\u0435\u0440\u0435\u0434 \u043d\u0430\u043c\u0438 \u0432\u0441\u0442\u0430\u043b\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 \u0441\u043a\u0435\u043b\u0435\u0442\u043d\u043e\u0439 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438. \u041f\u043e \u0441\u043e\u0432\u0435\u0442\u0443 \u043a\u043e\u043b\u043b\u0435\u0433 \u043c\u044b \u043e\u0431\u0440\u0430\u0442\u0438\u043b\u0438 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 <a href=\"http:\/\/esotericsoftware.com\/\">Spine<\/a>.<br \/>  \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0441\u0442\u0430\u043b\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u044e\u0442 \u043d\u0430\u0448\u0438\u043c \u043d\u0443\u0436\u0434\u0430\u043c (<a href=\"http:\/\/habrahabr.ru\/post\/207904\/\">\u0437\u0434\u0435\u0441\u044c<\/a> \u0435\u0441\u0442\u044c \u043e\u0431\u0437\u043e\u0440 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0439), \u043c\u044b \u0441\u0442\u0430\u043b\u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c Spine \u0432 \u043d\u0430\u0448 \u0421++ \u0434\u0432\u0438\u0436\u043e\u043a. <\/p>\n<p>  <a name=\"habracut\"><\/a>  <\/p>\n<h4>\u0418\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438<\/h4>\n<p>  \u00ab\u041e\u0431\u0449\u0438\u0435\u00bb \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430 \u043d\u0430 \u0421 \u043b\u0435\u0436\u0430\u0442 <a href=\"https:\/\/github.com\/EsotericSoftware\/spine-runtimes\/tree\/master\/spine-c\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u0418\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u043f\u0440\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0432\u044b\u0434\u0430\u044e\u0442 3 \u043e\u0448\u0438\u0431\u043a\u0438 \u2013 \u043f\u0440\u0438 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u0434\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c 3 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u041e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u043d\u0438\u0436\u0435.<\/p>\n<h4>\u0424\u043e\u0440\u043c\u0430\u0442 \u0434\u0430\u043d\u043d\u044b\u0445<\/h4>\n<p>  \u0421\u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 (<a href=\"http:\/\/esotericsoftware.com\/spine-download\">\u0437\u0434\u0435\u0441\u044c <\/a>\u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440 \u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0430\u043d\u043c\u0438\u0430\u0446\u0438\u0439 \u0434\u043b\u044f \u0435\u0442\u0441\u0442\u0430) \u0441\u043e\u0441\u0442\u043e\u044f\u0442 \u0438\u0437 json-\u0444\u0430\u0439\u043b\u0430 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438, \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b (\u0430\u0442\u043b\u0430\u0441\u0430) \u0438 \u0444\u0430\u0439\u043b\u0430 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0430\u0442\u043b\u0430\u0441\u0430. <\/p>\n<h4>\u0418\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f, \u0430\u0442\u043b\u0430\u0441<\/h4>\n<p>  \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u043d\u043e\u0433\u043e \u0430\u0442\u043b\u0430\u0441\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043a\u043b\u0430\u0441\u0441- wrapper, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0438 \u0432\u044b\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u043d\u044b\u0435 \u0430\u0442\u043b\u0430\u0441\u044b \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 Spine.<\/p>\n<pre><code class=\"cpp\">\/\/ \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430   class SpineAtlas { public: \tSpineAtlas(const std::string& name); \t~SpineAtlas();  private: \tstd::string\t\tmName; \tspAtlas*\t\tmAtlas; }; \/\/ \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0430\u0442\u043b\u0430\u0441\u0430, store::Load \u0438 store::Free \u2013 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u0432\u0438\u0436\u043a\u0430, \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u044e\u0449\u0438\u0435 \u0444\u0430\u0439\u043b \u0432 \u043f\u0430\u043c\u044f\u0442\u044c \u0438 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u044e\u0449\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e. SpineAtlas::SpineAtlas(const std::string& name) :  \tmName(name), mAtlas(0) { \tint length = 0; \tconst char* data = (const char*)store::Load(name + &quot;.atlas&quot;, length);  \tif (data) \t{ \t\tmAtlas = spAtlas_create(data, length, &quot;&quot;, 0); \t\tstore::Free(name + &quot;.atlas&quot;); \t} } \/\/ \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0430 \u0430\u0442\u043b\u0430\u0441\u0430 SpineAtlas::~SpineAtlas() {     spAtlas_dispose(mAtlas); } <\/code><\/pre>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f <i>spAtlas_create<\/i> \u0438\u0437 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 SpineAtlas \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <i>_spAtlasPage_createTexture<\/i>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0430 \u043f\u0440\u0438 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438 Spine \u0432 \u0434\u0432\u0438\u0436\u043e\u043a. \u0417\u0434\u0435\u0441\u044c \u0436\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0438 \u043f\u0430\u0440\u043d\u0443\u044e \u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <i>_spAtlasPage_disposeTexture<\/i>.<\/p>\n<pre><code class=\"cpp\">extern &quot;C&quot; void _spAtlasPage_createTexture(spAtlasPage* self, const char* path) { \tTexture* texture = textures::LoadTexture(path); \tself-&gt;width = texture-&gt;width; \tself-&gt;height = texture-&gt;height; \tself-&gt;rendererObject = texture; }  extern &quot;C&quot; void _spAtlasPage_disposeTexture(spAtlasPage* self) { \tTexture* texture = (Texture*)self-&gt;rendererObject; \trender::ReleaseTexture(texture); } <\/code><\/pre>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f <i>textures::LoadTexture<\/i> \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c\u0443 \u043f\u0443\u0442\u0438. <i>render::ReleaseTexture<\/i> \u2013 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u043e\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u0430\u044f \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0430 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0438\u0437 \u043f\u0430\u043c\u044f\u0442\u0438. <\/p>\n<h4>\u0418\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f, \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044f<\/h4>\n<p>  \u041f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 wrapper \u0434\u043b\u044f Spine \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c.<\/p>\n<pre><code class=\"cpp\">\/\/ \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 class SpineAnimation { public: \tSpineAnimation(const std::string& name); \t~SpineAnimation();  \tvoid\t\t\tUpdate(float timeElapsed); \tvoid\t\t\tRender();  \tvoid\t\t\tPlay(const std::string& skin, const std::string& animation, bool looped); \tvoid\t\t\tStop();  \tvoid\t\t\tOnAnimationEvent(SpineAnimationState* state, int trackIndex, int type, spEvent* event, int loopCount);  private: \tspAnimation*\t\tGetAnimation(const std::string& name) const; \tvoid\t\t\tFillSlotVertices(Vertex* points, float x, float y, spSlot* slot, spRegionAttachment* attachment);  \tstd::string\t\tmName; \tstd::string\t\tmCurrentAnimation; \tSpineAtlas*\t\tmAtlas; \tspAnimationState*\tmState; \tspAnimationStateData* mStateData; \tspSkeleton*\t\tmSkeleton; \tbool\t\t\tmPlaying; };  \/\/ \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438  SpineAnimation::SpineAnimation(const std::string& name) :  \tmName(name), mAtlas(0), mState(0), mStateData(0), mSkeleton(0), mSpeed(1), mPlaying(false), mFlipX(false) { \tmAtlas = gAnimationHost.GetAtlas(mName);  \tspSkeletonJson* skeletonJson = spSkeletonJson_create(mAtlas-&gt;GetAtlas()); \tspSkeletonData* skeletonData = spSkeletonJson_readSkeletonDataFile(skeletonJson, (name + &quot;.json&quot;).c_str()); \tassert(skeletonData); \tspSkeletonJson_dispose(skeletonJson);  \tmSkeleton = spSkeleton_create(skeletonData); \tmStateData = spAnimationStateData_create(skeletonData); \tmState = spAnimationState_create(mStateData); \tmState-&gt;rendererObject = this; \tspSkeleton_update(mSkeleton, 0); \tspAnimationState_update(mState, 0); \tspAnimationState_apply(mState, mSkeleton); \tspSkeleton_updateWorldTransform(mSkeleton); } \/\/ \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0430 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 SpineAnimation::~SpineAnimation() { \tspAnimationState_dispose(mState); \tspAnimationStateData_dispose(mStateData); \tspSkeleton_dispose(mSkeleton); } \/\/ update \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 void SpineAnimation::Update(float timeElapsed) { \tif (IsPlaying()) \t{ \t\tspSkeleton_update(mSkeleton, timeElapsed \/ 1000); \/\/ timeElapsed - ms, Spine \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0432\u0440\u0435\u043c\u044f \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445 \t\tspAnimationState_update(mState, timeElapsed \/ 1000); \t\tspAnimationState_apply(mState, mSkeleton); \t\tspSkeleton_updateWorldTransform(mSkeleton); \t} } \/\/ \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0430 void SpineAnimation::Render() { \tint slotCount = mSkeleton-&gt;slotCount;  \tVertex vertices[6]; \tfor (int i = 0; i &lt; slotCount; ++i)  \t{ \t\tspSlot* slot = mSkeleton-&gt;slots[i]; \t\tspAttachment* attachment = slot-&gt;attachment; \t\tif (!attachment || attachment-&gt;type != SP_ATTACHMENT_REGION)  \t\t\tcontinue; \t\tspRegionAttachment* regionAttachment = (spRegionAttachment*)attachment; \t\tFillSlotVertices(vertices], 0, 0, slot, regionAttachment); \t\ttexture = (Texture*)((spAtlasRegion*)regionAttachment-&gt;rendererObject)-&gt;page-&gt;rendererObject; \t} } \/\/ \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043e\u0434\u043d\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 triangle list  \/\/ \u0444\u043e\u0440\u043c\u0430\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b Vertex: xyz \u2013 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b, uv \u2013 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u043d\u044b\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b, \u0441 - \u0446\u0432\u0435\u0442  void SpineAnimation::FillSlotVertices(Vertex* points, float x, float y, spSlot* slot, spRegionAttachment* attachment) { \tColor color(mSkeleton-&gt;r * slot-&gt;r, mSkeleton-&gt;g * slot-&gt;g, mSkeleton-&gt;b * slot-&gt;b, mSkeleton-&gt;a * slot-&gt;a); \tpoints[0].c = points[1].c = points[2].c = points[3].c = points[4].c = points[5].c = color; \tpoints[0].uv.x = points[5].uv.x = attachment-&gt;uvs[SP_VERTEX_X1]; \tpoints[0].uv.y = points[5].uv.y = attachment-&gt;uvs[SP_VERTEX_Y1]; \tpoints[1].uv.x = attachment-&gt;uvs[SP_VERTEX_X2]; \tpoints[1].uv.y = attachment-&gt;uvs[SP_VERTEX_Y2]; \tpoints[2].uv.x = points[3].uv.x = attachment-&gt;uvs[SP_VERTEX_X3]; \tpoints[2].uv.y = points[3].uv.y = attachment-&gt;uvs[SP_VERTEX_Y3]; \tpoints[4].uv.x = attachment-&gt;uvs[SP_VERTEX_X4]; \tpoints[4].uv.y = attachment-&gt;uvs[SP_VERTEX_Y4]; \tfloat* offset = attachment-&gt;offset; \tfloat xx = slot-&gt;skeleton-&gt;x + slot-&gt;bone-&gt;worldX; \tfloat yy = slot-&gt;skeleton-&gt;y + slot-&gt;bone-&gt;worldY; \tpoints[0].xyz.x = points[5].xyz.x = x + xx + offset[SP_VERTEX_X1] * slot-&gt;bone-&gt;m00 + offset[SP_VERTEX_Y1] * slot-&gt;bone-&gt;m01; \tpoints[0].xyz.y = points[5].xyz.y = y - yy - (offset[SP_VERTEX_X1] * slot-&gt;bone-&gt;m10 + offset[SP_VERTEX_Y1] * slot-&gt;bone-&gt;m11); \tpoints[1].xyz.x = x + xx + offset[SP_VERTEX_X2] * slot-&gt;bone-&gt;m00 + offset[SP_VERTEX_Y2] * slot-&gt;bone-&gt;m01; \tpoints[1].xyz.y = y - yy - (offset[SP_VERTEX_X2] * slot-&gt;bone-&gt;m10 + offset[SP_VERTEX_Y2] * slot-&gt;bone-&gt;m11); \tpoints[2].xyz.x = points[3].xyz.x = x + xx + offset[SP_VERTEX_X3] * slot-&gt;bone-&gt;m00 + offset[SP_VERTEX_Y3] * slot-&gt;bone-&gt;m01; \tpoints[2].xyz.y = points[3].xyz.y = y - yy - (offset[SP_VERTEX_X3] * slot-&gt;bone-&gt;m10 + offset[SP_VERTEX_Y3] * slot-&gt;bone-&gt;m11); \tpoints[4].xyz.x = x + xx + offset[SP_VERTEX_X4] * slot-&gt;bone-&gt;m00 + offset[SP_VERTEX_Y4] * slot-&gt;bone-&gt;m01; \tpoints[4].xyz.y = y - yy - (offset[SP_VERTEX_X4] * slot-&gt;bone-&gt;m10 + offset[SP_VERTEX_Y4] * slot-&gt;bone-&gt;m11); } \/\/ \u0413\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 listener \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 void SpineAnimationStateListener(spAnimationState* state, int trackIndex, spEventType type, spEvent* event, int loopCount) { \tSpineAnimation* sa = (SpineAnimation*)state-&gt;rendererObject; \tif (sa) \t\tsa-&gt;OnAnimationEvent((SpineAnimationState*)state, trackIndex, type, event, loopCount); } \/\/ \u043f\u0440\u043e\u0438\u0433\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 void SpineAnimation::Play(const std::string& animationName, bool looped) { \tif (mCurrentAnimation == animationName) \/\/ \u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0430\u043d\u043c\u0438\u0430\u0446\u0438\u044e \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \t\treturn;  \tspAnimation* animation = GetAnimation(animationName);   \tif (animation) \t{ \t\tmCurrentAnimation = animationName;\t     \t\tspTrackEntry* entry = spAnimationState_setAnimation(mState, 0, animation, looped); \t\tif (entry) \t\t\tentry-&gt;listener = SpineAnimationStateListener; \t\tmPlaying = true; \t} \telse \t\tStop(); } \/\/ \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 void SpineAnimation::Stop() { \tmCurrentAnimation.clear();    \tmPlaying = false; } \/\/ \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u043f\u043e \u0438\u043c\u0435\u043d\u0438 spAnimation* SpineAnimation::GetAnimation(const std::string& name) const { \treturn spSkeletonData_findAnimation(mSkeleton-&gt;data, name.c_str()); } \/\/ \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u043f\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044e void SpineAnimation::OnAnimationEvent(SpineAnimationState* state, int trackIndex, int type, spEvent* event, int loopCount) { \tspTrackEntry* entry = spAnimationState_getCurrent(state, trackIndex); \tif (entry && !entry-&gt;loop && type == SP_ANIMATION_COMPLETE) \t\tStop(); } <\/code><\/pre>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f <i>spSkeletonJson_readSkeletonDataFile<\/i> \u0438\u0437 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 SpineAnimaion \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <i>_spUtil_readFile<\/i>. \u042d\u0442\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0438\u0437 \u0442\u0440\u0435\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0432 \u043a\u043e\u0434\u0435, \u0434\u043b\u044f \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438 Spine. \u041e\u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 malloc \u0432 \u0441\u0442\u0438\u043b\u0435 Spine.  <\/p>\n<pre><code class=\"cpp\">extern &quot;C&quot; char* _spUtil_readFile(const char* path, int* length) { \tchar* result = 0; \tconst void* buffer = store::Load(path, *length); \tif (buffer) \t{ \t\tresult = (char*)_malloc(*length, __FILE__, __LINE__); \/\/ Spine malloc \t\tmemcpy(result, buffer, *length); \t\tstore::Free(path); \t} \treturn result; } <\/code><\/pre>\n<p>  <\/p>\n<h4>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0438\u0447\u0438<\/h4>\n<p>  \u041f\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u0444\u0430\u0439\u043b\u0430 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 scale (<i>SpineAnimation::SpineAnimation<\/i>).  <\/p>\n<pre><code class=\"cpp\">spSkeletonJson* skeletonJson = spSkeletonJson_create(mAtlas-&gt;GetAtlas()); skeletonJson-&gt;scale = scale; <\/code><\/pre>\n<p>  Skinning \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c (<i>SpineAnimation::Play<\/i>):  <\/p>\n<pre><code class=\"cpp\">if (!skinName.empty()) { \tspSkeleton_setSkinByName(mSkeleton, skinName.c_str());  \tspSkeleton_setSlotsToSetupPose(mSkeleton); } <\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u043f\u0440\u043e\u0438\u0433\u0440\u044b\u0432\u0430\u043d\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0437\u0435\u0440\u043a\u0430\u043b\u0438\u0442\u044c \u0435\u0435 \u043f\u043e \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u0438 \u0438\/\u0438\u043b\u0438 \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u0438 (<i>SpineAnimaiton::Update<\/i>):  <\/p>\n<pre><code class=\"cpp\">if (IsPlaying()) { \tmSkeleton-&gt;flipX = mFlipX; \tmSkeleton-&gt;flipY = mFlipY; \tspSkeleton_update(mSkeleton, timeElapsed * mSpeed \/ 1000);\t\t \t... } <\/code><\/pre>\n<p>  \u0412\u044b\u0431\u0440\u0430\u043d\u043d\u0443\u044e \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u043e \u0436\u0435\u043b\u0430\u0435\u043c\u043e\u0439 \u0442\u0440\u0430\u0435\u043a\u0442\u043e\u0440\u0438\u0438. \u041f\u043e\u0437\u0438\u0446\u0438\u044f \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0432\u0435\u0440\u0442\u0435\u043a\u0441\u0442\u043e\u0432 \u043f\u0440\u0438 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0435 (<i>SpineAnimaiton::Render<\/i>)  <\/p>\n<pre><code class=\"cpp\">FillSlotVertices(vertices], mPosition.x, mPosition.y, slot, regionAttachment); <\/code><\/pre>\n<h4>\u0418\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438<\/h4>\n<p>  \u0418\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435, \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c <a href=\"https:\/\/www.dropbox.com\/s\/lfk06fptt6ru7ad\/SpineAnimaiton4Habr.zip\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u0414\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u0447\u0442\u0435\u043d\u0438\u044f Set\/Get \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u043d\u0438\u0445 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442. <\/p>\n<p>  PS: \u041f\u0440\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u044f \u043d\u0430\u0448\u0435\u043b 2 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u043a\u043e\u0434\u0435. \u041f\u043e\u0447\u0430\u0449\u0435 \u043f\u0438\u0448\u0438\u0442\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u043d\u0430 \u0425\u0430\u0431\u0440!      \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/233027\/\"> http:\/\/habrahabr.ru\/post\/233027\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">     \t\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442! <\/p>\n<p>  \u041d\u0435\u0434\u0430\u0432\u043d\u043e \u043f\u0435\u0440\u0435\u0434 \u043d\u0430\u043c\u0438 \u0432\u0441\u0442\u0430\u043b\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 \u0441\u043a\u0435\u043b\u0435\u0442\u043d\u043e\u0439 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438. \u041f\u043e \u0441\u043e\u0432\u0435\u0442\u0443 \u043a\u043e\u043b\u043b\u0435\u0433 \u043c\u044b \u043e\u0431\u0440\u0430\u0442\u0438\u043b\u0438 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 <a href=\"http:\/\/esotericsoftware.com\/\">Spine<\/a>.<br \/>  \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0441\u0442\u0430\u043b\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u044e\u0442 \u043d\u0430\u0448\u0438\u043c \u043d\u0443\u0436\u0434\u0430\u043c (<a href=\"http:\/\/habrahabr.ru\/post\/207904\/\">\u0437\u0434\u0435\u0441\u044c<\/a> \u0435\u0441\u0442\u044c \u043e\u0431\u0437\u043e\u0440 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0439), \u043c\u044b \u0441\u0442\u0430\u043b\u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c Spine \u0432 \u043d\u0430\u0448 \u0421++ \u0434\u0432\u0438\u0436\u043e\u043a. <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-233027","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/233027","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=233027"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/233027\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=233027"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=233027"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=233027"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}