gpt4 book ai didi

android - 尝试实现 ar core 时无法加载 Renderable

转载 作者:行者123 更新时间:2023-12-05 00:05:15 24 4
gpt4 key购买 nike

为什么我在尝试创建 ar 应用程序时收到此错误?

Unable to load Renderable registryId='android.resource://com.nevco.ar/raw/cat'
java.util.concurrent.CompletionException: java.lang.AssertionError: No RCB file at uri: android.resource://com.nevco.ar/raw/cat

我正在按照本教程创建一个简单的 ar 应用程序,但每次我启动我的应用程序时,我都会收到此错误。我不知道该怎么做才能解决这个问题。一些帮助将不胜感激。我附上了教程的链接。 https://www.androidauthority.com/google-arcore-972579/

public class MainActivity extends AppCompatActivity {
private static final String TAG = MainActivity.class.getSimpleName();
private static final double MIN_OPENGL_VERSION = 3.0;

//Create a member variable for ModelRenderable//

private ModelRenderable dinoRenderable;

//Create a member variable for ArFragment//

private ArFragment arCoreFragment;

@RequiresApi(api = VERSION_CODES.N)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (!checkDevice((this))) {
return;
}

setContentView(R.layout.activity_main);
arCoreFragment = (ArFragment)

//Find the fragment, using fragment manager//

getSupportFragmentManager().findFragmentById(R.id.main_fragment);

if (Build.VERSION.SDK_INT >= VERSION_CODES.N) {

//Build the ModelRenderable//

ModelRenderable.builder()
.setSource(this, R.raw.cat)
.build()
.thenAccept(renderable -> dinoRenderable = renderable)
.exceptionally(

//If an error occurs...//

throwable -> {

//...then print the following message to Logcat//

Log.e(TAG, "Unable to load renderable");
return null;
});
}

//Listen for onTap events//

arCoreFragment.setOnTapArPlaneListener(
(HitResult hitResult, Plane plane, MotionEvent motionEvent) -> {
if (dinoRenderable == null) {
return;
}

Anchor anchor = hitResult.createAnchor();

//Build a node of type AnchorNode//

AnchorNode anchorNode = new AnchorNode(anchor);

//Connect the AnchorNode to the Scene//

anchorNode.setParent(arCoreFragment.getArSceneView().getScene());

//Build a node of type TransformableNode//

TransformableNode transformableNode = new TransformableNode(arCoreFragment.getTransformationSystem());

//Connect the TransformableNode to the AnchorNode//

transformableNode.setParent(anchorNode);

//Attach the Renderable//

transformableNode.setRenderable(dinoRenderable);

//Set the node//

transformableNode.select();
});
}

public static boolean checkDevice(final Activity activity) {

//If the device is running Android Marshmallow or earlier...//

if (Build.VERSION.SDK_INT < VERSION_CODES.N) {

//...then print the following message to Logcat//

Log.e(TAG, "Sceneform requires Android N or higher");
activity.finish();
return false;
}
String openGlVersionString =
((ActivityManager) activity.getSystemService(Context.ACTIVITY_SERVICE))
.getDeviceConfigurationInfo()

//Check the version of OpenGL ES//

.getGlEsVersion();

//If the device is running anything less than OpenGL ES 3.0...//

if (Double.parseDouble(openGlVersionString) < MIN_OPENGL_VERSION) {

//...then print the following message to Logcat//

Log.e(TAG, "Requires OpenGL ES 3.0 or higher");
activity.finish();
return false;
}
return true;
}

最佳答案

检查你的模型是.sfb文件还是.obj文件。

.sfb 正在为我工​​作,但我在 .obj 中遇到同样的错误。

关于android - 尝试实现 ar core 时无法加载 Renderable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60366284/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com