找回密码
 注册帐号

扫一扫,访问微社区

camera.viewporttoworldpoint 视窗转世界位置

2015-1-4 08:37| 发布者: 杨炎| 查看: 2238| 评论: 0|原作者: 蛮牛|来自: unity3d脚本manual

摘要: camera.viewporttoworldpoint 视窗转世界位置functionviewporttoworldpoint(position:vector3description描述transforms position from viewport space into world space.从视窗空间到世界空间的变换位置。viewport ...

camera.viewporttoworldpoint 视窗转世界位置

functionviewporttoworldpoint(position:vector3

description描述

transforms position from viewport space into world space.

从视窗空间到世界空间的变换位置。

viewport space is normalized and relative to the camera. the bottom-left of the camera is (0,0); the top-right is (1,1). the z position is in world units from the camera.

视口空间是归一化的并相对于相机的,相机的左下为(0,0);右上是(1,1);z的位置是以世界单位衡量的到相机的距离。

note that it transforms a x-y screen position, into a x-y-z position in 3d space.

请注意它是变换一个x-y屏幕位置到一个3d空间的x-y-z位置。

you provide the function with a vector where the x-y components of the vector are the screen coordinates and the z component is the distance of the resulting plane from the camera.

这个函数带有在屏幕坐标的x-y组件向量,并且z组件是在从相机产生的平面的距离。

c#

javascript

using unityengine;

using system.collections;

public class example :monobehaviour{

void ondrawgizmosselected() {

vector3p = camera.viewporttoworldpoint(new vector3(1, 1, camera.nearclipplane));

gizmos.color=color.yellow;

gizmos.drawsphere(p, 0.1f);

}

}

// draw a yellow sphere at top-right corner of the near plane

// for the selected camera in the scene view.

//在近裁剪面的右上角绘制一个黄色的球,针对在场景视图中选中的相机

function ondrawgizmosselected () {

var p :vector3(1,1, camera.nearclipplane));

gizmos.color=color.yellow;

gizmos.drawsphere(p, 0.1);

}

相关阅读

文章点评
相关文章