/// <summary>
        /// Constructor
        /// </summary>
        /// <remarks>
        /// <para>
        /// A 'no result' object will be created if the <paramref name="polyMesh"/> parameter 
        /// is null or has a polygon count of zero.
        /// </para>
        /// </remarks>
        /// <param name="tx">The x-index of the tile within the tile grid. (tx, tz)</param>
        /// <param name="tz">The z-index of the tile within the tile grid. (tx, tz)</param>
        /// <param name="polyMesh">The polymesh.</param>
        /// <param name="detailMesh">The detail mesh.</param>
        /// <param name="heightfield">The heightfield.</param>
        /// <param name="compactField">The compact field.</param>
        /// <param name="contours">The contour set.</param>
        public NMGenAssets(int tx, int tz
            , PolyMesh polyMesh
            , PolyMeshDetail detailMesh
            , Heightfield heightfield
            , CompactHeightfield compactField
            , ContourSet contours)
        {
            mTileX = tx;
            mTileZ = tz;

            if (polyMesh == null || polyMesh.PolyCount == 0)
            {
                mPolyMesh = null;
                mDetailMesh = null;
                mHeightfield = null;
                mCompactField = null;
                mContours = null;
            }
            else
            {
                mPolyMesh = polyMesh;
                mDetailMesh = detailMesh;  // OK to be null.
                mHeightfield = heightfield;
                mCompactField = compactField;
                mContours = contours;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a compact open heightfield from a solid heightfield.
        /// </summary>
        /// <param name="context">The context to use duing the operation.</param>
        /// <param name="sourceField">
        /// The solid heighfield to derive the compact heightfield from.
        /// </param>
        /// <param name="walkableHeight">
        /// The minimum floor to ceiling height that is still considered walkable.
        /// [Limit: >= <see cref="NMGen.MinWalkableHeight"/>]
        /// </param>
        /// <param name="walkableStep">
        /// The maximum floor to floor step that is still considered walkable.</param>
        /// <returns>True if the operation completed successfully.</returns>
        public static CompactHeightfield Build(BuildContext context
                                               , Heightfield sourceField
                                               , int walkableHeight
                                               , int walkableStep)
        {
            if (context == null ||
                sourceField == null || sourceField.IsDisposed ||
                walkableHeight < NMGen.MinWalkableHeight ||
                walkableStep < 0)
            {
                return(null);
            }

            CompactHeightfield field = new CompactHeightfield();

            if (CompactHeightfieldEx.nmcfBuildField(context.root
                                                    , walkableHeight
                                                    , walkableStep
                                                    , sourceField.root
                                                    , field))
            {
                return(field);
            }

            return(null);
        }
 /// <summary>
 /// Sets the context as having produced no result.
 /// </summary>
 public void SetAsNoResult()
 {
     mHeightfield = null;
     mCompactField = null;
     mContours = null;
     mPolyMesh = null;
     mDetailMesh = null;
     mNoResult = true;
 }
Esempio n. 4
0
        /// <summary>
        /// Creates a compact open heightfield from a solid heightfield.
        /// </summary>
        /// <param name="context">The context to use duing the operation.</param>
        /// <param name="sourceField">
        /// The solid heighfield to derive the compact heightfield from.
        /// </param>
        /// <param name="walkableHeight">
        /// The minimum floor to ceiling height that is still considered walkable. 
        /// [Limit: >= <see cref="NMGen.MinWalkableHeight"/>]
        /// </param>
        /// <param name="walkableStep">
        /// The maximum floor to floor step that is still considered walkable.</param>
        /// <returns>True if the operation completed successfully.</returns>
        public static CompactHeightfield Build(BuildContext context
            , Heightfield sourceField
            , int walkableHeight
            , int walkableStep)
        {
            if (context == null
                || sourceField == null || sourceField.IsDisposed
                || walkableHeight < NMGen.MinWalkableHeight
                || walkableStep < 0)
            {
                return null;
            }

            CompactHeightfield field = new CompactHeightfield();

            if (CompactHeightfieldEx.nmcfBuildField(context.root
                , walkableHeight
                , walkableStep
                , sourceField.root
                , field))
            {
                return field;
            }

            return null;
        }