找回密碼
 注冊帳號

掃一掃,訪問微社區

camera.cameratoworldmatrix 相機轉世界矩陣

2015-1-4 01:37| 發布者: 楊炎| 查看: 2508| 評論: 0|原作者: 蠻牛|來自: unity3d腳本manual

摘要: camera.cameratoworldmatrix 相機轉世界矩陣varcameratoworldmatrix:matrix4x4description描述matrix that transforms from camera space to world space (read only).從相機空間到世界空間的變換矩陣(只讀)。use ...

camera.cameratoworldmatrix 相機轉世界矩陣

varcameratoworldmatrix:matrix4x4

description描述

matrix that transforms from camera space to world space (read only).

從相機空間到世界空間的變換矩陣(只讀)。

use this to calculate where in the world a specific camera space point is.

使用這個來計算相機空間中的一個點在世界坐標中的什么位置上。

note that camera space matches opengl convention: camera's forward is the negative z axis. this is different from unity's convention, where forward is the positive z axis.

注意相機空間與opengl的約定時間;相機的前面為z軸負方向。這不同于unity的約定,向前為z軸正向。

c#

javascript

using unityengine;

using system.collections;

public class example :monobehaviour{

public float distance = -1.0f;

void ondrawgizmosselected() {

matrix4x4m = camera.cameratoworldmatrix;

vector3(0, 0, distance));

color.yellow;

gizmos.drawsphere(p, 0.2f);

}

}

// draw a yellow sphere in scene view at distance

// units along camera's viewing direction.

//在屏幕視圖繪制一個黃色的球,以distance單位,沿著相機所看方向

var distance : float = -1.0;

function ondrawgizmosselected () {

var m :matrix4x4= camera.cameratoworldmatrix;

var p :vector3(0,0,distance));

gizmos.color=color.yellow;

gizmos.drawsphere(p, 0.2);

}

相關閱讀

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