Esempio n. 1
0
        public LineGLVO BuildSpline(List <Vector3> points, float width, Color color, bool autoDelete = true, bool AA = false, bool continuous = false, bool stretch = false)
        {
            if (points.Count == 0)
            {
                return(null);
            }

            LineGLVO vo = ScriptableObject.CreateInstance <LineGLVO>();

            List <Vector3> p       = new List <Vector3>(points);
            List <Vector3> results = new List <Vector3>();

            if (continuous)
            {
                p.Remove(p[p.Count - 1]);
                results = MeshUtils.CatmullRom(p);
                results.Add(results[0]);
            }
            else
            {
                results = MeshUtils.CatmullRom(p);
            }
            vo.Points = results;

            vo.Color         = color;
            vo.AutoDelete    = autoDelete;
            vo.Width         = width;
            vo.VariableWidth = true;
            vo.Stretch       = stretch;
            vo.AA            = AA;
            vo.Continuous    = true;
            _vos.Add(vo);

            return(vo);
        }
Esempio n. 2
0
        public Shape BuildLinkedSpline <T>(List <Vector2> points, float width, Color color, Material mat, bool loop = false) where T : BaseLineStyle
        {
            GameObject go   = new GameObject();
            Mesh       mesh = new Mesh();

            go.AddComponent <MeshFilter>().mesh = mesh;
            MeshRenderer mr = go.AddComponent <MeshRenderer>();

            _basicMaterial = mat;

            if (_basicMaterial == null)
            {
                _basicMaterial = Resources.Load("Basic2DMaterial") as Material;
            }
            mr.material = _basicMaterial;

            BaseLineStyle lineStyle = ScriptableObject.CreateInstance(typeof(T)) as BaseLineStyle;

            List <Vector2> splinePoints = MeshUtils.Vector3ToVector2(MeshUtils.CatmullRom(MeshUtils.Vector2ToVector3(points)));

            BuildLinkedMesh(mesh, splinePoints, color, width, loop, lineStyle);
            Shape s = go.AddComponent <Shape>();

            s.Col             = color;
            s.Points          = Vector3ToVector2(mesh.vertices);
            s.BuiltGameObject = go;
            s.LineStyle       = lineStyle;
            s.LinePoints      = splinePoints.ToArray();

            return(s);
        }
Esempio n. 3
0
        public void RebuildLinkedSpline(Shape shape, List <Vector2> points, float width, bool loop = false)
        {
            Mesh m = shape.BuiltGameObject.GetComponent <MeshFilter>().sharedMesh;

            if (shape.LineStyle == null)
            {
                BaseLineStyle lineStyle = ScriptableObject.CreateInstance <BaseLineStyle>();
                shape.LineStyle = lineStyle;
            }

            List <Vector2> splinePoints = MeshUtils.Vector3ToVector2(MeshUtils.CatmullRom(MeshUtils.Vector2ToVector3(points)));

            BuildLinkedMesh(m, splinePoints, shape.Col, width, loop, shape.LineStyle);
            shape.Points     = Vector3ToVector2(m.vertices);
            shape.LinePoints = splinePoints.ToArray();
        }
Esempio n. 4
0
        public LineGLVO BuildStretchLine(List <Vector3> points, float width, Color color, bool autoDelete = true, bool AA = false, bool continuous = false)
        {
            if (points.Count == 0)
            {
                return(null);
            }

            LineGLVO vo = ScriptableObject.CreateInstance <LineGLVO>();

            vo.Points = MeshUtils.CatmullRom(points);

            vo.Color         = color;
            vo.AutoDelete    = autoDelete;
            vo.Width         = width;
            vo.VariableWidth = false;
            vo.AA            = AA;
            vo.Continuous    = true;
            vo.Stretch       = true;
            _vos.Add(vo);

            return(vo);
        }