예제 #1
0
파일: Registro.cs 프로젝트: Cdrix/SM
    /// <summary>
    /// Taken a list of vectors 3 will find NW, NE, and SW and from there will create a new rectangle
    /// Returns a rectangle in our system where North is on the higher Y value always
    ///
    /// Y val flipped at the end
    /// </summary>
    public static Rect FromALotOfVertexToRect(List <Vector3> list)
    {
        List <float> xS = UList.ReturnAxisList(list, H.X);
        List <float> zS = UList.ReturnAxisList(list, H.Z);

        float minX = UMath.ReturnMinimum(xS);
        float maxX = UMath.ReturnMax(xS);

        float minZ = UMath.ReturnMinimum(zS);
        float maxZ = UMath.ReturnMax(zS);

        //Poly List that only need a valid NW, NE, and SW
        Vector3 NW = new Vector3(minX, 0, maxZ);
        Vector3 NE = new Vector3(maxX, 0, maxZ);
        Vector3 SE = new Vector3(maxX, 0, minZ);
        Vector3 SW = new Vector3(minX, 0, minZ);

        List <Vector3> poly = new List <Vector3>()
        {
            NW, NE, SE, SW
        };

        //here i find the Rect from this poly and then
        // I invert the Y of the recatangle... other wise this big rectangle
        //is not overlapping anything will be far off in the Cordinates...
        //Due to North(up) is bigger here say 100,, and South(down) less say 0 all this on World Z axis
        //As long as MeshManager Hover Current Vertices is big as is its now 9 Lots (each lot 5x5 real polys)
        //the Rect of the buildings will work flawlessly
        return(U2D.ReturnRectYInverted(U2D.FromPolyToRect(poly)));
    }
예제 #2
0
    /// <summary>
    /// Creates the air and ground parts and addToRegistro
    /// </summary>
    public void CreatePartsRoutine()
    {
        //creates parts above river
        PlanesOnAirPos = ReturnPlanesOnAirPosAndDefinePlanesOnSoil();
        PartsOnAir     = ClassifyABridgeByParts(ReturnPlanesOnAirPosAndDefinePlanesOnSoil().Count);

        createAirPartsNow = true;

        //creates parts on gorund
        //bz has duplicates// the big number is so close tiles dont have a part created
        //only needed if is a road
        if (HType.ToString().Contains("Road"))
        {
            PlanesOnSoil = EliminatesDuplicateDependingOnDominantSide(PlanesOnSoil);
        }
        //if is a trail...
        else if (HType.ToString().Contains("Trail"))
        {
            PlanesOnSoil = UList.EliminateDuplicatesByDist(PlanesOnSoil, 0.01f);
        }

        //bz is not ordered. They need to be ordered to be clasified
        PlanesOnSoil = OrderByXorZ(PlanesOnSoil);
        PartsOnSoil  = ClassifyShorePoints();

        //must be called here... So still we are using the CurrentSpawnBuild obj
        AddBridgeToRegistro();
    }
예제 #3
0
파일: WaterBound.cs 프로젝트: naaturaz/SM
    /// <summary>
    /// This are the vertices that create the marine bound
    /// </summary>
    private void FindVertexUnderNeathWater()
    {
        var   yS         = UList.FindYAxisCommonValues(m.AllVertexs, H.Descending);
        float firstUnder = UList.FindFirstYBelow(yS, Program.gameScene.WaterBody.transform.position.y);

        _marineBounds = UList.FindVectorsOnSameHeight(m.AllVertexs, firstUnder, 0.05f); //0.07f
        _marineBounds = UList.EliminateDuplicatesByDist(_marineBounds, 0.3f);           //0.2

        float firstClos = UList.FindFirstYBelow(yS, m.IniTerr.MathCenter.y - 1f);
        var   closer    = UList.FindVectorsOnSameHeight(m.AllVertexs, firstClos, 0.02f); //0.07f

        closer = UList.EliminateDuplicatesByDist(closer, 0.3f);                          //0.2

        _marineBounds.AddRange(closer);

        float lowest = UMath.ReturnMinimumDifferentThanZero(yS) + 1f;
        var   low    = UList.FindVectorsOnSameHeight(m.AllVertexs, lowest, 0.01f); //0.07f

        low = UList.EliminateDuplicatesByDist(low, 0.4f);                          //0.2

        _marineBounds.AddRange(low);

        //RenderMarineBounds();
        Debug.Log(_marineBounds.Count + " _marineBounds");
        //AddMarinePositions();

        DefineSeaPath(_marineBounds);
        addMarine = true;

        //AddMarineBoundsToCrystal();
    }
예제 #4
0
파일: SubPolyr.cs 프로젝트: Cdrix/SM
    //Returns first row list based on the rotation facer
    private List <Vector3> ReturnFirstRow(List <Vector3> listSelected, int rotationFacer)
    {
        List <Vector3> res = new List <Vector3>();

        if (rotationFacer == 0)
        {
            List <float> allZ = UList.ReturnAxisList(listSelected, H.Z);
            float        zMax = UMath.ReturnMax(allZ);
            res = FirstRowLoop(listSelected, zMax, H.Z);
        }
        else if (rotationFacer == 1)
        {
            List <float> allX = UList.ReturnAxisList(listSelected, H.X);
            float        xMax = UMath.ReturnMax(allX);
            res = FirstRowLoop(listSelected, xMax, H.X);
        }
        else if (rotationFacer == 2)
        {
            List <float> allZ = UList.ReturnAxisList(listSelected, H.Z);
            float        zMin = UMath.ReturnMinimum(allZ);
            res = FirstRowLoop(listSelected, zMin, H.Z);
        }
        else if (rotationFacer == 3)
        {
            List <float> allX = UList.ReturnAxisList(listSelected, H.X);
            float        xMin = UMath.ReturnMinimum(allX);
            res = FirstRowLoop(listSelected, xMin, H.X);
        }
        return(res);
    }
예제 #5
0
파일: WaterBound.cs 프로젝트: naaturaz/SM
    public void FindVertexAboveTerrainLevel()
    {
        var   yS         = UList.FindYAxisCommonValues(m.AllVertexs, H.Ascending);
        float firstAbove = UList.FindFirstYAbove(yS, m.IniTerr.MathCenter.y + 2f);

        _mountainBounds = UList.FindVectorsOnSameHeight(m.AllVertexs, firstAbove, 0.07f);//0.07f
        _mountainBounds = UList.EliminateDuplicatesByDist(_mountainBounds, 1f);

        //a layer 2 toward the top
        float lay2   = UList.FindFirstYAbove(yS, m.IniTerr.MathCenter.y + 3f);
        var   layer2 = UList.FindVectorsOnSameHeight(m.AllVertexs, lay2, 0.07f);//0.07f

        layer2 = UList.EliminateDuplicatesByDist(layer2, 1f);
        _mountainBounds.AddRange(layer2);

        //a layer 3 toward the top
        float lay3   = UList.FindFirstYAbove(yS, m.IniTerr.MathCenter.y + 4f);
        var   layer3 = UList.FindVectorsOnSameHeight(m.AllVertexs, lay3, 0.07f);//0.07f

        layer3 = UList.EliminateDuplicatesByDist(layer3, 1f);
        _mountainBounds.AddRange(layer3);

        DefineMountPath(yS);

        _mountainBounds.AddRange(_mountainPath);
        Debug.Log("_mountainBounds count: " + _mountainPath.Count);

        //bz was used by marine b4

        Save();

        addMount = true;

        //RenderMountainBounds();
    }
예제 #6
0
파일: WaterBound.cs 프로젝트: naaturaz/SM
    private void DefineMountPath(List <float> yS)
    {
        float highest = UMath.ReturnMax(yS);

        _mountainPath = UList.FindVectorsOnSameHeight(m.AllVertexs, highest, 0.03f); //0.03f
        _mountainPath = UList.EliminateDuplicatesByDist(_mountainPath, 0.4f);        //0.2
    }
예제 #7
0
파일: Way.cs 프로젝트: Cdrix/SM
    void UpdateBigBoxesPrev()
    {
        InitializeBigBoxPrev();

        float diffYVertic = UMath.ReturnDiffBetwMaxAndMin(_verticPathNew, H.Y);
        float diffYHoriz  = UMath.ReturnDiffBetwMaxAndMin(_horPathNew, H.Y);
        float biggestDiff = UMath.ReturnMax(diffYVertic, diffYHoriz);

        List <float> yS = UList.ReturnAxisList(_verticPathNew, H.Y);

        yS.AddRange(UList.ReturnAxisList(_horPathNew, H.Y));
        float maxY = UMath.ReturnMax(yS);

        if (_dominantSide == H.Vertic)
        {
            var locVertBound = MakeListYVal(BoundsVertic, maxY);
            verticBigBox.UpdatePos(locVertBound, biggestDiff + 0.5f);
            verticBigBox.CheckAndSwitchColor(_isWayOK);
        }
        else if (_dominantSide == H.Horiz)
        {
            var locHorBound = MakeListYVal(BoundsHoriz, maxY);
            horizBigBox.UpdatePos(locHorBound, biggestDiff + 0.5f);
            horizBigBox.CheckAndSwitchColor(_isWayOK);
        }
        //this is for all but bridges and DraggableSquare. Dominant Side here is None
        else if (_dominantSide == H.None && !HType.ToString().Contains("Bridge") && Category != Ca.DraggableSquare)
        {
            UpdateBigBoxesPrevForAllButBridges(maxY, biggestDiff);
        }

        TogglePrevBigBoxesVisible();
    }
예제 #8
0
파일: Way.cs 프로젝트: Cdrix/SM
    /// <summary>
    /// If the minimun of the both path is higher than _minHeightToSpawn is true
    /// </summary>
    bool FindIFWayAboveWater()
    {
        bool  res      = false;
        float minYVert = 0;
        float minYHor  = 0;

        if (_verticPathNew.Count > 0)
        {
            var vertYs = UList.ReturnAxisList(_verticPathNew, H.Y);
            minYVert = UMath.ReturnMinimum(vertYs);
            if (minYVert > _minHeightToSpawn)
            {
                res = true;
            }
        }
        if (_horPathNew.Count > 0)
        {
            var horYs = UList.ReturnAxisList(_horPathNew, H.Y);
            minYHor = UMath.ReturnMinimum(horYs);
            if (minYHor > _minHeightToSpawn)
            {
                res = true;
            }
        }
        if (_verticPathNew.Count > 0 && _horPathNew.Count > 0)
        {
            var min = UMath.ReturnMinimum(minYVert, minYHor);
            if (min > _minHeightToSpawn)
            {
                res = true;
            }
        }

        return(res);
    }
예제 #9
0
 /// <summary>
 /// Конструктор для класса, генерирующий
 /// Def и Use цепочки по базовому блоку
 /// </summary>
 /// <param name="block">Базовый блок</param>
 public DULists(BasicBlock block)
 {
     this.Block    = block;
     DList         = new DList();
     UList         = new UList();
     UListNotValid = new List <DUVar>();
     BuildDULists();
 }
예제 #10
0
파일: UMesh.cs 프로젝트: naaturaz/SM
    public static List <Vector3> ReturnCurrentLotsVertex(List <int> currentIndexes, List <Lot> squares)
    {
        List <Vector3> vertexs = new List <Vector3>();

        for (int i = 0; i < currentIndexes.Count; i++)
        {
            vertexs = UList.AddOneListToList(vertexs, squares[currentIndexes[i]].LotVertices);
        }
        return(vertexs);
    }
예제 #11
0
 public void RemoveBubble(UserControl userControl)
 {
     UList.Remove(userControl);
     this.bubbleArea.Controls.Remove(userControl);
     setHeight();
     if (UList.Count == 0)
     {
         this.Dispose();
     }
 }
예제 #12
0
파일: MForm.cs 프로젝트: linxon/dnsblc
        // Действие выхода приложения...
        private void CloseWindowNow()
        {
            if (UpdateLinkStat == true)
            {
                UList.Abort();
            }

            Close();
            Application.Exit(); // Чао!
        }
예제 #13
0
    private void DebugHere()
    {
        if (_eaten.Count == 4 && _currVector3s.Count == 12 && _debug.Count == 0)
        {
            ShowDebug(_currVector3s, Root.blueSphereHelp);
            ShowDebug(_eaten, Root.yellowCube);

            var cut = UList.ReturnTrunckedList(_grid, 500);
            ShowDebug(cut, Root.blueCube);
        }
    }
예제 #14
0
    /// <summary>
    /// Scan Routine will add new lots to lots list from the result of ScanTerraRetLotVertex()
    /// </summary>
    /// <param name="inPolyDiv">how many div ex 5x5 a real poly will have</param>
    /// <param name="polyX">real polys in X will cover in each scan pass</param>
    /// <param name="polyZ">real polys in Z will cover in each scan pass</param>
    private void ScanProcedure(int inPolyDiv, int polyX, int polyZ)
    {
        //return;

        List <Vector3> newLotVertex = new List <Vector3>();

        newLotVertex = ScanTerraRetLotVertex(inPolyDiv, polyX, polyZ);
        Lots.Add(new Lot(newLotVertex, Lots.Count, lotStart, lotEnd));
        //print("LotsScanned:" + Lots.Count);
        AllVertexs = UList.AddOneListToList(AllVertexs, newLotVertex);
    }
예제 #15
0
파일: MForm.cs 프로젝트: linxon/dnsblc
        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            this.Text                = "DNSBL Checker: Обновление списка серверов...";
            this.ScanBtnStat         = true;
            this.AddressEdit.Enabled = false;
            UpdateLink.Enabled       = false;
            UpdateLinkStat           = true;
            this.ScanBtn.Enabled     = false;

            this.UList = new Thread(UpdateServerList);
            UList.Start();
        }
예제 #16
0
 /// <summary>
 /// This eliminates duplicates of the bridge parts vectors3. Some pos are to close
 /// based on dominant side this will elimitaes the duplicates taht are less than 5 times the subdive x or z - 0.01f
 /// </summary>
 private List <Vector3> EliminatesDuplicateDependingOnDominantSide(List <Vector3> list)
 {
     if (_dominantSide == H.Vertic)
     {
         return(UList.EliminateDuplicatesByDist(list, (Mathf.Abs(m.SubDivide.ZSubStep) * 5) - 0.01f));
     }
     if (_dominantSide == H.Horiz)
     {
         return(UList.EliminateDuplicatesByDist(list, (Mathf.Abs(m.SubDivide.XSubStep) * 5) - 0.01f));
     }
     return(null);
 }
예제 #17
0
        /// <summary>
        /// Создает Use цепочку для базового блока
        /// </summary>
        private void BuildUList()
        {
            foreach (var dN in DList)
            {
                var dVar = dN.DefVariable;

                foreach (var uVar in dN.UseVariables)
                {
                    UList.Add(new UNode(uVar as DUVar, dVar as DUVar));
                }
            }
        }
예제 #18
0
    /// <summary>
    /// Return the diff btw max value and min value
    /// </summary>
    public static float ReturnDiffBetwMaxAndMin(List <Vector3> list, H axis)
    {
        float res = 0;

        if (axis == H.Y)
        {
            List <float> yS  = UList.ReturnAxisList(list, axis);
            float        min = ReturnMinimum(yS);
            float        max = ReturnMax(yS);
            res = Mathf.Abs(Mathf.Abs(max) - Mathf.Abs(min));
        }
        return(res);
    }
예제 #19
0
파일: SubPolyr.cs 프로젝트: Cdrix/SM
    /// Creates a list for the selected sub polygons given the columns and rows
    List <Vector3> CreateListSelected(ref List <Vector3> objsHitTerrain, int columns, int rows, Vector3 iniHit,
                                      SubDivider subDivide, bool isMouseOnTerrain, Vertexer vertex, UPoly poly, List <Vector3> currentHoverVertices)
    {
        objsHitTerrain = UMesh.ReturnThePos(iniHit, subDivide.XSubStep, subDivide.ZSubStep, columns, rows);

        List <Vector3> res = new List <Vector3>();

        for (int i = 0; i < objsHitTerrain.Count; i++)
        {
            res = UList.AddOneListToList(res, CreateOneSubPoly(objsHitTerrain[i], isMouseOnTerrain, vertex,
                                                               subDivide, poly, currentHoverVertices));
        }
        //still needs to eliminate duplicates

        return(res);
    }
예제 #20
0
파일: UList.cs 프로젝트: naaturaz/SM
    /// <summary>
    /// Find the common values of the 'list' on the 'axis' passed.
    /// For ex: is used to find all the values of Y in the mesh
    ///
    /// Will order by if 'order' was specified
    /// </summary>
    /// <param name="axis"></param>
    /// <param name="list"></param>
    /// <returns></returns>
    public static List <float> FindXAxisCommonValues(List <Vector3> list, H order)
    {
        if (order == H.Descending)
        {
            list = list.OrderByDescending(a => a.x).ToList();
        }
        else if (order == H.Ascending)
        {
            list = list.OrderBy(a => a.x).ToList();
        }

        var res = UList.ReturnAxisList(list, H.X);

        res = res.Distinct().ToList();

        return(res);
    }
예제 #21
0
    /// <summary>
    /// This is the routine that is looped with the Update() will change CurrentLoop
    /// thru all steps
    /// </summary>
    private void SetListsRoutine()
    {
        if (CurrentLoop == H.TerraSpawn)
        {
            if (_prevWayHor.Count > 0)
            {
                MarkTerraSpawnRoutine(_prevWayHor[0].Radius, UList.ReturnTheVector3List(_prevWayHor));
            }
            if (_prevWayVertic.Count > 0)
            {
                MarkTerraSpawnRoutine(_prevWayVertic[0].Radius, UList.ReturnTheVector3List(_prevWayVertic));
            }

            _currentLoop = H.Vertic;
        }
        else if (CurrentLoop == H.Vertic)
        {
            if (_counter < _verticPathNew.Count)
            {
                _subMeshPathVertic.Add(FindSubMeshVert(_verticPathNew[_counter]));
                _planesDimVertic.Add(ReturnPlanesDim(_subMeshPathVertic[_counter]));
                _counter++;
            }
            else
            {
                _counter     = 0;
                _currentLoop = H.Horiz;
            }
        }
        else if (CurrentLoop == H.Horiz)
        {
            if (_counter < _horPathNew.Count)
            {
                _subMeshPathHor.Add(FindSubMeshVert(_horPathNew[_counter]));
                _planesDimHor.Add(ReturnPlanesDim(_subMeshPathHor[_counter]));
                _counter++;
            }
            else
            {
                _counter       = 0;
                _currentLoop   = H.PlanesVertic;
                _isToSetList   = false;
                _isBuildingWay = true;
            }
        }
    }
예제 #22
0
    void MapStructuresCatego()
    {
        var infrastructure = StInfr.GetValues(typeof(StInfr));
        var housing        = StHous.GetValues(typeof(StHous));
        var farming        = StFarm.GetValues(typeof(StFarm));
        var raw            = StRaw.GetValues(typeof(StRaw));
        var production     = StProd.GetValues(typeof(StProd));
        var industry       = StInd.GetValues(typeof(StInd));
        var trade          = StTrade.GetValues(typeof(StTrade));
        var govServ        = StGov.GetValues(typeof(StGov));
        var other          = StOther.GetValues(typeof(StOther));
        var mil            = StMil.GetValues(typeof(StMil));
        var structCateg    = StCat.GetValues(typeof(StCat));
        var dec            = StDec.GetValues(typeof(StDec));


        MenuGroupsList = UList.ConvertToList(structCateg);

        List <List <H> > listedArrays = new List <List <H> >();

        listedArrays.Add(UList.ConvertToList(infrastructure));
        listedArrays.Add(UList.ConvertToList(housing));
        listedArrays.Add(UList.ConvertToList(farming));
        listedArrays.Add(UList.ConvertToList(raw));
        listedArrays.Add(UList.ConvertToList(production));
        listedArrays.Add(UList.ConvertToList(industry));
        listedArrays.Add(UList.ConvertToList(trade));
        listedArrays.Add(UList.ConvertToList(govServ));
        listedArrays.Add(UList.ConvertToList(other));
        listedArrays.Add(UList.ConvertToList(mil));
        listedArrays.Add(UList.ConvertToList(dec));


        for (int i = 0; i < MenuGroupsList.Count; i++)
        {
            _structuresDict.Add(MenuGroupsList[i], listedArrays[i]);
        }

        foreach (KeyValuePair <H, List <H> > entry in StructuresDict)
        {
            for (int i = 0; i < entry.Value.Count; i++)
            {
                AllStructures.Add(entry.Value[i]);
            }
        }
    }
예제 #23
0
    /// <summary>
    /// Subdive a lot. Will move the ref Vector3 start to the end of
    ///  the lot and will send the value bak to the caller of this method
    /// </summary>
    /// <param name="start">Start point of the lot... will be ref back here</param>
    /// <param name="polyX">how many poly on X</param>
    /// <param name="polyZ">how many ppoly oin Z</param>
    /// <param name="stepX">how far in X a real vertices is from another</param>
    /// <param name="stepZ">how far in Z a real vertices is from another</param>
    /// <param name="inPolyDiv">in poly divisions</param>
    /// <param name="vertices">all mesh vertices[]</param>
    /// <returns>a Vector3 list with the lot</returns>
    public List <Vector3> SubDivideLot(ref Vector3 start, int polyX, int polyZ,
                                       float stepX, float stepZ, int inPolyDiv, Vector3[] vertices)
    {
        float          localStepZ = 0;
        List <Vector3> lot        = new List <Vector3>();
        Vector3        temp       = start;
        Vector3        real       = new Vector3();

        for (int i = 0; i < polyZ; i++)
        {
            temp   = start;
            temp.z = start.z + localStepZ;
            //to make sure we are on top of a real vertex
            Vector3 realDummy = m.Vertex.BuildVertexWithXandZ(temp.x, temp.z);
            real = m.Vertex.FindClosestVertex(realDummy, vertices);

            for (int j = 0; j < polyX; j++)
            {
                List <Vector3> poly   = returnPoly(real, vertices);
                List <Vector3> newLot = SubDividePoly(poly, inPolyDiv, H.Tile);

                CheckIfStopScanning(newLot, polyX, polyZ, start);

                lot    = UList.AddOneListToList(lot, newLot);
                temp.x = real.x + Mathf.Abs(stepX);

                realDummy = m.Vertex.BuildVertexWithXandZ(temp.x, temp.z); //

                //in the last row has to jump in Z: temp.z - Mathf.Abs(stepZ))
                if (j == polyX - 1)
                {
                    //to make sure we are on top of a real vertex
                    realDummy = m.Vertex.BuildVertexWithXandZ(temp.x, temp.z - Mathf.Abs(stepZ)); //
                }
                real = m.Vertex.FindClosestVertex(realDummy, vertices);
            }
            //with multoplicacton was loosing big time precision...
            //that why im adding here the values... with floats avoid multiplcations
            localStepZ = localStepZ + stepZ;
        }
        start = real;
        //lot = UList.EliminateDuplicatesByDist(lot, 0.01f);
        //print(lot.Count + ".lot.count");
        return(lot);
    }
예제 #24
0
    /// <summary>
    /// If realvertices in lots were not found will flagged. And when all were done will finally write the XML
    /// </summary>
    private void FinalWrite()
    {
        if (!isToSetRealVerticesOnLots && realVertiesDoneCount == 0)
        {
            isToSetRealVerticesOnLots = true;
        }
        else if (isToSetRealVerticesOnLots && realVertiesDoneCount == Lots.Count)
        {
            Malla.Lots = Lots;
            subMesh.AllSubMeshedLots    = Malla.Lots;
            subMesh.amountOfSubVertices = AllVertexs.Count;
            subMesh.mostCommonYValue    = UList.FindMostCommonValue(H.Y, Vertices.ToList());

            WriteXML();
            //print(subMesh.amountOfSubVertices + " subMesh.amountOfSubVertices ");
            isToSetRealVerticesOnLots = false;
        }
    }
예제 #25
0
파일: Way.cs 프로젝트: Cdrix/SM
    bool TellMeIfTopOnesAreEven(List <Vector3> list)
    {
        List <float> yS           = UList.ReturnAxisList(list, H.Y);
        float        planesOnAirY = FindPlanesOnAirHeight();

        for (int i = 0; i < list.Count; i++)
        {
            if (list[i].y > planesOnAirY)
            {
                float diff = Mathf.Abs(planesOnAirY - list[i].y);
                if (diff > _maxDiffAllowOnTerrainForARoad)
                {
                    return(false);
                }
            }
        }
        return(true);
    }
예제 #26
0
    private float valYSearch = 0.0001f;//0.05f

    private void PullMostCommonYLayer()
    {
        var   yS      = UList.FindYAxisCommonValues(m.AllVertexs, H.Descending);
        float yCommon = UList.FindFirstYBelow(yS, m.IniTerr.MathCenter.y);

        _commomLayer = UList.FindVectorsOnSameHeight(m.Vertices.ToList(), yCommon, valYSearch);

        Debug.Log("_commomLayer.Count:" + _commomLayer.Count);

        if (_commomLayer.Count == 0 && secCount < 1000)
        {
            valYSearch += 0.001f;
            secCount++;
            PullMostCommonYLayer();
        }
        else if (_commomLayer.Count == 0 && secCount >= 1000)
        {
            throw new Exception("Not pull anything from CommonY Layer");
        }
    }
예제 #27
0
파일: UPoly.cs 프로젝트: Cdrix/SM
    //will even many polys in Y. this Method has a bug that
    //put all vertices toghether
    public List <Vector3> EvenInYManyPolys(List <Vector3> manyPoly, ref Vector3[] vertices, ref bool isToEven,
                                           float maxHeightForEven, ref float minY)
    {
        float maxY = UMath.ReturnMax(UList.ReturnAxisList(manyPoly, H.Y));

        minY = UMath.ReturnMinimum(UList.ReturnAxisList(manyPoly, H.Y));
        float heightDiff = maxY - minY;

        if (heightDiff >= maxHeightForEven)
        {
            isToEven = false;
            return(manyPoly);
        }

        isToEven = true;
        //print(heightDiff + " heightDiff");

        for (int i = 0; i < manyPoly.Count; i++)
        {
            Vector3 newModifiedYPos = manyPoly[i];
            newModifiedYPos.y = minY;
            manyPoly[i]       = newModifiedYPos;
        }

        float epsilon = 0.1f;

        for (int i = 0; i < vertices.Length; i++)
        {
            for (int j = 0; j < manyPoly.Count; j++)
            {
                //if this are the same in X and Z we are updating
                bool x = UMath.nearlyEqual(vertices[i].x, manyPoly[j].x, epsilon);
                bool z = UMath.nearlyEqual(vertices[i].z, manyPoly[j].z, epsilon);
                if (x && z)
                {   //updating the whole vertices matrix
                    vertices[i] = manyPoly[j];
                }
            }
        }
        return(manyPoly);
    }
예제 #28
0
        static void Main(string[] args)
        {
            // get a slice of a List

            var utilList = new UList <int> {
                1, 2, 3, 5, 43, 42, 6, 88, 886, 864
            };

            Console.WriteLine("Original Util List: ");
            Console.WriteLine(utilList);

            // call the get next.
            Console.WriteLine(utilList.GetNext());
            Console.WriteLine(utilList.GetNext());
            utilList.GetNext();
            Console.WriteLine(utilList.GetNext());

            // make sure that the foreach still works
            Console.WriteLine(utilList);
            Console.WriteLine("Program Success.");
        }
예제 #29
0
    // Full,//this will use create object everywere in the poly
    //Tile//this one will only fill so the next poly doesnt create any obj was created on this one
    //already
    public List <Vector3> SubDividePoly(List <Vector3> poly, int divs, H fillStyle)
    {
        List <Vector3> filled   = new List <Vector3>();
        List <Vector3> topLine  = SubDivideLine(poly, 0, 1, divs, H.X);
        List <Vector3> leftLine = SubDivideLine(poly, 1, 2, divs, H.Z);

        if (fillStyle == H.Full)
        {
            List <Vector3> botLine   = SubDivideLine(poly, 2, 3, divs, H.X);
            List <Vector3> rightLine = SubDivideLine(poly, 3, 0, divs, H.Z);
            filled = UList.AddManyListToList(botLine, rightLine, leftLine);
        }
        List <Vector3> fill = FillPolygonWrite(topLine, leftLine);

        filled = UList.AddManyListToList(filled, topLine, leftLine);
        filled = UList.AddOneListToList(filled, fill);
        float dist = 0.001f;

        //filled = UList.EliminateDuplicatesByDist(filled, dist);
        filled = filled.Distinct().ToList();
        //print(filled.Count + "filled");
        return(filled);
    }
예제 #30
0
    private void DefineCurrentRow()
    {
        //_currRow.Add
        var xS = UList.FindXAxisCommonValues(_eaten, H.Descending);
        var zS = UList.FindZAxisCommonValues(_eaten, H.Descending);

        float find = 0;
        H     axis = H.None;

        //norht find the top value on z
        if (_direction == 0)
        {
            find = UMath.ReturnMax(zS);
            axis = H.Z;
        }
        //south
        else if (_direction == 2)
        {
            find = UMath.ReturnMinimum(zS);
            axis = H.Z;
        }
        //east
        else if (_direction == 1)
        {
            find = UMath.ReturnMax(xS);
            axis = H.X;
        }
        //west
        else if (_direction == 3)
        {
            find = UMath.ReturnMinimum(xS);
            axis = H.X;
        }

        _currRow = UList.FindVectorsOnSameRange(_eaten, find, axis, 0.05f);
    }