1、註釋
語法:#(comments)
# 計算A的值
A = (1 + 1)
# return 2
2、基本加減乘除、賦值:
A = 4
B = 2
#return 6
A + B
#return 2
A - B
#return 8
A * B
#return 2
A / B
3、類型轉換:
1)轉換成整形
語法:INT(value)
2)轉換成浮點類型
語法:FLOAT(value)
3)轉換成布爾類型
語法:BOOL(valued)
4)轉換成字符串類型
語法:STRING(value)
4、內置函數:
1)絕對值
語法:ABS(value)
2) 動畫
語法:Animation(property,“animationDataResourceID”)
3)計算大於等於的最小的整數
CEIL(value)
4)將值限定到一定範圍(MIN(MAX(value,low),high))
語法:CLAMP(low,high,value)
5)計算小於等於的最大整數
語法:FLOOR(value)
6)Linear step(return the same value as CLAMP(0,1,(value-low)/(high-low))
語法:LINEARSTEP(low,high,value)
7)Round(計算最接近的整數)
語法:ROUND(value)
8)指數
語法:POW(n,e)
9)求模
語法:MOD(value1,value2)
10)求平方根
語法:SQRT(n)
11)比較閾值
語法:STEP(threshold,value)
返回值:如果大於等於threshold,返回1,否則返回0.
12)顏色分量
語法:Color4(r,g,b,a)
# Sets the color to white and opaque.
Color4(1, 1, 1, 1)
# Same as above, but with alternative syntax.
Color(1, 1, 1, 1)
# Sets the color to red with 50% transparency.
Color4(1, 0, 0, 0.5)
# Invalid expression, one argument is missing.
Color4(0.1, 1, 0.4)
# Use variables as attributes of the Color4() to assign the
# attribute values of the whole Color property.
#
# Assigns custom properties Red, Green, and Blue to variables
# you use to control the color of an object.
red = {@./Red}
green = {@./Green}
blue = {@./Blue}
color = Color4(0, 0, 0, 1)
# Assigns the red, green, and blue variables to each color channel attribute.
color.ColorR = red
color.ColorG = green
color.ColorB = blue
color
13) 轉換分量
語法:MatrixSRT(ScaleX,ScaleY,ScaleZ,RotationX,RotationY,RotationZ,TranslationX,TranslationY,TranslationZ)
# Scales the object on the x, y, and z axes to 1 unit,
# rotates it around the x axis by 30 degrees
# and moves it on the z axis by 2 units.
MatrixSRT(1, 1, 1, 30, 0, 0, 0, 0, 2)
# Use variables as attributes of the MatrixSRT() to assign the
# attribute values of the whole Render Transformation property.
# Assigns custom property Rotation to a variable you use to control
# the rotation of an object.
rotate = {@./Rotation}
position = MatrixSRT(1, 1, 1, 0, 0, 0, 0, 0, 0)
# Assigns the rotation variable to each rotation attribute.
position.RotationX = rotate
position.RotationY = rotate
position.RotationZ = rotate
position
接下里看看綁定的表達式:
1、屬性綁定:
語法:{[path]/[property]}
當你在路徑前使用@符號,當資源和目標對象之間位置發生了改變,kanzi sudio會自動幫你更新綁定的表達式,否則,如果沒有用@符號,節點相對位置發生了改變,表達式不會更新,綁定就會失效。但是要注意使用@符號用於屬性綁定只能用於同一個模板,不能用於不同模板之間。
# Binds to property Layout Width of the current object.
{@./LayoutWidth}
# Binds to the property FOV of the Camera object.
{../Camera/Fov}
2、別名(alias)綁定
語法:{#[aliasName]/[property]}
# Binds to the Layout Width property of the target object of the alias named Sphere.
{#Sphere/LayoutWidth}
# Multiplies the FOV property of the target object of the alias named MainCamera
# with the Render Transformation property attribute Scale X.
{#MainCamera/Fov} * {../Box/RenderTransformation}.ScaleX
3、分量(attribute)綁定
語法:{[path]/[property].[attribute]}
# Binds to the attribute Scale X (value of the Scale X attribute)
# of the Box node's Layout Transformation property.
{../Box/LayoutTransformation}.ScaleX
# Multiply property FOV with Render Transformation property attribute Scale X.