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


C# Vector3F.RoundDown方法代码示例

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


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

示例1: MakeRoots

            void MakeRoots( IList<RootBase> rootBases ) {
                if( rootBases.Count == 0 ) return;
                foreach( Vector3I coord in FoliageCoords ) {
                    float dist = (float)Math.Sqrt( Sqr( coord[0] - Pos[0] ) + Sqr( coord[2] - Pos[2] ) );
                    float distY = coord[1] - Pos[1];
                    float value = (BranchDensity * 220 * Height) / Cub( distY + dist );
                    if( value < Args.Rand.NextDouble() ) continue;

                    RootBase rootBase = rootBases[Args.Rand.Next( 0, rootBases.Count )];
                    float rootBaseRadius = rootBase.Radius;

                    float randR = (float)(Math.Sqrt( Args.Rand.NextDouble() ) * rootBaseRadius * .618);
                    float randAng = (float)(Args.Rand.NextDouble() * 2 * Math.PI);
                    int randX = (int)(randR * Math.Sin( randAng ) + .5);
                    int randZ = (int)(randR * Math.Cos( randAng ) + .5);
                    int randY = (int)(Args.Rand.NextDouble() * rootBaseRadius * .5);
                    Vector3I startCoord = new Vector3I {
                        X = rootBase.X + randX,
                        Z = rootBase.Z + randZ,
                        Y = Pos[1] + randY
                    };
                    Vector3F offset = new Vector3F( startCoord - coord );

                    if( Args.Shape == TreeShape.Mangrove ) {
                        // offset = [int(val * 1.618 - 1.5) for val in offset]
                        offset = offset * 1.618f - HalfBlock * 3;
                    }

                    Vector3I endCoord = startCoord + offset.RoundDown();
                    float rootStartSize = (float)(rootBaseRadius * .618 * Math.Abs( offset[1] ) / (Height * .618));

                    if( rootStartSize < 1 ) rootStartSize = 1;
                    const float endSize = 1;

                    if( Args.Roots == RootMode.ToStone ||
                        Args.Roots == RootMode.Hanging ) {
                        float offLength = offset.Length;
                        if( offLength < 1 ) continue;
                        float rootMid = endSize;
                        Vector3F vec = offset / offLength;

                        Block searchIndex = Block.Air;
                        if( Args.Roots == RootMode.ToStone ) {
                            searchIndex = Block.Stone;
                        } else if( Args.Roots == RootMode.Hanging ) {
                            searchIndex = Block.Air;
                        }

                        int startDist = (int)(Args.Rand.NextDouble() * 6 * Math.Sqrt( rootStartSize ) + 2.8);
                        Vector3I searchStart = new Vector3I( startCoord + vec * startDist );

                        dist = startDist + DistanceToBlock( Args.Map, new Vector3F( searchStart ), vec, searchIndex );

                        if( dist < offLength ) {
                            rootMid += (rootStartSize - endSize) * (1 - dist / offLength);
                            endCoord = new Vector3I( startCoord + vec * dist );
                            if( Args.Roots == RootMode.Hanging ) {
                                float remainingDist = offLength - dist;
                                Vector3I bottomCord = endCoord;
                                bottomCord[1] -= (int)remainingDist;
                                TaperedLimb( endCoord, bottomCord, rootMid, endSize );
                            }
                        }
                        TaperedLimb( startCoord, endCoord, rootStartSize, rootMid );
                    } else {
                        TaperedLimb( startCoord, endCoord, rootStartSize, endSize );
                    }
                }
            }
开发者ID:fragmer,项目名称:fCraft,代码行数:69,代码来源:Forester.cs


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