Yurii.Lychak

  • 11 déc. 2024
  • Inscrit 24 nov. 2016
  • Hi. Yes it works good, but have one problem. Krita support multiply layers with same name, and if you have they exported json is crashing on import (small bug, need to add suffix when export if layer duplicate name), in other cases It works well (More faster then Gimp). About license author of script use MIT license, and will not deny if you use it.

  • Hi!
    For me and most of Linux user (or users that don't have Photoshop license) I think very painfully to use Gimp plugin for export from PSD files, because sometimes it crashes on Photoshop groups and you need to ungroup all layers, you need to don't forgot revers them cause it exports draw order reversal (very annoying when you forgot that and need export it again or change draw order manually) :S.
    Gimp have weaker support for PSD than Krita, and when you create all art in Krita or some artist send you PSD for animation you need to use Gimp for export it.
    When Krita 4 release, it have feature for create python plugins https://docs.krita.org/en/user_manual/python_scripting/introduction_to_python_scripting.html.
    There are is unofficial plugin https://github.com/chartinger/krita-unofficial-spine-export, but it will be grate to create official plugin, to avoid Gimp in work.

  • Hello.
    Earlier I use spine 3.33 and now try to update, but when I launch a new version of editor it randomly every few seconds call Compiz manager and takes the opportunity to using mouse on desktop.

  • Hi
    I do not know what to do, again. The problem is that I have to change spRegionAttachment structure, and this is part of the runtime. The main problem is that an array with UVS - static.

    typedef struct spRegionAttachment {
       spAttachment super;
       const char* path;
       float x, y, scaleX, scaleY, rotation, width, height;
       float r, g, b, a;
    
       void* rendererObject;
       int regionOffsetX, regionOffsetY; /* Pixels stripped from the bottom left, unrotated. */
       int regionWidth, regionHeight; /* Unrotated, stripped pixel size. */
       int regionOriginalWidth, regionOriginalHeight; /* Unrotated, unstripped pixel size. */
    
       float offset[8];
       float uvs[8];
    } spRegionAttachment;

    And I can't change its length. I also can't write the structure , because in this case I would have to change part of the runtime. Also, I do not know where I was to free the memory used by the array of UVS. Can I just integrate polygonal atlases in the spine without interfering with the runtime? If yes, how to do it. If this impossible, can I leave issue on github for the development of it in cocos2d-x runtime.

  • Hi
    Thanks for the answer. But when I used your pseudo-code I got the same result.
    I'll try to explain what I wanted to do.
    When I'm using attachment with quad everything works well. But I would like to maximize count of objects in one atlas. I wont use polygonal objects as attachment of slots (currently I use quads).
    I have a polygonal atlas created using TexturePacker.
     Loading Image
    For example, I took 2 object Scaffold uses cocos2d-x polygonal sprite and spine animation. When displaying a polygonal atlas quad I get such a result (which is taken for granted).
     Loading Image
    Once connected, your pseudo-code I got something psychedelic.
     Loading Image
    Then I decided to replace atlas by pink rectangle. And I got just such an interesting thing.
     Loading Image

    1. 1. Number of vertices on the objects is not the same.

      1. Vertices are in a strange position. (Not exactly a randomly polviny simply they do not exist on etomu I ranshe and divided by 2). I write all vertices to console and have:
        Vertex 0 U: 0.201172 V: 0.175781
        Vertex 1 U: 0.201172 V: 0.337891
        Vertex 2 U: 0.136719 V: 0.337891
        Vertex 3 U: 0.070312 V: 0.291016
        Vertex 4 U: 0.001953 V: 0.273438
        Vertex 5 U: 0.001953 V: 0.107422
        Vertex 6 U: 0.064453 V: 0.107422
        Vertex 7 U: 0.000000 V: 0.000000
        Vertex 8 U: 0.000000 V: 0.000000
        Vertex 9 U: 0.000000 V: 0.000000
        Vertex 10 U: 0.000000 V: 0.000000
        Vertex 11 U: 0.000000 V: 0.000000
        Vertex 12 U: 0.000000 V: 0.000000
        Vertex 13 U: 0.000000 V: 0.000000

    And I drew attention to the function thet create attachment.

    void spRegionAttachment_setUVs (spRegionAttachment* self, float u, float v, float u2, float v2, int/[i]bool[/i]/rotate) {
       if (rotate) {
          self->uvs[SP_VERTEX_X2] = u;
          self->uvs[SP_VERTEX_Y2] = v2;
          self->uvs[SP_VERTEX_X3] = u;
          self->uvs[SP_VERTEX_Y3] = v;
          self->uvs[SP_VERTEX_X4] = u2;
          self->uvs[SP_VERTEX_Y4] = v;
          self->uvs[SP_VERTEX_X1] = u2;
          self->uvs[SP_VERTEX_Y1] = v2;
       } else {
          self->uvs[SP_VERTEX_X1] = u;
          self->uvs[SP_VERTEX_Y1] = v2;
          self->uvs[SP_VERTEX_X2] = u;
          self->uvs[SP_VERTEX_Y2] = v;
          self->uvs[SP_VERTEX_X3] = u2;
          self->uvs[SP_VERTEX_Y3] = v;
          self->uvs[SP_VERTEX_X4] = u2;
          self->uvs[SP_VERTEX_Y4] = v2;
       }
    }

    It turns out that it affects the size of the rendering area. But looking into it, I realized that there is always passed 4 vertex. Does it affect somehow to the creation of attachment.
    Sorry, sure that the writing is so abstract. Since I am familiar with OpenGL below average.
    Thanks for the answer.

  • Hi.
    Thank you for response. I wrote my own attachment loader. It's easy. I dont use mashes or FFD and dont now if my loader will work correct for it. For simple quad attachment it works well.
    First of all I move attachment creating from AtlasAttachmentLoader to my loader, and create rendererObject from cocos2d::Sprite:

    spAttachment* _NativeAttachmentLoader_createAttachment (spAttachmentLoader* loader, spSkin* skin, spAttachmentType type,
          const char* name, const char* path) {
        switch (type) {
        case SP_ATTACHMENT_REGION: {
            spRegionAttachment* attachment;
    
        //Get name in atlas
        std::string spritePath = path;
        spritePath += ".png";
    
        //Creating some sprite to save information
        Sprite* region = Sprite::createWithSpriteFrameName(spritePath);
        if (!region) {
            _spAttachmentLoader_setError(loader, "Region not found: ", path);
            return 0;
        }
        // Now cocos can't delete sprite
        region->retain();
    
        //Seting values from sprite
        const cocos2d::Size& regionSize = region->getContentSize();
        const V3F_C4B_T2F_Quad spriteQuad = region->getQuad();
        attachment = spRegionAttachment_create(name);
        attachment->rendererObject =  region;
        spRegionAttachment_setUVs(attachment,
                                  spriteQuad.bl.texCoords.u,
                                  spriteQuad.bl.texCoords.v,
                                  spriteQuad.tr.texCoords.u,
                                  spriteQuad.tr.texCoords.v,
                                  0);
        attachment->regionOffsetX = 0;
        attachment->regionOffsetY = 0;
        attachment->regionWidth = regionSize.width;
        attachment->regionHeight = regionSize.height;
        attachment->regionOriginalWidth = regionSize.width;
        attachment->regionOriginalHeight = regionSize.height;
        return SUPER(attachment);
    }
       ...
    }

    After that I change a little function that config attachment:

    void _NativeAttachmentLoader_configureAttachment (spAttachmentLoader* loader, spAttachment* attachment) {
       attachment->attachmentLoader = loader;
    
       switch (attachment->type) {
       case SP_ATTACHMENT_REGION: {
          spRegionAttachment* regionAttachment = SUB_CAST(spRegionAttachment, attachment);
    
        //Getting region from sprite
        Sprite* region = (Sprite*)regionAttachment->rendererObject;
    
        // Create vertex aatachment from sprite texture
        AttachmentVertices* attachmentVertices = new AttachmentVertices(region->getTexture(), 4, quadTriangles, 6);
        V3F_C4B_T2F* vertices = attachmentVertices->_triangles->verts;
    
        // Create uv's from sprite quad
        const V3F_C4B_T2F_Quad& spriteQuad = region->getQuad();
        vertices[1].texCoords = spriteQuad.tl.texCoords;
        vertices[2].texCoords = spriteQuad.tr.texCoords;
        vertices[3].texCoords = spriteQuad.br.texCoords;
        vertices[0].texCoords = spriteQuad.bl.texCoords;
    
        //Sefty delete sprite
        region->release();
    
      regionAttachment->rendererObject = attachmentVertices;
      break;
       }
       ...
    }

    And set in the default value of spAtlass in loader constructor to nullptr, because when I removing it the runtime is crash

    NativeAttachmentLoader* NativeAttachmentLoader_create (spAtlas* atlas = nullptr);

    But now I try to include polygon sprites and it don't work correct. I read all TriangleCommand from sprite.

    void _NativeAttachmentLoader_configureAttachment (spAttachmentLoader* loader, spAttachment* attachment) {
       attachment->attachmentLoader = loader;
    
       switch (attachment->type) {
       case SP_ATTACHMENT_REGION: {
          spRegionAttachment* regionAttachment = SUB_CAST(spRegionAttachment, attachment);
    
        //Getting region from sprite
        Sprite* region = (Sprite*)regionAttachment->rendererObject;
    
        //Get frame of sprite
        SpriteFrame* regionFrame = region->getSpriteFrame();
        //Get info about triangles in sprite
        const PolygonInfo& regionPolygonInfo = regionFrame->getPolygonInfo();
        //Get all triangles
        const TrianglesCommand::Triangles& regionTriangles = regionPolygonInfo.triangles;
    
    
        uint triangleCount = regionTriangles.vertCount / 2;
    
        // Create vertex aatachment from sprite texture
        AttachmentVertices* attachmentVertices = new AttachmentVertices(region->getTexture(), triangleCount, regionTriangles.indices, regionTriangles.indexCount);
        V3F_C4B_T2F* vertices = attachmentVertices->_triangles->verts;
        // Texture cords in atlas
        V3F_C4B_T2F* regionVertices = regionTriangles.verts;
    
        for(uint i = 0; i < triangleCount; ++i)
        {
            vertices[i].texCoords.u = regionVertices[i].texCoords.u;
            vertices[i].texCoords.v = regionVertices[i].texCoords.v;
        }
    
        //Sefty delete sprite
        region->release();
    
      regionAttachment->rendererObject = attachmentVertices;
      break;
       }
            ...

    Maybe you can help me or show me where I was wrong. I tried change indices and clone TriangleCommand object, but it didn't help.
    Result should be:
     Loading Image
    and I have something like this
     Loading Image
    Image I'm posted from Ubuntu, on my working Mac I have more psychedelic results.

    Thank you.

  • Hello.

    Now company where I work, is developing a farm-game. For mobile platforms we use Cocos2d-x. For this type of games engine must display a lot of animated objects at the same time. I need to pack as many objects as I can to one atlas, to reduce number of calls to the GPU. Standard Cocos2d-x atlases use a more advanced level of compression than Spine atlases (basically I mean the package using polygons). Also it would be great to add sprites for particle system in the same atlas that contains the objects (cause they are above the objects, and generate a lot of calls to GPU).

    Can I use textures from TextureCache when creating animations? I saw post
    http://esotericsoftware.com/forum/Cocos2d-x-runtime-integration-with-CCSpriteFrameCache-1694
    but post was published three years ago, and I do not know whether I will be able to use it appropriately polygonal fragments from atlas. In addition, I would like to have all the atlases of project in the same format (.plist).

    Thank you.