当前位置: 首页>>代码示例>>C#>>正文


C# Vec3.Floor方法代码示例

本文整理汇总了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);
        }
开发者ID:johtela,项目名称:Compose3D,代码行数:39,代码来源:PerlinNoise.cs

示例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);
        }
开发者ID:johtela,项目名称:Compose3D,代码行数:37,代码来源:PerlinNoise.cs


注:本文中的Vec3.Floor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。