-
Member
Operations! How to use them, what they are for?
Hello, I've got a pretty basic set of knowledge of most of the editor at this point. But... I need a better knowledge of operations. I have already watched the tutorial for Trials Evo, and hadn't really learned a heck of a lot. I guess if I had some examples of how they were used, what could be done with them; or if there are any LBP2 people here, possibly how they would compare to the tools found there.
I doubt that I am the only person who does not know how to use these and wants to know how to use them.
I believe knowing how to use them, we as a community could start creating great tracks! I know some of the functions of operations are very much math based, and not being the greatest at math myself is not really an issue. I just need a basic understanding of each operations tool, how they differ, and what they are used for. Anything more complex I will learn on my own through just using them, and trying to figure out new things.
Much thanks for anyone able to help me, and other out! 
Cheers, Archon453
-
Senior Member
hey Archon453, im just going to dive right in with these :P
Operators:
Distance Operator: (output in meters)
Type: World
Output: Distance between the two selected "Selected Source 1" and "Selected Source 2" objects.
Type: Plane
Output: Distance on the X/Z plane between the two selected "Selected Source 1" and "Selected Source 2" objects.
Type: Height
Output: Distance in the Y axis only, between the two selected "Selected Source 1" and "Selected Source 2" objects.
( World² = Plane² + Height² )
Type: Driving Line
Output: Distance between the two selected "Selected Source 1" and "Selected Source 2" objects, along the driving line, including any curves.
( Output="Selected Source 1"- "Selected Source 2" )
N-input and Two-input operator
N-input and Two-input output a number based on the supplied operands (any tool card that outputs a number). The Two-input calculates its output based on the results of the two operands selected. The N-input works the same as the Two-input, except it can use any number of selected operands.
The N-input calculates its output based on the "Operation" of the selected "Select Operands" , unlike the Two input operator:-
Output = "Operand 1" "Operation" "Operand 2" , eg Output="A" "+" "B"
N-input and Two-input operator share a number of operations between them:-
Operations: Max
Output: The "Max" function inspects all the values and outputs the highest from the selected operands.
eg:
4=Max( -1,- 2, 3, 4 )
Operations: Min
Output: The "Min" function inspects all the values and outputs the lowest from the selected operands.
eg:
-2=Min( -1,- 2, 3, 4 )
Operations: Mean
Output: The "Mean" function inspects all the values and outputs the average (or mean) from the selected operands.
eg:
Mean=(A+B+C+D+E) / 5
Operations: Equals, Not Equals, Greater (+Equals), Less (+Equals)
(some of these operations are not present in the N-input)
This set of operations work in the same principle as the "Generic Filter"
Output: The conditional check (a true/false statement) based on the selected "Operation", applies the conditional check against the selected operands and outputs a 1 if the condition was true or a 0 if it was false.
my thoughts, this is a fairly handy tool set to use, you can do things like set the state of a switch (Enable, Reset in checkpoint restart, Physics (not recommended), Light, etc) based on things like how far you are along on the driving line (if player>50% enable physics joint), this though is better served by an area trigger and the state enable tools, as this is evaluated every time any operand is altered and not by the bike simply trigging the area trigger.
Operations: AND, NAND, OR, XOR, XNOR
Boolean algebra (Wiki)
Operations: Pow
Output: "Operand 1" to the power of "Operand 2"
Operations: Modulo
Output: (Wiki)
Operations: ArcTan2 (IN degrees of a circle)
(wiki)
Output: calculates the slope of two points. The output can then be combined with conditionally checking the signs of the inputs against some rules to form the angle of between the two points.
eg: finding the slope (-90 to 90 degrees, or one quadrant of the circle) between two objects in the world
objects A and B are located apart , i would like to know the angle between them as i want object A to face object B (on the XZ plane, finding the Yaw)
create a vector (v) from A.xz - B.xz (the .xz from an Object Vector Position shows the plane im working on. I'm just ignoring the y axis as im only interested in finding the Yaw value)
so
v.xz = A.xz - B.xz
or
v.x = A.x - B.x
v.z = A.z - B.z
Output = ArcTan2 ( "Operand 1" targets v.x , "Operand 2" targets v.z )
using some logic based on the sign of v.x and/or v.z add 90/180 etc degrees to the value of AcrTan2 to shift quadrant in the circle.
One-input operator
as its name implies, this operator only uses one operand.
Operations: Neg
swaps the sign of the operand, negative numbers become positive and visa-versa.
Output: "Operand" multiplied by -1
Operations: Abs
short for absolute, turns negative numbers positive.
Operations: Sign
outputs 1 or -1 based on if the number is positive or negative
Operations: Sin(x)*1000, Cos(x)*1000
x (the "Operand") in degrees 0 to 360
Form the coordinates for a circle with a radius of 1000 (note normally sin/cos output -1 to 1 to form a circle with a radius of 1, the *1000 scales this to help with internal resolution)
if you wanted to move an object around another object, you need a number to loop from 0 to 360, this is passed into both sin and cos, these are then scaled and added to the target objects position info and then OPE'd for animating.
(sin forms one axis of a circle while cos forms the other axis.)
Operations: Tan(x)*1000
short for tangent (wiki)
Operations: ArcSin(x/1000), ArcCos(x/1000), ArcTan(x/1000)
The counter parts to sin, cos and tan, return value in degrees from coordinate space, the degrees used to get there from sin, cos and tan respectively.
(the /1000 again for internal resolution means you need to multiply you operand by 1000 before passing into the "Operand")
Operations: Log
short for logarithm (Wiki)
Operations: Sqrt
short for square root (wiki)
Operations: Round, Floor, Ceil
Round: rounds (remove decimal fraction) the number to nearest whole number
Floor: rounds the number down, eg 3.0001 to 3.99999 get rounded to 3
Ceil: rounds the number up, eg 3.0001 to 3.99999 get rounded to 4
Operations: Not
(this doesn't behave as i expected)
Output: (along the lines of) floor or ceil (Abs( x + 1 ) * -1
Scalar operator
Input Type: Vector
Operation: Length
Outputs a scalar (single value, not a vector) that is the length of the vector, object A to B , vector:length of A minus B in meters, taken from the object vector info.
Operation: Size
Outputs the size of the vector, if operand pointed to a "Two dimensional vector" the width of the 2dv will be returned.
Operation: Sum
Output: the sum of all the values in the vector, similar to the N-input.
Input Type: 2 Vector
Operation: Dot Product
The dot product has many useful applications, its formula o=A.x*B.x+A.y*B.y+A.z*B.z (wiki)
Calculating the cosine between two angles (or vectors), in this instance both vectors need to have a unit length (form a circle with a radius of 1), this can be achieved by Normalizing the vector (wiki)
when you have the unit length vectors pass the values into operand 1 and operand 2 and the result is the cosine of the angle, to get the degrees back use cosine counter part ArcCos.
Calculating the distance of an object to an arbitrary rotated plane, you need to find the normal (wiki) of the plane you want to get the distance to, the normal is a vector that is perpendicular to the surface (it sticks directly out) and has a radius of 1.
to get the distance to the surface:
get the dot product the surface normal with the objects vector position, and subtract from this:-
the dot product of the surface normal with any point that lay on the surface plane you are testing against.
Operation: Equals, Not Equal
this is the same as the N-input and Two input operators, with the exception Op1.x is tested to Op2.x, Op1.y is tested to Op2.y and Op1.z is tested to Op2.z
Equals outputs 1 if all the same or 0 if not.
Not Equals outputs 0 if the same and 1 if not.
left to add, vector, selector
-
Member
Great! But that generic filter.. I can't get to work. :/ I'm trying to make it so that when in my game, you shoot the gun twice, that you can't shoot it until you reload. I wanted to use a equals, set to an off state event, until a reload was initiated, although I can't get it to work. :/ Soo... any idea as to how I can get that to work? It's really annoying me and I swear I've tried everything!
-
Member
Excellent book you wrote there about those operators. I learned some new stuff
So Archon453. Did you ask about operators just so you would figure out a solution to that problem you have with the Generic Filter?
Solution would be to just have a variable representing the number of shots you can fire. Make it have the value 2, and every time you shoot, the value is reduced by 1, and before the shot gets fired it checks with a Generic Filter if that value Greater Equals 1. When you reload, set the value back to 2.
-
Member
Ironically I hadn't.
My issue with it occurred after I made the post. I'll try what you suggested, hopefully I can get it to work!
Thanks, and thank you very much @dasraizer, that is going to help me and many more people with the complications of Operations. They seem to be on of the more complicated set of tools, so a good description of each, and what they do is really going to help quite a bit.
It's my hope that this will help quite a few more people as well.
-
Senior Member
filters need to be triggerd(have a red line going towards them)
it will only check the condition if it recieves an impulse an wll send it to true or false accordingly
also avoid using equals, pc's can have rounding errors like it can for example have the value 1.9999999 when it should be 2 making it not equal anymore
use <= and >= instead
-
Member
Thanks! I'll keep that in mind sperkierjonesz , I took what Megamanne said, and well did some modifications to it, to get it to work perfectly.