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


C# Planet.GetBilinearInterpolatedModifierAt方法代码示例

本文整理汇总了C#中Planet.GetBilinearInterpolatedModifierAt方法的典型用法代码示例。如果您正苦于以下问题:C# Planet.GetBilinearInterpolatedModifierAt方法的具体用法?C# Planet.GetBilinearInterpolatedModifierAt怎么用?C# Planet.GetBilinearInterpolatedModifierAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Planet的用法示例。


在下文中一共展示了Planet.GetBilinearInterpolatedModifierAt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Initialize

        /// <summary>
        /// Initializes the surface, called by the genetor to pass parameters
        /// </summary>
        public void Initialize(int level, Vector3 start, Vector3 end, Vector3 topRight, Vector3 bottomLeft, Planet planet, Planet.SurfacePosition sp, Surface parent, int sx, int sy)
        {
            // save reference
            this.planet = planet;
            this.surfacePosition = sp;
            this.parent = parent;
            this.subX = sx;
            this.subY = sy;

            // surface start and end points
            this.topleft = start;
            this.bottomright = end;
            this.topright = topRight;
            this.bottomleft = bottomLeft;

            // lod subdivision level
            lodLevel = level;

            // modifier starting point
            modifierStartX = 0;
            modifierStartY = 0;
            if(lodLevel == 0) {
            modifierResolution = planet.modifierResolution / (float)planet.subdivisions;
            }
            else {
            modifierResolution = parent.modifierResolution / 2f;
            modifierStartX += parent.modifierStartX;
            modifierStartY += parent.modifierStartY;
            }

            modifierStartX += subX * modifierResolution;
            modifierStartY += subY * modifierResolution;

            modifierMultiplier = modifierResolution / planet.meshResolution;

            // uv
            uvStartX = 0f;
            uvStartY = 0f;
            if(lodLevel == 0) {
            uvResolution = 1f / planet.subdivisions;
            }
            else {
            uvResolution = parent.uvResolution / 2f;
            uvStartX += parent.uvStartX;
            uvStartY += parent.uvStartY;
            }
            uvStartX += subX * uvResolution;
            uvStartY += subY * uvResolution;

            // corners
            subSurfaces = new List<Surface>();
            if(planet.useLod) {
            /*topLeftCorner = SperifyPoint(topleft) * planet.radius;
            bottomRightCorner = SperifyPoint(bottomright) * planet.radius;

            middlePoint = SperifyPoint((start + end) / 2f) * planet.radius;

            topRightCorner = SperifyPoint(topright) * planet.radius;
            bottomLeftCorner = SperifyPoint(bottomleft) * planet.radius;*/

            // TOP LEFT
            topLeftCorner = SperifyPoint(topleft);
            float displacement = planet.Terrain.module.GetValue(topLeftCorner);
            float rx = modifierStartX + 0 * modifierMultiplier;
            float cy = modifierStartY + 0 * modifierMultiplier;
            if(planet.useBicubicInterpolation)
                displacement += planet.GetBicubicInterpolatedModifierAt(rx, cy, surfacePosition);
            else
                displacement += planet.GetBilinearInterpolatedModifierAt(rx, cy, surfacePosition);
            topLeftCorner += topLeftCorner * displacement * planet.heightVariation;
            topLeftCorner *= planet.radius;

            // BOTTOM RIGHT
            bottomRightCorner = SperifyPoint(bottomright);
            displacement = planet.Terrain.module.GetValue(bottomRightCorner);
            rx = modifierStartX + planet.meshResolution * modifierMultiplier;
            cy = modifierStartY + planet.meshResolution * modifierMultiplier;
            if(planet.useBicubicInterpolation)
                displacement += planet.GetBicubicInterpolatedModifierAt(rx, cy, surfacePosition);
            else
                displacement += planet.GetBilinearInterpolatedModifierAt(rx, cy, surfacePosition);
            bottomRightCorner += bottomRightCorner * displacement * planet.heightVariation;
            bottomRightCorner *= planet.radius;

            // MIDDLE POINT
            middlePoint = SperifyPoint((start + end) / 2f);
            displacement = planet.Terrain.module.GetValue(middlePoint);
            rx = modifierStartX + (planet.meshResolution/2) * modifierMultiplier;
            cy = modifierStartY + (planet.meshResolution/2) * modifierMultiplier;
            if(planet.useBicubicInterpolation)
                displacement += planet.GetBicubicInterpolatedModifierAt(rx, cy, surfacePosition);
            else
                displacement += planet.GetBilinearInterpolatedModifierAt(rx, cy, surfacePosition);
            middlePoint += middlePoint * displacement * planet.heightVariation;
            middlePoint *= planet.radius;

            // TOP RIGHT
//.........这里部分代码省略.........
开发者ID:kurtdog,项目名称:DoubleTapp,代码行数:101,代码来源:Surface.cs


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