mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
Fixed meshes.
This commit is contained in:
parent
dc4ab94644
commit
162ce9f5aa
@ -779,6 +779,7 @@ spAttachment* spSkeletonBinary_readAttachment(spSkeletonBinary* self, _dataInput
|
|||||||
}
|
}
|
||||||
if (nonessential) readInt(input); /* Skip color. */
|
if (nonessential) readInt(input); /* Skip color. */
|
||||||
if (freeName) FREE(name);
|
if (freeName) FREE(name);
|
||||||
|
spAttachmentLoader_configureAttachment(self->attachmentLoader, attachment);
|
||||||
return attachment;
|
return attachment;
|
||||||
}
|
}
|
||||||
case SP_ATTACHMENT_POINT: {
|
case SP_ATTACHMENT_POINT: {
|
||||||
@ -791,6 +792,7 @@ spAttachment* spSkeletonBinary_readAttachment(spSkeletonBinary* self, _dataInput
|
|||||||
if (nonessential) {
|
if (nonessential) {
|
||||||
readColor(input, &point->color.r, &point->color.g, &point->color.b, &point->color.a);
|
readColor(input, &point->color.r, &point->color.g, &point->color.b, &point->color.a);
|
||||||
}
|
}
|
||||||
|
spAttachmentLoader_configureAttachment(self->attachmentLoader, attachment);
|
||||||
return attachment;
|
return attachment;
|
||||||
}
|
}
|
||||||
case SP_ATTACHMENT_CLIPPING: {
|
case SP_ATTACHMENT_CLIPPING: {
|
||||||
|
|||||||
@ -52,7 +52,7 @@ bool BatchingExample::init () {
|
|||||||
|
|
||||||
// This attachment loader configures attachments with data needed for cocos2d-x rendering.
|
// This attachment loader configures attachments with data needed for cocos2d-x rendering.
|
||||||
// Do not dispose the attachment loader until the skeleton data is disposed!
|
// Do not dispose the attachment loader until the skeleton data is disposed!
|
||||||
_attachmentLoader = new (__FILE__, __LINE__) AtlasAttachmentLoader(_atlas);
|
_attachmentLoader = new (__FILE__, __LINE__) Cocos2dAtlasAttachmentLoader(_atlas);
|
||||||
|
|
||||||
// Load the skeleton data.
|
// Load the skeleton data.
|
||||||
SkeletonJson* json = new (__FILE__, __LINE__) SkeletonJson(_attachmentLoader);
|
SkeletonJson* json = new (__FILE__, __LINE__) SkeletonJson(_attachmentLoader);
|
||||||
|
|||||||
@ -189,7 +189,7 @@ void SkeletonRenderer::initWithData (SkeletonData* skeletonData, bool ownsSkelet
|
|||||||
|
|
||||||
void SkeletonRenderer::initWithJsonFile (const std::string& skeletonDataFile, Atlas* atlas, float scale) {
|
void SkeletonRenderer::initWithJsonFile (const std::string& skeletonDataFile, Atlas* atlas, float scale) {
|
||||||
_atlas = atlas;
|
_atlas = atlas;
|
||||||
_attachmentLoader = new (__FILE__, __LINE__) AtlasAttachmentLoader(_atlas);
|
_attachmentLoader = new (__FILE__, __LINE__) Cocos2dAtlasAttachmentLoader(_atlas);
|
||||||
|
|
||||||
SkeletonJson* json = new (__FILE__, __LINE__) SkeletonJson(_attachmentLoader);
|
SkeletonJson* json = new (__FILE__, __LINE__) SkeletonJson(_attachmentLoader);
|
||||||
json->setScale(scale);
|
json->setScale(scale);
|
||||||
@ -207,7 +207,7 @@ void SkeletonRenderer::initWithJsonFile (const std::string& skeletonDataFile, co
|
|||||||
_atlas = new (__FILE__, __LINE__) Atlas(atlasFile.c_str(), &textureLoader);
|
_atlas = new (__FILE__, __LINE__) Atlas(atlasFile.c_str(), &textureLoader);
|
||||||
CCASSERT(_atlas, "Error reading atlas file.");
|
CCASSERT(_atlas, "Error reading atlas file.");
|
||||||
|
|
||||||
_attachmentLoader = new (__FILE__, __LINE__) AtlasAttachmentLoader(_atlas);
|
_attachmentLoader = new (__FILE__, __LINE__) Cocos2dAtlasAttachmentLoader(_atlas);
|
||||||
|
|
||||||
SkeletonJson* json = new (__FILE__, __LINE__) SkeletonJson(_attachmentLoader);
|
SkeletonJson* json = new (__FILE__, __LINE__) SkeletonJson(_attachmentLoader);
|
||||||
json->setScale(scale);
|
json->setScale(scale);
|
||||||
@ -224,7 +224,7 @@ void SkeletonRenderer::initWithJsonFile (const std::string& skeletonDataFile, co
|
|||||||
|
|
||||||
void SkeletonRenderer::initWithBinaryFile (const std::string& skeletonDataFile, Atlas* atlas, float scale) {
|
void SkeletonRenderer::initWithBinaryFile (const std::string& skeletonDataFile, Atlas* atlas, float scale) {
|
||||||
_atlas = atlas;
|
_atlas = atlas;
|
||||||
_attachmentLoader = new (__FILE__, __LINE__) AtlasAttachmentLoader(_atlas);
|
_attachmentLoader = new (__FILE__, __LINE__) Cocos2dAtlasAttachmentLoader(_atlas);
|
||||||
|
|
||||||
SkeletonBinary* binary = new (__FILE__, __LINE__) SkeletonBinary(_attachmentLoader);
|
SkeletonBinary* binary = new (__FILE__, __LINE__) SkeletonBinary(_attachmentLoader);
|
||||||
binary->setScale(scale);
|
binary->setScale(scale);
|
||||||
@ -241,7 +241,7 @@ void SkeletonRenderer::initWithBinaryFile (const std::string& skeletonDataFile,
|
|||||||
_atlas = new (__FILE__, __LINE__) Atlas(atlasFile.c_str(), &textureLoader);
|
_atlas = new (__FILE__, __LINE__) Atlas(atlasFile.c_str(), &textureLoader);
|
||||||
CCASSERT(_atlas, "Error reading atlas file.");
|
CCASSERT(_atlas, "Error reading atlas file.");
|
||||||
|
|
||||||
_attachmentLoader = new (__FILE__, __LINE__) AtlasAttachmentLoader(_atlas);
|
_attachmentLoader = new (__FILE__, __LINE__) Cocos2dAtlasAttachmentLoader(_atlas);
|
||||||
|
|
||||||
SkeletonBinary* binary = new (__FILE__, __LINE__) SkeletonBinary(_attachmentLoader);
|
SkeletonBinary* binary = new (__FILE__, __LINE__) SkeletonBinary(_attachmentLoader);
|
||||||
binary->setScale(scale);
|
binary->setScale(scale);
|
||||||
@ -260,37 +260,6 @@ void SkeletonRenderer::update (float deltaTime) {
|
|||||||
if (_ownsSkeleton) _skeleton->update(deltaTime * _timeScale);
|
if (_ownsSkeleton) _skeleton->update(deltaTime * _timeScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void deleteAttachmentVertices (void* vertices) {
|
|
||||||
delete (AttachmentVertices *) vertices;
|
|
||||||
}
|
|
||||||
|
|
||||||
static unsigned short quadTriangles[6] = {0, 1, 2, 2, 3, 0};
|
|
||||||
|
|
||||||
static void setAttachmentVertices(RegionAttachment* attachment) {
|
|
||||||
if (!attachment->getRendererObject()) {
|
|
||||||
AtlasRegion* region = (AtlasRegion*)attachment->getRendererObject();
|
|
||||||
AttachmentVertices* attachmentVertices = new AttachmentVertices((Texture2D*)region->page->getRendererObject(), 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) {
|
|
||||||
AtlasRegion* region = (AtlasRegion*)attachment->getRendererObject();
|
|
||||||
AttachmentVertices* attachmentVertices = new AttachmentVertices((Texture2D*)region->page->getRendererObject(),
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SkeletonRenderer::draw (Renderer* renderer, const Mat4& transform, uint32_t transformFlags) {
|
void SkeletonRenderer::draw (Renderer* renderer, const Mat4& transform, uint32_t transformFlags) {
|
||||||
SkeletonBatch* batch = SkeletonBatch::getInstance();
|
SkeletonBatch* batch = SkeletonBatch::getInstance();
|
||||||
SkeletonTwoColorBatch* twoColorBatch = SkeletonTwoColorBatch::getInstance();
|
SkeletonTwoColorBatch* twoColorBatch = SkeletonTwoColorBatch::getInstance();
|
||||||
@ -336,7 +305,6 @@ void SkeletonRenderer::draw (Renderer* renderer, const Mat4& transform, uint32_t
|
|||||||
|
|
||||||
if (slot->getAttachment()->getRTTI().isExactly(RegionAttachment::rtti)) {
|
if (slot->getAttachment()->getRTTI().isExactly(RegionAttachment::rtti)) {
|
||||||
RegionAttachment* attachment = (RegionAttachment*)slot->getAttachment();
|
RegionAttachment* attachment = (RegionAttachment*)slot->getAttachment();
|
||||||
setAttachmentVertices(attachment);
|
|
||||||
attachmentVertices = (AttachmentVertices*)attachment->getRendererObject();
|
attachmentVertices = (AttachmentVertices*)attachment->getRendererObject();
|
||||||
|
|
||||||
if (!isTwoColorTint) {
|
if (!isTwoColorTint) {
|
||||||
@ -364,7 +332,6 @@ void SkeletonRenderer::draw (Renderer* renderer, const Mat4& transform, uint32_t
|
|||||||
}
|
}
|
||||||
else if (slot->getAttachment()->getRTTI().isExactly(MeshAttachment::rtti)) {
|
else if (slot->getAttachment()->getRTTI().isExactly(MeshAttachment::rtti)) {
|
||||||
MeshAttachment* attachment = (MeshAttachment*)slot->getAttachment();
|
MeshAttachment* attachment = (MeshAttachment*)slot->getAttachment();
|
||||||
setAttachmentVertices(attachment);
|
|
||||||
attachmentVertices = (AttachmentVertices*)attachment->getRendererObject();
|
attachmentVertices = (AttachmentVertices*)attachment->getRendererObject();
|
||||||
|
|
||||||
if (!isTwoColorTint) {
|
if (!isTwoColorTint) {
|
||||||
@ -373,7 +340,7 @@ void SkeletonRenderer::draw (Renderer* renderer, const Mat4& transform, uint32_t
|
|||||||
triangles.verts = batch->allocateVertices(attachmentVertices->_triangles->vertCount);
|
triangles.verts = batch->allocateVertices(attachmentVertices->_triangles->vertCount);
|
||||||
triangles.vertCount = attachmentVertices->_triangles->vertCount;
|
triangles.vertCount = attachmentVertices->_triangles->vertCount;
|
||||||
memcpy(triangles.verts, attachmentVertices->_triangles->verts, sizeof(cocos2d::V3F_C4B_T2F) * attachmentVertices->_triangles->vertCount);
|
memcpy(triangles.verts, attachmentVertices->_triangles->verts, sizeof(cocos2d::V3F_C4B_T2F) * attachmentVertices->_triangles->vertCount);
|
||||||
attachment->computeWorldVertices(*slot, 0, triangles.vertCount * sizeof(cocos2d::V3F_C4B_T2F) / 4, (float*)triangles.verts, 0, 6);
|
attachment->computeWorldVertices(*slot, 0, attachment->getWorldVerticesLength(), (float*)triangles.verts, 0, 6);
|
||||||
} else {
|
} else {
|
||||||
trianglesTwoColor.indices = attachmentVertices->_triangles->indices;
|
trianglesTwoColor.indices = attachmentVertices->_triangles->indices;
|
||||||
trianglesTwoColor.indexCount = attachmentVertices->_triangles->indexCount;
|
trianglesTwoColor.indexCount = attachmentVertices->_triangles->indexCount;
|
||||||
@ -382,7 +349,7 @@ void SkeletonRenderer::draw (Renderer* renderer, const Mat4& transform, uint32_t
|
|||||||
for (int i = 0; i < trianglesTwoColor.vertCount; i++) {
|
for (int i = 0; i < trianglesTwoColor.vertCount; i++) {
|
||||||
trianglesTwoColor.verts[i].texCoords = attachmentVertices->_triangles->verts[i].texCoords;
|
trianglesTwoColor.verts[i].texCoords = attachmentVertices->_triangles->verts[i].texCoords;
|
||||||
}
|
}
|
||||||
attachment->computeWorldVertices(*slot, 0, trianglesTwoColor.vertCount * sizeof(V3F_C4B_C4B_T2F) / 4, (float*)trianglesTwoColor.verts, 0, 7);
|
attachment->computeWorldVertices(*slot, 0, attachment->getWorldVerticesLength(), (float*)trianglesTwoColor.verts, 0, 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
color.r = attachment->getColor().r;
|
color.r = attachment->getColor().r;
|
||||||
|
|||||||
@ -35,6 +35,48 @@
|
|||||||
USING_NS_CC;
|
USING_NS_CC;
|
||||||
using namespace spine;
|
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) {
|
||||||
|
AtlasRegion* region = (AtlasRegion*)attachment->getRendererObject();
|
||||||
|
AttachmentVertices* attachmentVertices = new AttachmentVertices((Texture2D*)region->page->getRendererObject(), 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) {
|
||||||
|
AtlasRegion* region = (AtlasRegion*)attachment->getRendererObject();
|
||||||
|
AttachmentVertices* attachmentVertices = new AttachmentVertices((Texture2D*)region->page->getRendererObject(),
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GLuint wrap (TextureWrap wrap) {
|
GLuint wrap (TextureWrap wrap) {
|
||||||
return wrap == TextureWrap_ClampToEdge ? GL_CLAMP_TO_EDGE : GL_REPEAT;
|
return wrap == TextureWrap_ClampToEdge ? GL_CLAMP_TO_EDGE : GL_REPEAT;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,6 +39,13 @@
|
|||||||
#include <spine/SkeletonBatch.h>
|
#include <spine/SkeletonBatch.h>
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
|
class Cocos2dAtlasAttachmentLoader: public AtlasAttachmentLoader {
|
||||||
|
public:
|
||||||
|
Cocos2dAtlasAttachmentLoader(Atlas* atlas);
|
||||||
|
virtual ~Cocos2dAtlasAttachmentLoader();
|
||||||
|
virtual void configureAttachment(Attachment* attachment);
|
||||||
|
};
|
||||||
|
|
||||||
class Cocos2dTextureLoader: public TextureLoader {
|
class Cocos2dTextureLoader: public TextureLoader {
|
||||||
public:
|
public:
|
||||||
Cocos2dTextureLoader();
|
Cocos2dTextureLoader();
|
||||||
|
|||||||
@ -62,6 +62,8 @@ namespace spine {
|
|||||||
|
|
||||||
virtual ClippingAttachment* newClippingAttachment(Skin& skin, const String& name);
|
virtual ClippingAttachment* newClippingAttachment(Skin& skin, const String& name);
|
||||||
|
|
||||||
|
virtual void configureAttachment(Attachment* attachment);
|
||||||
|
|
||||||
AtlasRegion* findRegion(const String& name);
|
AtlasRegion* findRegion(const String& name);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -37,6 +37,7 @@
|
|||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
class Skin;
|
class Skin;
|
||||||
|
class Attachment;
|
||||||
class RegionAttachment;
|
class RegionAttachment;
|
||||||
class MeshAttachment;
|
class MeshAttachment;
|
||||||
class BoundingBoxAttachment;
|
class BoundingBoxAttachment;
|
||||||
@ -67,6 +68,8 @@ namespace spine {
|
|||||||
virtual PointAttachment* newPointAttachment(Skin& skin, const String& name) = 0;
|
virtual PointAttachment* newPointAttachment(Skin& skin, const String& name) = 0;
|
||||||
|
|
||||||
virtual ClippingAttachment* newClippingAttachment(Skin& skin, const String& name) = 0;
|
virtual ClippingAttachment* newClippingAttachment(Skin& skin, const String& name) = 0;
|
||||||
|
|
||||||
|
virtual void configureAttachment(Attachment* attachment) = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -115,6 +115,10 @@ ClippingAttachment *AtlasAttachmentLoader::newClippingAttachment(Skin &skin, con
|
|||||||
return new(__FILE__, __LINE__) ClippingAttachment(name);
|
return new(__FILE__, __LINE__) ClippingAttachment(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AtlasAttachmentLoader::configureAttachment(Attachment* attachment) {
|
||||||
|
SP_UNUSED(attachment);
|
||||||
|
}
|
||||||
|
|
||||||
AtlasRegion *AtlasAttachmentLoader::findRegion(const String &name) {
|
AtlasRegion *AtlasAttachmentLoader::findRegion(const String &name) {
|
||||||
return _atlas->findRegion(name);
|
return _atlas->findRegion(name);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -294,6 +294,7 @@ SkeletonData *SkeletonBinary::readSkeletonData(const unsigned char *binary, cons
|
|||||||
}
|
}
|
||||||
linkedMesh->_mesh->setParentMesh(static_cast<MeshAttachment *>(parent));
|
linkedMesh->_mesh->setParentMesh(static_cast<MeshAttachment *>(parent));
|
||||||
linkedMesh->_mesh->updateUVs();
|
linkedMesh->_mesh->updateUVs();
|
||||||
|
_attachmentLoader->configureAttachment(linkedMesh->_mesh);
|
||||||
}
|
}
|
||||||
ContainerUtil::cleanUpVectorOfPointers(_linkedMeshes);
|
ContainerUtil::cleanUpVectorOfPointers(_linkedMeshes);
|
||||||
_linkedMeshes.clear();
|
_linkedMeshes.clear();
|
||||||
@ -469,6 +470,7 @@ Attachment *SkeletonBinary::readAttachment(DataInput *input, Skin *skin, int slo
|
|||||||
region->_height = readFloat(input) * _scale;
|
region->_height = readFloat(input) * _scale;
|
||||||
readColor(input, region->getColor());
|
readColor(input, region->getColor());
|
||||||
region->updateOffset();
|
region->updateOffset();
|
||||||
|
_attachmentLoader->configureAttachment(region);
|
||||||
return region;
|
return region;
|
||||||
}
|
}
|
||||||
case AttachmentType_Boundingbox: {
|
case AttachmentType_Boundingbox: {
|
||||||
@ -479,6 +481,7 @@ Attachment *SkeletonBinary::readAttachment(DataInput *input, Skin *skin, int slo
|
|||||||
/* Skip color. */
|
/* Skip color. */
|
||||||
readInt(input);
|
readInt(input);
|
||||||
}
|
}
|
||||||
|
_attachmentLoader->configureAttachment(box);
|
||||||
return box;
|
return box;
|
||||||
}
|
}
|
||||||
case AttachmentType_Mesh: {
|
case AttachmentType_Mesh: {
|
||||||
@ -504,6 +507,7 @@ Attachment *SkeletonBinary::readAttachment(DataInput *input, Skin *skin, int slo
|
|||||||
mesh->_width = 0;
|
mesh->_width = 0;
|
||||||
mesh->_height = 0;
|
mesh->_height = 0;
|
||||||
}
|
}
|
||||||
|
_attachmentLoader->configureAttachment(mesh);
|
||||||
return mesh;
|
return mesh;
|
||||||
}
|
}
|
||||||
case AttachmentType_Linkedmesh: {
|
case AttachmentType_Linkedmesh: {
|
||||||
@ -541,6 +545,7 @@ Attachment *SkeletonBinary::readAttachment(DataInput *input, Skin *skin, int slo
|
|||||||
/* Skip color. */
|
/* Skip color. */
|
||||||
readInt(input);
|
readInt(input);
|
||||||
}
|
}
|
||||||
|
_attachmentLoader->configureAttachment(path);
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
case AttachmentType_Point: {
|
case AttachmentType_Point: {
|
||||||
@ -553,7 +558,7 @@ Attachment *SkeletonBinary::readAttachment(DataInput *input, Skin *skin, int slo
|
|||||||
/* Skip color. */
|
/* Skip color. */
|
||||||
readInt(input);
|
readInt(input);
|
||||||
}
|
}
|
||||||
|
_attachmentLoader->configureAttachment(point);
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
case AttachmentType_Clipping: {
|
case AttachmentType_Clipping: {
|
||||||
@ -566,6 +571,7 @@ Attachment *SkeletonBinary::readAttachment(DataInput *input, Skin *skin, int slo
|
|||||||
/* Skip color. */
|
/* Skip color. */
|
||||||
readInt(input);
|
readInt(input);
|
||||||
}
|
}
|
||||||
|
_attachmentLoader->configureAttachment(clip);
|
||||||
return clip;
|
return clip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -495,7 +495,7 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
region->updateOffset();
|
region->updateOffset();
|
||||||
|
_attachmentLoader->configureAttachment(region);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AttachmentType_Mesh:
|
case AttachmentType_Mesh:
|
||||||
@ -548,6 +548,7 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) {
|
|||||||
mesh->_edges[ii] = entry->_valueInt;
|
mesh->_edges[ii] = entry->_valueInt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_attachmentLoader->configureAttachment(mesh);
|
||||||
} else {
|
} else {
|
||||||
mesh->_inheritDeform = Json::getInt(attachmentMap, "deform", 1) ? true : false;
|
mesh->_inheritDeform = Json::getInt(attachmentMap, "deform", 1) ? true : false;
|
||||||
LinkedMesh *linkedMesh = new(__FILE__, __LINE__) LinkedMesh(mesh,
|
LinkedMesh *linkedMesh = new(__FILE__, __LINE__) LinkedMesh(mesh,
|
||||||
@ -567,6 +568,7 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) {
|
|||||||
|
|
||||||
int vertexCount = Json::getInt(attachmentMap, "vertexCount", 0) << 1;
|
int vertexCount = Json::getInt(attachmentMap, "vertexCount", 0) << 1;
|
||||||
readVertices(attachmentMap, box, vertexCount);
|
readVertices(attachmentMap, box, vertexCount);
|
||||||
|
_attachmentLoader->configureAttachment(attachment);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AttachmentType_Path: {
|
case AttachmentType_Path: {
|
||||||
@ -587,6 +589,7 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) {
|
|||||||
for (curves = curves->_child, ii = 0; curves; curves = curves->_next, ++ii) {
|
for (curves = curves->_child, ii = 0; curves; curves = curves->_next, ++ii) {
|
||||||
pathAttatchment->_lengths[ii] = curves->_valueFloat * _scale;
|
pathAttatchment->_lengths[ii] = curves->_valueFloat * _scale;
|
||||||
}
|
}
|
||||||
|
_attachmentLoader->configureAttachment(attachment);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AttachmentType_Point: {
|
case AttachmentType_Point: {
|
||||||
@ -597,6 +600,7 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) {
|
|||||||
point->_x = Json::getFloat(attachmentMap, "x", 0) * _scale;
|
point->_x = Json::getFloat(attachmentMap, "x", 0) * _scale;
|
||||||
point->_y = Json::getFloat(attachmentMap, "y", 0) * _scale;
|
point->_y = Json::getFloat(attachmentMap, "y", 0) * _scale;
|
||||||
point->_rotation = Json::getFloat(attachmentMap, "rotation", 0);
|
point->_rotation = Json::getFloat(attachmentMap, "rotation", 0);
|
||||||
|
_attachmentLoader->configureAttachment(attachment);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AttachmentType_Clipping: {
|
case AttachmentType_Clipping: {
|
||||||
@ -612,6 +616,7 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) {
|
|||||||
}
|
}
|
||||||
vertexCount = Json::getInt(attachmentMap, "vertexCount", 0) << 1;
|
vertexCount = Json::getInt(attachmentMap, "vertexCount", 0) << 1;
|
||||||
readVertices(attachmentMap, clip, vertexCount);
|
readVertices(attachmentMap, clip, vertexCount);
|
||||||
|
_attachmentLoader->configureAttachment(attachment);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -640,6 +645,7 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) {
|
|||||||
}
|
}
|
||||||
linkedMesh->_mesh->setParentMesh(static_cast<MeshAttachment *>(parent));
|
linkedMesh->_mesh->setParentMesh(static_cast<MeshAttachment *>(parent));
|
||||||
linkedMesh->_mesh->updateUVs();
|
linkedMesh->_mesh->updateUVs();
|
||||||
|
_attachmentLoader->configureAttachment(linkedMesh->_mesh);
|
||||||
}
|
}
|
||||||
ContainerUtil::cleanUpVectorOfPointers(_linkedMeshes);
|
ContainerUtil::cleanUpVectorOfPointers(_linkedMeshes);
|
||||||
_linkedMeshes.clear();
|
_linkedMeshes.clear();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user