SpatialMap_Dense_BallGame¶
Attention
This page is outdated, updates will be online soon…
Note
This sample supports AR Foundation (it can also work without AR Foundation). If you want to use AR Foundation, please refer to AR Foundation Configuration for configuration.
Demonstrate how to use dense SpatialMap.
Demonstrate how to render dense SpatialMap mesh
Demonstrate how to use dense SpatialMap to do collision and occlusion
Reference: Motion Tracking and EasyAR Features.
How to Use¶

A ball will be shot when clicking the screen. You can shoot the ball onto the mesh if one is build.
How It Works¶
Build dense spatial map¶
Dense spatial map can be build when a DenseSpatialMapBuilderFrameFilter is running in the session.
Render mesh on/off¶
DenseSpatialMapBuilderFrameFilter.RenderMesh can be used to control mesh render.
public void RenderMesh(bool show)
{
...
dense.RenderMesh = show;
}
Render transparent mesh¶
DenseSpatialMapBuilderFrameFilter.MeshColor can be used to control mesh color, including the alpha value.
public void TransparentMesh(bool trans)
{
...
dense.MeshColor = trans ? Color.clear : meshColor;
}
Shoot ball¶
Shoot balls from camera, they will be driven by Unity physics system.
Ray ray = Camera.main.ScreenPointToRay(Input.touches[0].position);
var launchPoint = Camera.main.transform;
var ball = Instantiate(Ball, launchPoint.position, launchPoint.rotation);
var rigid = ball.GetComponent<Rigidbody>();
rigid.velocity = Vector3.zero;
rigid.AddForce(ray.direction * 15f + Vector3.up * 5f);