包含30節(jié)視頻教程
(本教程houdini技術(shù)已老請購買之后houdini更新課程)Houdini是一款功能強(qiáng)大的3D合成軟件,曾經(jīng)效力于300部以上經(jīng)典電影的特效制作,比如煙火,水等復(fù)雜的后期合成都少不了它。
|
ArrayOverviewVEX includes an array datatype. This is useful in several places: VEX包含一個(gè)數(shù)組數(shù)據(jù)類型。用于以下幾處:
Note Currently VEX does not support multi-dimensional arrays.目前,VEX不支持多維數(shù)組。 This example shows off some of the crazy things that you can do with arrays: 這個(gè)例子展示了你可以用數(shù)組做的一些瘋狂的事情:
Declaring array types 聲明數(shù)組類型To declare an array variable, the general form is 要聲明數(shù)組變量,一般的形式是 member_type var_name[]:
You can optionally put a size inside the square brackets, but the VEX compiler currently ignores it. 您可以選擇將大小放在方括號中,但是VEX編譯器目前會忽略它。 To declare a function that returns an array: 聲明一個(gè)返回?cái)?shù)組的函數(shù):
To declare a nested function that returns an array: 聲明返回?cái)?shù)組的嵌套函數(shù):
To specify a literal array, use curly braces, with the array members separated by commas: 若要指定內(nèi)容數(shù)組,請使用大括號,數(shù)組成員之間用逗號分隔:
If you specify scalars where a vector is expected, the compiler assigns the scalar value to all components of the vector: 如果你指定標(biāo)量,其中一個(gè)向量是預(yù)期的,編譯器分配標(biāo)量值給向量的所有組件:
The array() function creates an array from its arguments. array() 函數(shù)的作用是:從數(shù)組的參數(shù)中創(chuàng)建一個(gè)數(shù)組。 int my_array[] = array(1, 2, 3, 4, 5);You can use array() to generate an array of any type. To force array() to generate vectors (for example): 可以使用array()生成任何類型的數(shù)組。強(qiáng)制array()生成向量(例如): vector (array (value1, value2, ...) );Accessing and setting array values訪問和設(shè)置數(shù)組值Use arrayname[index] to look up a value by its position in the array. 使用arrayname[index]根據(jù)值在數(shù)組中的位置查找值。
Array bounds are checked at run time. Reading out of bounds will return 0 or "". This may generate a warning or optional run-time error in the future. Writing past the end of an array will resize the array to include the index written to. The new entries will be set to 0 or "". 數(shù)組邊界在運(yùn)行時(shí)檢查。讀取超出數(shù)組范圍時(shí)將返回0或“”。這可能在將來生成警告或可選的運(yùn)行時(shí)錯(cuò)誤。寫入數(shù)組末尾后,將調(diào)整數(shù)組大小以包含寫入的索引。新條目將被設(shè)置為0或“”。 Python-style indexing is used. This means negative indices refer to positions from the end of the array. 使用python風(fēng)格的索引。這意味著負(fù)索引指的是數(shù)組末尾的位置,從1開始倒著數(shù)的位置,最后一位是 -1。
You can also assign values using the square brackets notation: 你也可以使用方括號符號賦值:
(The getcomp and setcomp functions are equivalents for using the square brackets notation.) getcomp和setcomp函數(shù)是使用方括號符號的等價(jià)函數(shù)。比如:getcomp(array[], int index) 取array[]中下標(biāo)為index的值 Note The square-brackets operator also works on vectors. You can use it with matrices as well using a pair of brackets: float a = m3[0][1]; 方括號運(yùn)算符也適用于向量。您可以將它與矩陣一起使用,也可以使用一對括號:float a = m3[0][1]; Slicing Arrays 分割數(shù)組The square-brackets can be used to extract sub-arrays using the Python slicing notation. 方括號可用于使用Python切片符號提取子數(shù)組。詳見:https://blog.csdn.net/qq_41973536/article/details/82690242
The slice function is the equivalent for using the slice-based square brackets notation. 對于使用基于切片的方括號符號,slice函數(shù)是等效的。 Copying between arrays and vectors/matrices數(shù)組和向量/矩陣之間的復(fù)制The assignment operator supports assigning values between vector types and arrays of floats: 賦值運(yùn)算符支持在向量類型和浮點(diǎn)數(shù)組之間賦值:
If the array is not long enough to fill the vector/matrix, the last member is repeated as often as necessary. 如果數(shù)組不夠長,不足以填充向量/矩陣,則根據(jù)需要重復(fù)最后一個(gè)成員。
You can also assign between matrix types and arrays of vector2/vector/vector4: 你也可以在矩陣類型和vector2/vector/vector4的數(shù)組之間分配:
In summary: 總之
Looping over an arraySee foreach. Working with arraysThe following functions let you query and manipulate arrays. 下面的函數(shù)允許查詢和操作數(shù)組。 resize Sets the length of the array. If the array is enlarged, intermediate values will be 0 or "". 設(shè)置數(shù)組的長度。如果數(shù)組被放大,中間值將為0或“”。 len Returns the length of an array. 返回?cái)?shù)組的長度 pop Removes the last item from the array (decreasing the size of the array by 1) and returns it. 從數(shù)組中刪除最后一項(xiàng)(將數(shù)組大小減少1)并返回它。 push Adds an item to the end of an array (increasing the size of the array by 1). 將項(xiàng)添加到數(shù)組末尾(將數(shù)組大小增加1)。 getcomp Gets the value of an array component, the same as array[num]. 獲取與array[num]相同的數(shù)組元素的值。 setcomp Sets the value of an array component, the same as array[num] = value. 設(shè)置數(shù)組組件的值,與array[num] = value相同。 array Efficiently creates an array from its arguments. 有效地根據(jù)它的元素創(chuàng)建數(shù)組。 serialize Flattens an array of vectors or matrices into an array of floats. 將一組向量或矩陣展開成一組浮點(diǎn)數(shù)。 unserialize Reverses the effect of serialize: assembles a flat array of floats into an array of vectors or matrices. 反轉(zhuǎn)序列化的效果:將浮點(diǎn)數(shù)的平面數(shù)組組裝成向量或矩陣數(shù)組。 neighbours An array-based replacement for the neighbourcount/neighbour combo. Returns an array of the point numbers of the neighbors of a given point. 一個(gè)基于數(shù)組的對neighborcount /neighbour組合的替換。返回給定點(diǎn)的相鄰點(diǎn)的點(diǎn)編號數(shù)組。 In addition, the following functions work with arrays: 此外,以下函數(shù)可以處理數(shù)組:
VCC pragmasThe ramp pragma lets you specify a ramp user interface for a set of parameters. ramp pragma允許您為一組參數(shù)指定ramp用戶界面。 #pragma ramp <ramp_parm> <basis_parm> <keys_parm> <values_parm>See VCC pragmas for more information. http://www.sidefx.com/docs/houdini/vex/pragmas.html Limitations 局限
贊0 踩0 |
未知用戶
2005-2024 朱峰社區(qū) 版權(quán)所有 遼ICP備2021001865號-1
2005-2024 ZhuFeng Community All Rights Reserved
VIP