找回密碼
 注冊帳號

掃一掃,訪問微社區

camera.viewporttoworldpoint 視窗轉世界位置

2015-1-4 08:37| 發布者: 楊炎| 查看: 2196| 評論: 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);

}

相關閱讀

文章點評
相關文章
女校游泳队彩金