From 4a6e1373893d704f07287b7ea4ca3693a8ea46ce Mon Sep 17 00:00:00 2001 From: andyque Date: Thu, 16 Jan 2014 12:10:41 +0800 Subject: [PATCH] fixed #3683. fixed convertToWorldSpaceAR of CCSkin returning error coordinate --- .../cocostudio/CCDisplayFactory.cpp | 2 +- cocos/editor-support/cocostudio/CCSkin.cpp | 2 +- .../CocoStudioArmatureTest/ArmatureScene.cpp | 16 +++++++++++++++- .../CocoStudioArmatureTest/ArmatureScene.h | 2 ++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCDisplayFactory.cpp b/cocos/editor-support/cocostudio/CCDisplayFactory.cpp index 20f826cb2b..7463ff54ff 100644 --- a/cocos/editor-support/cocostudio/CCDisplayFactory.cpp +++ b/cocos/editor-support/cocostudio/CCDisplayFactory.cpp @@ -115,7 +115,7 @@ void DisplayFactory::updateDisplay(Bone *bone, float dt, bool dirty) anchorPoint = PointApplyTransform(anchorPoint, displayTransform); displayTransform.mat[12] = anchorPoint.x; displayTransform.mat[13] = anchorPoint.y; - kmMat4 t = TransformConcat(displayTransform, bone->getArmature()->getNodeToParentTransform()); + kmMat4 t = TransformConcat( bone->getArmature()->getNodeToParentTransform(),displayTransform); detector->updateTransform(t); } while (0); diff --git a/cocos/editor-support/cocostudio/CCSkin.cpp b/cocos/editor-support/cocostudio/CCSkin.cpp index 94ba291e2b..d26199c205 100644 --- a/cocos/editor-support/cocostudio/CCSkin.cpp +++ b/cocos/editor-support/cocostudio/CCSkin.cpp @@ -197,7 +197,7 @@ void Skin::updateTransform() kmMat4 Skin::getNodeToWorldTransform() const { - return TransformConcat(_transform, _bone->getArmature()->getNodeToWorldTransform()); + return TransformConcat( _bone->getArmature()->getNodeToWorldTransform(), _transform); } kmMat4 Skin::getNodeToWorldTransformAR() const diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp index 1349970d67..fdf76c80a0 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp @@ -1067,8 +1067,22 @@ void TestColliderDetector::update(float delta) } void TestColliderDetector::draw() { - armature2->drawContour(); + _customCommand.init(0, _vertexZ); + _customCommand.func = CC_CALLBACK_0(TestColliderDetector::onDraw, this); + Director::getInstance()->getRenderer()->addCommand(&_customCommand); } + +void TestColliderDetector::onDraw() +{ + kmMat4 oldMat; + kmGLGetMatrix(KM_GL_MODELVIEW, &oldMat); + kmGLLoadMatrix(&_modelViewTransform); + + armature2->drawContour(); + + kmGLLoadMatrix(&oldMat); +} + #endif diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h index c3b64debb9..9a07cc0d5d 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h @@ -271,6 +271,7 @@ public: virtual std::string title() const override; virtual void update(float delta); virtual void draw(); + void onDraw(); void onFrameEvent(cocostudio::Bone *bone, const std::string& evt, int originFrameIndex, int currentFrameIndex); @@ -278,6 +279,7 @@ public: cocostudio::Armature *armature; cocostudio::Armature *armature2; + CustomCommand _customCommand; //new render needed this for drawing primitives cocos2d::Sprite *bullet; }; #endif