Director::getMatrix returns Matrix instead of kmMat4

This commit is contained in:
Huabing.Xu 2014-04-04 17:31:21 +08:00
parent ea6d8e4e42
commit f1b1678900
9 changed files with 29 additions and 29 deletions

View File

@ -578,7 +578,7 @@ void Director::pushMatrix(MATRIX_STACK_TYPE type)
}
}
kmMat4 Director::getMatrix(MATRIX_STACK_TYPE type)
Matrix Director::getMatrix(MATRIX_STACK_TYPE type)
{
Matrix result;
if(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW == type)
@ -607,7 +607,7 @@ kmMat4 Director::getMatrix(MATRIX_STACK_TYPE type)
// {
// CCASSERT(false, "Error in director matrix stack");
// }
return matrixToKmMat4(result);
return result;
}
void Director::setProjection(Projection projection)
@ -739,7 +739,7 @@ static void GLToClipTransform(kmMat4 *transformOut)
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
kmMat4 projection;
projection = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
projection = matrixToKmMat4(director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION));
#if CC_TARGET_PLATFORM == CC_PLATFORM_WP8
//if needed, we need to undo the rotation for Landscape orientation in order to get the correct positions
@ -747,7 +747,7 @@ static void GLToClipTransform(kmMat4 *transformOut)
#endif
kmMat4 modelview;
modelview = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
modelview = matrixToKmMat4(director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW));
kmMat4Multiply(transformOut, &projection, &modelview);
}

View File

@ -111,7 +111,7 @@ public:
void loadIdentityMatrix(MATRIX_STACK_TYPE type);
void loadMatrix(MATRIX_STACK_TYPE type, const kmMat4& mat);
void multiplyMatrix(MATRIX_STACK_TYPE type, const kmMat4& mat);
kmMat4 getMatrix(MATRIX_STACK_TYPE type);
Matrix getMatrix(MATRIX_STACK_TYPE type);
void resetMatrixStack();
public:
static const char *EVENT_PROJECTION_CHANGED;

View File

@ -633,14 +633,14 @@ void GLProgram::setUniformsForBuiltins()
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
kmMat4 matrixMV;
matrixMV = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
matrixMV = matrixToKmMat4(director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW));
setUniformsForBuiltins(matrixMV);
}
void GLProgram::setUniformsForBuiltins(const kmMat4 &matrixMV)
{
kmMat4 matrixP = Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
kmMat4 matrixP = matrixToKmMat4(Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION));
if(_flags.usesP)
setUniformLocationWithMatrix4fv(_uniforms[UNIFORM_P_MATRIX], matrixP.mat, 1);

View File

@ -933,8 +933,8 @@ void Node::draw(Renderer* renderer, const kmMat4 &transform, bool transformUpdat
void Node::visit()
{
auto renderer = Director::getInstance()->getRenderer();
kmMat4 parentTransform = Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
visit(renderer, parentTransform, true);
Matrix parentTransform = Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
visit(renderer, matrixToKmMat4(parentTransform), true);
}
void Node::visit(Renderer* renderer, const kmMat4 &parentTransform, bool parentTransformUpdated)

View File

@ -524,10 +524,10 @@ void RenderTexture::onBegin()
//
Director *director = Director::getInstance();
Size size = director->getWinSizeInPixels();
_oldProjMatrix = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
_oldProjMatrix = matrixToKmMat4(director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION));
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, _projectionMatrix);
_oldTransMatrix = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
_oldTransMatrix = matrixToKmMat4(director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW));
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _transformMatrix);
if(!_keepMatrix)
@ -678,10 +678,10 @@ void RenderTexture::begin()
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
_projectionMatrix = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
_projectionMatrix = matrixToKmMat4(director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION));
director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
_transformMatrix = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
_transformMatrix = matrixToKmMat4(director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW));
if(!_keepMatrix)
{

View File

@ -610,7 +610,7 @@ void Sprite::drawDebugData()
Director* director = Director::getInstance();
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
kmMat4 oldModelView;
oldModelView = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
oldModelView = matrixToKmMat4(director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW));
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform);
// draw bounding box
Point vertices[4] = {

View File

@ -221,7 +221,7 @@ kmMat4 Skin::getNodeToWorldTransformAR() const
void Skin::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
kmMat4 mv = Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
kmMat4 mv = matrixToKmMat4(Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW));
//TODO implement z order
_quadCommand.init(_globalZOrder, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, mv);

View File

@ -1678,9 +1678,9 @@ void ActionCatmullRomStacked::draw(Renderer *renderer, const kmMat4 &transform,
kmMat4Translation(&translation,50,50,0);
director->multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, translation);
_modelViewMV1 = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
_modelViewMV1 = matrixToKmMat4(director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW));
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
_modelViewMV2 = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
_modelViewMV2 = matrixToKmMat4(director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW));
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(ActionCatmullRomStacked::onDraw, this, transform, transformUpdated);
@ -1693,7 +1693,7 @@ void ActionCatmullRomStacked::onDraw(const kmMat4 &transform, bool transformUpda
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
kmMat4 oldMat;
oldMat = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
oldMat = matrixToKmMat4(director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW));
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewMV1);
DrawPrimitives::drawCatmullRom(_array1,50);
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewMV2);
@ -1798,7 +1798,7 @@ void ActionCardinalSplineStacked::draw(Renderer *renderer, const kmMat4 &transfo
kmMat4Translation(&translation,50,50,0);
director->multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, translation);
_modelViewMV1 = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
_modelViewMV1 = matrixToKmMat4(director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW));
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
auto s = Director::getInstance()->getWinSize();
@ -1809,7 +1809,7 @@ void ActionCardinalSplineStacked::draw(Renderer *renderer, const kmMat4 &transfo
kmMat4Translation(&translation,s.width/2,50,0);
director->multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, translation);
_modelViewMV2 = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
_modelViewMV2 = matrixToKmMat4(director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW));
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
_customCommand.init(_globalZOrder);
@ -1823,7 +1823,7 @@ void ActionCardinalSplineStacked::onDraw(const kmMat4 &transform, bool transform
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
kmMat4 oldMat;
oldMat = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
oldMat = matrixToKmMat4(director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW));
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewMV1);
DrawPrimitives::drawCardinalSpline(_array, 0, 100);
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewMV2);
@ -2179,10 +2179,10 @@ void ActionCatmullRom::draw(Renderer *renderer, const kmMat4 &transform, bool tr
//Create a rotation matrix using the axis and the angle
kmMat4Translation(&translation,50,50,0);
director->multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, translation);
_modelViewMV1 = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
_modelViewMV1 = matrixToKmMat4(director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW));
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
_modelViewMV2 = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
_modelViewMV2 = matrixToKmMat4(director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW));
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(ActionCatmullRom::onDraw, this, transform, transformUpdated);
@ -2196,7 +2196,7 @@ void ActionCatmullRom::onDraw(const kmMat4 &transform, bool transformUpdated)
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
kmMat4 oldMat;
oldMat = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
oldMat = matrixToKmMat4(director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW));
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewMV1);
DrawPrimitives::drawCatmullRom(_array1, 50);
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewMV2);
@ -2284,7 +2284,7 @@ void ActionCardinalSpline::draw(Renderer *renderer, const kmMat4 &transform, boo
//Create a rotation matrix using the axis and the angle
kmMat4Translation(&translation,50,50,0);
director->multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, translation);
_modelViewMV1 = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
_modelViewMV1 = matrixToKmMat4(director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW));
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
auto s = Director::getInstance()->getWinSize();
@ -2294,7 +2294,7 @@ void ActionCardinalSpline::draw(Renderer *renderer, const kmMat4 &transform, boo
//Create a rotation matrix using the axis and the angle
kmMat4Translation(&translation,s.width/2,50,0);
director->multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, translation);
_modelViewMV2 = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
_modelViewMV2 = matrixToKmMat4(director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW));
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
_customCommand.init(_globalZOrder);
@ -2308,7 +2308,7 @@ void ActionCardinalSpline::onDraw(const kmMat4 &transform, bool transformUpdated
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
kmMat4 oldMat;
oldMat = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
oldMat = matrixToKmMat4(director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW));
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewMV1);
DrawPrimitives::drawCardinalSpline(_array, 0, 100);
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewMV2);

View File

@ -152,7 +152,7 @@ void Box2DTestLayer::draw(Renderer *renderer, const kmMat4 &transform, bool tran
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
_modelViewMV = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
_modelViewMV = matrixToKmMat4(director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW));
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(Box2DTestLayer::onDraw, this);
@ -169,7 +169,7 @@ void Box2DTestLayer::onDraw()
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
kmMat4 oldMV;
oldMV = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
oldMV = matrixToKmMat4(director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW));
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewMV);
world->DrawDebugData();
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, oldMV);