More Sceneform AR physics experiments
Jul 19, 2020
I added a new experimental scenario to my AR Physics app: I call it the collision box. I outlined this as a plan in my previous AR Physics blog post. Right now the start screen of the app presents a choice between the plank tower scenario and this new collision box scenario.
In the collision box example, I evenly arrange wooden planks standing upright in a grid pattern inside a rectangular 1-meter-by-1-meter box, and place a red cylinder that the user can drag around at the center. Right now, this scenario still experiences an explosion effect, so the planks fall and jitter. But during or after the transition to an equilibrium phase, the user can drag the cylinder around, which stirs the planks confined within the invisible collision box walls.
I was right that the cylinder needed to be a "Kinematic object" so the physics engine would not be able to move it, but it would still interact with the planks. Unfortunately, the jittering effect (along with the unwanted initial jumping) is visible in this scenario as well, even more so than in the plank tower. There’s another issue: the physics engine keeps resetting the cylinder position back to the center and when that happens the visual position differs from the simulated position creating a hollow cylinder at the center of the collision box. Getting the scenario to work even to this extent still required a lot of experimentation. I used Sceneform’s TransformableNode to let the user move the cylinder around: the user taps on the cylinder and drags it. I also needed to constrain the cylinder’s movement to the ground plane to avoid vertical displacements.
I fixed a limitation of the simulation that was preventing the planks from rotating: I had to explicitly call calculateLocalInertia. I still need to integrate Sceneform-Bullet and JMonkey as selectable physics engines. I need to form API layers between my app’s internal physics logic and the AR logic to make it extensible. I also want to eliminate the jitter bug.
Here is a demo video of the ARPhysics app in action:
This browser does not support the YouTube video player. Watch on YouTube
Demo video of the Sceneform ARPhysics application.