remove kmMat4 interface in AffineTransform

This commit is contained in:
Huabing.Xu 2014-04-09 14:21:41 +08:00
parent 8d01d4e07d
commit 504fa2aa60
3 changed files with 21 additions and 16 deletions

View File

@ -397,7 +397,8 @@ void Renderer::convertToWorldCoordinates(V3F_C4B_T2F_Quad* quads, ssize_t quanti
// kmGLGetMatrix(KM_GL_PROJECTION, &matrixP);
// kmMat4Multiply(&mvp, &matrixP, &modelView);
kmMat4 modelView2 = modelView;
for(ssize_t i=0; i<quantity; ++i) {
for(ssize_t i=0; i<quantity; ++i)
{
V3F_C4B_T2F_Quad *q = &quads[i];
kmVec3 *vec1 = (kmVec3*)&q->bl.vertices;

View File

@ -46,10 +46,11 @@ Point __CCPointApplyAffineTransform(const Point& point, const AffineTransform& t
return p;
}
Point PointApplyTransform(const Point& point, const kmMat4& transform)
Point PointApplyTransform(const Point& point, const Matrix& transform)
{
kmVec3 vec = {point.x, point.y, 0};
kmVec3Transform(&vec, &vec, &transform);
kmMat4 transform2 = transform;
kmVec3Transform(&vec, &vec, &transform2);
return Point(vec.x, vec.y);
}
@ -91,22 +92,24 @@ Rect RectApplyAffineTransform(const Rect& rect, const AffineTransform& anAffineT
return Rect(minX, minY, (maxX - minX), (maxY - minY));
}
Rect RectApplyTransform(const Rect& rect, const kmMat4& transform)
Rect RectApplyTransform(const Rect& rect, const Matrix& transform)
{
float top = rect.getMinY();
float left = rect.getMinX();
float right = rect.getMaxX();
float bottom = rect.getMaxY();
kmMat4 transform2 = transform;
kmVec3 topLeft = {left, top};
kmVec3 topRight = {right, top};
kmVec3 bottomLeft = {left, bottom};
kmVec3 bottomRight = {right, bottom};
kmVec3Transform(&topLeft, &topLeft, &transform);
kmVec3Transform(&topRight, &topRight, &transform);
kmVec3Transform(&bottomLeft, &bottomLeft, &transform);
kmVec3Transform(&bottomRight, &bottomRight, &transform);
kmVec3Transform(&topLeft, &topLeft, &transform2);
kmVec3Transform(&topRight, &topRight, &transform2);
kmVec3Transform(&bottomLeft, &bottomLeft, &transform2);
kmVec3Transform(&bottomRight, &bottomRight, &transform2);
float minX = min(min(topLeft.x, topRight.x), min(bottomLeft.x, bottomRight.x));
float maxX = max(max(topLeft.x, topRight.x), max(bottomLeft.x, bottomRight.x));
@ -150,11 +153,9 @@ AffineTransform AffineTransformConcat(const AffineTransform& t1, const AffineTra
t1.tx * t2.b + t1.ty * t2.d + t2.ty); //ty
}
kmMat4 TransformConcat(const kmMat4& t1, const kmMat4& t2)
Matrix TransformConcat(const Matrix& t1, const Matrix& t2)
{
kmMat4 ret;
kmMat4Multiply(&ret, &t1, &t2);
return ret;
return t1 * t2;
}

View File

@ -29,9 +29,12 @@ THE SOFTWARE.
#include "CCGeometry.h"
#include "CCPlatformMacros.h"
#include "kazmath/kazmath.h"
#include "CCMath.h"
NS_CC_BEGIN
USING_NS_CC_MATH;
struct AffineTransform {
float a, b, c, d;
float tx, ty;
@ -51,8 +54,8 @@ CC_DLL Size __CCSizeApplyAffineTransform(const Size& size, const AffineTransform
CC_DLL AffineTransform AffineTransformMakeIdentity();
CC_DLL Rect RectApplyAffineTransform(const Rect& rect, const AffineTransform& anAffineTransform);
CC_DLL Rect RectApplyTransform(const Rect& rect, const kmMat4& transform);
CC_DLL Point PointApplyTransform(const Point& point, const kmMat4& transform);
CC_DLL Rect RectApplyTransform(const Rect& rect, const Matrix& transform);
CC_DLL Point PointApplyTransform(const Point& point, const Matrix& transform);
CC_DLL AffineTransform AffineTransformTranslate(const AffineTransform& t, float tx, float ty);
CC_DLL AffineTransform AffineTransformRotate(const AffineTransform& aTransform, float anAngle);
@ -61,7 +64,7 @@ CC_DLL AffineTransform AffineTransformConcat(const AffineTransform& t1, const Af
CC_DLL bool AffineTransformEqualToTransform(const AffineTransform& t1, const AffineTransform& t2);
CC_DLL AffineTransform AffineTransformInvert(const AffineTransform& t);
kmMat4 TransformConcat(const kmMat4& t1, const kmMat4& t2);
Matrix TransformConcat(const Matrix& t1, const Matrix& t2);
extern CC_DLL const AffineTransform AffineTransformIdentity;