Variable type(資料型態)有分成五個種類
1.Integer numbers
2.Floating-point numbers
3.Vector numbers
4.String
5.Matrices
Integer
Declare Boolean & enum attribute
0 -->false, no, off
1 -->true, yes, on
》Index value
在list中物件(items)的位置, 從”0”開始。
》 用法:int $i = 4; 宣告變數 i 為4,資料型態為integer
Floating Points
在Maya中,最常使用到的資料型態。
1.記憶體需求量、是使用空間(footprint)
2. A foating point takes up significantly more RAM than an integer does.
》 用法:float $pi = 3.1415926536;
Vector
Entered, returned 輸入和回傳,使用逗號分隔三個浮點數、用角括號包圍
》 用法: vector $up = << 0, 1, 0 > ;
由文字所組成。
- Sensitivity(敏感度):有大小寫的分別,cat和Cat, CAT是不一樣的。
- 也可組成text-formatting information,ex. carriage return or tab indent.
》 用法: string $sentence = “Please set the visibility to \”on”.\n”
\n:換行
\r: carriage return
\t: tab character
Array 陣列
像list一樣,可存放多個值(value)。Integers, floating points, vectors, strings皆可宣告成陣列。
》 用法:int $number[ ] ;
float $position[3] ;
》index value : 當我們要在陣列中使用個別的item,要使用index value。
》而陣列中第一個index數字則是「0」。
Ex.
$object[0] polySurface1;
$object[1] polySurface2;
$object[2] polySurface3;
$object[3] polySurface4;
$object[4] polySurface4;
Matrices 矩陣
宣告矩陣的方式和陣列類似,使用方括號(square bracket)來指定陣列的大小。用陣列的概念來想矩陣,矩陣比陣列多了一個大小的指定,第一個數字指定了陣列的大小,而第二個數字宣告該數字元素內的陣列。
Ex.
matrix $firstMatrix[3][2] = <<3.8, 19.73; 4.14, 19.75; 25.6, 94.01>;
matrix $secondMatrix[5][5];
print($secondMatrix.size);
//result : 25 //
第二個陣列變數,$secondMatrix總共有5*5 = 25個元素,每個元素被指派(assign)到數值0。
宣告矩陣的方式和陣列類似,使用方括號(square bracket)來指定陣列的大小。用陣列的概念來想矩陣,矩陣比陣列多了一個大小的指定,第一個數字指定了陣列的大小,而第二個數字宣告該數字元素內的陣列。
Ex.
matrix $firstMatrix[3][2] = <<3.8, 19.73; 4.14, 19.75; 25.6, 94.01>;
matrix $secondMatrix[5][5];
print($secondMatrix.size);
//result : 25 //
第二個陣列變數,$secondMatrix總共有5*5 = 25個元素,每個元素被指派(assign)到數值0。
沒有留言:
張貼留言