mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[cocos2dx] Removed VertexEffect, see #2076
This commit is contained in:
parent
53f69d0f48
commit
ee1c698197
@ -36,7 +36,6 @@ using namespace spine;
|
|||||||
|
|
||||||
PowInterpolation pow2(2);
|
PowInterpolation pow2(2);
|
||||||
PowOutInterpolation powOut2(2);
|
PowOutInterpolation powOut2(2);
|
||||||
SwirlVertexEffect effect(400, powOut2);
|
|
||||||
|
|
||||||
Scene *RaptorExample::scene() {
|
Scene *RaptorExample::scene() {
|
||||||
Scene *scene = Scene::create();
|
Scene *scene = Scene::create();
|
||||||
@ -52,10 +51,6 @@ bool RaptorExample::init() {
|
|||||||
skeletonNode->addAnimation(1, "gun-grab", false, 2);
|
skeletonNode->addAnimation(1, "gun-grab", false, 2);
|
||||||
skeletonNode->setTwoColorTint(true);
|
skeletonNode->setTwoColorTint(true);
|
||||||
|
|
||||||
effect.setCenterY(200);
|
|
||||||
swirlTime = 0;
|
|
||||||
|
|
||||||
skeletonNode->setVertexEffect(&effect);
|
|
||||||
|
|
||||||
skeletonNode->setPosition(Vec2(_contentSize.width / 2, 20));
|
skeletonNode->setPosition(Vec2(_contentSize.width / 2, 20));
|
||||||
addChild(skeletonNode);
|
addChild(skeletonNode);
|
||||||
@ -77,10 +72,3 @@ bool RaptorExample::init() {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RaptorExample::update(float fDelta) {
|
|
||||||
swirlTime += fDelta;
|
|
||||||
float percent = spine::MathUtil::fmod(swirlTime, 2);
|
|
||||||
if (percent > 1) percent = 1 - (percent - 1);
|
|
||||||
effect.setAngle(pow2.interpolate(-60.0f, 60.0f, percent));
|
|
||||||
}
|
|
||||||
|
|||||||
@ -39,9 +39,7 @@ public:
|
|||||||
|
|
||||||
CREATE_FUNC(RaptorExample);
|
CREATE_FUNC(RaptorExample);
|
||||||
|
|
||||||
virtual bool init();
|
virtual bool init();
|
||||||
|
|
||||||
virtual void update(float fDelta);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
spine::SkeletonAnimation *skeletonNode;
|
spine::SkeletonAnimation *skeletonNode;
|
||||||
|
|||||||
@ -137,26 +137,26 @@ namespace spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SkeletonRenderer::SkeletonRenderer()
|
SkeletonRenderer::SkeletonRenderer()
|
||||||
: _atlas(nullptr), _attachmentLoader(nullptr), _timeScale(1), _debugSlots(false), _debugBones(false), _debugMeshes(false), _debugBoundingRect(false), _effect(nullptr), _startSlotIndex(0), _endSlotIndex(std::numeric_limits<int>::max()) {
|
: _atlas(nullptr), _attachmentLoader(nullptr), _timeScale(1), _debugSlots(false), _debugBones(false), _debugMeshes(false), _debugBoundingRect(false), _startSlotIndex(0), _endSlotIndex(std::numeric_limits<int>::max()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SkeletonRenderer::SkeletonRenderer(Skeleton *skeleton, bool ownsSkeleton, bool ownsSkeletonData, bool ownsAtlas)
|
SkeletonRenderer::SkeletonRenderer(Skeleton *skeleton, bool ownsSkeleton, bool ownsSkeletonData, bool ownsAtlas)
|
||||||
: _atlas(nullptr), _attachmentLoader(nullptr), _timeScale(1), _debugSlots(false), _debugBones(false), _debugMeshes(false), _debugBoundingRect(false), _effect(nullptr), _startSlotIndex(0), _endSlotIndex(std::numeric_limits<int>::max()) {
|
: _atlas(nullptr), _attachmentLoader(nullptr), _timeScale(1), _debugSlots(false), _debugBones(false), _debugMeshes(false), _debugBoundingRect(false), _startSlotIndex(0), _endSlotIndex(std::numeric_limits<int>::max()) {
|
||||||
initWithSkeleton(skeleton, ownsSkeleton, ownsSkeletonData, ownsAtlas);
|
initWithSkeleton(skeleton, ownsSkeleton, ownsSkeletonData, ownsAtlas);
|
||||||
}
|
}
|
||||||
|
|
||||||
SkeletonRenderer::SkeletonRenderer(SkeletonData *skeletonData, bool ownsSkeletonData)
|
SkeletonRenderer::SkeletonRenderer(SkeletonData *skeletonData, bool ownsSkeletonData)
|
||||||
: _atlas(nullptr), _attachmentLoader(nullptr), _timeScale(1), _debugSlots(false), _debugBones(false), _debugMeshes(false), _debugBoundingRect(false), _effect(nullptr), _startSlotIndex(0), _endSlotIndex(std::numeric_limits<int>::max()) {
|
: _atlas(nullptr), _attachmentLoader(nullptr), _timeScale(1), _debugSlots(false), _debugBones(false), _debugMeshes(false), _debugBoundingRect(false), _startSlotIndex(0), _endSlotIndex(std::numeric_limits<int>::max()) {
|
||||||
initWithData(skeletonData, ownsSkeletonData);
|
initWithData(skeletonData, ownsSkeletonData);
|
||||||
}
|
}
|
||||||
|
|
||||||
SkeletonRenderer::SkeletonRenderer(const std::string &skeletonDataFile, Atlas *atlas, float scale)
|
SkeletonRenderer::SkeletonRenderer(const std::string &skeletonDataFile, Atlas *atlas, float scale)
|
||||||
: _atlas(nullptr), _attachmentLoader(nullptr), _timeScale(1), _debugSlots(false), _debugBones(false), _debugMeshes(false), _debugBoundingRect(false), _effect(nullptr), _startSlotIndex(0), _endSlotIndex(std::numeric_limits<int>::max()) {
|
: _atlas(nullptr), _attachmentLoader(nullptr), _timeScale(1), _debugSlots(false), _debugBones(false), _debugMeshes(false), _debugBoundingRect(false), _startSlotIndex(0), _endSlotIndex(std::numeric_limits<int>::max()) {
|
||||||
initWithJsonFile(skeletonDataFile, atlas, scale);
|
initWithJsonFile(skeletonDataFile, atlas, scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
SkeletonRenderer::SkeletonRenderer(const std::string &skeletonDataFile, const std::string &atlasFile, float scale)
|
SkeletonRenderer::SkeletonRenderer(const std::string &skeletonDataFile, const std::string &atlasFile, float scale)
|
||||||
: _atlas(nullptr), _attachmentLoader(nullptr), _timeScale(1), _debugSlots(false), _debugBones(false), _debugMeshes(false), _debugBoundingRect(false), _effect(nullptr), _startSlotIndex(0), _endSlotIndex(std::numeric_limits<int>::max()) {
|
: _atlas(nullptr), _attachmentLoader(nullptr), _timeScale(1), _debugSlots(false), _debugBones(false), _debugMeshes(false), _debugBoundingRect(false), _startSlotIndex(0), _endSlotIndex(std::numeric_limits<int>::max()) {
|
||||||
initWithJsonFile(skeletonDataFile, atlasFile, scale);
|
initWithJsonFile(skeletonDataFile, atlasFile, scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,10 +280,6 @@ namespace spine {
|
|||||||
SkeletonTwoColorBatch *twoColorBatch = SkeletonTwoColorBatch::getInstance();
|
SkeletonTwoColorBatch *twoColorBatch = SkeletonTwoColorBatch::getInstance();
|
||||||
const bool hasSingleTint = (isTwoColorTint() == false);
|
const bool hasSingleTint = (isTwoColorTint() == false);
|
||||||
|
|
||||||
if (_effect) {
|
|
||||||
_effect->begin(*_skeleton);
|
|
||||||
}
|
|
||||||
|
|
||||||
const Color3B displayedColor = getDisplayedColor();
|
const Color3B displayedColor = getDisplayedColor();
|
||||||
Color nodeColor;
|
Color nodeColor;
|
||||||
nodeColor.r = displayedColor.r / 255.f;
|
nodeColor.r = displayedColor.r / 255.f;
|
||||||
@ -437,28 +433,14 @@ namespace spine {
|
|||||||
|
|
||||||
const float *verts = _clipper->getClippedVertices().buffer();
|
const float *verts = _clipper->getClippedVertices().buffer();
|
||||||
const float *uvs = _clipper->getClippedUVs().buffer();
|
const float *uvs = _clipper->getClippedUVs().buffer();
|
||||||
if (_effect) {
|
V3F_C4B_T2F *vertex = batchedTriangles->getTriangles().verts;
|
||||||
V3F_C4B_T2F *vertex = batchedTriangles->getTriangles().verts;
|
for (int v = 0, vn = batchedTriangles->getTriangles().vertCount, vv = 0; v < vn; ++v, vv += 2, ++vertex) {
|
||||||
Color darkTmp;
|
vertex->vertices.x = verts[vv];
|
||||||
for (int v = 0, vn = batchedTriangles->getTriangles().vertCount, vv = 0; v < vn; ++v, vv += 2, ++vertex) {
|
vertex->vertices.y = verts[vv + 1];
|
||||||
Color lightCopy = color;
|
vertex->texCoords.u = uvs[vv];
|
||||||
vertex->vertices.x = verts[vv];
|
vertex->texCoords.v = uvs[vv + 1];
|
||||||
vertex->vertices.y = verts[vv + 1];
|
vertex->colors = color4B;
|
||||||
vertex->texCoords.u = uvs[vv];
|
}
|
||||||
vertex->texCoords.v = uvs[vv + 1];
|
|
||||||
_effect->transform(vertex->vertices.x, vertex->vertices.y, vertex->texCoords.u, vertex->texCoords.v, lightCopy, darkTmp);
|
|
||||||
vertex->colors = ColorToColor4B(lightCopy);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
V3F_C4B_T2F *vertex = batchedTriangles->getTriangles().verts;
|
|
||||||
for (int v = 0, vn = batchedTriangles->getTriangles().vertCount, vv = 0; v < vn; ++v, vv += 2, ++vertex) {
|
|
||||||
vertex->vertices.x = verts[vv];
|
|
||||||
vertex->vertices.y = verts[vv + 1];
|
|
||||||
vertex->texCoords.u = uvs[vv];
|
|
||||||
vertex->texCoords.v = uvs[vv + 1];
|
|
||||||
vertex->colors = color4B;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Not clipping.
|
// Not clipping.
|
||||||
#if COCOS2D_VERSION < 0x00040000
|
#if COCOS2D_VERSION < 0x00040000
|
||||||
@ -466,21 +448,10 @@ namespace spine {
|
|||||||
#else
|
#else
|
||||||
cocos2d::TrianglesCommand *batchedTriangles = batch->addCommand(renderer, _globalZOrder, attachmentVertices->_texture, _programState, blendFunc, triangles, transform, transformFlags);
|
cocos2d::TrianglesCommand *batchedTriangles = batch->addCommand(renderer, _globalZOrder, attachmentVertices->_texture, _programState, blendFunc, triangles, transform, transformFlags);
|
||||||
#endif
|
#endif
|
||||||
|
V3F_C4B_T2F *vertex = batchedTriangles->getTriangles().verts;
|
||||||
if (_effect) {
|
for (int v = 0, vn = batchedTriangles->getTriangles().vertCount; v < vn; ++v, ++vertex) {
|
||||||
V3F_C4B_T2F *vertex = batchedTriangles->getTriangles().verts;
|
vertex->colors = color4B;
|
||||||
Color darkTmp;
|
}
|
||||||
for (int v = 0, vn = batchedTriangles->getTriangles().vertCount; v < vn; ++v, ++vertex) {
|
|
||||||
Color lightCopy = color;
|
|
||||||
_effect->transform(vertex->vertices.x, vertex->vertices.y, vertex->texCoords.u, vertex->texCoords.v, lightCopy, darkTmp);
|
|
||||||
vertex->colors = ColorToColor4B(lightCopy);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
V3F_C4B_T2F *vertex = batchedTriangles->getTriangles().verts;
|
|
||||||
for (int v = 0, vn = batchedTriangles->getTriangles().vertCount; v < vn; ++v, ++vertex) {
|
|
||||||
vertex->colors = color4B;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Two color tinting.
|
// Two color tinting.
|
||||||
@ -509,30 +480,15 @@ namespace spine {
|
|||||||
const float *verts = _clipper->getClippedVertices().buffer();
|
const float *verts = _clipper->getClippedVertices().buffer();
|
||||||
const float *uvs = _clipper->getClippedUVs().buffer();
|
const float *uvs = _clipper->getClippedUVs().buffer();
|
||||||
|
|
||||||
if (_effect) {
|
V3F_C4B_C4B_T2F *vertex = batchedTriangles->getTriangles().verts;
|
||||||
V3F_C4B_C4B_T2F *vertex = batchedTriangles->getTriangles().verts;
|
for (int v = 0, vn = batchedTriangles->getTriangles().vertCount, vv = 0; v < vn; ++v, vv += 2, ++vertex) {
|
||||||
for (int v = 0, vn = batchedTriangles->getTriangles().vertCount, vv = 0; v < vn; ++v, vv += 2, ++vertex) {
|
vertex->position.x = verts[vv];
|
||||||
Color lightCopy = color;
|
vertex->position.y = verts[vv + 1];
|
||||||
Color darkCopy = darkColor;
|
vertex->texCoords.u = uvs[vv];
|
||||||
vertex->position.x = verts[vv];
|
vertex->texCoords.v = uvs[vv + 1];
|
||||||
vertex->position.y = verts[vv + 1];
|
vertex->color = color4B;
|
||||||
vertex->texCoords.u = uvs[vv];
|
vertex->color2 = darkColor4B;
|
||||||
vertex->texCoords.v = uvs[vv + 1];
|
}
|
||||||
_effect->transform(vertex->position.x, vertex->position.y, vertex->texCoords.u, vertex->texCoords.v, lightCopy, darkCopy);
|
|
||||||
vertex->color = ColorToColor4B(lightCopy);
|
|
||||||
vertex->color2 = ColorToColor4B(darkCopy);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
V3F_C4B_C4B_T2F *vertex = batchedTriangles->getTriangles().verts;
|
|
||||||
for (int v = 0, vn = batchedTriangles->getTriangles().vertCount, vv = 0; v < vn; ++v, vv += 2, ++vertex) {
|
|
||||||
vertex->position.x = verts[vv];
|
|
||||||
vertex->position.y = verts[vv + 1];
|
|
||||||
vertex->texCoords.u = uvs[vv];
|
|
||||||
vertex->texCoords.v = uvs[vv + 1];
|
|
||||||
vertex->color = color4B;
|
|
||||||
vertex->color2 = darkColor4B;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
#if COCOS2D_VERSION < 0x00040000
|
#if COCOS2D_VERSION < 0x00040000
|
||||||
@ -541,22 +497,11 @@ namespace spine {
|
|||||||
TwoColorTrianglesCommand *batchedTriangles = lastTwoColorTrianglesCommand = twoColorBatch->addCommand(renderer, _globalZOrder, attachmentVertices->_texture, _programState, blendFunc, trianglesTwoColor, transform, transformFlags);
|
TwoColorTrianglesCommand *batchedTriangles = lastTwoColorTrianglesCommand = twoColorBatch->addCommand(renderer, _globalZOrder, attachmentVertices->_texture, _programState, blendFunc, trianglesTwoColor, transform, transformFlags);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (_effect) {
|
V3F_C4B_C4B_T2F *vertex = batchedTriangles->getTriangles().verts;
|
||||||
V3F_C4B_C4B_T2F *vertex = batchedTriangles->getTriangles().verts;
|
for (int v = 0, vn = batchedTriangles->getTriangles().vertCount; v < vn; ++v, ++vertex) {
|
||||||
for (int v = 0, vn = batchedTriangles->getTriangles().vertCount; v < vn; ++v, ++vertex) {
|
vertex->color = color4B;
|
||||||
Color lightCopy = color;
|
vertex->color2 = darkColor4B;
|
||||||
Color darkCopy = darkColor;
|
}
|
||||||
_effect->transform(vertex->position.x, vertex->position.y, vertex->texCoords.u, vertex->texCoords.v, lightCopy, darkCopy);
|
|
||||||
vertex->color = ColorToColor4B(lightCopy);
|
|
||||||
vertex->color2 = ColorToColor4B(darkCopy);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
V3F_C4B_C4B_T2F *vertex = batchedTriangles->getTriangles().verts;
|
|
||||||
for (int v = 0, vn = batchedTriangles->getTriangles().vertCount; v < vn; ++v, ++vertex) {
|
|
||||||
vertex->color = color4B;
|
|
||||||
vertex->color2 = darkColor4B;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_clipper->clipEnd(*slot);
|
_clipper->clipEnd(*slot);
|
||||||
@ -597,8 +542,6 @@ namespace spine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_effect) _effect->end();
|
|
||||||
|
|
||||||
if (_debugBoundingRect || _debugSlots || _debugBones || _debugMeshes) {
|
if (_debugBoundingRect || _debugSlots || _debugBones || _debugMeshes) {
|
||||||
drawDebug(renderer, transform, transformFlags);
|
drawDebug(renderer, transform, transformFlags);
|
||||||
}
|
}
|
||||||
@ -797,10 +740,6 @@ namespace spine {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonRenderer::setVertexEffect(VertexEffect *effect) {
|
|
||||||
this->_effect = effect;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SkeletonRenderer::setSlotsRange(int startSlotIndex, int endSlotIndex) {
|
void SkeletonRenderer::setSlotsRange(int startSlotIndex, int endSlotIndex) {
|
||||||
_startSlotIndex = startSlotIndex == -1 ? 0 : startSlotIndex;
|
_startSlotIndex = startSlotIndex == -1 ? 0 : startSlotIndex;
|
||||||
_endSlotIndex = endSlotIndex == -1 ? std::numeric_limits<int>::max() : endSlotIndex;
|
_endSlotIndex = endSlotIndex == -1 ? std::numeric_limits<int>::max() : endSlotIndex;
|
||||||
|
|||||||
@ -102,9 +102,6 @@ namespace spine {
|
|||||||
/* Whether two color tinting is enabled */
|
/* Whether two color tinting is enabled */
|
||||||
bool isTwoColorTint();
|
bool isTwoColorTint();
|
||||||
|
|
||||||
/* Sets the vertex effect to be used, set to 0 to disable vertex effects */
|
|
||||||
void setVertexEffect(VertexEffect *effect);
|
|
||||||
|
|
||||||
/* Sets the range of slots that should be rendered. Use -1, -1 to clear the range */
|
/* Sets the range of slots that should be rendered. Use -1, -1 to clear the range */
|
||||||
void setSlotsRange(int startSlotIndex, int endSlotIndex);
|
void setSlotsRange(int startSlotIndex, int endSlotIndex);
|
||||||
|
|
||||||
@ -150,8 +147,7 @@ namespace spine {
|
|||||||
bool _debugBones;
|
bool _debugBones;
|
||||||
bool _debugMeshes;
|
bool _debugMeshes;
|
||||||
bool _debugBoundingRect;
|
bool _debugBoundingRect;
|
||||||
SkeletonClipping *_clipper;
|
SkeletonClipping *_clipper;
|
||||||
VertexEffect *_effect;
|
|
||||||
cocos2d::Rect _boundingRect;
|
cocos2d::Rect _boundingRect;
|
||||||
|
|
||||||
int _startSlotIndex;
|
int _startSlotIndex;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user