Вот как я его использую: < /p>
Код: Выделить всё
camera.getProjectionMatrix(projectionMatrix, 0, 0.1f, 100.0f)
camera.getViewMatrix(viewMatrix, 0)
val qEUS = geoPose.eastUpSouthQuaternion
val worldPointsData = FloatArray(pointsOfInterest.size * 4)
var bufferIndex = 0
// converting azimuth/elevation to EUS
for ((azimuth, elevation) in pointsOfInterest) {
val azRad = Math.toRadians(azimuth.toDouble())
val elRad = Math.toRadians(elevation.toDouble())
val eusX = (cos(elRad) * sin(azRad)).toFloat()
val eusY = sin(elRad).toFloat()
val eusZ = (-cos(elRad) * cos(azRad)).toFloat()
val vEUS = floatArrayOf(eusX, eusY, eusZ)
// using a Pose with no translation
val rotationPoseEUS = Pose(floatArrayOf(0f,0f,0f), qEUS)
val vWorldDir = rotationPoseEUS.rotateVector(vEUS)
worldPointsData[bufferIndex++] = vWorldDir[0]
worldPointsData[bufferIndex++] = vWorldDir[1]
worldPointsData[bufferIndex++] = vWorldDir[2]
worldPointsData[bufferIndex++] = 0.0f // at infinite
}
pointsVertexBuffer.clear()
pointsVertexBuffer.put(worldPointsData)
pointsVertexBuffer.position(0)
GLES20.glUseProgram(pointProgram)
// I suspect I'm doing things wrong here
// Misinterpreting what geoPose.eastUpSouthQuaternion gives me
// And if I have to use projection matrix and viewMatrix from ARCore camera
Matrix.multiplyMM(modelViewProjectionMatrix, 0, projectionMatrix, 0, viewMatrix, 0)
GLES20.glUniformMatrix4fv(mvpUniformPoint, 1, false, modelViewProjectionMatrix, 0)
// Binding points to GL Program
// Everything fine as points are displyed but not at right position in space
// And behaviour is wrong when moving phone
GLES20.glEnableVertexAttribArray(positionAttribPoint)
GLES20.glVertexAttribPointer(
positionAttribPoint, 4, GLES20.GL_FLOAT, false, 0, pointsVertexBuffer
)
GLES20.glUniform4f(colorUniformPoint, 1.0f, 0.0f, 0.0f, 1.0f) // Red lines
GLES20.glDrawArrays(GLES20.GL_POINTS, 0, pointsOfInterest.size)
if (pointsOfInterest.size > 1) {
GLES20.glLineWidth(8.0f)
GLES20.glUniform4f(colorUniformPoint, 0.0f, 1.0f, 0.0f, 1.0f) // Green points
GLES20.glDrawArrays(GLES20.GL_LINE_STRIP, 0, pointsOfInterest.size)
}
GLES20.glDisableVertexAttribArray(positionAttribPoint)
GLES20.glUseProgram(0)
Подробнее здесь: https://stackoverflow.com/questions/796 ... patialmode