Example #1
0
        public void Reset()
        {
            // TODO: set defaults using attributes?
            stepHeight  = kDefaultStepHeight;
            stepDepth   = kDefaultStepDepth;
            treadHeight = kDefaultTreadHeight;
            nosingDepth = kDefaultNosingDepth;
            nosingWidth = kDefaultNosingWidth;

            width  = kDefaultWidth;
            height = kDefaultHeight;
            depth  = kDefaultDepth;

            plateauHeight = kDefaultPlateauHeight;

            riserType  = StairsRiserType.ThinRiser;
            leftSide   = StairsSideType.None;
            rightSide  = StairsSideType.None;
            riserDepth = kDefaultRiserDepth;
            sideDepth  = kDefaultSideDepth;
            sideWidth  = kDefaultSideWidth;
            sideHeight = kDefaultSideHeight;

            if (surfaceDefinition != null)
            {
                surfaceDefinition.Reset();
            }
        }
Example #2
0
        public void Reset()
        {
            origin = Vector3.zero;

            stepHeight = kDefaultStepHeight;

            treadHeight = kDefaultTreadHeight;
            nosingDepth = kDefaultNosingDepth;
            nosingWidth = kDefaultNosingWidth;

            innerDiameter = kDefaultInnerDiameter;
            outerDiameter = kDefaultOuterDiameter;
            height        = kDefaultHeight;

            startAngle = kDefaultStartAngle;
            rotation   = kDefaultRotation;

            innerSegments = kDefaultInnerSegments;
            outerSegments = kDefaultOuterSegments;

            riserType  = StairsRiserType.ThickRiser;
            riserDepth = kDefaultRiserDepth;

            bottomSmoothingGroup = 0;
            if (surfaceDefinition != null)
            {
                surfaceDefinition.Reset();
            }
        }
Example #3
0
        public static int CountPathedStairBrushes(UnsafeList <SegmentVertex> shapeVertices,
                                                  bool closedLoop,

                                                  ChiselAABB bounds,

                                                  float stepHeight,
                                                  float stepDepth,

                                                  float treadHeight,

                                                  float nosingDepth,

                                                  float plateauHeight,

                                                  StairsRiserType riserType,
                                                  float riserDepth,

                                                  StairsSideType leftSide,
                                                  StairsSideType rightSide,

                                                  float sideWidth,
                                                  float sideHeight,
                                                  float sideDepth)
        {
            var totalSubMeshCount = 0;

            for (int i = 0; i < shapeVertices.Length; i++)
            {
                if (i == 0 && !closedLoop)
                {
                    continue;
                }

                var segmentLeftSide  = (!closedLoop && i == 1) ? leftSide : StairsSideType.None;
                var segmentRightSide = (!closedLoop && i == shapeVertices.Length - 1) ? rightSide : StairsSideType.None;

                var description = new LineairStairsData(bounds, stepHeight, stepDepth, treadHeight,
                                                        nosingDepth, nosingWidth: 0, plateauHeight,
                                                        riserType, riserDepth,
                                                        segmentLeftSide, segmentRightSide,
                                                        sideWidth, sideHeight, sideDepth);
                totalSubMeshCount += description.subMeshCount;
            }
            return(totalSubMeshCount);
        }
Example #4
0
        // TODO: kind of broken, needs fixing
        public static bool GeneratePathedStairs(NativeList <ChiselBlobAssetReference <BrushMeshBlob> > brushMeshes,
                                                UnsafeList <SegmentVertex> shapeVertices,
                                                bool closedLoop,
                                                ChiselAABB bounds,

                                                float stepHeight,
                                                float stepDepth,

                                                float treadHeight,

                                                float nosingDepth,

                                                float plateauHeight,

                                                StairsRiserType riserType,
                                                float riserDepth,

                                                StairsSideType leftSide,
                                                StairsSideType rightSide,

                                                float sideWidth,
                                                float sideHeight,
                                                float sideDepth,
                                                in ChiselBlobAssetReference <NativeChiselSurfaceDefinition> surfaceDefinitionBlob,
        // TODO: remove all stairs specific parameters
        static void GenerateTopRamp(CSGBrushSubMesh[] subMeshes, int startIndex, int stepCount, Vector3 min, Vector3 max, Vector3 extrusion, float sideHeight, float extraDepth, float maxDepth, StairsRiserType riserType, CSGLinearStairsDefinition definition, CSGSurfaceAsset[] surfaceAssets, SurfaceDescription[] surfaceDescriptions)
        {
            //var diffY			= (max.y - min.y);
            //var diffZ			= (max.z - min.z);
            //var aspect		= diffY / diffZ;
            var diagonalHeight = sideHeight + definition.treadHeight; //Mathf.Max(sideHeight + definition.treadHeight, (aspect * (riserDepth)));// + definition.nosingDepth)) + definition.treadHeight;

            for (int i = 0, j = startIndex; i < stepCount; i++, j++)
            {
                var topY    = max.y + diagonalHeight;
                var bottomY = min.y;
                var middleY = (bottomY + diagonalHeight);            // - (lastStep ? (riserDepth * aspect) : 0);
                var rightZ  = Mathf.Max(maxDepth, max.z);            // + (lastStep ? riserDepth : 0);
                var leftZ   = Mathf.Max(maxDepth, min.z);

                //            topY leftZ
                //          0    4
                //           *--*
                //           |   \
                //           |    \
                //  lefterZ  |     \ 3
                //           |      *
                //           |      |   rightZ
                //           *------*
                //          1        2
                //            bottomY
                var lefterZ  = (i == 0 || (riserType == StairsRiserType.FillDown)) ? maxDepth : Mathf.Max(maxDepth, leftZ - extraDepth);
                var vertices = new[] {
                    new Vector3(min.x, topY, lefterZ),                     // 0
                    new Vector3(min.x, bottomY, lefterZ),                  // 1
                    new Vector3(min.x, bottomY, rightZ),                   // 2
                    new Vector3(min.x, middleY, rightZ),                   // 3
                    new Vector3(min.x, topY, leftZ),                       // 4
                };

                CreateExtrudedSubMesh(subMeshes[j + 0], vertices, extrusion,
                                      new int[] { 0, 1, 2, 3, 3, 3, 3 }, // TODO: fix this
                                      new int[] { 0, 1, 2, 2, 2, 2, 2 }, // TODO: fix this
                                      surfaceAssets, surfaceDescriptions);

                min.z += definition.stepDepth;
                max.z += definition.stepDepth;
                min.y -= definition.stepHeight;
                max.y -= definition.stepHeight;
            }
        }
        // TODO: remove all stairs specific parameters
        static void GenerateBottomRamp(CSGBrushSubMesh[] subMeshes, int startIndex, int stepCount, Vector3 min, Vector3 max, Vector3 extrusion, StairsRiserType riserType, float riserDepth, float extraDepth, float maxDepth, CSGLinearStairsDefinition definition, CSGSurfaceAsset[] surfaceAssets, SurfaceDescription[] surfaceDescriptions)
        {
            for (int i = 0, j = startIndex; i < stepCount; i++, j++)
            {
                Vector3[] vertices;
                var       z0 = Mathf.Max(maxDepth, min.z - extraDepth);
                var       z1 = Mathf.Max(maxDepth, max.z - extraDepth);
                var       z2 = Mathf.Max(maxDepth, min.z + riserDepth);/*
                                                                        * if (z2 < z1)
                                                                        * {
                                                                        * var t = z1; z1 = z2; z2 = t;
                                                                        * z1 = Mathf.Max(maxDepth, min.z - extraDepth + definition.stepDepth);
                                                                        * z2 = Mathf.Max(maxDepth, max.z);
                                                                        * }*/
                if (i != stepCount - 1)
                {
                    vertices = new[] {
                        new Vector3(min.x, max.y, z2),                  // 0
                        new Vector3(min.x, max.y, z0),                  // 1
                        new Vector3(min.x, min.y, z1),                  // 2
                        new Vector3(min.x, min.y, z2),                  // 3
                    };
                }
                else
                {
                    vertices = new[] {
                        new Vector3(min.x, max.y, z2),                          // 0
                        new Vector3(min.x, max.y, z0),                          // 1
                        new Vector3(min.x, min.y + definition.treadHeight, z1), // 2
                        new Vector3(min.x, min.y + definition.treadHeight, z2), // 3
                    };
                }

                CreateExtrudedSubMesh(subMeshes[j], vertices, extrusion,
                                      new int[] { 0, 1, 2, 3, 3, 3 }, // TODO: fix this
                                      new int[] { 0, 1, 2, 2, 2, 2 }, // TODO: fix this
                                      surfaceAssets, surfaceDescriptions);

                min.z += definition.stepDepth;
                max.z += definition.stepDepth;
                min.y -= definition.stepHeight;
                max.y -= definition.stepHeight;
            }
        }
Example #7
0
 // TODO: remove all stairs specific parameters
 static void GenerateBottomRamp(ref ChiselBrushContainer brushContainer, int startIndex, int stepCount, Vector3 min, Vector3 max, Vector3 extrusion, StairsRiserType riserType, float riserDepth, float extraDepth, float maxDepth, ChiselLinearStairsDefinition definition, in ChiselSurfaceDefinition surfaceDefinition)