Browse Source

[cocos2dx] Fixed mesh rendering

badlogic 8 years ago
parent
commit
38c3687e85

+ 2 - 2
spine-cocos2dx/example/Classes/BatchingExample.cpp

@@ -53,7 +53,7 @@ bool BatchingExample::init () {
 
 
 	// Load the skeleton data.
 	// Load the skeleton data.
 	spSkeletonJson* json = spSkeletonJson_createWithLoader(_attachmentLoader);
 	spSkeletonJson* json = spSkeletonJson_createWithLoader(_attachmentLoader);
-	json->scale = 0.6f; // Resizes skeleton data to 60% of the size it was in Spine.
+	json->scale = 0.1f; // Resizes skeleton data to 60% of the size it was in Spine.
 	_skeletonData = spSkeletonJson_readSkeletonDataFile(json, "spineboy.json");
 	_skeletonData = spSkeletonJson_readSkeletonDataFile(json, "spineboy.json");
 	CCASSERT(_skeletonData, json->error ? json->error : "Error reading skeleton data file.");
 	CCASSERT(_skeletonData, json->error ? json->error : "Error reading skeleton data file.");
 	spSkeletonJson_dispose(json);
 	spSkeletonJson_dispose(json);
@@ -65,7 +65,7 @@ bool BatchingExample::init () {
 
 
 	int xMin = _contentSize.width * 0.10f, xMax = _contentSize.width * 0.90f;
 	int xMin = _contentSize.width * 0.10f, xMax = _contentSize.width * 0.90f;
 	int yMin = 0, yMax = _contentSize.height * 0.7f;
 	int yMin = 0, yMax = _contentSize.height * 0.7f;
-	for (int i = 0; i < 5000; i++) {
+	for (int i = 0; i < 500; i++) {
 		// Each skeleton node shares the same atlas, skeleton data, and mix times.
 		// Each skeleton node shares the same atlas, skeleton data, and mix times.
 		SkeletonAnimation* skeletonNode = SkeletonAnimation::createWithData(_skeletonData, false);
 		SkeletonAnimation* skeletonNode = SkeletonAnimation::createWithData(_skeletonData, false);
 		skeletonNode->setAnimationStateData(_stateData);
 		skeletonNode->setAnimationStateData(_stateData);

+ 1 - 1
spine-cocos2dx/src/spine/SkeletonRenderer.cpp

@@ -216,7 +216,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);
-			spVertexAttachment_computeWorldVertices(SUPER(attachment), slot, 0, triangles.vertCount, (float*)triangles.verts, 0, 6);
+			spVertexAttachment_computeWorldVertices(SUPER(attachment), slot, 0, triangles.vertCount * sizeof(cocos2d::V3F_C4B_T2F) / 4, (float*)triangles.verts, 0, 6);
             color.r = attachment->color.r;
             color.r = attachment->color.r;
             color.g = attachment->color.g;
             color.g = attachment->color.g;
             color.b = attachment->color.b;
             color.b = attachment->color.b;