Unity官方文档:

Camera.ScreenPointToRay

public function ScreenPointToRay(position: Vector3): Ray;

Description

Returns a ray going from camera through a screen point.

Resulting ray is in world space, starting on the near plane of the camera and going through position's (x,y) pixel coordinates on the screen (position.z is ignored).

Screenspace is defined in pixels. The bottom-left of the screen is (0,0); the right-top is (pixelWidth,pixelHeight).

    // Draws a line in the scene view going through a point 200 pixels
// from the lower-left corner of the screen
function Update () {
var ray : Ray = camera.ScreenPointToRay (Vector3(,,));
Debug.DrawRay (ray.origin, ray.direction * , Color.yellow);
}

解释说明:

Returns a ray going from camera through a screen point.

返回一条射线,从相机开始并且穿过一个屏幕中的点。

Resulting ray is in world space, starting on the near plane of the camera and going through position's (x,y) pixel coordinates on the screen (position.z is ignored).

返回的射线在世界坐标空间,从相机的近剪裁面开始穿过一个屏幕中的以像素为单位的点(x,y),(忽略z坐标)

Screenspace is defined in pixels. The bottom-left of the screen is (0,0); the right-top is (pixelWidth,pixelHeight).

屏幕空间是用像素定义的。左下角是(0,0)点,右上角是(pixelWidth,pixelHeight)点。

补充:

near plane 是近剪裁面的意思。

剪裁面是相机的可见范围,他就像一个被削了尖的金字塔,近剪裁面就是金字塔顶部,这也表示了相机可以看到的最近距离,远剪裁面就是金字塔的底部,表示相机可以看到的最远距离。

Camera.ScreenPointToRay 解析的更多相关文章

  1. Qualcomm 8X camera过程解析【转】

    本文转载自:http://blog.csdn.net/gabbzang/article/details/19906687 http://www.01yun.com/mobile_development ...

  2. camera render texture 游戏里的监控视角

    Camera里: 新建render texture并拖入到target texture里 新建材质球 拖入render texture      camera里的视角会在材质球上出现  新建一个pla ...

  3. Unity API 解析 (陈泉宏著)

    1 Application类 2 Camera类 3 GameObject类 4 HideFlags类 5 Mathf类 6 Matrix4x4类 7 Object类 8 Quaternion类 9 ...

  4. ScreenPointToRay - 近视口到屏幕的射线

    正如题目所说,ScreenPointToRay可以计算从Camera的近视口nearClip向前发射一条射线到屏幕上的点的坐标. 函数原型为: public Ray ScreenPointToRay( ...

  5. Unity3D脚本中文系列教程(十三)

    http://dong2008hong.blog.163.com/blog/static/469688272014032334486/ Unity3D脚本中文系列教程(十二) ◆ function G ...

  6. Unity3D脚本学习——运行时类

    AssetBundle 类,继承自Object.AssetBundles让你通过WWW类流式加载额外的资源并在运行时实例化它们.AssetBundles通过BuildPipeline.BuildAss ...

  7. [Unity3D]利用Raycast实现物体的选择与操作

    本文系作者原创 转载请注明出处 如果是一个2D的平面项目或者说需要在三维空间选择一个物体时(经常表现为抓取物件),我们需要用到Raycast事件 那么首先先说说什么是Raycast 按照字面上来理解的 ...

  8. 【Unity3D游戏开发】基础知识之Tags和Layers (三二)[转]

    Tags和Layers分别表示是Unity引擎里面的标签和层,他们都是用来对GameObject进行标识的属性,Tags常用于单个GameObject,Layers常用于一组的GameObject.添 ...

  9. [Unity2D]Tags和Layers

    Tags和Layers分别表示是Unity引擎里面的标签和层,他们都是用来对GameObject进行标识的属性,Tags常用于单个GameObject,Layers常用于一组的GameObject.添 ...

随机推荐

  1. PAT (Advanced Level) 1050. String Subtraction (20)

    简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> ...

  2. Chapter 1 First Sight——7

    Eventually we made it to Charlie's. 最终我们到了查理斯的家. He still lived in the small,two-bedroom house that ...

  3. CodeForces 609A USB Flash Drives

    水题 #include<cstdio> #include<cmath> #include<algorithm> using namespace std; +; in ...

  4. tcpdump的表达元

    (nt: True 在以下的描述中含义为: 相应条件表达式中只含有以下所列的一个特定表达元, 此时表达式为真, 即条件得到满足) dst host host如果IPv4/v6 数据包的目的域是host ...

  5. (简单) POJ 2750 Potted Flower,环+线段树。

    Description The little cat takes over the management of a new park. There is a large circular statue ...

  6. libconfig第一篇———使用指南

    官网:http://www.hyperrealm.com/libconfig/ 1 libconfig是什么? Libconfig是一个结构化的配置文件库,它可以定义一些配置文件,例如test.cfg ...

  7. java XML转JSON格式

    标签: XML转Json json 2014-05-20 20:55 6568人阅读 评论(6) 收藏 举报  分类: [J2SE基础](20)  代码如下所示,从这个例子中发现了代码库的重要性,如果 ...

  8. Vector类

    /* * Vector的特有功能 * * Vector出现较早,比集合更早出现 * * 1:添加功能 * public void addElement(Object obj);//用add()替代 * ...

  9. [repost]Xcode因为证书问题经常报的那些错

    [reference]http://www.jianshu.com/p/b10680a32d3 1.   确认下证书是不是开发证书,如果是发布证书就会出现这样的提示. 2.   证书失效了,去开发者中 ...

  10. Linux - tomcat -jndi数据源配置

    Linux - tomcat -jndi数据源配置 tomcat/conf/context .xml 文件中修改如下 <Resource name="/jdbc/--" au ...