OpenGL ES:矩阵变换(平移、旋转、缩放)

总的变换矩阵:
mvpMatrix = projectionMatrix * viewMatrix * modelMatrix;

投影矩阵(projectrionMatrix):

    //根据屏幕宽高计算
    float ratio = (float) width / height;
    //计算投影矩阵
    Matrix.frustumM(mProjectionMatrix, 0, -ratio, ratio, -1, 1, 3, 7);

视图矩阵(viewMatrix):

    float[] resultTransform = new float[16];
    //设置观察视角 eye相机坐标 center 目标坐标 up 相机正上方 向量vuv(相机头部指向)
    Matrix.setLookAtM(mViewMatrix, 0,
            0, 0, 3,
            0f, 0f, 0f,
            0f, 1f, 0.0f);

模型矩阵(modelMatrix):

modelMatrix=translateMatrix * scaleMatrix * rotateMatrix

            private final float[] mBaseMatrix = new float[]{
            1f, 0f, 0f, 0f,
            0f, 1f, 0f, 0f,
            0f, 0f, 1f, 0f,
            0f, 0f, 0f, 1f
		   };
		    // x y z 向量设置绕着哪个轴旋转
            Matrix.setRotateM(mRotationMatrix, 0, mAngle, 0f, 0, 1f);
            // x y z 代表缩放到比例
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值