Android ARCore渲染没有场景窗体的对象
我想渲染球体,如下图所示,连接到锚。 不幸的是,所有示例都基于我不想使用的场景表单。球体在空气中应该是自由的,而不是束缚在平坦的表面上 在谷歌的例子中,我能够将一个3D球体渲染到空间中,并将其固定到一个锚上 有了它,我就可以在离相机1米远的空中创建一个黑色球体 我的问题是:Android ARCore渲染没有场景窗体的对象,android,3d,arcore,Android,3d,Arcore,我想渲染球体,如下图所示,连接到锚。 不幸的是,所有示例都基于我不想使用的场景表单。球体在空气中应该是自由的,而不是束缚在平坦的表面上 在谷歌的例子中,我能够将一个3D球体渲染到空间中,并将其固定到一个锚上 有了它,我就可以在离相机1米远的空中创建一个黑色球体 我的问题是: 这是一个好的/正确的方法吗 由于颜色值对对象没有影响,如何更改球体的颜色 如何使其透明 非常感谢。您需要将其连接到锚点。您不需要使用sceneform。Sceneform只是两种方法之一。 在颜色和透明度方面,这取决于你
非常感谢。您需要将其连接到锚点。您不需要使用sceneform。Sceneform只是两种方法之一。
在颜色和透明度方面,这取决于你服务对象的方式。在您的代码中,我看到您使用的是材质,因此很难更改颜色。您能说出另一种颜色方法或举个例子吗?@Fintasys my bad我以为您使用的是sceneform更改颜色,但现在我看到您使用的是OpenGL。在这种情况下,这可能会帮助您,谢谢您,这对我很有帮助。我不得不使用GLES20而不是GL10THO。我还必须使模型透明,并设置此处提到的一些属性:
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
...
backgroundRenderer.createOnGlThread(this);
virtualObject.createOnGlThread(this, "models/sphere.obj", "models/sphere.png");
virtualObject.setMaterialProperties(0.0f, 0.0f, 0.0f, 0.0f);
...
}
@Override
public void onDrawFrame(GL10 gl) {
...
// Get projection matrix.
float[] projmtx = new float[16];
camera.getProjectionMatrix(projmtx, 0, 0.1f, 100.0f);
// Get camera matrix and draw.
float[] viewmtx = new float[16];
camera.getViewMatrix(viewmtx, 0);
// Compute lighting from average intensity of the image.
// The first three components are color scaling factors.
// The last one is the average pixel intensity in gamma space.
final float[] colorCorrectionRgba = new float[] {255f, 0, 0, 255f};
frame.getLightEstimate().getColorCorrection(colorCorrectionRgba, 0);
// Visualize anchors created by touch.
float scaleFactor = 1.0f;
for (Anchor anchor : anchors) {
if (anchor.getTrackingState() != TrackingState.TRACKING) {
continue;
}
anchor.getPose().toMatrix(anchorMatrix, 0);
virtualObject.updateModelMatrix(anchorMatrix, scaleFactor);
float[] objColor = new float[] { 255f, 255f, 255f, 0 };
virtualObject.draw(viewmtx, projmtx, colorCorrectionRgba, objColor);
}
}