コード例 #1
0
ファイル: ShineEffect.cs プロジェクト: Badeye/impulse
 public void Triangulate(VertexHelper vh)
 {
     int triangleCount = vh.currentVertCount - 2;
     Debug.Log(triangleCount);
     for (int i = 0; i <= triangleCount / 2 + 1; i += 2)
     {
         vh.AddTriangle(i, i + 1, i + 2);
         vh.AddTriangle(i + 2, i + 3, i + 1);
     }
 }
コード例 #2
0
 private void AddTriangle(VertexHelper vh)
 {
     for (int i = 1; i < _pointCount - 1; i++)
     {
         vh.AddTriangle(0, i + 1, i);
     }
 }
コード例 #3
0
ファイル: Polygon.cs プロジェクト: selik0/Unity_Polygon
    protected override void OnPopulateMesh(VertexHelper vh)
    {
        base.OnPopulateMesh(vh);
        //清除所有顶点缓存
        vh.Clear();
        //初始化
        Init();
        int verts = GetVerts();

        for (int i = 0; i < verts + 1; i++)
        {
            vh.AddVert(vertexsPosArr[i], Color.white, Vector2.zero);
        }
        // 方法1: n边形画n个三角形
        //int y = 0;
        //for (int i = 0; i < verts; i++)
        //{
        //    y = i + 1;
        //    if (y >= verts)
        //    {
        //        y = 0;
        //    }
        //    vh.AddTriangle(i, y, verts);
        //    Debug.Log("---" + i + " " + y + " " + (verts));
        //}
        //方法2 画n-2个三角形
        for (int i = 0; i < verts - 2; i++)
        {
            vh.AddTriangle(0, i + 1, i + 2);
        }
    }
コード例 #4
0
        void addVert(VertexHelper vh, UIVertex v1, UIVertex v2, UIVertex v3)
        {
            int index = vh.currentVertCount;

            vh.AddVert(v1); vh.AddVert(v2);
            vh.AddVert(v3); vh.AddTriangle(index, index + 1, index + 2);
        }
コード例 #5
0
    public void DrawRoundEdge(VertexHelper vh, Vector2 p0, Vector2 p1, Color color, float width = -1)
    {
        if (width < 0)
        {
            width = m_width;
        }

        Vector2 widthVector = Vector3.Cross(p0 - p1, new Vector3(0, 0, 1));

        widthVector.Normalize();
        widthVector = widthVector * width / 2f;
        Vector2 lineVector = (p0 - p1).normalized * width / 2f;

        int   count     = roundEdgePolygonCount;
        int   current   = vh.currentVertCount;
        float angleUnit = Mathf.PI / (count - 1);

        vh.AddVert(p0, color, Vector2.one * 0.5f);
        vh.AddVert(p0 + widthVector, color, Vector2.zero);

        for (int n = 0; n < count; n++)
        {
            vh.AddVert(p0 + Mathf.Cos(angleUnit * n) * widthVector + Mathf.Sin(angleUnit * n) * lineVector, color, Vector2.zero);
            vh.AddTriangle(current, current + 2 + n, current + 1 + n);
        }
    }
コード例 #6
0
    public int statusValMax;               //ステータス値の最大値

    /// <summary>
    /// 描画
    /// </summary>
    /// <param name="vh">Vh.</param>
    protected override void OnPopulateMesh(VertexHelper vh)
    {
        vh.Clear();                  // 描画のクリア
        var v = UIVertex.simpleVert; // 各頂点の情報

        v.color = color;             // 色

        // 中心座標の登録
        Vector2 center = CreatePos(0.5f, 0.5f);

        v.position = center;
        vh.AddVert(v);

        //各頂点座標
        Vector2 p;

        for (int i = 1; i <= statusListCount; i++)
        {
            float rad = (90f - (360f / (float)statusListCount) * (i - 1)) * Mathf.Deg2Rad;
            float x   = 0.5f + Mathf.Cos(rad) * GetVolume(i - 1) * radius;
            float y   = 0.5f + Mathf.Sin(rad) * GetVolume(i - 1) * radius;

            p          = CreatePos(x, y);
            v.position = p;
            vh.AddVert(v);
            vh.AddTriangle(
                0,
                i,
                i == statusListCount ? 1 : i + 1
                );
        }
    }
コード例 #7
0
        public static void AddRect(
            Bounds b,
            VertexHelper vh,
            Color vertexColor = default(Color),
            Vector2 uv        = default(Vector2))
        {
            uv = new Vector2(0.5f, 0.5f);
            int vertIdx = vh.currentVertCount;

            vh.AddVert(b.BottomLeft(), vertexColor, uv);
            vh.AddVert(b.TopLeft(), vertexColor, uv);
            vh.AddVert(b.BottomRight(), vertexColor, uv);
            vh.AddVert(b.TopRight(), vertexColor, uv);
            vh.AddTriangle(vertIdx, vertIdx + 1, vertIdx + 2);
            vh.AddTriangle(vertIdx + 2, vertIdx + 1, vertIdx + 3);
        }
コード例 #8
0
        private void ExportVerticesToUGUI(VertexHelper vh)
        {
            vh.Clear();
            var ioffset = 0;

            for (int i = 0; i < mOriginalVertices.Size; ++i)
            {
                vh.AddVert(mOriginalVertices.Buffer[i].position, mOriginalVertices.Buffer[i].color, mOriginalVertices.Buffer[i].uv, mOriginalVertices.Buffer[i].uv1, mOriginalVertices.Buffer[i].normal, mOriginalVertices.Buffer[i].tangent);
            }

            for (int i = 0; i < mOriginalVertices.Size; i += 4)
            {
                vh.AddTriangle(ioffset + i, ioffset + i + 1, ioffset + i + 2);
                vh.AddTriangle(ioffset + i + 2, ioffset + i + 3, ioffset + i);
            }
        }
コード例 #9
0
        protected override void OnPopulateMesh(VertexHelper vh)
        {
            var center = new UIVertex {
                color    = color,
                position = Vector2.zero,
                uv0      = Vector2.zero,
            };
            var radius = rectTransform.sizeDelta;

            vh.Clear();
            vh.AddVert(center);
            for (ushort currentVert = 1; currentVert <= totalVertices; currentVert++)
            {
                var vert    = new UIVertex();
                var percent = (float)currentVert / totalVertices;
                var angle   = percent * UIUtility.TwoPi;
                var x       = Mathf.Cos(angle) * radius.x;
                var y       = Mathf.Sin(angle) * radius.y;
                vert.position = new Vector3(x, y);
                vert.color    = color;
                vh.AddVert(vert);
                int next;
                if (currentVert != totalVertices)
                {
                    next = currentVert + 1;
                }
                else
                {
                    next = 1;
                }

                vh.AddTriangle(currentVert, next, 0);
            }
        }
コード例 #10
0
ファイル: GadgetUtil.cs プロジェクト: waterminer/StagerStudio
 // Fill
 public static void FillDisc(VertexHelper toFill, float startAngle, float endAngle, int step, float radius, Vector2 pivot)
 {
     if (startAngle > endAngle)
     {
         float temp = startAngle;
         startAngle = endAngle;
         endAngle   = temp;
     }
     VertexCache[0].position = pivot;
     VertexCache[1].position = GetPos(startAngle);
     for (int i = 0; i < step; i++)
     {
         float angleR = Mathf.Lerp(startAngle, endAngle, (float)(i + 1) / step);
         VertexCache[2].position = GetPos(angleR);
         // Fill
         int vCount = toFill.currentVertCount;
         toFill.AddVert(VertexCache[0]);
         toFill.AddVert(VertexCache[1]);
         toFill.AddVert(VertexCache[2]);
         toFill.AddTriangle(vCount, vCount + 1, vCount + 2);
         // Final
         VertexCache[1].position = VertexCache[2].position;
     }
     // Func
     Vector3 GetPos(float angle) => new Vector3(
         Mathf.Sin(angle * Mathf.Deg2Rad) * radius + pivot.x,
         Mathf.Cos(angle * Mathf.Deg2Rad) * radius + pivot.y,
         0f
         );
 }
コード例 #11
0
        /// <summary>
        /// 画出一个面片
        /// </summary>
        /// <param name="vertexHelper"></param>
        /// <param name="posMin"></param>
        /// <param name="posMax"></param>
        /// <param name="color"></param>
        /// <param name="uvMin"></param>
        /// <param name="uvMax"></param>
        private void AddQuad(
            VertexHelper vertexHelper,
            Vector2 posMin,
            Vector2 posMax,
            Color32 color,
            Vector2 uvMin,
            Vector2 uvMax)
        {
            int i0 = AddVert(vertexHelper, new Vector3(posMin.x, posMin.y, 0.0f), color, new Vector2(uvMin.x, uvMin.y));
            int i1 = AddVert(vertexHelper, new Vector3(posMin.x, posMax.y, 0.0f), color, new Vector2(uvMin.x, uvMax.y));
            int i2 = AddVert(vertexHelper, new Vector3(posMax.x, posMax.y, 0.0f), color, new Vector2(uvMax.x, uvMax.y));
            int i3 = AddVert(vertexHelper, new Vector3(posMax.x, posMin.y, 0.0f), color, new Vector2(uvMax.x, uvMin.y));

            vertexHelper.AddTriangle(i0, i1, i2);
            vertexHelper.AddTriangle(i2, i3, i0);
        }
コード例 #12
0
    protected override void OnPopulateMesh(VertexHelper vh)
    {
        Init();
        vh.Clear(); // これが無いと正常に描画されない。

        // 頂点の順番
        for (int i = 0; i < triangleList.Count / 3; i++)
        {
            int t0 = triangleList[i * 3 + 0];
            int t1 = triangleList[i * 3 + 1];
            int t2 = triangleList[i * 3 + 2];
            vh.AddTriangle(t0, t1, t2);
        }

        // UIVertex:各頂点の情報
        for (int i = 0; i < pointList.Count; i++)
        {
            var v = new UIVertex();
            v.position = pointList[i];
            v.uv0      = uvList[i];
            v.normal   = normalList[i];
            v.color    = colorList[i] * this.color;

            vh.AddVert(v);
        }
    }
コード例 #13
0
    protected override void OnPopulateMesh(VertexHelper vh)
    {
        Vector2[] points = null;
        Mesh      mesh   = new Mesh();

        var rect = rectTransform.rect;

        Collider2dPointsGetter.GetCircleCoordinates(rect.center, CalcRadius(), ref points, Proximity);
        //Collider2dPointsGetter.GetCircleCoordinates(rectTransform.anchoredPosition, 1f, ref points, Proximity);

        float ppu = (Camera.main.orthographicSize * 2) / Screen.height * 300;

        PolygonTriangulator.TriangulateAsLine(points, mesh, ppu, true);

        vh.Clear();

        for (int i = 0; i < mesh.vertices.Length; i++)
        {
            vh.AddVert(mesh.vertices[i], new Color32(1, 1, 1, 1), new Vector2(0.5f, 0.5f));
        }

        for (int i = 0; i < mesh.triangles.Length; i += 3)
        {
            vh.AddTriangle(mesh.triangles[i], mesh.triangles[i + 1], mesh.triangles[i + 2]);
        }
    }
コード例 #14
0
    protected override void OnPopulateMesh(VertexHelper vh)
    {
        // 頂点の順番
        vh.AddTriangle(0, 1, 2);

        // UIVertex:各頂点の情報
        var v0 = new UIVertex();

        v0.position = new Vector3(-100f, -100f);
        // 修正箇所 : 色情報追加
        v0.color = new Color32(255, 0, 255, 255);
        var v1 = new UIVertex();

        v1.position = new Vector3(0, 100f);
        // 修正箇所 : 色情報追加
        v1.color = new Color32(255, 255, 255, 255);
        var v2 = new UIVertex();

        v2.position = new Vector3(100f, -100f);
        // 修正箇所 : 色情報追加
        v2.color = new Color32(255, 255, 0, 255);

        // 頂点情報を渡す
        vh.AddVert(v0);
        vh.AddVert(v1);
        vh.AddVert(v2);
    }
コード例 #15
0
    /// <summary>
    /// Defines where the rectangle is drawn when calling UpdateGeometry().
    /// </summary>
    protected override void OnPopulateMesh(VertexHelper vh)
    {
        vh.Clear();

        UIVertex vert = UIVertex.simpleVert;

        for (int i = 0; i < 4; i++)
        {
            vert.position = pos[i];
            vert.color    = color;
            vh.AddVert(vert);
        }

        vh.AddTriangle(0, 1, 2);
        vh.AddTriangle(2, 3, 0);
    }
コード例 #16
0
    protected override void OnPopulateMesh(VertexHelper vh)
    {
        if (this.mesh == null)
        {
            return;
        }

        var color32 = this.color;

        vh.Clear();

        var vs = this.mesh.vertices;

        for (int i = 0; i < vs.Length; ++i)
        {
            var v = vs[i];
            vh.AddVert(new Vector3(v.x, v.y), color32, Vector2.zero);
        }

        var ts = this.mesh.triangles;

        for (int i = 0; i < ts.Length; i += 3)
        {
            var t1 = ts[i];
            var t2 = ts[i + 1];
            var t3 = ts[i + 2];

            vh.AddTriangle(t1, t2, t3);
        }
    }
    protected override void OnPopulateMesh(VertexHelper vh)
    {
        vh.Clear();
        if (_sprite == null)
        {
            return;
        }
        var spriteRect = _sprite.rect;
        var sizeDelta  = rectTransform.sizeDelta;
        var scale      = new Vector2(
            _sprite.pixelsPerUnit * sizeDelta.x / spriteRect.width,
            _sprite.pixelsPerUnit * sizeDelta.y / spriteRect.height);
        var offset = new Vector2(
            sizeDelta.x * (0.5f - rectTransform.pivot.x),
            sizeDelta.y * (0.5f - rectTransform.pivot.y));

        for (int i = 0; i < _sprite.vertices.Length; i++)
        {
            var v = new Vector2(
                _sprite.vertices[i].x * scale.x,
                _sprite.vertices[i].y * scale.y);
            v += offset;
            vh.AddVert(v, this.color, _sprite.uv[i]);
        }

        for (int i = 0; i < _sprite.triangles.Length; i += 3)
        {
            vh.AddTriangle(_sprite.triangles[i + 0], _sprite.triangles[i + 1], _sprite.triangles[i + 2]);
        }
    }
コード例 #18
0
        private void GenerateV18T6(VertexHelper vh, Vector2 apex, Vector2 side)
        {
            float flipVer = -.866f * _mScaleReference.width;


            // VERTICES

            UIVertex vert = UIVertex.simpleVert;

            vert.color = color;

            Vector2 v0 = new Vector2(apex.x, apex.y),
                    v1 = new Vector2(side.x, side.y),
                    v2 = new Vector2(side.x, side.y - _mScaleReference.height / 2),
                    v3 = new Vector2(apex.x, apex.y - _mScaleReference.height),
                    v4 = new Vector2(side.x + flipVer, side.y - _mScaleReference.height / 2),
                    v5 = new Vector2(side.x + flipVer, side.y),
                    o  = new Vector2(apex.x, apex.y - _mScaleReference.height / 2);

            AddVertexOfPositions(vh, vert, 0, o, v0, v1);
            AddVertexOfPositions(vh, vert, 1, o, v1, v2);
            AddVertexOfPositions(vh, vert, 2, o, v2, v3);
            AddVertexOfPositions(vh, vert, 3, o, v3, v4);
            AddVertexOfPositions(vh, vert, 4, o, v4, v5);
            AddVertexOfPositions(vh, vert, 5, o, v5, v0);


            // TRIANGLES

            for (var i = 0; i < 6; i++)
            {
                vh.AddTriangle(3 * i, 3 * i + 1, 3 * i + 2);
            }
        }
コード例 #19
0
        public static void DrawTriangle(VertexHelper vh, Vector3 p1,
                                        Vector3 p2, Vector3 p3, Color32 color)
        {
            UIVertex v1 = new UIVertex();

            v1.position = p1;
            v1.color    = color;
            v1.uv0      = Vector3.zero;
            UIVertex v2 = new UIVertex();

            v2.position = p2;
            v2.color    = color;
            v2.uv0      = Vector3.zero;
            UIVertex v3 = new UIVertex();

            v3.position = p3;
            v3.color    = color;
            v3.uv0      = Vector3.zero;
            int startIndex = vh.currentVertCount;

            vh.AddVert(v1);
            vh.AddVert(v2);
            vh.AddVert(v3);
            vh.AddTriangle(startIndex, startIndex + 1, startIndex + 2);
        }
コード例 #20
0
        protected virtual void AddDot(VertexHelper vh, Vector3 pt, float radius, Color32 color)
        {
            if (radius <= 0)
            {
                return;
            }
            vh.AddVert(new Vector3(pt.x, pt.y - radius, -pt.z), color, Vector2.zero);
            vh.AddVert(new Vector3(pt.x - radius, pt.y, -pt.z), color, Vector2.zero);
            vh.AddVert(new Vector3(pt.x, pt.y + radius, -pt.z), color, Vector2.zero);
            vh.AddVert(new Vector3(pt.x + radius, pt.y, -pt.z), color, Vector2.zero);

            var vertId = vh.currentVertCount - 1;

            vh.AddTriangle(vertId - 3, vertId - 2, vertId - 1);
            vh.AddTriangle(vertId - 1, vertId, vertId - 3);
        }
コード例 #21
0
    protected override void OnPopulateMesh(VertexHelper vh)
    {
        vh.Clear();
        List <Vector3> normalVectors = new List <Vector3>();

        normalMesh.GetVertices(normalVectors);
        List <Vector2> normalUVs = new List <Vector2>();

        normalMesh.GetUVs(0, normalUVs);

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

        changedMesh.GetVertices(changedVectors);

        Vector3 position = Vector3.zero;
        double  x, y;

        for (int i = 0; i < normalVectors.Count; i++)
        {
            x        = normalVectors[i].x * (1.0 - changeRate) + changedVectors[i].x * changeRate;
            y        = normalVectors[i].z * (1.0 - changeRate) + changedVectors[i].z * changeRate;
            position = new Vector3((float)x, (float)y, 0);
            vh.AddVert(position * scaleSize, color, normalUVs[i]);
        }

        for (int i = 2; i < normalMesh.triangles.Length; i += 3)
        {
            vh.AddTriangle(normalMesh.triangles[i - 2], normalMesh.triangles[i - 1], normalMesh.triangles[i]);
        }
    }
コード例 #22
0
        protected override void OnPopulateMesh(VertexHelper vh)
        {
            vh.Clear();
            var v = UIVertex.simpleVert;

            v.color = color;

            Vector2 center = CreatePos(0.5f, 0.5f);

            v.position = center;
            vh.AddVert(v);

            //各頂点座標
            for (int i = 1; i <= VerticesCount; i++)
            {
                float rad = (90f - (360f / (float)VerticesCount) * (i - 1)) * Mathf.Deg2Rad;
                float x   = 0.5f + Mathf.Cos(rad) * RADIUS * GetVolume(i - 1);
                float y   = 0.5f + Mathf.Sin(rad) * RADIUS * GetVolume(i - 1);

                Vector2 p = CreatePos(x, y);
                v.position = p;
                vh.AddVert(v);

                vh.AddTriangle(
                    0,
                    i,
                    i == VerticesCount ? 1 : i + 1
                    );
            }
        }
コード例 #23
0
ファイル: AdvImage.cs プロジェクト: Lucas1805/Teek_AR
        /// <summary>
        /// Generate vertices for a simple Image.
        /// </summary>
        void GenerateSimpleSprite(VertexHelper vh, bool lPreserveAspect)
        {
            Vector4 v  = GetDrawingDimensions(lPreserveAspect);
            var     uv = (overrideSprite != null) ? Sprites.DataUtility.GetOuterUV(overrideSprite) : Vector4.zero;

            var color32 = color;

            vh.Clear();
            vh.AddVert(new Vector3(v.x, v.y), color32, new Vector2(uv.x, uv.y));
            vh.AddVert(new Vector3(v.x, v.w), color32, new Vector2(uv.x, uv.w));
            vh.AddVert(new Vector3(v.z, v.w), color32, new Vector2(uv.z, uv.w));
            vh.AddVert(new Vector3(v.z, v.y), color32, new Vector2(uv.z, uv.y));

            vh.AddTriangle(0, 1, 2);
            vh.AddTriangle(2, 3, 0);
        }
コード例 #24
0
 /// <summary>
 /// 为VertexHelper添加三角面信息
 /// </summary>
 /// <param name="vertexHelper"></param>
 private void AddTriangle(VertexHelper vertexHelper)
 {
     for (int i = 1; i < circleVertexCount - 1; i++)
     {
         vertexHelper.AddTriangle(i, 0, i + 1);
     }
 }
コード例 #25
0
        protected override void OnPopulateMesh(VertexHelper vh)
        {
            vh.Clear();

            if (PathList == null)
            {
                return;
            }

            int offset = 0;

            foreach (var path in PathList)
            {
                var points = path.Points.Select(p => p + path.Offset).ToArray();
                foreach (var p in points)
                {
                    vh.AddVert(p, path.Color, Vector2.zero);
                }
                var triangles = new Triangulator(points).Triangulate();
                for (int i = 0; i < triangles.Length; i += 3)
                {
                    vh.AddTriangle(offset + triangles[i], offset + triangles[i + 1], offset + triangles[i + 2]);
                }
                offset += path.Points.Length;
            }
        }
コード例 #26
0
ファイル: RadarChart.cs プロジェクト: linda012518/Unity-Chart
        protected override void OnPopulateMesh(VertexHelper toFill)
        {
            Color32 color32 = color;

            // 创建多边形网格
            Mesh mesh = Create(values, offsetAngle);

            toFill.Clear();
            // 顶点和uv
            for (int i = 0; i < mesh.vertices.Length; i++)
            {
                toFill.AddVert(mesh.vertices[i], color32, mesh.uv[i]);
            }
            // 三角
            for (int i = 0; i < mesh.triangles.Length / 3; i++)
            {
                toFill.AddTriangle(mesh.triangles[3 * i], mesh.triangles[3 * i + 1], mesh.triangles[3 * i + 2]);
            }


            // 记录当前多边形的值
            m_nowValues = new float[values.Length];
            Array.Copy(values, m_nowValues, values.Length);
            m_nowOffsetAngle = offsetAngle;
        }
コード例 #27
0
        protected override void OnPopulateMesh(VertexHelper vh)
        {
            vh.Clear();
            if (lastPolyShape == null)
            {
                return;
            }
            if (needGenerateMesh)
            {
                contex.Clear();
                contex.polyShape         = lastPolyShape;
                contex.mesh.defaultColor = this.color;
                nodeSet.Do(contex);
                needGenerateMesh = false;
            }

            var mesh = contex.mesh;

            for (int i = 0; i < contex.mesh.vertexes.Count; i++)
            {
                vh.AddVert(mesh.vertexes[i], mesh.GetColor(i), mesh.GetUV(i));
            }
            for (int i = 0; i < mesh.triangles.Count; i += 3)
            {
                vh.AddTriangle(mesh.triangles[i], mesh.triangles[i + 1], mesh.triangles[i + 2]);
            }
        }
コード例 #28
0
        protected override void OnPopulateMesh(VertexHelper vh)
        {
            if (m_Sprite == null)
            {
                FillQuad(vh);
                return;
            }
            vh.Clear();
            Rect    rect = GetPixelAdjustedRect();
            Bounds  b    = m_Sprite.bounds;
            Vector2 mul;

            mul.x = 1 / b.size.x;
            mul.y = 1 / b.size.y;
            Vector2[] verts     = m_Sprite.vertices;
            Vector2[] uvs       = m_Sprite.uv;
            ushort[]  triangles = m_Sprite.triangles;
            Vector2   inuv      = Vector2.zero;

            for (int i = 0; i < verts.Length; i++)
            {
                UIVertex vert = new UIVertex();
                vert.uv0      = uvs[i];
                inuv.x        = (verts[i].x - b.min.x) * mul.x;
                inuv.y        = (verts[i].y - b.min.y) * mul.y;
                vert.position = Lerp(rect, inuv);
                vert.color    = color;
                vh.AddVert(vert);
            }
            for (int i = 0; i < triangles.Length; i += 3)
            {
                vh.AddTriangle(triangles[i], triangles[i + 1], triangles[i + 2]);
            }
        }
コード例 #29
0
ファイル: LeanBox.cs プロジェクト: DrManhattan115/vr-mod
 private void WriteTriangleDisc(VertexHelper vh)
 {
     for (var i = 0; i < pointCount - 2; i++)
     {
         vh.AddTriangle(0, i + 1, i + 2);
     }
 }
コード例 #30
0
ファイル: GraphCanvas.cs プロジェクト: NickJ25/AnimateVR
    private void createLine(Vector3 start, Vector3 end, float thickness, Color32 color, VertexHelper vh)
    {
        // Obtain offset to get thickness
        Vector3 border = findOffset(start, end) * thickness;

        // Add vertices
        vh.AddVert(start + border, color, Vector2.zero);
        vh.AddVert(start - border, color, Vector2.zero);
        vh.AddVert(end + border, color, Vector2.zero);
        vh.AddVert(end - border, color, Vector2.zero);

        // Turn into a rectangular line
        vh.AddTriangle(lineIndex, lineIndex + 1, lineIndex + 2);
        vh.AddTriangle(lineIndex + 2, lineIndex + 3, lineIndex + 1);
        lineIndex += 4;
    }
コード例 #31
0
        protected virtual void OnPopulateMeshMainProcess(Translator translator,
                                                         RectTransform rectTrans,
                                                         Sprite sprite,
                                                         VertexHelper toFill)
        {
            if (!sprite || Type.Simple != this.type)
            {
                base.OnPopulateMesh(toFill);
                return;
            }

            var baseColor = this.color;

            toFill.Clear();

            if (null != this.runtimeData)
            {
                var vertices = this.runtimeData.Vertices;
                var uv       = this.runtimeData.UVs;
                for (int n = 0, cnt = vertices.Length; n < cnt; ++n)
                {
                    toFill.AddVert(translator.Translate(vertices[n]), baseColor, uv[n]);
                }

                var tris   = this.runtimeData.Triangles;
                var ti     = 0;
                var triLen = tris.Length;
                for (int n = 0; n < triLen; n += 3)
                {
                    toFill.AddTriangle((int)tris[ti++],
                                       ti < triLen ? (int)tris[ti++] : -1,
                                       ti < triLen ? (int)tris[ti++] : -1);
                }
            }
        }
コード例 #32
0
        protected override void OnPopulateMesh(VertexHelper vh)
        {
            vh.Clear();
            float wHalf = rectTransform.rect.width / 2;
            //float hHalf = rectTransform.rect.height / 2;
            a = Math.Min(1, Math.Max(0, a));
            b = Math.Min(1, Math.Max(0, b));
            c = Math.Min(1, Math.Max(0, c));
            d = Math.Min(1, Math.Max(0, d));

            Color32 color32 = color;
            vh.AddVert(new Vector3(-wHalf * a, 0), color32, new Vector2(0f, 0f));
            vh.AddVert(new Vector3(0, wHalf * b), color32, new Vector2(0f, 1f));
            vh.AddVert(new Vector3(wHalf * c, 0), color32, new Vector2(1f, 1f));
            vh.AddVert(new Vector3(0, -wHalf * d), color32, new Vector2(1f, 0f));

            vh.AddTriangle(0, 1, 2);
            vh.AddTriangle(2, 3, 0);
        }
コード例 #33
0
ファイル: ShineEffect.cs プロジェクト: Badeye/impulse
        protected override void OnPopulateMesh(VertexHelper vh)
        {
            var r = GetPixelAdjustedRect();
            var v = new Vector4(r.x, r.y, r.x + r.width, r.y + r.height);
            float dif = (v.w - v.y) * 2;
            Color32 color32 = color;
            vh.Clear();

            color32.a = (byte)0;
            vh.AddVert(new Vector3(v.x - 50, width * v.y + yoffset * dif), color32, new Vector2(0f, 0f));
            vh.AddVert(new Vector3(v.z + 50, width * v.y + yoffset * dif), color32, new Vector2(1f, 0f));

            color32.a = (byte)(color.a * 255);
            vh.AddVert(new Vector3(v.x - 50, width * (v.y / 4) + yoffset * dif), color32, new Vector2(0f, 1f));
            vh.AddVert(new Vector3(v.z + 50, width * (v.y / 4) + yoffset * dif), color32, new Vector2(1f, 1f));

            color32.a = (byte)(color.a * 255);
            vh.AddVert(new Vector3(v.x - 50, width * (v.w / 4) + yoffset * dif), color32, new Vector2(0f, 1f));
            vh.AddVert(new Vector3(v.z + 50, width * (v.w / 4) + yoffset * dif), color32, new Vector2(1f, 1f));
            color32.a = (byte)(color.a * 255);

            color32.a = (byte)0;
            vh.AddVert(new Vector3(v.x - 50, width * v.w + yoffset * dif), color32, new Vector2(0f, 1f));
            vh.AddVert(new Vector3(v.z + 50, width * v.w + yoffset * dif), color32, new Vector2(1f, 1f));

            vh.AddTriangle(0, 1, 2);
            vh.AddTriangle(2, 3, 1);

            vh.AddTriangle(2, 3, 4);
            vh.AddTriangle(4, 5, 3);

            vh.AddTriangle(4, 5, 6);
            vh.AddTriangle(6, 7, 5);
        }
コード例 #34
0
ファイル: UICornerCut.cs プロジェクト: GlitchBoss/TextWars
        private static void AddSquare(Vector2 a, Vector2 b, Vector2 c, Vector2 d, Rect rectUV, Color32 color32, VertexHelper vh) {
            int v0 = AddVert(a.x, a.y, rectUV, color32, vh);
            int v1 = AddVert(b.x, b.y, rectUV, color32, vh);
            int v2 = AddVert(c.x, c.y, rectUV, color32, vh);
            int v3 = AddVert(d.x, d.y, rectUV, color32, vh);
 
            vh.AddTriangle(v0, v1, v2);
            vh.AddTriangle(v2, v3, v0);
        }
コード例 #35
0
ファイル: UICornerCut.cs プロジェクト: GlitchBoss/TextWars
        private static void AddSquare(Rect rect, Rect rectUV, Color32 color32, VertexHelper vh) {
            int v0 = AddVert(rect.xMin, rect.yMin, rectUV, color32, vh);
            int v1 = AddVert(rect.xMin, rect.yMax, rectUV, color32, vh);
            int v2 = AddVert(rect.xMax, rect.yMax, rectUV, color32, vh);
            int v3 = AddVert(rect.xMax, rect.yMin, rectUV, color32, vh);
 
            vh.AddTriangle(v0, v1, v2);
            vh.AddTriangle(v2, v3, v0);
        }