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


C# Polygon.GetPolygonCenter方法代码示例

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


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

示例1: Subdivide


//.........这里部分代码省略.........
                // on ajoute chaque point de l'arc de cercle
                ArchedPoint2 ar = currentPoint as ArchedPoint2;

                int startCurveIndex = _subdividedPolygon.Count;

                // ajout de l'indice du premier point de l'arc de cercle
                // pour le mapping dans PolygonLofter
                _curveIndices.Add (startCurveIndex);

                // on associe l'indice de debut de courbe au type d'angle courant
                _indexedAngleType.Add (startCurveIndex, currentPoint.GetAngleType ());

                foreach (Vector2 p in ar.GetCurve ())
                {
                    ptIndices++;
                    _subdividedPolygon.Add (p);
                }

                int endCurveIndex = _subdividedPolygon.Count - 1;

                // ajout de l'indice du dernier point de l'arc de cercle
                // pour le mapping dans PolygonLofter
                _curveIndices.Add (endCurveIndex);
            }
        }

        // decoupage au niveau du point 0 et du segment precedent le point 0
        // meme procedure que precedemment
        Point2 firstPoint = _polygon.GetPoints ()[0];
        Edge2 firstPrevEdge = firstPoint.GetPrevEdge ();

        if (firstPrevEdge != null && firstPoint.GetJunction () == JunctionType.Broken)
        {
            float rimWidth = 0.31f * 100;
            float sectionLength = rimWidth * firstPoint.GetNormalScaleFactor ();
            float outsideLength = Mathf.Sqrt (sectionLength * sectionLength - rimWidth * rimWidth);
            float subdividedLimit = RIM_SIZE; //+ RIM_SIZE / 2;

            if (firstPoint.GetAngleType () == AngleType.Inside)
            {
                Vector2 prevSubdVector = _subdividedPolygon[_subdividedPolygon.Count - 1];
                float prevEdgeLength = Vector2.Distance (firstPoint, prevSubdVector);

                if (prevEdgeLength > subdividedLimit)
                {
                    if (outsideLength >= RIM_SIZE - MIN_INSIDE_RIM_LENGTH)
                    {
                        Vector2 prevDirection = firstPrevEdge.ToVector2 ().normalized * -1;
                        Vector2 prevPoint = firstPoint + prevDirection * (outsideLength + MIN_INSIDE_RIM_LENGTH);

                        ptIndices++;
                        _subdividedPolygon.Add (prevPoint);
                    }
                    else
                    {
                        Vector2 prevDirection = firstPrevEdge.ToVector2 ().normalized * -1;
                        Vector2 prevPoint = firstPoint + prevDirection * RIM_SIZE;

                        ptIndices++;
                        _subdividedPolygon.Add (prevPoint);
                    }
                }
            }

            if (firstPoint.GetAngleType () == AngleType.Outside && !Utils.Approximately (firstPoint.GetAngle (), 90))
            {
                Vector2 prevSubdVector = _subdividedPolygon[_subdividedPolygon.Count - 1];
                float prevEdgeLength = Vector2.Distance (firstPoint, prevSubdVector);

                if (prevEdgeLength > subdividedLimit)
                {
                    if (outsideLength <= RIM_SIZE - MIN_INSIDE_RIM_LENGTH)
                    {
                        float length = RIM_SIZE - outsideLength;
                        Vector2 prevDirection = firstPrevEdge.ToVector2 ().normalized * -1;
                        Vector2 prevPoint = firstPoint + prevDirection * length;

                        ptIndices++;
                        _subdividedPolygon.Add (prevPoint);
                    }
                    else
                    {
                        Vector2 prevDirection = firstPrevEdge.ToVector2 ().normalized * -1;
                        Vector2 prevPoint = firstPoint + prevDirection * MIN_INSIDE_RIM_LENGTH;

                        ptIndices++;
                        _subdividedPolygon.Add (prevPoint);
                    }
                }
            }
        }

        // on exprime le polygone subdivisé en coordonnées monde, avec son repere centré sur son centre
        Vector2 translation = _polygon.GetPolygonCenter () * -1;

        for (int ptIndex = 0; ptIndex < _subdividedPolygon.Count; ++ptIndex)
        {
            _subdividedPolygon[ptIndex] = (_subdividedPolygon[ptIndex] + translation) * _polygonScaleFactor;
        }
    }
开发者ID:gviaud,项目名称:OS-unity-5,代码行数:101,代码来源:RimSubdivider.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.GetPolygonCenter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。