简体   繁体   English

renderscript rsMatrixMultiply函数

[英]renderscript rsMatrixMultiply function

I am developing an OpenGL ES 2.0 android application, by porting the code from an renderscript created application. 我正在通过移植来自renderscript创建的应用程序中的代码来开发OpenGL ES 2.0 android应用程序。 In renderscript this function is used: 在renderscript中使用此函数:

float4 rsMatrixMultiply(rs_matrix4x4 *m, float3 in);

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. 有谁知道该函数的确切功能以及如何实现,因为我需要在使用Java的OpenGL应用程序中使用它。

This does standard matrix multiplication between the matrix 'm' and the vector 'in'. 这在矩阵“ m”和向量“ in”之间进行了标准矩阵乘法。 The result is placed back in 'm'. 结果放回“ 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. 为了将4x4矩阵与大小为3的向量相乘,此函数的行为就好像向量是w4维值为1的float4一样。

For the documentation around this function, take a look here: http://developer.android.com/reference/renderscript/rs__matrix_8rsh.html 有关此功能的文档,请在此处查看: http : //developer.android.com/reference/renderscript/rs__matrix_8rsh.html

Below is the actual code from rs_core.c of the AOSP: 以下是来自AOSP的rs_core.c的实际代码:

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;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM