SFM/Expression Operator: Difference between revisions
< SFM
Jump to navigation
Jump to search
(SFM Expression Operator) |
Thunder4ik (talk | contribs) |
||
(9 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
== | {{Multiple issues| | ||
{{Dead end|date=January 2024}} | |||
{{Orphan|date=January 2024}} | |||
}} | |||
DmeExpressionOperator is a DmeOperator that writes to its "value" float attribute the evaluated expression stored in its "expr" string attribute. | ''DmeExpressionOperator'' is a DmeOperator that writes to its "value" float attribute the evaluated expression stored in its "expr" string attribute. | ||
The expression can read other float attributes on the DmeExpressionOperator, and can nest | The expression can read other float attributes on the DmeExpressionOperator, and can nest arbitrarily deep. | ||
For example, the expression "clamp(distance * cos(angle), 0, 10)" will cause the DmeExpressionOperator to write a value between 0 and 10 into its "value" attribute, depending upon the value of its "distance" and "angle" float attributes. | For example, the expression "clamp(distance * cos(angle), 0, 10)" will cause the DmeExpressionOperator to write a value between 0 and 10 into its "value" attribute, depending upon the value of its "distance" and "angle" float attributes. | ||
== Operator Precedence == | |||
* unary operators: + - ! func var | * unary operators: + - ! func var | ||
Line 16: | Line 19: | ||
* ?: | * ?: | ||
== Functions == | |||
; dtor(d) : converts degrees to radians | |||
; rtod(r) : converts radians to degrees | |||
; abs(a) : absolute value | |||
; floor(a) : rounds down to the nearest integer | |||
; ceiling(a) : rounds up to the nearest integer | |||
; round(a) : rounds to the nearest integer | |||
; sgn(a) : if a < 0 returns -1 else 1 | |||
; sqr(a) : returns a * a | |||
; sqrt(a) : returns sqrt(a) | |||
; sin(a) : sin(a), a is in degrees | |||
; asin(a) : asin(a) returns degrees | |||
; cos(a) : cos(a), a is in degrees | |||
; acos(a) : acos(a) returns degrees | |||
; tan(a) : tan(a), a is in degrees | |||
; exp(a) : returns the exponential function of a | |||
; log(a) : returns the natural logarithm of a | |||
; min(a,b) : if a < b returns a else b | |||
; max(a,b) : if a > b returns a else b | |||
; atan2(a,b) : atan(a/b) returns radians (it's Arg(b+ia) actually) | |||
; pow(a,b) : function returns a raised to the power of b | |||
; inrange(x,a,b) : if x is between a and b, returns 1 else returns 0 | |||
; clamp(x,a,b) : if x < a returns a else if x > b returns b else returns x | |||
; ramp(value,a,b) : returns 0 -> 1 as value goes from a to b | |||
; lerp(factor,a,b) : returns a -> b as factor goes from 0 to 1 | |||
; cramp(value,a,b) : clamp(ramp(value,a,b),0,1) | |||
; clerp(factor,a,b) : clamp(lerp(factor,a,b),a,b) | |||
; elerp(x,a,b) : ramp( 3*x*x - 2*x*x*x, a, b) | |||
; noise(a,b,c) : { solid noise pattern (improved perlin noise) indexed with three numbers } | |||
; rescale (X,Xa,Xb,Ya,Yb) : lerp(ramp(X,Xa,Xb),Ya,Yb) | |||
; crescale(X,Xa,Xb,Ya,Yb) : clamp(rescale(X,Xa,Xb,Ya,Yb),Ya,Yb) | |||
*'''Note''' : arithmetic priorites may not work as intended (for instance, 0-0+3 = -3), so adding brackets might be needed. | |||
{{shortpagetitle}} | |||
[[Category:Source Filmmaker]] |
Latest revision as of 10:10, 21 January 2024

This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these template messages)

This article has no
links to other VDC articles. Please help improve this article by adding links
that are relevant to the context within the existing text.
January 2024


January 2024

This article is an orphan, meaning that few or no articles link to it.
You can help by
adding links to this article from other relevant articles.
January 2024
You can help by

January 2024
DmeExpressionOperator is a DmeOperator that writes to its "value" float attribute the evaluated expression stored in its "expr" string attribute. The expression can read other float attributes on the DmeExpressionOperator, and can nest arbitrarily deep. For example, the expression "clamp(distance * cos(angle), 0, 10)" will cause the DmeExpressionOperator to write a value between 0 and 10 into its "value" attribute, depending upon the value of its "distance" and "angle" float attributes.
Operator Precedence
- unary operators: + - ! func var
- * / %
- + -
- < > <= >=
- == !=
- &&
- ||
- ?:
Functions
- dtor(d)
- converts degrees to radians
- rtod(r)
- converts radians to degrees
- abs(a)
- absolute value
- floor(a)
- rounds down to the nearest integer
- ceiling(a)
- rounds up to the nearest integer
- round(a)
- rounds to the nearest integer
- sgn(a)
- if a < 0 returns -1 else 1
- sqr(a)
- returns a * a
- sqrt(a)
- returns sqrt(a)
- sin(a)
- sin(a), a is in degrees
- asin(a)
- asin(a) returns degrees
- cos(a)
- cos(a), a is in degrees
- acos(a)
- acos(a) returns degrees
- tan(a)
- tan(a), a is in degrees
- exp(a)
- returns the exponential function of a
- log(a)
- returns the natural logarithm of a
- min(a,b)
- if a < b returns a else b
- max(a,b)
- if a > b returns a else b
- atan2(a,b)
- atan(a/b) returns radians (it's Arg(b+ia) actually)
- pow(a,b)
- function returns a raised to the power of b
- inrange(x,a,b)
- if x is between a and b, returns 1 else returns 0
- clamp(x,a,b)
- if x < a returns a else if x > b returns b else returns x
- ramp(value,a,b)
- returns 0 -> 1 as value goes from a to b
- lerp(factor,a,b)
- returns a -> b as factor goes from 0 to 1
- cramp(value,a,b)
- clamp(ramp(value,a,b),0,1)
- clerp(factor,a,b)
- clamp(lerp(factor,a,b),a,b)
- elerp(x,a,b)
- ramp( 3*x*x - 2*x*x*x, a, b)
- noise(a,b,c)
- { solid noise pattern (improved perlin noise) indexed with three numbers }
- rescale (X,Xa,Xb,Ya,Yb)
- lerp(ramp(X,Xa,Xb),Ya,Yb)
- crescale(X,Xa,Xb,Ya,Yb)
- clamp(rescale(X,Xa,Xb,Ya,Yb),Ya,Yb)
- Note : arithmetic priorites may not work as intended (for instance, 0-0+3 = -3), so adding brackets might be needed.