EasyAR稠密空间图
1.稠密空间图
EasyAR稠密空间地图利用RGB相机图像对周围环境进行三维稠密重建,得到稠密的点云地图和网格地图。利用稠密空间地图让虚拟物体更好的融入真实环境之中,用以实现真实物体和虚拟物体正确遮挡、碰撞等AR应用。
2.在Unity中的构建
代码编写
public GameObject prefab;
public DenseSpatialMapBuilderFrameFilter dense;
private void Start()
{
dense.MeshColor = Color.gray;
}
private void Update()
{
if(Input.GetMouseButtonDown(0)&&Input.touchCount>0
&&!EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId))
{
Ray ray = Camera.main.ScreenPointToRay(Input.touches[0].position);
var point = Camera.main.transform;
var ball = Instantiate(prefab,point.position,point.rotation);
var rigid = ball.GetComponent<Rigidbody>();
rigid.velocity = Vector3.zero;
rigid.AddForce(ray.direction * 15f + Vector3.up*5f);
}
}
public void MeshRender(bool Show)
{
dense.RenderMesh = Show;
}
public void ClearRender(bool clear)
{
dense.MeshColor = Color.clear;
}