renderscript rsMatrixMultiply功能 [英] renderscript rsMatrixMultiply function

查看:190
本文介绍了renderscript rsMatrixMultiply功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发的OpenGL ES 2.0的Andr​​oid应用程序,通过移植从renderscript的code创建的应用程序。在renderscript使用此函数:

I am developing an OpenGL ES 2.0 android application, by porting the code from an renderscript created application. In renderscript this function is used:

float4 rsMatrixMultiply(rs_matrix4x4 *m, float3 in);

有谁知道正是这种功能是什么,它​​是如何实现的,因为我需要使用Java使用它在我的OpenGL应用程序。

Does anyone knows what exactly this function does and how it is implemented, because I need to use it in my OpenGL application using Java.

推荐答案

这确实矩阵'm'和'在'向量之间的标准矩阵乘法。其结果是在M放回。为了乘以​​大小为3的向量的4x4矩阵,这个函数的行为就好像载体分别与W尺寸值为1 FLOAT4。

This does standard matrix multiplication between the matrix 'm' and the vector 'in'. The result is placed back in 'm'. In order to multiply the 4x4 matrix with a vector of size 3, this function behaves as if the vector were float4 with a value of 1 for the w dimension.

有关解决这个函数的文档,下面一起来看看:
http://developer.android.com/reference/renderscript/rs__matrix_8rsh.html

For the documentation around this function, take a look here: http://developer.android.com/reference/renderscript/rs__matrix_8rsh.html

下面是从AOSP的rs_core.c实际code:

Below is the actual code from rs_core.c of the AOSP:

extern float4 __attribute__((overloadable))
rsMatrixMultiply(const rs_matrix4x4 *m, float3 in) {
    float4 ret;
    ret.x = (m->m[0] * in.x) + (m->m[4] * in.y) + (m->m[8] * in.z) + m->m[12];
    ret.y = (m->m[1] * in.x) + (m->m[5] * in.y) + (m->m[9] * in.z) + m->m[13];
    ret.z = (m->m[2] * in.x) + (m->m[6] * in.y) + (m->m[10] * in.z) + m->m[14];
    ret.w = (m->m[3] * in.x) + (m->m[7] * in.y) + (m->m[11] * in.z) + m->m[15];
    return ret;
}

这篇关于renderscript rsMatrixMultiply功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆