fragment.getArSceneView().getSession().getConfig().setPlaneFindingMode(Config.PlaneFindingMode.HORIZONTAL);
This code is not working. It does not meter where to place this code - still finding vertical surfaces.
Try extending ArFragment and overriding the method getSessionConfiguration
@dsternfeld7 Thanks. It works if I override getSessionConfiguration like this:
@Override
protected Config getSessionConfiguration(Session session) {
Config config = new Config(session);
config.setPlaneFindingMode(Config.PlaneFindingMode.HORIZONTAL);
return config;
}
Hi! How about if I want to switch between modes? As @dementia2029 , I find fragment.getArSceneView().getSession().getConfig().setPlaneFindingMode(Config.PlaneFindingMode.HORIZONTAL); to do nothing. I want to switch between finding and not finding planes. Thanks a lot!
@dementia2029 found a way to toggle it in runtime.
Config config = fragment.getArSceneView().getSession().getConfig();
config.setPlaneFindingMode(Config.PlaneFindingMode.HORIZONTAL);
fragment.getArSceneView().getSession().configure(config);
Hope it helps someone!
@dementia2029 found a way to toggle it in runtime.
Config config = fragment.getArSceneView().getSession().getConfig();
config.setPlaneFindingMode(Config.PlaneFindingMode.HORIZONTAL);
fragment.getArSceneView().getSession().configure(config);Hope it helps someone!
@dementia2029
Where do you place this? I get session null in onCreate.
@EdwinMurari Hi. You need to extend ArFragment class and override getSessionConfiguration()
@EdwinMurari do you want to be able to toggle between different plane finding modes or simply create a session with a finding mode different from HORIZONTAL_AND_VERTICAL?
If you want the latter, just extend ArFragment class, like @dementia2029 said:
class CustomArFragment : ArFragment () {
override fun getSessionConfiguration(session: Session?): Config {
val config = super.getSessionConfiguration(session)
config.planeFindingMode = Config.PlaneFindingMode.DISABLED //Whatever mode you would like
return config
}
}
If, on the other hand, you would like to be able to toggle between modes during the use of the application (say, by pressing a button), then the way I found to do so is this:
This is a function that you can call inside an onClickListener, for example, that will disable plane finding asuming your ArFragment is stored in a global variable in your activity:
fun disablePlaneFinding() {
val config = fragment?.arSceneView?.session?.config
config?.planeFindingMode = Config.PlaneFindingMode.DISABLED
fragment?.arSceneView?.session?.configure(config)
}
PS: Sorry formatting, first time posting on GH
@EdwinMurari do you want to be able to toggle between different plane finding modes or simply create a session with a finding mode different from HORIZONTAL_AND_VERTICAL?
If you want the latter, just extend ArFragment class, like @dementia2029 said:
class CustomArFragment : ArFragment () {
override fun getSessionConfiguration(session: Session?): Config {
val config = super.getSessionConfiguration(session)
config.planeFindingMode = Config.PlaneFindingMode.DISABLED //Whatever mode you would like
return config
}
}If, on the other hand, you would like to be able to toggle between modes during the use of the application (say, by pressing a button), then the way I found to do so is this:
This is a function that you can call inside an onClickListener, for example, that will disable plane finding asuming your ArFragment is stored in a global variable in your activity:
fun disablePlaneFinding() {
val config = fragment?.arSceneView?.session?.config
config?.planeFindingMode = Config.PlaneFindingMode.DISABLED
fragment?.arSceneView?.session?.configure(config)
}
Thanks a lot man, I did by extending ArFragment, I thought there was another way to do it, maybe in onCreate.
I have successfully changed it to horizontal plane detection only.
But i have another issue which is in my ontaparfragment i have used that if plane().type==horizontal_upward_facing return;
but as i move my device towards ceiling . its also detecting the ceiling and treating is as a horizontal upward facing plane. so how can i correct this?
Most helpful comment
@dsternfeld7 Thanks. It works if I override getSessionConfiguration like this: