【发布时间】:2018-02-20 03:06:33
【问题描述】:
我正在努力了解Google's ARCore API并推送他们的sample project (java_arcore_hello_ar) to GitHub。
在此示例中,当您将应用部署到 Android 时,会检测到任何水平表面/平面。如果您点击检测到的平面,“Andy”Andrid 机器人将在您点击的位置呈现。很酷。
我正在尝试查找代码中的位置:
- 检测到水平表面/平面;和
- 正确调整 Andy 大小和重新定向 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-conditional 基本上说“渲染 Andy 如果用户已经点击了检测到的平面/表面。”。谁能发现这可能发生在哪里?
【问题讨论】:
标签: java android augmented-reality arcore