Ale*_*sny 6 android augmented-reality kotlin arcore sceneform
我想在 SceneView 中展示模型时使用正交相机(没有 AR)。在 API 中找不到这样做的方法。我是否遗漏了什么或缺少该功能?
据我所知,目前没有在/中进行相机投影的ORTHO
方法(立方体平截头体)。但是您可以通过 4x4 Matrix 自己制作。所以,你需要做的是计算,,,,和使用特性以下原则。ARCore
Sceneform
left
right
top
bottom
near
far
您的投影矩阵 4x4 必须如下所示:
编辑:工作代码,其中scaleFactor
1 左右的值和height
/width
是SceneView
.
private fun buildOrthographicMatrix(right: Float,
top: Float,
far: Float,
near: Float): FloatArray {
val matrix = FloatArray(16)
matrix[0] = 1 / right
matrix[1] = 0f
matrix[2] = 0f
matrix[3] = 0f
matrix[4] = 0f
matrix[5] = 1 / top
matrix[6] = 0f
matrix[7] = 0f
matrix[8] = 0f
matrix[9] = 0f
matrix[10] = -2 / (far - near)
matrix[11] = 0f
matrix[12] = 0f
matrix[13] = 0f
matrix[14] = -(far + near) / (far - near)
matrix[15] = 1f
return matrix
}
val newMatrix = buildOrthographicMatrix(1f / scaleFactor,
1f / scaleFactor * height / width,
30f,
0.01f)
camera.projectionMatrix = Matrix(newMatrix)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
609 次 |
最近记录: |