Beispiel #1
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();
        }
Beispiel #2
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);
        }
Beispiel #3
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);
        }