@@ -57,35 +57,33 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) {
57
57
case cc . Director . PROJECTION_2D :
58
58
cc . kmGLMatrixMode ( cc . KM_GL_PROJECTION ) ;
59
59
cc . kmGLLoadIdentity ( ) ;
60
- var orthoMatrix = new cc . kmMat4 ( ) ;
61
- cc . kmMat4OrthographicProjection (
62
- orthoMatrix ,
60
+ var orthoMatrix = cc . math . Matrix4 . createOrthographicProjection (
63
61
- ox ,
64
- size . width - ox ,
62
+ size . width - ox ,
65
63
- oy ,
66
- size . height - oy ,
64
+ size . height - oy ,
67
65
- 1024 , 1024 ) ;
68
66
cc . kmGLMultMatrix ( orthoMatrix ) ;
69
67
cc . kmGLMatrixMode ( cc . KM_GL_MODELVIEW ) ;
70
68
cc . kmGLLoadIdentity ( ) ;
71
69
break ;
72
70
case cc . Director . PROJECTION_3D :
73
71
var zeye = _t . getZEye ( ) ;
74
- var matrixPerspective = new cc . kmMat4 ( ) , matrixLookup = new cc . kmMat4 ( ) ;
72
+ var matrixPerspective = new cc . math . Matrix4 ( ) , matrixLookup = new cc . math . Matrix4 ( ) ;
75
73
cc . kmGLMatrixMode ( cc . KM_GL_PROJECTION ) ;
76
74
cc . kmGLLoadIdentity ( ) ;
77
75
78
76
// issue #1334
79
- cc . kmMat4PerspectiveProjection ( matrixPerspective , 60 , size . width / size . height , 0.1 , zeye * 2 ) ;
77
+ matrixPerspective = cc . math . Matrix4 . createPerspectiveProjection ( 60 , size . width / size . height , 0.1 , zeye * 2 ) ;
80
78
81
79
cc . kmGLMultMatrix ( matrixPerspective ) ;
82
80
83
81
cc . kmGLMatrixMode ( cc . KM_GL_MODELVIEW ) ;
84
82
cc . kmGLLoadIdentity ( ) ;
85
- var eye = cc . kmVec3Fill ( null , - ox + size . width / 2 , - oy + size . height / 2 , zeye ) ;
86
- var center = cc . kmVec3Fill ( null , - ox + size . width / 2 , - oy + size . height / 2 , 0.0 ) ;
87
- var up = cc . kmVec3Fill ( null , 0.0 , 1.0 , 0.0 ) ;
88
- cc . kmMat4LookAt ( matrixLookup , eye , center , up ) ;
83
+ var eye = new cc . math . Vec3 ( - ox + size . width / 2 , - oy + size . height / 2 , zeye ) ;
84
+ var center = new cc . math . Vec3 ( - ox + size . width / 2 , - oy + size . height / 2 , 0.0 ) ;
85
+ var up = new cc . math . Vec3 ( 0.0 , 1.0 , 0.0 ) ;
86
+ matrixLookup . lookAt ( eye , center , up ) ;
89
87
cc . kmGLMultMatrix ( matrixLookup ) ;
90
88
break ;
91
89
case cc . Director . PROJECTION_CUSTOM :
@@ -238,38 +236,31 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) {
238
236
} ;
239
237
240
238
_p . convertToGL = function ( uiPoint ) {
241
- var transform = new cc . kmMat4 ( ) ;
239
+ var transform = new cc . math . Matrix4 ( ) ;
242
240
cc . GLToClipTransform ( transform ) ;
243
241
244
- var transformInv = new cc . kmMat4 ( ) ;
245
- cc . kmMat4Inverse ( transformInv , transform ) ;
242
+ var transformInv = transform . inverse ( ) ;
246
243
247
244
// Calculate z=0 using -> transform*[0, 0, 0, 1]/w
248
245
var zClip = transform . mat [ 14 ] / transform . mat [ 15 ] ;
249
-
250
246
var glSize = this . _openGLView . getDesignResolutionSize ( ) ;
251
- var clipCoord = new cc . kmVec3 ( 2.0 * uiPoint . x / glSize . width - 1.0 , 1.0 - 2.0 * uiPoint . y / glSize . height , zClip ) ;
252
-
253
- var glCoord = new cc . kmVec3 ( ) ;
254
- cc . kmVec3TransformCoord ( glCoord , clipCoord , transformInv ) ;
255
-
247
+ var glCoord = new cc . math . Vec3 ( 2.0 * uiPoint . x / glSize . width - 1.0 , 1.0 - 2.0 * uiPoint . y / glSize . height , zClip ) ;
248
+ glCoord . transformCoord ( transformInv ) ;
256
249
return cc . p ( glCoord . x , glCoord . y ) ;
257
250
} ;
258
251
259
252
_p . convertToUI = function ( glPoint ) {
260
- var transform = new cc . kmMat4 ( ) ;
253
+ var transform = new cc . math . Matrix4 ( ) ;
261
254
cc . GLToClipTransform ( transform ) ;
262
255
263
- var clipCoord = new cc . kmVec3 ( ) ;
256
+ var clipCoord = new cc . math . Vec3 ( glPoint . x , glPoint . y , 0.0 ) ;
264
257
// Need to calculate the zero depth from the transform.
265
- var glCoord = new cc . kmVec3 ( glPoint . x , glPoint . y , 0.0 ) ;
266
- cc . kmVec3TransformCoord ( clipCoord , glCoord , transform ) ;
258
+ clipCoord . transformCoord ( transform ) ;
267
259
268
260
var glSize = this . _openGLView . getDesignResolutionSize ( ) ;
269
261
return cc . p ( glSize . width * ( clipCoord . x * 0.5 + 0.5 ) , glSize . height * ( - clipCoord . y * 0.5 + 0.5 ) ) ;
270
262
} ;
271
263
272
-
273
264
_p . getVisibleSize = function ( ) {
274
265
//if (this._openGLView) {
275
266
return this . _openGLView . getVisibleSize ( ) ;
0 commit comments