Merge branch '4.1' into 4.2-beta

# Conflicts:
#	spine-cocos2dx/spine-cocos2dx/src/spine/spine-cocos2dx.cpp
This commit is contained in:
Mario Zechner 2022-10-03 14:51:30 +02:00
commit 63d3971ffe
16 changed files with 228 additions and 128 deletions

View File

@ -61,6 +61,10 @@ cp -f ../tank/export/tank.png "$ROOT/spine-cocos2d-objc/Resources/"
echo "spine-cocos2dx"
rm -rf "$ROOT/spine-cocos2dx/example/Resources/common/"*
cp -f ../dragon/export/dragon-ess.skel "$ROOT/spine-cocos2dx/example/Resources/common/"
cp -f ../dragon/export/dragon-pma.atlas "$ROOT/spine-cocos2dx/example/Resources/common/"
cp -f ../dragon/export/dragon-pma*.png "$ROOT/spine-cocos2dx/example/Resources/common/"
cp -f ../coin/export/coin-pro.skel "$ROOT/spine-cocos2dx/example/Resources/common/"
cp -f ../coin/export/coin.atlas "$ROOT/spine-cocos2dx/example/Resources/common/"
cp -f ../coin/export/coin.png "$ROOT/spine-cocos2dx/example/Resources/common/"

View File

@ -34,6 +34,7 @@
#include "AppMacros.h"
#include "IKExample.h"
#include "SequenceExample.h"
#include <spine/Debug.h>
#include <spine/spine-cocos2dx.h>
@ -110,7 +111,7 @@ bool AppDelegate::applicationDidFinishLaunching() {
// create a scene. it's an autorelease object
//auto scene = RaptorExample::scene();
auto scene = IKExample::scene();
auto scene = SequenceExample::scene();
// run
director->runWithScene(scene);

View File

@ -28,7 +28,7 @@
*****************************************************************************/
#include "BatchingExample.h"
#include "IKExample.h"
#include "SequenceExample.h"
USING_NS_CC;
using namespace spine;
@ -95,7 +95,7 @@ bool BatchingExample::init() {
EventListenerTouchOneByOne *listener = EventListenerTouchOneByOne::create();
listener->onTouchBegan = [this](Touch *touch, cocos2d::Event *event) -> bool {
Director::getInstance()->replaceScene(IKExample::scene());
Director::getInstance()->replaceScene(SequenceExample::scene());
return true;
};
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);

View File

@ -27,27 +27,35 @@
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#include <spine/AttachmentVertices.h>
#include "SequenceExample.h"
#include "IKExample.h"
USING_NS_CC;
using namespace spine;
namespace spine {
Scene *SequenceExample::scene() {
Scene *scene = Scene::create();
scene->addChild(SequenceExample::create());
return scene;
}
AttachmentVertices::AttachmentVertices(Texture2D *texture, int verticesCount, unsigned short *triangles, int trianglesCount) {
_texture = texture;
if (_texture) _texture->retain();
bool SequenceExample::init() {
if (!LayerColor::initWithColor(Color4B(128, 128, 128, 255))) return false;
_triangles = new TrianglesCommand::Triangles();
_triangles->verts = new V3F_C4B_T2F[verticesCount];
_triangles->vertCount = verticesCount;
_triangles->indices = triangles;
_triangles->indexCount = trianglesCount;
}
skeletonNode = SkeletonAnimation::createWithBinaryFile("dragon-ess.skel", "dragon-pma.atlas", 1);
skeletonNode->setAnimation(0, "flying", true);
AttachmentVertices::~AttachmentVertices() {
delete[] _triangles->verts;
delete _triangles;
if (_texture) _texture->release();
}
skeletonNode->setPosition(Vec2(_contentSize.width / 2, _contentSize.height / 2));
addChild(skeletonNode);
}// namespace spine
scheduleUpdate();
EventListenerTouchOneByOne *listener = EventListenerTouchOneByOne::create();
listener->onTouchBegan = [this](Touch *touch, cocos2d::Event *event) -> bool {
Director::getInstance()->replaceScene(IKExample::scene());
return true;
};
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
return true;
}

View File

@ -27,22 +27,22 @@
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef SPINE_ATTACHMENTVERTICES_H_
#define SPINE_ATTACHMENTVERTICES_H_
#ifndef _SEQUENCEEXAMPLE_H_
#define _SEQUENCEEXAMPLE_H_
#include "cocos2d.h"
#include <spine/spine-cocos2dx.h>
namespace spine {
class SequenceExample : public cocos2d::LayerColor {
public:
static cocos2d::Scene *scene();
class AttachmentVertices {
public:
AttachmentVertices(cocos2d::Texture2D *texture, int verticesCount, unsigned short *triangles, int trianglesCount);
virtual ~AttachmentVertices();
CREATE_FUNC(SequenceExample);
cocos2d::Texture2D *_texture;
cocos2d::TrianglesCommand::Triangles *_triangles;
};
virtual bool init();
}// namespace spine
private:
spine::SkeletonAnimation *skeletonNode;
};
#endif /* SPINE_ATTACHMENTVERTICES_H_ */
#endif

View File

@ -0,0 +1,129 @@
dragon-pma.png
size: 1024, 1024
filter: Linear, Linear
pma: true
back
bounds: 564, 534, 190, 185
chest
bounds: 2, 645, 136, 122
chin
bounds: 140, 619, 214, 146
front-toe-a
bounds: 2, 862, 29, 50
rotate: 90
front-toe-b
bounds: 467, 835, 56, 57
rotate: 90
head
bounds: 756, 398, 296, 260
rotate: 90
left-front-leg
bounds: 599, 834, 84, 57
left-front-thigh
bounds: 782, 819, 84, 72
left-rear-leg
bounds: 356, 558, 206, 177
left-rear-thigh
bounds: 216, 767, 91, 149
rotate: 90
left-wing01
bounds: 2, 268, 264, 589
rotate: 90
left-wing02
bounds: 2, 2, 264, 589
rotate: 90
right-front-leg
bounds: 113, 769, 101, 89
right-front-thigh
bounds: 758, 709, 108, 108
right-rear-leg
bounds: 640, 721, 116, 100
right-rear-thigh
bounds: 367, 742, 91, 149
rotate: 90
right-rear-toe
bounds: 2, 781, 109, 77
tail01
bounds: 868, 696, 120, 153
rotate: 90
tail02
bounds: 518, 737, 95, 120
rotate: 90
tail03
bounds: 868, 818, 73, 92
rotate: 90
tail04
bounds: 526, 835, 56, 71
rotate: 90
tail05
bounds: 406, 839, 52, 59
rotate: 90
tail06
bounds: 685, 823, 95, 68
thiagobrayner
bounds: 54, 860, 350, 31
dragon-pma_2.png
size: 1024, 1024
filter: Linear, Linear
pma: true
left-wing03
bounds: 2, 534, 264, 589
rotate: 90
left-wing04
bounds: 2, 268, 264, 589
rotate: 90
left-wing05
bounds: 593, 209, 264, 589
left-wing06
bounds: 2, 2, 264, 589
rotate: 90
dragon-pma_3.png
size: 1024, 1024
filter: Linear, Linear
pma: true
left-wing07
bounds: 2, 694, 264, 589
rotate: 90
left-wing08
bounds: 2, 428, 264, 589
rotate: 90
left-wing09
bounds: 593, 369, 264, 589
right-wing01
bounds: 2, 2, 365, 643
rotate: 90
dragon-pma_4.png
size: 1024, 1024
filter: Linear, Linear
pma: true
right-wing02
bounds: 2, 369, 365, 643
right-wing03
bounds: 369, 369, 365, 643
right-wing04
bounds: 2, 2, 365, 643
rotate: 90
dragon-pma_5.png
size: 1024, 1024
filter: Linear, Linear
pma: true
right-wing05
bounds: 2, 369, 365, 643
right-wing06
bounds: 369, 369, 365, 643
right-wing07
bounds: 2, 2, 365, 643
rotate: 90
dragon-pma_6.png
size: 1024, 1024
filter: Linear, Linear
pma: true
right-wing08
bounds: 2, 2, 365, 643
right-wing09
bounds: 369, 2, 365, 643

Binary file not shown.

After

Width:  |  Height:  |  Size: 355 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

View File

@ -28,7 +28,6 @@
*****************************************************************************/
#include <algorithm>
#include <spine/AttachmentVertices.h>
#include <spine/Extension.h>
#include <spine/spine-cocos2dx.h>
@ -100,34 +99,13 @@ namespace spine {
}
void SkeletonRenderer::setupGLProgramState(bool twoColorTintEnabled) {
if (twoColorTintEnabled) {
#if COCOS2D_VERSION < 0x00040000
if (twoColorTintEnabled) {
setGLProgramState(SkeletonTwoColorBatch::getInstance()->getTwoColorTintProgramState());
#endif
return;
}
Texture2D *texture = nullptr;
for (int i = 0, n = _skeleton->getSlots().size(); i < n; i++) {
Slot *slot = _skeleton->getDrawOrder()[i];
Attachment *const attachment = slot->getAttachment();
if (!attachment) continue;
if (attachment->getRTTI().isExactly(RegionAttachment::rtti)) {
RegionAttachment *regionAttachment = static_cast<RegionAttachment *>(attachment);
texture = static_cast<AttachmentVertices *>(regionAttachment->getRendererObject())->_texture;
} else if (attachment->getRTTI().isExactly(MeshAttachment::rtti)) {
MeshAttachment *meshAttachment = static_cast<MeshAttachment *>(attachment);
texture = static_cast<AttachmentVertices *>(meshAttachment->getRendererObject())->_texture;
} else {
continue;
}
if (texture != nullptr) {
break;
}
}
#if COCOS2D_VERSION < 0x00040000
setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP, texture));
setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP, nullptr));
#endif
}
@ -290,11 +268,9 @@ namespace spine {
Color color;
Color darkColor;
const float darkPremultipliedAlpha = _premultipliedAlpha ? 1.f : 0;
AttachmentVertices *attachmentVertices = nullptr;
TwoColorTrianglesCommand *lastTwoColorTrianglesCommand = nullptr;
for (int i = 0, n = _skeleton->getSlots().size(); i < n; ++i) {
Slot *slot = _skeleton->getDrawOrder()[i];
;
if (nothingToDraw(*slot, _startSlotIndex, _endSlotIndex)) {
_clipper->clipEnd(*slot);
@ -303,31 +279,39 @@ namespace spine {
cocos2d::TrianglesCommand::Triangles triangles;
TwoColorTriangles trianglesTwoColor;
static unsigned short quadIndices[6] = {0, 1, 2, 2, 3, 0};
Texture2D *texture = nullptr;
if (slot->getAttachment()->getRTTI().isExactly(RegionAttachment::rtti)) {
RegionAttachment *attachment = static_cast<RegionAttachment *>(slot->getAttachment());
attachmentVertices = static_cast<AttachmentVertices *>(attachment->getRendererObject());
texture = (Texture2D*)((AtlasRegion*)attachment->getRegion())->page->getRendererObject();
float *dstTriangleVertices = nullptr;
int dstStride = 0;// in floats
if (hasSingleTint) {
triangles.indices = attachmentVertices->_triangles->indices;
triangles.indexCount = attachmentVertices->_triangles->indexCount;
triangles.verts = batch->allocateVertices(attachmentVertices->_triangles->vertCount);
triangles.vertCount = attachmentVertices->_triangles->vertCount;
triangles.indices = quadIndices;
triangles.indexCount = 6;
triangles.verts = batch->allocateVertices(4);
triangles.vertCount = 4;
assert(triangles.vertCount == 4);
memcpy(triangles.verts, attachmentVertices->_triangles->verts, sizeof(cocos2d::V3F_C4B_T2F) * attachmentVertices->_triangles->vertCount);
for (int v = 0, i = 0; v < triangles.vertCount; v++, i += 2) {
auto &texCoords = triangles.verts[v].texCoords;
texCoords.u = attachment->getUVs()[i];
texCoords.v = attachment->getUVs()[i + 1];
}
dstStride = sizeof(V3F_C4B_T2F) / sizeof(float);
dstTriangleVertices = reinterpret_cast<float *>(triangles.verts);
} else {
trianglesTwoColor.indices = attachmentVertices->_triangles->indices;
trianglesTwoColor.indexCount = attachmentVertices->_triangles->indexCount;
trianglesTwoColor.verts = twoColorBatch->allocateVertices(attachmentVertices->_triangles->vertCount);
trianglesTwoColor.vertCount = attachmentVertices->_triangles->vertCount;
trianglesTwoColor.indices = quadIndices;
trianglesTwoColor.indexCount = 6;
trianglesTwoColor.verts = twoColorBatch->allocateVertices(4);
trianglesTwoColor.vertCount = 4;
assert(trianglesTwoColor.vertCount == 4);
for (int v = 0; v < trianglesTwoColor.vertCount; v++) {
trianglesTwoColor.verts[v].texCoords = attachmentVertices->_triangles->verts[v].texCoords;
}
for (int v = 0, i = 0; v < trianglesTwoColor.vertCount; v++, i += 2) {
auto &texCoords = trianglesTwoColor.verts[v].texCoords;
texCoords.u = attachment->getUVs()[i];
texCoords.v = attachment->getUVs()[i + 1];
}
dstTriangleVertices = reinterpret_cast<float *>(trianglesTwoColor.verts);
dstStride = sizeof(V3F_C4B_C4B_T2F) / sizeof(float);
}
@ -338,28 +322,34 @@ namespace spine {
color = attachment->getColor();
} else if (slot->getAttachment()->getRTTI().isExactly(MeshAttachment::rtti)) {
MeshAttachment *attachment = (MeshAttachment *) slot->getAttachment();
attachmentVertices = (AttachmentVertices *) attachment->getRendererObject();
texture = (Texture2D*)((AtlasRegion*)attachment->getRegion())->page->getRendererObject();
float *dstTriangleVertices = nullptr;
int dstStride = 0;// in floats
int dstVertexCount = 0;
if (hasSingleTint) {
triangles.indices = attachmentVertices->_triangles->indices;
triangles.indexCount = attachmentVertices->_triangles->indexCount;
triangles.verts = batch->allocateVertices(attachmentVertices->_triangles->vertCount);
triangles.vertCount = attachmentVertices->_triangles->vertCount;
memcpy(triangles.verts, attachmentVertices->_triangles->verts, sizeof(cocos2d::V3F_C4B_T2F) * attachmentVertices->_triangles->vertCount);
triangles.indices = attachment->getTriangles().buffer();
triangles.indexCount = (unsigned short)attachment->getTriangles().size();
triangles.verts = batch->allocateVertices(attachment->getWorldVerticesLength() / 2);
triangles.vertCount = attachment->getWorldVerticesLength() / 2;
for (int v = 0, i = 0; v < triangles.vertCount; v++, i += 2) {
auto &texCoords = triangles.verts[v].texCoords;
texCoords.u = attachment->getUVs()[i];
texCoords.v = attachment->getUVs()[i + 1];
}
dstTriangleVertices = (float *) triangles.verts;
dstStride = sizeof(V3F_C4B_T2F) / sizeof(float);
dstVertexCount = triangles.vertCount;
} else {
trianglesTwoColor.indices = attachmentVertices->_triangles->indices;
trianglesTwoColor.indexCount = attachmentVertices->_triangles->indexCount;
trianglesTwoColor.verts = twoColorBatch->allocateVertices(attachmentVertices->_triangles->vertCount);
trianglesTwoColor.vertCount = attachmentVertices->_triangles->vertCount;
for (int v = 0; v < trianglesTwoColor.vertCount; v++) {
trianglesTwoColor.verts[v].texCoords = attachmentVertices->_triangles->verts[v].texCoords;
}
trianglesTwoColor.indices = attachment->getTriangles().buffer();
trianglesTwoColor.indexCount = (unsigned short)attachment->getTriangles().size();
trianglesTwoColor.verts = twoColorBatch->allocateVertices(attachment->getWorldVerticesLength() / 2);
trianglesTwoColor.vertCount = attachment->getWorldVerticesLength() / 2;
for (int v = 0, i = 0; v < trianglesTwoColor.vertCount; v++, i += 2) {
auto &texCoords = trianglesTwoColor.verts[v].texCoords;
texCoords.u = attachment->getUVs()[i];
texCoords.v = attachment->getUVs()[i + 1];
}
dstTriangleVertices = (float *) trianglesTwoColor.verts;
dstStride = sizeof(V3F_C4B_C4B_T2F) / sizeof(float);
dstVertexCount = trianglesTwoColor.vertCount;
@ -405,7 +395,7 @@ namespace spine {
const cocos2d::Color4B color4B = ColorToColor4B(color);
const cocos2d::Color4B darkColor4B = ColorToColor4B(darkColor);
const BlendFunc blendFunc = makeBlendFunc(slot->getData().getBlendMode(), attachmentVertices->_texture->hasPremultipliedAlpha());
const BlendFunc blendFunc = makeBlendFunc(slot->getData().getBlendMode(), texture->hasPremultipliedAlpha());
_blendFunc = blendFunc;
if (hasSingleTint) {
@ -421,14 +411,13 @@ namespace spine {
triangles.vertCount = _clipper->getClippedVertices().size() / 2;
triangles.verts = batch->allocateVertices(triangles.vertCount);
triangles.indexCount = _clipper->getClippedTriangles().size();
triangles.indices =
batch->allocateIndices(triangles.indexCount);
triangles.indices = batch->allocateIndices(triangles.indexCount);
memcpy(triangles.indices, _clipper->getClippedTriangles().buffer(), sizeof(unsigned short) * _clipper->getClippedTriangles().size());
#if COCOS2D_VERSION < 0x00040000
cocos2d::TrianglesCommand *batchedTriangles = batch->addCommand(renderer, _globalZOrder, attachmentVertices->_texture, _glProgramState, blendFunc, triangles, transform, transformFlags);
cocos2d::TrianglesCommand *batchedTriangles = batch->addCommand(renderer, _globalZOrder, texture, _glProgramState, blendFunc, triangles, transform, transformFlags);
#else
cocos2d::TrianglesCommand *batchedTriangles = batch->addCommand(renderer, _globalZOrder, attachmentVertices->_texture, _programState, blendFunc, triangles, transform, transformFlags);
cocos2d::TrianglesCommand *batchedTriangles = batch->addCommand(renderer, _globalZOrder, texture, _programState, blendFunc, triangles, transform, transformFlags);
#endif
const float *verts = _clipper->getClippedVertices().buffer();
@ -444,9 +433,9 @@ namespace spine {
} else {
// Not clipping.
#if COCOS2D_VERSION < 0x00040000
cocos2d::TrianglesCommand *batchedTriangles = batch->addCommand(renderer, _globalZOrder, attachmentVertices->_texture, _glProgramState, blendFunc, triangles, transform, transformFlags);
cocos2d::TrianglesCommand *batchedTriangles = batch->addCommand(renderer, _globalZOrder, texture, _glProgramState, blendFunc, triangles, transform, transformFlags);
#else
cocos2d::TrianglesCommand *batchedTriangles = batch->addCommand(renderer, _globalZOrder, attachmentVertices->_texture, _programState, blendFunc, triangles, transform, transformFlags);
cocos2d::TrianglesCommand *batchedTriangles = batch->addCommand(renderer, _globalZOrder, texture, _programState, blendFunc, triangles, transform, transformFlags);
#endif
V3F_C4B_T2F *vertex = batchedTriangles->getTriangles().verts;
for (int v = 0, vn = batchedTriangles->getTriangles().vertCount; v < vn; ++v, ++vertex) {
@ -472,9 +461,9 @@ namespace spine {
memcpy(trianglesTwoColor.indices, _clipper->getClippedTriangles().buffer(), sizeof(unsigned short) * _clipper->getClippedTriangles().size());
#if COCOS2D_VERSION < 0x00040000
TwoColorTrianglesCommand *batchedTriangles = lastTwoColorTrianglesCommand = twoColorBatch->addCommand(renderer, _globalZOrder, attachmentVertices->_texture->getName(), _glProgramState, blendFunc, trianglesTwoColor, transform, transformFlags);
TwoColorTrianglesCommand *batchedTriangles = lastTwoColorTrianglesCommand = twoColorBatch->addCommand(renderer, _globalZOrder, texture->getName(), _glProgramState, blendFunc, trianglesTwoColor, transform, transformFlags);
#else
TwoColorTrianglesCommand *batchedTriangles = lastTwoColorTrianglesCommand = twoColorBatch->addCommand(renderer, _globalZOrder, attachmentVertices->_texture, _programState, blendFunc, trianglesTwoColor, transform, transformFlags);
TwoColorTrianglesCommand *batchedTriangles = lastTwoColorTrianglesCommand = twoColorBatch->addCommand(renderer, _globalZOrder, texture, _programState, blendFunc, trianglesTwoColor, transform, transformFlags);
#endif
const float *verts = _clipper->getClippedVertices().buffer();
@ -492,9 +481,9 @@ namespace spine {
} else {
#if COCOS2D_VERSION < 0x00040000
TwoColorTrianglesCommand *batchedTriangles = lastTwoColorTrianglesCommand = twoColorBatch->addCommand(renderer, _globalZOrder, attachmentVertices->_texture->getName(), _glProgramState, blendFunc, trianglesTwoColor, transform, transformFlags);
TwoColorTrianglesCommand *batchedTriangles = lastTwoColorTrianglesCommand = twoColorBatch->addCommand(renderer, _globalZOrder, texture->getName(), _glProgramState, blendFunc, trianglesTwoColor, transform, transformFlags);
#else
TwoColorTrianglesCommand *batchedTriangles = lastTwoColorTrianglesCommand = twoColorBatch->addCommand(renderer, _globalZOrder, attachmentVertices->_texture, _programState, blendFunc, trianglesTwoColor, transform, transformFlags);
TwoColorTrianglesCommand *batchedTriangles = lastTwoColorTrianglesCommand = twoColorBatch->addCommand(renderer, _globalZOrder, texture, _programState, blendFunc, trianglesTwoColor, transform, transformFlags);
#endif
V3F_C4B_C4B_T2F *vertex = batchedTriangles->getTriangles().verts;

View File

@ -153,6 +153,8 @@ namespace spine {
int _startSlotIndex;
int _endSlotIndex;
bool _twoColorTint;
Pool<AttachmentVertices*> _verticesPool;
};
}// namespace spine

View File

@ -27,51 +27,18 @@
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#include <spine/AttachmentVertices.h>
#include <spine/Extension.h>
#include <spine/spine-cocos2dx.h>
USING_NS_CC;
using namespace spine;
static void deleteAttachmentVertices(void *vertices) {
delete (AttachmentVertices *) vertices;
}
static unsigned short quadTriangles[6] = {0, 1, 2, 2, 3, 0};
static void setAttachmentVertices(RegionAttachment *attachment) {
AttachmentVertices *attachmentVertices = new AttachmentVertices((Texture2D *) attachment->getRegion()->rendererObject, 4, quadTriangles, 6);
V3F_C4B_T2F *vertices = attachmentVertices->_triangles->verts;
for (int i = 0, ii = 0; i < 4; ++i, ii += 2) {
vertices[i].texCoords.u = attachment->getUVs()[ii];
vertices[i].texCoords.v = attachment->getUVs()[ii + 1];
}
attachment->setRendererObject(attachmentVertices, deleteAttachmentVertices);
}
static void setAttachmentVertices(MeshAttachment *attachment) {
AttachmentVertices *attachmentVertices = new AttachmentVertices((Texture2D *)attachment->getRegion()->rendererObject,
attachment->getWorldVerticesLength() >> 1, attachment->getTriangles().buffer(), attachment->getTriangles().size());
V3F_C4B_T2F *vertices = attachmentVertices->_triangles->verts;
for (int i = 0, ii = 0, nn = attachment->getWorldVerticesLength(); ii < nn; ++i, ii += 2) {
vertices[i].texCoords.u = attachment->getUVs()[ii];
vertices[i].texCoords.v = attachment->getUVs()[ii + 1];
}
attachment->setRendererObject(attachmentVertices, deleteAttachmentVertices);
}
Cocos2dAtlasAttachmentLoader::Cocos2dAtlasAttachmentLoader(Atlas *atlas) : AtlasAttachmentLoader(atlas) {
}
Cocos2dAtlasAttachmentLoader::~Cocos2dAtlasAttachmentLoader() {}
void Cocos2dAtlasAttachmentLoader::configureAttachment(Attachment *attachment) {
if (attachment->getRTTI().isExactly(RegionAttachment::rtti)) {
setAttachmentVertices((RegionAttachment *) attachment);
} else if (attachment->getRTTI().isExactly(MeshAttachment::rtti)) {
setAttachmentVertices((MeshAttachment *) attachment);
}
}
#if COCOS2D_VERSION >= 0x0040000