Camera里:

   新建render texture并拖入到target texture里

   新建材质球 拖入render texture      camera里的视角会在材质球上出现

   新建一个plane 将材质球拖入片中,片上会显示出camera里的场景

 

   render texture将camera与material联系起来,将camera的视角播放在material上,plane以这个material为材质,实现监控视角。

 

 

ps:

Normal map 法线效果图   增强凹凸感和光线变化的立体效果

 

图片的效果和材质球的设置(shader)以及图片本身的设置有关

 

坐标系

 屏幕坐标系  右上角(1024, 768)

 视窗坐标系  右上角(1, 1)

 

屏幕坐标转世界坐标 z轴为物体到camera的距离

屏幕坐标转射线     z轴忽略

cube跟随鼠标(cube距cameraz轴距离为9)

cube.transform.position = camera.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 9)) ;

鼠标位置画射线

Ray ray = camera.ScreenPointToRay(Input.mousePosition) ;
Debug.DrawRay(ray.origin, ray.direction, Color.red) ;

 

 

RaycastHit  获取射线碰撞

Ray ray = camera.ScreenPointToRay(Input.mousePosition) ;
RaycastHit hit ;
Debug.DrawRay(ray.origin, ray.direction*100, Color.red) ;
if(Physics.Raycast(ray, out hit)){
  print (hit.transform);
}

hit.transform    碰撞物体名字

hit.transform.position  碰撞物体位置

hit.point  碰撞射线照射位置

posted on 2013-08-23 10:32  追逐.  阅读(517)  评论(0编辑  收藏  举报