Closed weijiaqi closed 1 year ago
Only the entrance is kept, and the white part is hidden. How to do it?
Hi! It isn't a simple question. You should experiment with occlusion materials and rendering priority if you want the white shell to be invisible but hide objects inside it.
AnchorNode anchorNode = new AnchorNode();
Vector3 point = new Vector3(0, 0, -2);
anchorNode.setWorldPosition(point);
anchorNode.setParent(arFragment.getArSceneView().getScene());
TransformableNode andy = new TransformableNode(transformationSystem);
andy.setParent(anchorNode);
andy.setRenderable(this.model4).animate(true).start();
andy.setWorldScale(new Vector3(5f, 5f, 5f));
andy.setLocalPosition(new Vector3(0f, 2f, -7f));
andy.setLocalRotation(Quaternion.axisAngle(new Vector3(0f, 1f, 0f), 180f));
andy.getScaleController().setEnabled(false);
// andy.getRotationController().setEnabled(false);
//model4 is the inner object model3 is the white mask
Node node = new Node();
node.setParent(andy);
node.setRenderable(this.model3).animate(true).start();
Is it correct to write the rendering priority like this?
https://download.redph.cn/meta/ar/q1.glb https://download.redph.cn/meta/ar/q2.glb With these two models it is not possible to achieve a white shell that is invisible but hides the objects inside it,Can you help me see if I'm missing any steps?
ModelRenderable.builder() .setSource(this, Uri.parse("models/baike1.glb")) .setIsFilamentGltf(true) .setAsyncLoadEnabled(true) .build() .thenAccept(model -> { MainActivity activity = weakActivity.get(); if (activity != null) { activity.model3 = model; activity.model3.setRenderPriority(Renderable.RENDER_PRIORITY_LAST); activity.model3.setShadowCaster(true); activity.model3.setShadowReceiver(true); } }) .exceptionally(throwable -> { Toast.makeText( this, "Unable to load model", Toast.LENGTH_LONG).show(); return null; });
ModelRenderable.builder()
.setSource(this, Uri.parse("models/tiankongdimian1.glb"))
.setIsFilamentGltf(true)
.setAsyncLoadEnabled(true)
.build()
.thenAccept(model -> {
MainActivity activity = weakActivity.get();
if (activity != null) {
activity.model4 = model;
activity.model4.setRenderPriority(0);
activity.model4.setShadowCaster(true);
activity.model4.setShadowReceiver(true);
}
})
.exceptionally(throwable -> {
Toast.makeText(
this, "Unable to load model", Toast.LENGTH_LONG).show();
return null;
});
The effect I want to achieve is ar portal, but I have been unable to make the white mask transparent
hi, brother, please reply when you see it, give me some ideas to solve it
See how this is done for augmented faces: https://github.com/SceneView/sceneform-android/blob/master/ux/src/main/java/com/google/ar/sceneform/ux/AugmentedFaceNode.java#L243 I'm not sure if it is possible to achieve in glTF.
When did you write a demo of an ar portal? There is very little Android-related information on git.
I haven't. It is just a similar functionality of hiding other objects with an invisible face mesh :sweat_smile:
@grassydragon I exited and entered multiple times in my class, and then a black screen appeared in the interface rendering, but the click event of the model still existed. I checked all the related problems and could not solve it. How can I avoid this situation? How to write it in the onDestroy method
I actually haven't used any special code in the onDestroy
method and haven't encountered this problem.
On the Samsung Note10, I first entered the class class to render the model, and the screen went black when I exited and then entered. How do I destroy the previously rendered ones?
Is the model too complicated?
Are you using a fragment or an activity for the AR screen?
fragment
This can cause some problems if the fragment isn't destroyed. You can try using an activity.
ok, thanks
I tried to modify it, and I changed it to the same as the ar-model-viewer-java provided in the demo, but there will still be a black screen after exiting and re-entering
This is my model, will it have something to do with the material of the model?
I tried to modify it, and I changed it to the same as the ar-model-viewer-java provided in the demo, but there will still be a black screen after exiting and re-entering
If you see the same behavior when you replace the model in the sample application, it can be a problem with the model, yes.
How can I turn off the ambient light, when I go to view the model at night, it is dark
ArSceneViewKt.setLightEstimationConfig(this.arSceneView, LightEstimationConfig.DISABLED);
After I turned it off, the model started to turn yellow
this.arSceneView.setFrameRateFactor(SceneView.FrameRate.FULL);
ArSceneViewKt.setLightEstimationConfig(arSceneView, LightEstimationConfig.DISABLED);
HDREnvironmentKt.loadEnvironmentAsync(
HDRLoader.INSTANCE,
this,
"environments/studio_small_09_2k.hdr",
false,
LifecycleOwnerKt.getLifecycleScope(this),
hdrEnvironment -> {
float indirectLightIntensity = SceneViewKt.getEnvironment(arSceneView).getIndirectLight().getIntensity();
SceneViewKt.setEnvironment(arSceneView, new Environment(hdrEnvironment.getSphericalHarmonics(), hdrEnvironment.getIndirectLight(), null));
SceneViewKt.getEnvironment(arSceneView).getIndirectLight().setIntensity(indirectLightIntensity);
return Unit.INSTANCE;
}
);
I saw this part of the code you wrote, and I still have a problem after adding it
After adding the effect
the effect i want
After I turned it off, the model started to turn yellow
It comes from the default HDR environment.
I saw this part of the code you wrote, and I still have a problem after adding it
Rendering the occlusion shell shouldn't affect the materials of other objects.
So how do I write it, I want my model not to be affected by any light, and the model will show what it looks like
Take a look at this issue: https://github.com/SceneView/sceneform-android/issues/322 I don't remember if it is actually possible to set the ambient light to a color instead of an HDR texture.
You have to set the sceneView.environment.indirectLight
to the same .hdr that was used inside your model.
But anyway, this is more a not exported gltf texture issue.
hi, my model doesn't use hdr textures, I use jpg or png, how can I avoid yellowing?@ThomasGorisse
hi, my model doesn't use hdr textures, I use jpg or png, how can I avoid yellowing?@ThomasGorisse
Hi! Maybe not inside your model but in the 3D modeling program that was used for creating and previewing the model.
I found that the modeling program uses softUmbrella.hdr, but after I added it, the program could not run and crashed directly
This is all the hdr in the modeling program, I tried each of them individually, but still didn't show the desired effect
The problem of the black screen still exists. The following situation occurs on some Xiaomi phones and Samsung phones. I have not found a good solution. When I kill the app from the background and enter again, it is normal. I am exiting the current Do I need to do anything related to the class?
I have hidden the cloud aiming point, which is directly presented by opening the current activity. I will send you the relevant code. Please help me to see
This is the code for the layout
<androidx.fragment.app.FragmentContainerView
android:id="@+id/arFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Below is the activity
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState == null) {
if (Sceneform.isSupported(this)) {
getSupportFragmentManager().beginTransaction()
.add(R.id.arFragment, CleanArFragment.class, null)
.commit();
}
}
loadModels();
}
public void loadModels() {
WeakReference<ArCenterConsoleActivity> weakActivity = new WeakReference<>(this);
ModelRenderable.builder()
.setSource(this, Uri.parse("models/shijieqiu.glb"))
.setIsFilamentGltf(true)
.setAsyncLoadEnabled(true)
.build()
.thenAccept(model -> {
ArCenterConsoleActivity activity = weakActivity.get();
if (activity != null) {
activity.model = model;
}
})
.exceptionally(throwable -> {
Toast.makeText(
this, "Unable to load model", Toast.LENGTH_LONG).show();
return null;
});
handlerModel = new Handler();
handlerModel.postDelayed(mAdModel, 1000);
}
Runnable mAdModel = () -> showObj();
private void showObj() {
anchorNode = new AnchorNode();
anchorNode.setParent(arFragment.getArSceneView().getScene());
andy = new TransformableNode(transformationSystem);
andy.setParent(anchorNode);
andy.setRenderable(this.model).animate(true).start();
andy.setWorldScale(new Vector3(0.3f, 0.3f, 0.3f));
andy.setLocalPosition(new Vector3(0f, 3.7f, -10.5f));
andy.getRenderableInstance().setCulling(false);
andy.getScaleController().setEnabled(false);
andy.getRotationController().setEnabled(false);
andy.getTranslationController().setEnabled(false);
andy.select();
}
Hi!
While it isn't probably related to the issue with a black screen, I suggest not to use a timeout (handlerModel.postDelayed(mAdModel, 1000);
) but to show the model in thenAccept
.
Other than that Xiaomi and Samsung can modify Android more than other brands. Is the activity destroyed when going back from it?
Ok thanks, I removed the handler and the phone started to get hot when loading multiple models. Is there a solution to this?
I don't think these things are related to each other.