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


C# Mesh.Clear方法代码示例

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


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

示例1: OnPopulateMesh

        protected override void OnPopulateMesh(Mesh toFill)
        {
            float outer = -rectTransform.pivot.x * rectTransform.rect.width;
            float inner = -rectTransform.pivot.x * rectTransform.rect.width + this.thickness;

            toFill.Clear();
            var vbo = new VertexHelper(toFill);

            Vector2 prevX = Vector2.zero;
            Vector2 prevY = Vector2.zero;
            Vector2 uv0 = new Vector2(0, 0);
            Vector2 uv1 = new Vector2(0, 1);
            Vector2 uv2 = new Vector2(1, 1);
            Vector2 uv3 = new Vector2(1, 0);
            Vector2 pos0;
            Vector2 pos1;
            Vector2 pos2;
            Vector2 pos3;

            float f = (this.fillPercent / 100f);
            float degrees = 360f / segments;
            int fa = (int)((segments + 1) * f);

            for (int i = 0; i < fa; i++)
            {
                float rad = Mathf.Deg2Rad * (i * degrees);
                float c = Mathf.Cos(rad);
                float s = Mathf.Sin(rad);

                uv0 = new Vector2(0, 1);
                uv1 = new Vector2(1, 1);
                uv2 = new Vector2(1, 0);
                uv3 = new Vector2(0, 0);

                pos0 = prevX;
                pos1 = new Vector2(outer * c, outer * s);

                if (fill)
                {
                    pos2 = Vector2.zero;
                    pos3 = Vector2.zero;
                }
                else
                {
                    pos2 = new Vector2(inner * c, inner * s);
                    pos3 = prevY;
                }

                prevX = pos1;
                prevY = pos2;

                vbo.AddUIVertexQuad(SetVbo(new[] { pos0, pos1, pos2, pos3 }, new[] { uv0, uv1, uv2, uv3 }));

            }

            if (vbo.currentVertCount > 3)
            {
                vbo.FillMesh(toFill);
            }
        }
开发者ID:renketsu0,项目名称:oculus_data_vis,代码行数:60,代码来源:UICircle.cs

示例2: FillMesh

        public void FillMesh(Mesh mesh)
        {
            mesh.Clear();

            if (m_Positions.Count >= 65000)
                throw new ArgumentException("Mesh can not have more than 65000 vertices");

            mesh.SetVertices(m_Positions);
            mesh.SetColors(m_Colors);
            mesh.SetUVs(0, m_Uv0S);
            mesh.SetUVs(1, m_Uv1S);
            mesh.SetNormals(m_Normals);
            mesh.SetTangents(m_Tangents);
            mesh.SetTriangles(m_Indices, 0);
            mesh.RecalculateBounds();
        }
开发者ID:gdzzzyyy,项目名称:UGUIlok,代码行数:16,代码来源:VertexHelper.cs

示例3: OnPopulateMesh

        protected override void OnPopulateMesh(Mesh toFill)
        {
            // requires sets of quads
            if (Points == null || Points.Length < 2)
                Points = new[] { new Vector2(0, 0), new Vector2(1, 1) };
            var capSize = 24;
            var sizeX = rectTransform.rect.width;
            var sizeY = rectTransform.rect.height;
            var offsetX = -rectTransform.pivot.x * rectTransform.rect.width;
            var offsetY = -rectTransform.pivot.y * rectTransform.rect.height;

            // don't want to scale based on the size of the rect, so this is switchable now
            if (!relativeSize)
            {
                sizeX = 1;
                sizeY = 1;
            }
            // build a new set of points taking into account the cap sizes.
            // would be cool to support corners too, but that might be a bit tough :)
            var pointList = new List<Vector2>();
            pointList.Add(Points[0]);
            var capPoint = Points[0] + (Points[1] - Points[0]).normalized * capSize;
            pointList.Add(capPoint);

            // should bail before the last point to add another cap point
            for (int i = 1; i < Points.Length - 1; i++)
            {
                pointList.Add(Points[i]);
            }
            capPoint = Points[Points.Length - 1] - (Points[Points.Length - 1] - Points[Points.Length - 2]).normalized * capSize;
            pointList.Add(capPoint);
            pointList.Add(Points[Points.Length - 1]);

            var TempPoints = pointList.ToArray();
            if (UseMargins)
            {
                sizeX -= Margin.x;
                sizeY -= Margin.y;
                offsetX += Margin.x / 2f;
                offsetY += Margin.y / 2f;
            }

            toFill.Clear();
            var vbo = new VertexHelper(toFill);

            Vector2 prevV1 = Vector2.zero;
            Vector2 prevV2 = Vector2.zero;

            for (int i = 1; i < TempPoints.Length; i++)
            {
                var prev = TempPoints[i - 1];
                var cur = TempPoints[i];
                prev = new Vector2(prev.x * sizeX + offsetX, prev.y * sizeY + offsetY);
                cur = new Vector2(cur.x * sizeX + offsetX, cur.y * sizeY + offsetY);

                float angle = Mathf.Atan2(cur.y - prev.y, cur.x - prev.x) * 180f / Mathf.PI;

                var v1 = prev + new Vector2(0, -LineThickness / 2);
                var v2 = prev + new Vector2(0, +LineThickness / 2);
                var v3 = cur + new Vector2(0, +LineThickness / 2);
                var v4 = cur + new Vector2(0, -LineThickness / 2);

                v1 = RotatePointAroundPivot(v1, prev, new Vector3(0, 0, angle));
                v2 = RotatePointAroundPivot(v2, prev, new Vector3(0, 0, angle));
                v3 = RotatePointAroundPivot(v3, cur, new Vector3(0, 0, angle));
                v4 = RotatePointAroundPivot(v4, cur, new Vector3(0, 0, angle));

                Vector2 uvTopLeft = Vector2.zero;
                Vector2 uvBottomLeft = new Vector2(0, 1);

                Vector2 uvTopCenter = new Vector2(0.5f, 0);
                Vector2 uvBottomCenter = new Vector2(0.5f, 1);

                Vector2 uvTopRight = new Vector2(1, 0);
                Vector2 uvBottomRight = new Vector2(1, 1);

                Vector2[] uvs = new[] { uvTopCenter, uvBottomCenter, uvBottomCenter, uvTopCenter };

                if (i > 1)
                    vbo.AddUIVertexQuad(SetVbo(new[] { prevV1, prevV2, v1, v2 }, uvs));

                if (i == 1)
                    uvs = new[] { uvTopLeft, uvBottomLeft, uvBottomCenter, uvTopCenter };
                else if (i == TempPoints.Length - 1)
                    uvs = new[] { uvTopCenter, uvBottomCenter, uvBottomRight, uvTopRight };

                vbo.AddUIVertexQuad(SetVbo(new[] { v1, v2, v3, v4 }, uvs));

                prevV1 = v3;
                prevV2 = v4;
            }

            if (vbo.currentVertCount > 3)
            {
                vbo.FillMesh(toFill);
            }
        }
开发者ID:timowang1991,项目名称:SIC2015-Fish-Unity,代码行数:97,代码来源:UILineTextureRenderer.cs

示例4: OnMouseUp

 protected override void OnMouseUp(MouseEventArgs e)
 {
     bool shiftPressed = ((Control.ModifierKeys & Keys.Shift) != Keys.None);
     bool controlPressed = ((Control.ModifierKeys & Keys.Control) != Keys.None);
     if (!ShowColors && ( shiftPressed|| controlPressed))
         return;
     if (ShowColors && !shiftPressed)
         lastShift = -1;
     if (ShowColors && !controlPressed)
         lastControl = -1;
     float linkLength = scaleSize ;
     int x = e.X - Margin.Left - additionalXMargin;
     int y = e.Y - Margin.Top - additionalYMargin;
     float realX = x/linkLength;
     float realY = y/linkLength;
     int closestEdge = -1;
     int closestCell = -1;
     float distance = 1;
     for (int i = 0; i < mesh.Edges.Count; i++)
     {
         Edge edge = mesh.Edges[i];
         float sx, sy, ex, ey;
         mesh.GetEdgeExtent(edge, out sx, out sy, out ex, out ey);
         float curDist = DistanceToSegment(realX, realY, sx, sy, ex, ey);
         if (curDist <= distance)
         {
             closestEdge = i;
             distance = curDist;
         }
     }
     if (showCellColors)
     {
         for (int i = 0; i < mesh.Cells.Count; i++)
         {
             float cx = 0.0F;
             float cy = 0.0F;
             foreach (int inters in mesh.Cells[i].Intersections)
             {
                 cx += mesh.Intersections[inters].X;
                 cy += mesh.Intersections[inters].Y;
             }
             cx /= mesh.Cells[i].Intersections.Count;
             cy /= mesh.Cells[i].Intersections.Count;
             float distx = cx - realX;
             float disty = cy - realY;
             float curDist = (float)Math.Sqrt(distx * distx + disty * disty);
             if (curDist <= distance)
             {
                 closestEdge = -1;
                 closestCell = i;
                 distance = curDist;
             }
         }
     }
     if (closestEdge != -1)
     {
         if (noToggle && mesh.Edges[closestEdge].State != EdgeState.Empty)
             return;
         if (shiftPressed || controlPressed)
         {
             if (shiftPressed)
             {
                 if (lastShift == -1)
                     lastShift = closestEdge;
                 else
                 {
                     ColorJoinAction colorAction = new ColorJoinAction(mesh, lastShift, closestEdge, true);
                     if (lastShift != closestEdge)
                         undoTree.Do(colorAction);
                     lastShift = -1;
                 }
             }
             else if (controlPressed)
             {
                 if (lastControl == -1)
                     lastControl = closestEdge;
                 else
                 {
                     ColorJoinAction colorAction = new ColorJoinAction(mesh, lastControl, closestEdge, false);
                     if (lastControl != closestEdge)
                         undoTree.Do(colorAction);
                     lastControl = -1;
                 }
             }
             this.Refresh();
             return;
         }
         LoopClickAction action = new LoopClickAction(mesh, closestEdge, e.Button, autoMove, disallowFalseMove, useICInAuto, considerMultipleLoopsInAuto, useColoringInAuto, useCellColoringInAuto, useEdgeRestrictsInAuto, useCellPairsInAuto);
         if (!undoTree.Do(action))
         {
             redEdge = closestEdge;
             Thread thread = new Thread(new ThreadStart(ClearRed));
             thread.IsBackground = true;
             thread.Start();
         }
         else if (noToggle)
         {
             if (MovePerformed != null)
                 MovePerformed(this, new MoveEventArgs(closestEdge, e.Button == MouseButtons.Left));
         }
//.........这里部分代码省略.........
开发者ID:Tilps,项目名称:LoopDeLoop,代码行数:101,代码来源:LoopDisplay.cs

示例5: PerformAction

 private void PerformAction(bool? right, int closestEdge, int closestCell)
 {
     if (closestEdge != -1)
     {
         if (markedEdges.Contains(closestEdge))
             return;
         if (noToggle && Mesh.Edges[closestEdge].State != EdgeState.Empty)
             return;
         /*if (shiftPressed || controlPressed)
         {
             if (shiftPressed)
             {
                 if (lastShift == -1)
                     lastShift = closestEdge;
                 else
                 {
                     ColorJoinAction colorAction = new ColorJoinAction(Mesh, lastShift, closestEdge, true);
                     if (lastShift != closestEdge)
                         undoTree.Do(colorAction);
                     lastShift = -1;
                 }
             }
             else if (controlPressed)
             {
                 if (lastControl == -1)
                     lastControl = closestEdge;
                 else
                 {
                     ColorJoinAction colorAction = new ColorJoinAction(Mesh, lastControl, closestEdge, false);
                     if (lastControl != closestEdge)
                         undoTree.Do(colorAction);
                     lastControl = -1;
                 }
             }
             UpdateChildControls();
             return;
         }*/
         LoopClickAction action;
         if (right.HasValue)
         {
             action = new LoopClickAction(Mesh, closestEdge, right.Value, autoMove, disallowFalseMove, useICInAuto, considerMultipleLoopsInAuto, useColoringInAuto, useCellColoringInAuto);
         }
         else
         {
             if (Mesh.Edges[closestEdge].State == lastState)
                 return;
             bool pretendRight = false;
             switch (lastState)
             {
                 case EdgeState.Filled:
                     if (Mesh.Edges[closestEdge].State == EdgeState.Excluded)
                         pretendRight = true;
                     break;
                 case EdgeState.Excluded:
                     if (Mesh.Edges[closestEdge].State == EdgeState.Empty)
                         pretendRight = true;
                     break;
                 case EdgeState.Empty:
                     if (Mesh.Edges[closestEdge].State == EdgeState.Filled)
                         pretendRight = true;
                     break;
             }
             action = new LoopClickAction(Mesh, closestEdge, pretendRight, autoMove, disallowFalseMove, useICInAuto, considerMultipleLoopsInAuto, useColoringInAuto, useCellColoringInAuto);
         }
         if (!undoTree.Do(action))
         {
             /*
             redEdge = closestEdge;
             Thread thread = new Thread(new ThreadStart(ClearRed));
             thread.IsBackground = true;
             thread.Start();
              */
         }
         else if (noToggle)
         {
             /*
             if (MovePerformed != null)
                 MovePerformed(this, new MoveEventArgs(closestEdge, e.Button == MouseButtons.Left));
              * */
         }
         else
         {
             if (right.HasValue)
             {
                 lastState = Mesh.Edges[closestEdge].State;
             }
             bool satisified = true;
             for (int i = 0; i < Mesh.Cells.Count; i++)
             {
                 if (Mesh.Cells[i].TargetCount >= 0 && Mesh.Cells[i].FilledCount != Mesh.Cells[i].TargetCount)
                     satisified = false;
             }
             if (satisified)
             {
                 Mesh copy = new Mesh(Mesh);
                 try
                 {
                     copy.Clear();
                     bool failed = false;
                     if (copy.TrySolve() != SolveState.Solved)
//.........这里部分代码省略.........
开发者ID:Tilps,项目名称:LoopDeLoop,代码行数:101,代码来源:LoopDisplaySilverlight.cs

示例6: OnPopulateMesh

 protected override void OnPopulateMesh(Mesh m)
 {
     base.OnPopulateMesh (m);
     m.Clear();
 }
开发者ID:tettasun,项目名称:BookSample,代码行数:5,代码来源:UIGraphicCast.cs

示例7: SelfTest

        private void SelfTest(int height, int width, MeshType meshType, bool extensive)
        {
            Output(string.Format("SelfTesting {0}, {1}, {2}, {3}", height, width, meshType, extensive));
            List<string> codes = new List<string>{"S", "SC", "SCO", "SCOM", "SC+OM", "SC+EOM", "SC+EOMP", "SC+EOMP+", "FC+EOMP+"};
            List<string> extraCodes = new List<string>{"SI", "SIC", "SIO", "SM", "SIM", "SOM", "SP", "SP+", "SC+EP", "SE", "SEP", "SC+E", "SCE", "SCP"};
            try
            {
                int solvedCount=0;
                for (int i = 0; i < (extensive ? 100 : 5); i++)
                {
                    Mesh m = new Mesh(width, height, meshType);
                    m.SetRatingCodeOptions("F");
                    m.GenerateBoringFraction = 0.5/height;
                    m.GenerateLengthFraction = 0.7;
                    m.Generate();
                    bool solved = false;
                    int lastDepth = int.MaxValue;
                    foreach (string code_in in codes)
                    {
                        bool solvedByCode = false;
                        for (int j = 0; j < (extensive ? height * height : 1); j++ )
                        {
                            string code = code_in;
                            if (extensive)
                                code += (j-1).ToString();
                            m.Clear();
                            m.SetRatingCodeOptions(code);
                            SolveState result = m.TrySolve();
                            if (result == SolveState.Solved)
                            {
                                solvedByCode = true;
                                if (!solved)
                                    solved = true;
                                if (extensive)
                                {
                                    if (j < lastDepth)
                                        lastDepth = j;
                                }
                            }
                            else
                            {
                                if (solved)
                                {
                                    if (!extensive || j > lastDepth || j == height*height-1)
                                    {
                                        Output(string.Format("Code {0} failed to solve puzzle solved with less powerful solvers.", code));
                                        using (TextWriter writer = File.CreateText("SelfTestOuput" + failCount + "-" + code + ".loop"))
                                        {
                                            m.Save(writer);
                                        }
                                    }
                                    failCount++;
                                }
                            }
                        }
                        if (solvedByCode)
                            solvedCount++;
                    }

                    m.FullClear();
                    m.SetRatingCodeOptions("S");
                    m.Generate();
                    foreach (string code in codes.Concat(extraCodes))
                    {
                        m.Clear();
                        m.SetRatingCodeOptions(code);
                        SolveState result = m.TrySolve();
                        if (result != SolveState.Solved)
                        {
                            Output(string.Format("Code {0} failed to solve puzzle generated with less powerful generator.", code));
                            using (TextWriter writer = File.CreateText("SelfTestOuput" + failCount + "-" + code + ".loop"))
                            {
                                m.Save(writer);
                            }
                            failCount++;
                        }
                    }
                }
                Output(string.Format("{0} codes solved {1} full generator puzzles {2} times.", codes.Count, extensive ? 100 : 5, solvedCount));
            }
            catch (Exception ex)
            {
                if (!(ex is ThreadAbortException))
                {
                    Output(string.Format("Failure {0}", ex));
                }
            }
        }
开发者ID:Tilps,项目名称:LoopDeLoop,代码行数:88,代码来源:HelpForm.cs


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