コード例 #1
0
        /// <summary>
        /// スプライトの更新
        /// </summary>
        private void UpdateSprite()
        {
            if (!circle.Processing)
            {
                return;
            }
            if (!lerpSprite)
            {
                return;
            }

            //座標の調整
            float   centerAngle  = (circle.NowEnd - circle.NowStart) * 0.5f + circle.NowStart;
            float   radiusRange  = (circle.NowOuter - circle.NowInner);
            float   centerRadius = radiusRange * 0.5f + circle.NowInner;
            Vector3 pos          = GeomUtil.DegToVector2(centerAngle) * centerRadius;

            pos.z = transform.localPosition.z - 1f;

            //lerpSpriteは自身のローカルにいること?
            lerpSprite.transform.localPosition = pos;

            //大きさの調整
            if (adjustSpriteScale)
            {
                Vector2 size  = lerpSprite.Target.sprite.bounds.size;
                float   scale = radiusRange / size.magnitude;
                lerpSprite.transform.localScale = Vector2.one * (scale * adjustScale);
            }
        }
コード例 #2
0
ファイル: RadialSnap.cs プロジェクト: seiroise/GonPolyProject
        public override bool Snap(Vector2 input, out Vector2 output)
        {
            float angle = GeomUtil.TwoPointAngle(point, input);
            //最も近い放射角度を求める
            float nearAngle = 0f;
            float halfDelta = deltaAngle * 0.5f;

            for (int i = 0; i < angles.Length; ++i)
            {
                if ((angles[i] - halfDelta) < angle && angle < (angles[i] + halfDelta))
                {
                    nearAngle = angles[i];
                    break;
                }
            }
            //線上の射影からスナップ座標を求める
            Vector2 p, q;

            p = GeomUtil.DegToVector2(nearAngle);
            q = input - point;
            float dot        = GeomUtil.Dot(p, q);
            float projection = dot / p.magnitude;               //射影距離

            output = p.normalized * projection + point;

            //スナップ座標との距離を測る
            if ((output - input).magnitude <= snapForce)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
ファイル: RadialSnap.cs プロジェクト: seiroise/GonPolyProject
        public override EasyMesh GetEasyMesh(Color color)
        {
            Vector3[] vertices = new Vector3[count * 4];
            Color[]   colors   = new Color[vertices.Length];
            int[]     indices  = new int[count * 6];

            for (int i = 0; i < count; ++i)
            {
                Vector2 dir    = GeomUtil.DegToVector2(angles[i]);
                Vector2 verDir = GeomUtil.RotateVector2(dir, 90f);
                dir    *= drawDistance;
                verDir *= width * 0.5f;

                int index        = i * 4;
                int indicesIndex = i * 6;

                //頂点
                vertices[index + 0] = dir + verDir + point;
                vertices[index + 1] = dir - verDir + point;
                vertices[index + 2] = -dir - verDir + point;
                vertices[index + 3] = -dir + verDir + point;

                //色
                colors[index + 0] = color;
                colors[index + 1] = color;
                colors[index + 2] = color;
                colors[index + 3] = color;

                //インデックス
                indices[indicesIndex + 0] = index + 0;
                indices[indicesIndex + 1] = index + 1;
                indices[indicesIndex + 2] = index + 2;
                indices[indicesIndex + 3] = index + 0;
                indices[indicesIndex + 4] = index + 2;
                indices[indicesIndex + 5] = index + 3;
            }

            return(new EasyMesh(vertices, colors, indices));
        }
コード例 #4
0
        /// <summary>
        /// 簡易メッシュの作成
        /// </summary>
        private EasyMesh MakeEasyMesh()
        {
            EasyMesh eMesh = new EasyMesh();
            //角度
            float diffAngle = lerpEnd.Value - lerpStart.Value;
            float addAngle  = (diffAngle > 0 ? 1f : -1f) * density;
            float angle     = 0f;
            int   addNum    = (int)(diffAngle / addAngle);
            int   i         = 0;

            //下準備
            Vector3[] verts   = new Vector3[(addNum + 2) * 2];
            Color[]   colors  = new Color[verts.Length];
            int[]     indices = new int[(addNum + 1) * 6];

            do
            {
                //verts
                verts[i * 2 + 0] = GeomUtil.DegToVector2(angle + lerpStart.Value) * lerpInner.Value;
                verts[i * 2 + 1] = GeomUtil.DegToVector2(angle + lerpStart.Value) * lerpOuter.Value;

                //colors
                colors[i * 2 + 0] = drawColor;
                colors[i * 2 + 1] = drawColor;

                //indices
                if (diffAngle > 0)
                {
                    indices[i * 6 + 0] = (i + 0) * 2 + 0;
                    indices[i * 6 + 1] = (i + 1) * 2 + 0;
                    indices[i * 6 + 2] = (i + 0) * 2 + 1;
                    indices[i * 6 + 3] = (i + 1) * 2 + 0;
                    indices[i * 6 + 4] = (i + 1) * 2 + 1;
                    indices[i * 6 + 5] = (i + 0) * 2 + 1;
                }
                else
                {
                    indices[i * 6 + 0] = (i + 0) * 2 + 0;
                    indices[i * 6 + 1] = (i + 0) * 2 + 1;
                    indices[i * 6 + 2] = (i + 1) * 2 + 0;
                    indices[i * 6 + 3] = (i + 1) * 2 + 0;
                    indices[i * 6 + 4] = (i + 0) * 2 + 1;
                    indices[i * 6 + 5] = (i + 1) * 2 + 1;
                }
                angle += addAngle;
                ++i;
            } while(addNum >= i);
            angle = diffAngle;
            //verts
            verts[i * 2 + 0] = GeomUtil.DegToVector2(lerpEnd.Value) * lerpInner.Value;
            verts[i * 2 + 1] = GeomUtil.DegToVector2(lerpEnd.Value) * lerpOuter.Value;

            //colors
            colors[i * 2 + 0] = drawColor;
            colors[i * 2 + 1] = drawColor;

            eMesh.verts   = verts;
            eMesh.colors  = colors;
            eMesh.indices = indices;

            return(eMesh);
        }