本文整理汇总了C#中Vec3.Floor方法的典型用法代码示例。如果您正苦于以下问题:C# Vec3.Floor方法的具体用法?C# Vec3.Floor怎么用?C# Vec3.Floor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vec3
的用法示例。
在下文中一共展示了Vec3.Floor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Noise
public float Noise(Vec3 vec)
{
var cube = vec.Floor ();
var pt = vec - cube;
var faded = Fade (pt);
var X = (int)cube.X;
var Y = (int)cube.Y;
var Z = (int)cube.Z;
int A = Permutation (X) + Y,
AA = Permutation (A) + Z,
AB = Permutation (A + 1) + Z,
B = Permutation (X + 1) + Y,
BA = Permutation (B) + Z,
BB = Permutation (B + 1) + Z;
return GLMath.Mix (
GLMath.Mix (
GLMath.Mix (
Gradient (Permutation (AA), pt.X, pt.Y, pt.Z),
Gradient (Permutation (BA), pt.X - 1f, pt.Y, pt.Z),
faded.X),
GLMath.Mix (
Gradient (Permutation (AB), pt.X, pt.Y - 1f, pt.Z),
Gradient (Permutation (BB), pt.X - 1f, pt.Y - 1f, pt.Z),
faded.X),
faded.Y),
GLMath.Mix (
GLMath.Mix (
Gradient (Permutation (AA + 1), pt.X, pt.Y, pt.Z - 1f),
Gradient (Permutation (BA + 1), pt.X - 1f, pt.Y, pt.Z - 1f),
faded.X),
GLMath.Mix (
Gradient (Permutation (AB + 1), pt.X, pt.Y - 1f, pt.Z - 1f),
Gradient (Permutation (BB + 1), pt.X - 1f, pt.Y - 1f, pt.Z - 1f),
faded.X),
faded.Y),
faded.Z);
}
示例2: PeriodicNoise
public float PeriodicNoise(Vec3 vec, Vec3 period)
{
var cube = vec.Floor ();
var pt = vec - cube;
var faded = Fade (pt);
var iv = cube.Mod (period).Floor<Vec3, Vec3i> ();
var jv = (cube + new Vec3 (1f)).Mod (period).Floor<Vec3, Vec3i> ();
int A = Permutation (iv.X),
AA = Permutation (A + iv.Y),
AB = Permutation (A + jv.Y),
B = Permutation (jv.X),
BA = Permutation (B + iv.Y),
BB = Permutation (B + jv.Y);
return GLMath.Mix (
GLMath.Mix (
GLMath.Mix (
Gradient (Permutation (AA + iv.Z), pt.X, pt.Y, pt.Z),
Gradient (Permutation (BA + iv.Z), pt.X - 1f, pt.Y, pt.Z),
faded.X),
GLMath.Mix (
Gradient (Permutation (AB + iv.Z), pt.X, pt.Y - 1f, pt.Z),
Gradient (Permutation (BB + iv.Z), pt.X - 1f, pt.Y - 1f, pt.Z),
faded.X),
faded.Y),
GLMath.Mix (
GLMath.Mix (
Gradient (Permutation (AA + jv.Z), pt.X, pt.Y, pt.Z - 1f),
Gradient (Permutation (BA + jv.Z), pt.X - 1f, pt.Y, pt.Z - 1f),
faded.X),
GLMath.Mix (
Gradient (Permutation (AB + jv.Z), pt.X, pt.Y - 1f, pt.Z - 1f),
Gradient (Permutation (BB + jv.Z), pt.X - 1f, pt.Y - 1f, pt.Z - 1f),
faded.X),
faded.Y),
faded.Z);
}