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


C# Polygon.SetClosed方法代码示例

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


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

示例1: Generate

    public void Generate(Polygon _polygon)
    {
        _rimParts.Clear ();
        _rimLofters.Clear ();
        _corners.Clear ();

        foreach (Transform child in _rim.transform)
        {
            GameObject.Destroy (child.gameObject);
        }

        _rars.Subdivide (_polygon);
        Polygon subdividedPolygon = new Polygon (_rars.GetSubdividedPolygon ());
        subdividedPolygon.SetClosed (_polygon.IsClosed ());

        //******************* OBTENTION DU PROFILE A EXTERNALISER ********************//
        PolygonRawData shapeRaw = new PolygonRawData ();

        /*shapeRaw.Add (new Vector2 (0, 0));
        shapeRaw.Add (new Vector2 (0, 0.01f));
        shapeRaw.Add (new Vector2 (-0.015f, 0.026f));
        shapeRaw.Add (new Vector2 (-0.015f, 0.042f));
        shapeRaw.Add (new Vector2 (-0.006f, 0.06f));
        shapeRaw.Add (new Vector2 (0.01f, 0.069f));
        shapeRaw.Add (new Vector2 (0.03f, 0.071f));
        shapeRaw.Add (new Vector2 (0.049f, 0.066f));
        shapeRaw.Add (new Vector2 (0.071f, 0.06f));

        shapeRaw.Add (new Vector2 (0.1f, 0.052f));
        shapeRaw.Add (new Vector2 (0.169f, 0.044f));
        shapeRaw.Add (new Vector2 (0.249f, 0.041f));
        shapeRaw.Add (new Vector2 (0.29f, 0.04f));
        shapeRaw.Add (new Vector2 (0.298f, 0.038f));
        shapeRaw.Add (new Vector2 (0.305f, 0.033f));
        shapeRaw.Add (new Vector2 (0.309f, 0.024f));
        shapeRaw.Add (new Vector2 (0.31f, 0.014f));
        shapeRaw.Add (new Vector2 (0.31f, 0));*/

        shapeRaw.Add (new Vector2 (-0.02f, 0.0f));
        shapeRaw.Add (new Vector2 (0.28f, 0.0f));
        shapeRaw.Add (new Vector2 (0.28f, 0.001f));
        shapeRaw.Add (new Vector2 (-0.02f, 0.001f));

        Polygon profile = new Polygon (shapeRaw);
        profile.SetClosed (false);
        //************************************************************************//

        Polygon currentPortion = null;
        bool inPortion = false;
        bool inCurve = false;

        int pointCounter = 0;
        int indexOffset = 0;

        // pour chaque point du polygon subdivisé
        // si c'est un angle prédéfini on charge le mesh margelle associé
        // sinon on crée un section avec l'outil loft jusqu'au prochain angle prédéfini
        foreach (Point2 currentPoint in subdividedPolygon.GetPoints ())
        {
            float angle = currentPoint.GetAngle ();
            AngleType angleType = currentPoint.GetAngleType ();

            if (inPortion || inCurve)
            {
                Point2 pointToAdd = new Point2 (currentPoint);
                currentPortion.AddPoint (pointToAdd);
            }

            Edge2 nextEdge = currentPoint.GetNextEdge ();
            Edge2 prevEdge = currentPoint.GetPrevEdge ();
            Point2 nextPoint = null;
            Point2 prevPoint = null;

            if (nextEdge != null)
            {
                nextPoint = nextEdge.GetNextPoint2 ();
                prevPoint = prevEdge.GetPrevPoint2 ();

                float nextAngle = nextPoint.GetAngle ();
                AngleType nextAngleType = nextPoint.GetAngleType ();
                // stop case for onr portion
                if (Utils.Approximately (nextAngle, 90) && inPortion && nextAngleType == AngleType.Outside)
                {
                    inPortion = false;
                    currentPortion.SetClosed (false);

                    GameObject portionGO = new GameObject ("portion");
                    portionGO.transform.parent = _rim.transform;
                    portionGO.transform.localPosition = Vector3.zero;
                    portionGO.transform.localRotation = Quaternion.identity;
                    portionGO.transform.localScale = Vector3.one;

                    portionGO.AddComponent<MeshRenderer> ();
                    MeshFilter meshFilter = portionGO.AddComponent<MeshFilter> ();

                    PolygonLofter polyLofter = new PolygonLofter (currentPortion, profile, meshFilter.mesh);
                    polyLofter.SetCurveIndices (_rars.GetCurveIndices ());
                    polyLofter.SetIndexedAngleType (_rars.GetIndexedAngleType ());

                    polyLofter.SetIndexOffset (indexOffset + 1, subdividedPolygon.GetPoints ().Count);
//.........这里部分代码省略.........
开发者ID:gviaud,项目名称:OS-unity-5,代码行数:101,代码来源:RimGenerator.cs

示例2: Generate

    public void Generate(Polygon _polygon)
    {
        //_polygon = new Polygon(_polygon.GenerateWithCurveInverse());
        // On genere les meshs des composants de la piscine

        if (_polygon.GetPoints ().Count < 3)
            return;

        if (!_polygon.IsClosed ())
        {
            _polygon.Close ();
        }

        _polygon = _polygon.GetMirrorX();

        _polygon.UpdateBounds ();
        Vector2 translation = _polygon.GetPolygonCenter () * -1;
        Vector2 mirror = new Vector2(1,-1);
        // exprime le polygone en coordonnées monde, avec son repere centré sur son centre
        PolygonRawData polyRaw = new PolygonRawData ();
        foreach (Vector2 pt in _polygon.GenerateWithCurve ())
        //foreach (Vector2 pt in _polygon.GenerateWithCurveInverse ())
        //PolygonRawData polydata = _polygon.GenerateWithCurveInverse ();
        //polydata.Reverse();
        //foreach (Vector2 pt in polydata)
        {
            Vector2 transformedPt = (pt + translation) * _polygonScaleFactor;
            /*Vector2 newpt = new Vector2();
            newpt.x=pt.x;
            newpt.y=pt.y;

            newpt.y = 2*_polygon.bounds.center.z - newpt.y;
            Vector2 transformedPt = (newpt + translation) * _polygonScaleFactor;*/
            polyRaw.Add (transformedPt);
        }

        _transformedPolygon = new Polygon (polyRaw);

        // generate liner
        Mesh linerMesh = _liner.GetComponent<MeshFilter> ().mesh;
        PolygonExtruder linerExtrusion = new PolygonExtruder (_transformedPolygon, linerMesh, -1.5f, false, true, true);
        linerExtrusion.Generate ();

        LinerScatteringMapper lsm = new LinerScatteringMapper (linerMesh);
        lsm.Generate ();

        PolygonExtruderMapper pem = new PolygonExtruderMapper (linerExtrusion);
        pem.Generate ();

        // generate sidewalk
        Mesh sidewalkMesh = _sidewalk.GetComponent<MeshFilter> ().mesh;
        SideWalkExtruder se = new SideWalkExtruder (_transformedPolygon, sidewalkMesh, -0.02f, 2);
        se.Generate ();

        PlannarMapper pm = new PlannarMapper (sidewalkMesh, Vector3.up);
        pm.Generate ();

        // generate rim
        _rimGenerator.Generate (_polygon);

        // generate occlusion
        PolygonRawData occluShape = new PolygonRawData ();
        occluShape.Add (new Vector2 (0.28f, 0));
        occluShape.Add (new Vector2 (0.33f, 0));

        Polygon occluProfile = new Polygon (occluShape);
        occluProfile.SetClosed (false);

        Mesh occluMesh = _occlusion.GetComponent<MeshFilter> ().mesh;
        PolygonLofter occluLofter = new PolygonLofter (_transformedPolygon, occluProfile, occluMesh);
        _occlusion.GetComponent<Renderer>().enabled = false;
        occluLofter.Generate ();

        // generate water
        Mesh waterMesh = _water.GetComponent<MeshFilter> ().mesh;
        PolygonExtruder waterPlan = new PolygonExtruder (_transformedPolygon, waterMesh, 0, true, false, false);
        waterPlan.Generate ();

        PlannarMapper waterMapper = new PlannarMapper (waterMesh, Vector3.down, UVChannel.uv0, 5);
        waterMapper.Generate ();

        // generate frieze
        Mesh friezeMesh = _frieze.GetComponent<MeshFilter> ().mesh;
        PolygonExtruder friezeExtrusion = new PolygonExtruder (_transformedPolygon, friezeMesh, -0.10f, false, false, true);
        friezeExtrusion.Generate ();

        PolygonExtruderMapper friezeMapper = new PolygonExtruderMapper (friezeExtrusion);
        friezeMapper.Generate ();

        LinerScatteringMapper lsmFrieze = new LinerScatteringMapper (friezeMesh);
        lsmFrieze.Generate ();

        // generate mask
        Mesh maskMesh = _mask.GetComponent<MeshFilter> ().mesh;
        PolygonExtruder maskExtrusion = new PolygonExtruder (_transformedPolygon, maskMesh, -0.10f, false, false, true);
        maskExtrusion.Generate ();

        PolygonExtruderMapper maskMapper = new PolygonExtruderMapper (maskExtrusion);
        maskMapper.Generate ();

//.........这里部分代码省略.........
开发者ID:gviaud,项目名称:OS-unity-5,代码行数:101,代码来源:PoolGenerator.cs


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