From 080132d0720f6ddf06f6b1bc65a1f4cd1ca30ae4 Mon Sep 17 00:00:00 2001 From: lvlong Date: Tue, 17 Mar 2015 12:15:03 +0800 Subject: [PATCH 1/3] modify sub node transform! --- cocos/3d/CCSprite3D.cpp | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/cocos/3d/CCSprite3D.cpp b/cocos/3d/CCSprite3D.cpp index a20be76a4f..42c83babdb 100644 --- a/cocos/3d/CCSprite3D.cpp +++ b/cocos/3d/CCSprite3D.cpp @@ -370,7 +370,22 @@ Sprite3D* Sprite3D::createSprite3DNode(NodeData* nodedata,ModelData* modeldata,c } } } - sprite->setAdditionalTransform(&nodedata->transform); + //sprite->setAdditionalTransform(&nodedata->transform); + Vec3 pos; + nodedata->transform.getTranslation(&pos); + + Quaternion qua; + nodedata->transform.getRotation(&qua); + + Vec3 scale; + nodedata->transform.getScale(&scale); + + sprite->setPosition3D(pos); + sprite->setRotationQuat(qua); + sprite->setScaleX(scale.x); + sprite->setScaleY(scale.y); + sprite->setScaleZ(scale.z); + sprite->addMesh(mesh); sprite->autorelease(); sprite->genGLProgramState(); @@ -527,7 +542,22 @@ void Sprite3D::createNode(NodeData* nodedata, Node* root, const MaterialDatas& m if(node) { node->setName(nodedata->id); - node->setAdditionalTransform(&nodedata->transform); + //node->setAdditionalTransform(&nodedata->transform); + + Vec3 pos; + nodedata->transform.getTranslation(&pos); + + Quaternion qua; + nodedata->transform.getRotation(&qua); + + Vec3 scale; + nodedata->transform.getScale(&scale); + + node->setPosition3D(pos); + node->setRotationQuat(qua); + node->setScaleX(scale.x); + node->setScaleY(scale.y); + node->setScaleZ(scale.z); if(root) { root->addChild(node); From 733a89100e53d763adfb0722832cf7d37ddff905 Mon Sep 17 00:00:00 2001 From: lvlong Date: Tue, 17 Mar 2015 13:13:03 +0800 Subject: [PATCH 2/3] remove old code! --- cocos/3d/CCSprite3D.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/cocos/3d/CCSprite3D.cpp b/cocos/3d/CCSprite3D.cpp index 42c83babdb..5cb2cc8921 100644 --- a/cocos/3d/CCSprite3D.cpp +++ b/cocos/3d/CCSprite3D.cpp @@ -370,16 +370,14 @@ Sprite3D* Sprite3D::createSprite3DNode(NodeData* nodedata,ModelData* modeldata,c } } } - //sprite->setAdditionalTransform(&nodedata->transform); + + // set locale transform Vec3 pos; nodedata->transform.getTranslation(&pos); - Quaternion qua; nodedata->transform.getRotation(&qua); - Vec3 scale; nodedata->transform.getScale(&scale); - sprite->setPosition3D(pos); sprite->setRotationQuat(qua); sprite->setScaleX(scale.x); @@ -542,22 +540,20 @@ void Sprite3D::createNode(NodeData* nodedata, Node* root, const MaterialDatas& m if(node) { node->setName(nodedata->id); - //node->setAdditionalTransform(&nodedata->transform); + // set locale transform Vec3 pos; nodedata->transform.getTranslation(&pos); - Quaternion qua; nodedata->transform.getRotation(&qua); - Vec3 scale; nodedata->transform.getScale(&scale); - node->setPosition3D(pos); node->setRotationQuat(qua); node->setScaleX(scale.x); node->setScaleY(scale.y); node->setScaleZ(scale.z); + if(root) { root->addChild(node); From 3ce0449c97f6dd4ac26b2467bcf634703b6f5c96 Mon Sep 17 00:00:00 2001 From: lvlong Date: Tue, 17 Mar 2015 15:17:23 +0800 Subject: [PATCH 3/3] decompose --- cocos/3d/CCSprite3D.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/cocos/3d/CCSprite3D.cpp b/cocos/3d/CCSprite3D.cpp index 5cb2cc8921..f5f482d60c 100644 --- a/cocos/3d/CCSprite3D.cpp +++ b/cocos/3d/CCSprite3D.cpp @@ -373,11 +373,9 @@ Sprite3D* Sprite3D::createSprite3DNode(NodeData* nodedata,ModelData* modeldata,c // set locale transform Vec3 pos; - nodedata->transform.getTranslation(&pos); Quaternion qua; - nodedata->transform.getRotation(&qua); Vec3 scale; - nodedata->transform.getScale(&scale); + nodedata->transform.decompose(&scale, &qua, &pos); sprite->setPosition3D(pos); sprite->setRotationQuat(qua); sprite->setScaleX(scale.x); @@ -543,11 +541,9 @@ void Sprite3D::createNode(NodeData* nodedata, Node* root, const MaterialDatas& m // set locale transform Vec3 pos; - nodedata->transform.getTranslation(&pos); Quaternion qua; - nodedata->transform.getRotation(&qua); Vec3 scale; - nodedata->transform.getScale(&scale); + nodedata->transform.decompose(&scale, &qua, &pos); node->setPosition3D(pos); node->setRotationQuat(qua); node->setScaleX(scale.x);