-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ProtoFlux/Math/Constants/EpsilonDouble.cs ProtoFlux/Math/Constants/EpsilonFloat.cs ProtoFlux/Math/Random/RandomInt2.cs ProtoFlux/Math/Random/RandomBool2.cs ProtoFlux/Math/Random/RandomBool3.cs ProtoFlux/Math/Random/RandomDouble.cs ProtoFlux/Math/Random/RandomEulerAngles.cs ProtoFlux/Math/Random/RandomBool4.cs ProtoFlux/Math/Random/RandomCharacter.cs
- Loading branch information
Showing
9 changed files
with
188 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Elements.Core; | ||
using ProtoFlux.Core; | ||
using ProtoFlux.Runtimes.Execution; | ||
|
||
[NodeCategory("LogiX/NeosPlus/Math/Constants")] | ||
[NodeName("Epsilon Double")] | ||
public class EpsilonDouble : ValueFunctionNode<ExecutionContext, double> | ||
{ | ||
protected override double Compute(ExecutionContext context) | ||
{ | ||
return MathX.DOUBLE_EPSILON; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Elements.Core; | ||
using ProtoFlux.Core; | ||
using ProtoFlux.Runtimes.Execution; | ||
|
||
[NodeCategory("Protoflux/Obsidian/Math/Constants")] | ||
[NodeName("Epsilon Float")] | ||
public class EpsilonFloat : ValueFunctionNode<ExecutionContext, float> | ||
{ | ||
protected override float Compute(ExecutionContext context) | ||
{ | ||
return MathX.FLOAT_EPSILON; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System; | ||
using Elements.Core; | ||
using ProtoFlux.Core; | ||
using ProtoFlux.Runtimes.Execution; | ||
using ProtoFlux.Runtimes.Execution.Nodes.Actions; | ||
|
||
[NodeCategory("ProtoFlux/Obsidian/Math/Random")] | ||
[ContinuouslyChanging] | ||
|
||
public class RandomBool2 : ObjectFunctionNode<ExecutionContext, bool2> | ||
{ | ||
public ValueInput<float2> Chance; | ||
|
||
protected override bool2 Compute(ExecutionContext context) | ||
{ | ||
float2 chance = Chance.Evaluate(context); | ||
bool2 result = new bool2( | ||
RandomX.Chance(chance.x), | ||
RandomX.Chance(chance.y) | ||
); | ||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Elements.Core; | ||
using ProtoFlux.Core; | ||
using ProtoFlux.Runtimes.Execution; | ||
using ProtoFlux.Runtimes.Execution.Nodes.Actions; | ||
using FrooxEngine; | ||
|
||
[NodeCategory("ProtoFlux/Obsidian/Math/Random")] | ||
[NodeName("Random Bool3")] | ||
[ContinuouslyChanging] | ||
public class RandomBool3 : ValueFunctionNode<ExecutionContext, bool3> | ||
{ | ||
public ValueInput<float3> Chance; | ||
|
||
protected override bool3 Compute(ExecutionContext context) | ||
{ | ||
var chance = Chance.Evaluate(context); | ||
return new bool3(RandomX.Chance(chance.x), RandomX.Chance(chance.y), RandomX.Chance(chance.z)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using Elements.Core; | ||
using ProtoFlux.Core; | ||
using ProtoFlux.Runtimes.Execution; | ||
using ProtoFlux.Runtimes.Execution.Nodes.Actions; | ||
using FrooxEngine; | ||
|
||
[NodeCategory("ProtoFlux/Obsidian/Math/Random")] | ||
[NodeName("Random Bool4")] | ||
[ContinuouslyChanging] | ||
public class RandomBool4 : ValueFunctionNode<ExecutionContext, bool4> | ||
{ | ||
public ValueInput<float4> Chance; | ||
|
||
protected override bool4 Compute(ExecutionContext context) | ||
{ | ||
var chance = Chance.Evaluate(context); | ||
return new bool4( | ||
RandomX.Chance(chance.x), | ||
RandomX.Chance(chance.y), | ||
RandomX.Chance(chance.z), | ||
RandomX.Chance(chance.w) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Elements.Core; | ||
using ProtoFlux.Core; | ||
using ProtoFlux.Runtimes.Execution; | ||
using ProtoFlux.Runtimes.Execution.Nodes.Actions; | ||
|
||
[NodeCategory("ProtoFlux/Obsidian/Math/Random")] | ||
[NodeName("Random Character")] | ||
[ContinuouslyChanging] | ||
public class RandomCharacter : ValueFunctionNode<ExecutionContext, char> | ||
{ | ||
public ValueInput<int> Start; | ||
public ValueInput<int> End; | ||
public ObjectInput<string> String; | ||
|
||
protected override char Compute(ExecutionContext context) | ||
{ | ||
var str = String.Evaluate(context); | ||
var start = MathX.Clamp(Start.Evaluate(context), 0, str.Length); | ||
var end = MathX.Clamp(End.Evaluate(context,str.Length), start, str.Length); | ||
return str[RandomX.Range(start, end)]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using Elements.Core; | ||
using ProtoFlux.Core; | ||
using ProtoFlux.Runtimes.Execution; | ||
using ProtoFlux.Runtimes.Execution.Nodes.Actions; | ||
|
||
[NodeCategory("ProtoFlux/Obsidian/Math/Random")] | ||
[NodeName("Random Double")] | ||
[ContinuouslyChanging] | ||
public class RandomDouble : ValueFunctionNode<ExecutionContext, double> | ||
{ | ||
public ValueInput<double> Min; | ||
public ValueInput<double> Max; | ||
|
||
protected override double Compute(ExecutionContext context) | ||
{ | ||
var min = Min.Evaluate(context); | ||
var max = Max.Evaluate(context); | ||
if (min > max) | ||
{ | ||
var num1 = max; | ||
var num2 = min; | ||
min = num1; | ||
max = num2; | ||
} | ||
|
||
return min + RandomX.Double * (max - min); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Elements.Core; | ||
using FrooxEngine; | ||
using ProtoFlux.Core; | ||
using ProtoFlux.Runtimes.Execution; | ||
|
||
[NodeCategory("ProtoFlux/Obsidian/Math/Random")] | ||
[NodeName("Random Euler Angles")] | ||
[ContinuouslyChanging] | ||
|
||
public class RandomEulerAngles : ValueFunctionNode<ExecutionContext, float3> | ||
{ | ||
public ValueInput<float> minPitch; | ||
public ValueInput<float> maxPitch; | ||
public ValueInput<float> minYaw; | ||
public ValueInput<float> maxYaw; | ||
public ValueInput<float> minRoll; | ||
public ValueInput<float> maxRoll; | ||
|
||
protected override float3 Compute(ExecutionContext context) | ||
{ | ||
float pitch = RandomX.Range(minPitch.Evaluate(context), maxPitch.Evaluate(context)); | ||
float yaw = RandomX.Range(minYaw.Evaluate(context), maxYaw.Evaluate(context)); | ||
float roll = RandomX.Range(minRoll.Evaluate(context), maxRoll.Evaluate(context)); | ||
|
||
return new float3(pitch, yaw, roll); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Elements.Core; | ||
using ProtoFlux.Core; | ||
using ProtoFlux.Runtimes.Execution; | ||
|
||
[NodeCategory("ProtoFlux/Obsidian/Math/Random")] | ||
[NodeName("Random Int2")] | ||
public class RandomInt2 : ValueFunctionNode<ExecutionContext, int2> | ||
{ | ||
public ValueInput<int2> Min; | ||
public ValueInput<int2> Max; | ||
|
||
protected override int2 Compute(ExecutionContext context) | ||
{ | ||
int2 min = Min.Evaluate(context,int2.Zero); | ||
int2 max = Max.Evaluate(context,int2.One); | ||
|
||
return new int2(RandomX.Range(min.x, max.x), RandomX.Range(min.y, max.y)); | ||
} | ||
} |