在此示例中,当您将应用程序部署到Android时,会检测到任何水平曲面/平面 . 如果您点击检测到的平面,“Andy”将会在您点击的位置渲染Andrid机器人 . 很酷 .
我试图找到代码中的位置:
这是检测到水平表面/平面;和
逻辑在哪里正确地调整大小并重新定位Andy(我假设你点击的点离相机更远,他会变小,等等)
我相信当检测到飞机时,Android框架会调用 onSurfaceCreated 方法:
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
GLES20.glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
// Create the texture and pass it to ARCore session to be filled during update().
mBackgroundRenderer.createOnGlThread(/*context=*/this);
mSession.setCameraTextureName(mBackgroundRenderer.getTextureId());
// Prepare the other rendering objects.
try {
mVirtualObject.createOnGlThread(/*context=*/this, "andy.obj", "andy.png");
mVirtualObject.setMaterialProperties(0.0f, 3.5f, 1.0f, 6.0f);
mVirtualObjectShadow.createOnGlThread(/*context=*/this,
"andy_shadow.obj", "andy_shadow.png");
mVirtualObjectShadow.setBlendMode(BlendMode.Shadow);
mVirtualObjectShadow.setMaterialProperties(1.0f, 0.0f, 0.0f, 1.0f);
} catch (IOException e) {
Log.e(TAG, "Failed to read obj file");
}
try {
mPlaneRenderer.createOnGlThread(/*context=*/this, "trigrid.png");
} catch (IOException e) {
Log.e(TAG, "Failed to read plane texture");
}
mPointCloud.createOnGlThread(/*context=*/this);
}
但是,该代码看起来假设用户已经在表面上轻敲 . 我没有看到一个 if -有条件的,基本上说“用户已经检测到平面/表面上的渲染Andy _1300261” . 任何人都可以发现这可能发生的地方吗?