public MegaXMLNode()
 {
     tagName    = "NONE";
     parentNode = null;
     children   = new List <MegaXMLNode>();
     values     = new List <MegaXMLValue>();
 }
示例#2
0
    public void ParseSpline(MegaXMLNode node, MegaShape shape)
    {
        MegaSpline spline = new MegaSpline();

        for (int i = 0; i < node.values.Count; i++)
        {
            MegaXMLValue val = node.values[i];

            //Debug.Log("Spline val " + val.name);
            switch (val.name)
            {
            case "flags": break;

            case "closed": spline.closed = int.Parse(val.value) > 0 ? true : false; break;
            }
        }

        foreach (MegaXMLNode n in node.children)
        {
            //Debug.Log("Spline tagName " + n.tagName);
            switch (n.tagName)
            {
            case "K": ParseKnot(n, shape, spline); break;
            }
        }

        //Debug.Log("************** Add Spline");
        shape.splines.Add(spline);
    }
示例#3
0
	public void ParseSpline(MegaXMLNode node, MegaShape shape)
	{
		MegaSpline spline = new MegaSpline();

		for ( int i = 0; i < node.values.Count; i++ )
		{
			MegaXMLValue val = node.values[i];

			//Debug.Log("Spline val " + val.name);
			switch ( val.name )
			{
				case "flags": break;
				case "closed": spline.closed = int.Parse(val.value) > 0 ? true : false; break;
			}
		}

		foreach ( MegaXMLNode n in node.children )
		{
			//Debug.Log("Spline tagName " + n.tagName);
			switch ( n.tagName )
			{
				case "K": ParseKnot(n, shape, spline); break;
			}
		}

		//Debug.Log("************** Add Spline");
		shape.splines.Add(spline);
	}
示例#4
0
    public void ParseShape(MegaXMLNode node, MegaShape shape)
    {
        for (int i = 0; i < node.values.Count; i++)
        {
            MegaXMLValue val = node.values[i];

            //Debug.Log("Shape val " + val.name);
            switch (val.name)
            {
            case "name": break;

            case "p": break;

            case "r": break;

            case "s": break;
            }
        }

        foreach (MegaXMLNode n in node.children)
        {
            //Debug.Log("Shape tagName " + n.tagName);

            switch (n.tagName)
            {
            case "Spline":
                ParseSpline(n, shape);
                break;
            }
        }
    }
示例#5
0
	public void ParseShape(MegaXMLNode node, MegaShape shape)
	{
		for ( int i = 0; i < node.values.Count; i++ )
		{
			MegaXMLValue val = node.values[i];

			//Debug.Log("Shape val " + val.name);
			switch ( val.name )
			{
				case "name": break;
				case "p": break;
				case "r": break;
				case "s": break;
			}
		}

		foreach ( MegaXMLNode n in node.children )
		{
			//Debug.Log("Shape tagName " + n.tagName);

			switch ( n.tagName )
			{
				case "Spline":
					ParseSpline(n, shape);
					break;
			}
		}
	}
示例#6
0
    public void ParseKnot(MegaXMLNode node, MegaShape shape, MegaSpline spline)
    {
        Vector3 p      = Vector3.zero;
        Vector3 invec  = Vector3.zero;
        Vector3 outvec = Vector3.zero;

        for (int i = 0; i < node.values.Count; i++)
        {
            MegaXMLValue val = node.values[i];

            //Debug.Log("Knot val " + val.name);
            switch (val.name)
            {
            case "p": p = ParseV3Split(val.value, 0); break;

            case "i": invec = ParseV3Split(val.value, 0); break;

            case "o": outvec = ParseV3Split(val.value, 0); break;

            case "l": break;
            }
        }

        spline.AddKnot(p, invec, outvec);
    }
示例#7
0
    public void ParseTag(MegaXMLNode node, MegaShapeOSMWay way)
    {
        MegaShapeOSMTag tag = null;

        for (int i = 0; i < node.values.Count; i++)
        {
            MegaXMLValue val = node.values[i];


            switch (val.name)
            {
            case "k":
                tag = FindTagK(val.value);

                if (tag == null)
                {
                    tag   = new MegaShapeOSMTag();
                    tag.k = val.value;
                    tags.Add(tag);
                }

                break;

            case "v":
                way.tags.Add(AddV(tag, val.value));
                break;
            }
        }
    }
示例#8
0
    public void ParseWay(MegaXMLNode node)
    {
        MegaShapeOSMWay way = new MegaShapeOSMWay();

        way.name = "";

        for (int i = 0; i < node.values.Count; i++)
        {
            MegaXMLValue val = node.values[i];

            switch (val.name)
            {
            case "id": way.id = ulong.Parse(val.value); break;
            }
        }

        foreach (MegaXMLNode n in node.children)
        {
            switch (n.tagName)
            {
            case "nd": ParseND(n, way); break;

            case "tag": ParseTag(n, way); break;
            }
        }

        osmways.Add(way);
    }
示例#9
0
 public MegaXMLNode()
 {
     tagName = "NONE";
     parentNode = null;
     children = new ArrayList();
     values = new List<MegaXMLValue>();
 }
    public MegaXMLNode read(String xml)
    {
        int         index       = 0;
        int         lastIndex   = 0;
        MegaXMLNode rootNode    = new MegaXMLNode();
        MegaXMLNode currentNode = rootNode;

        xml = xml.Replace(" \n", "");
        xml = xml.Replace("\n", "");

        while (true)
        {
            index = xml.IndexOf(TAG_START, lastIndex);

            if (index < 0 || index >= xml.Length)
            {
                break;
            }

            index++;

            lastIndex = xml.IndexOf(TAG_END, index);
            if (lastIndex < 0 || lastIndex >= xml.Length)
            {
                break;
            }

            int    tagLength = lastIndex - index;
            String xmlTag    = xml.Substring(index, tagLength);

            if (xmlTag[0] == SLASH)
            {
                currentNode = currentNode.parentNode;
                continue;
            }

            bool openTag = true;

            if (xmlTag[tagLength - 1] == SLASH)
            {
                xmlTag  = xmlTag.Substring(0, tagLength - 1);
                openTag = false;
            }


            MegaXMLNode node = parseTag(xmlTag);
            node.parentNode = currentNode;
            currentNode.children.Add(node);

            if (openTag)
            {
                currentNode = node;
            }
        }

        return(rootNode);
    }
示例#11
0
    public void LoadXML(string svgdata, MegaShape shape)
    {
        MegaXMLReader xml  = new MegaXMLReader();
        MegaXMLNode   node = xml.read(svgdata);

        shape.splines.Clear();
        shape.selcurve = 0;
        splineindex    = 0;
        ParseXML(node, shape);
    }
示例#12
0
    public void LoadXMLTags(string sxldata)     //, float scale, bool cspeed, string name, float smoothness)
    {
        osmnodes.Clear();
        osmways.Clear();
        tags.Clear();

        MegaXMLReader xml  = new MegaXMLReader();
        MegaXMLNode   node = xml.read(sxldata);

        ParseXML(node);
    }
示例#13
0
	public void ParseXML(MegaXMLNode node, MegaShape shape)
	{
		foreach ( MegaXMLNode n in node.children )
		{
			switch ( n.tagName )
			{
				case "Shape": ParseShape(n, shape); break;
			}

			ParseXML(n, shape);
		}
	}
示例#14
0
    public void ParseXML(MegaXMLNode node)
    {
        foreach (MegaXMLNode n in node.children)
        {
            switch (n.tagName)
            {
            case "osm": ParseOSM(n); break;
            }

            ParseXML(n);
        }
    }
示例#15
0
    public void ParseXML(MegaXMLNode node, MegaShape shape)
    {
        foreach (MegaXMLNode n in node.children)
        {
            switch (n.tagName)
            {
            case "Shape": ParseShape(n, shape); break;
            }

            ParseXML(n, shape);
        }
    }
示例#16
0
    public void ParseND(MegaXMLNode node, MegaShapeOSMWay way)
    {
        for (int i = 0; i < node.values.Count; i++)
        {
            MegaXMLValue val = node.values[i];

            switch (val.name)
            {
            case "ref":     way.nodes.Add(ulong.Parse(val.value));  break;
            }
        }
    }
示例#17
0
    public void ParseOSM(MegaXMLNode node)
    {
        foreach (MegaXMLNode n in node.children)
        {
            switch (n.tagName)
            {
            case "node":    ParseNode(n);   break;

            case "way":             ParseWay(n);    break;
            }
        }
    }
示例#18
0
	public MegaXMLNode read(String xml)
	{
		int index = 0;
		int lastIndex = 0;
		MegaXMLNode rootNode = new MegaXMLNode();
		MegaXMLNode currentNode = rootNode;

		xml = xml.Replace(" \n", "");
		xml = xml.Replace("\n", "");

		while ( true )
		{
			index = xml.IndexOf(TAG_START, lastIndex);

			if ( index < 0 || index >= xml.Length )
				break;

			index++;

			lastIndex = xml.IndexOf(TAG_END, index);
			if ( lastIndex < 0 || lastIndex >= xml.Length )
				break;

			int tagLength = lastIndex - index;
			String xmlTag = xml.Substring(index, tagLength);

			if ( xmlTag[0] == SLASH )
			{
				currentNode = currentNode.parentNode;
				continue;
			}

			bool openTag = true;

			if ( xmlTag[tagLength - 1] == SLASH )
			{
				xmlTag = xmlTag.Substring(0, tagLength - 1);
				openTag = false;
			}


			MegaXMLNode node = parseTag(xmlTag);
			node.parentNode = currentNode;
			currentNode.children.Add(node);

			if ( openTag )
				currentNode = node;
		}

		return rootNode;
	}
示例#19
0
    public void LoadXML(string svgdata, MegaShape shape, bool clear, int start)
    {
        MegaXMLReader xml  = new MegaXMLReader();
        MegaXMLNode   node = xml.read(svgdata);

        if (!clear)
        {
            shape.splines.Clear();
        }

        shape.selcurve = start;
        splineindex    = start;
        ParseXML(node, shape);
    }
示例#20
0
    public void ParseXML(MegaXMLNode node, MegaShape shape)
    {
        foreach ( MegaXMLNode n in node.children )
        {
            switch ( n.tagName )
            {
                case "circle":	ParseCircle(n, shape); break;
                case "path": ParsePath(n, shape); break;
                case "ellipse": ParseEllipse(n, shape); break;
                case "rect": ParseRect(n, shape); break;
                case "polygon": ParsePolygon(n, shape); break;
                default:	break;
            }

            ParseXML(n, shape);
        }
    }
示例#21
0
    void ParseRect(MegaXMLNode node, MegaShape shape)
    {
        MegaSpline spline = GetSpline(shape);

        Vector3[] ppoints = new Vector3[4];

        float w = 0.0f;
        float h = 0.0f;
        float x = 0.0f;
        float y = 0.0f;

        for (int i = 0; i < node.values.Count; i++)
        {
            MegaXMLValue val = node.values[i];

            switch (val.name)
            {
            case "x": x = float.Parse(val.value); break;

            case "y": y = float.Parse(val.value); break;

            case "width": w = float.Parse(val.value); break;

            case "height": h = float.Parse(val.value); break;

            case "transform": Debug.Log("SVG Transform not implemented yet");
                break;
            }
        }

        ppoints[0] = new Vector3(x, 0.0f, y);
        ppoints[1] = new Vector3(x, 0.0f, y + h);
        ppoints[2] = new Vector3(x + w, 0.0f, y + h);
        ppoints[3] = new Vector3(x + w, 0.0f, y);

        spline.closed = true;
        spline.knots.Clear();
        //spline.AddKnot(ppoints[0], ppoints[0], ppoints[0]);
        //spline.AddKnot(ppoints[1], ppoints[1], ppoints[1]);
        //spline.AddKnot(ppoints[2], ppoints[2], ppoints[2]);
        //spline.AddKnot(ppoints[3], ppoints[3], ppoints[3]);
        AddKnot(spline, ppoints[0], ppoints[0], ppoints[0], shape.axis);
        AddKnot(spline, ppoints[1], ppoints[1], ppoints[1], shape.axis);
        AddKnot(spline, ppoints[2], ppoints[2], ppoints[2], shape.axis);
        AddKnot(spline, ppoints[3], ppoints[3], ppoints[3], shape.axis);
    }
    public MegaXMLNode parseAttributes(String xmlTag, MegaXMLNode node)
    {
        int index         = 0;
        int attrNameIndex = 0;
        int lastIndex     = 0;

        while (true)
        {
            index = xmlTag.IndexOf(BEGIN_QUOTE, lastIndex);
            if (index < 0 || index > xmlTag.Length)
            {
                break;
            }

            attrNameIndex = xmlTag.LastIndexOf(SPACE, index);
            if (attrNameIndex < 0 || attrNameIndex > xmlTag.Length)
            {
                break;
            }

            attrNameIndex++;
            String attrName = xmlTag.Substring(attrNameIndex, index - attrNameIndex);

            index += 2;

            lastIndex = xmlTag.IndexOf(QUOTE, index);
            if (lastIndex < 0 || lastIndex > xmlTag.Length)
            {
                break;
            }

            int    tagLength = lastIndex - index;
            String attrValue = xmlTag.Substring(index, tagLength);

            MegaXMLValue val = new MegaXMLValue();
            val.name  = attrName;
            val.value = attrValue;
            node.values.Add(val);
        }

        return(node);
    }
    public MegaXMLNode parseTag(String xmlTag)
    {
        MegaXMLNode node = new MegaXMLNode();

        int nameEnd = xmlTag.IndexOf(SPACE, 0);

        if (nameEnd < 0)
        {
            node.tagName = xmlTag;
            return(node);
        }

        String tagName = xmlTag.Substring(0, nameEnd);

        node.tagName = tagName;

        String attrString = xmlTag.Substring(nameEnd, xmlTag.Length - nameEnd);

        return(parseAttributes(attrString, node));
    }
示例#24
0
    public void ParseXML(MegaXMLNode node, MegaShape shape)
    {
        foreach (MegaXMLNode n in node.children)
        {
            switch (n.tagName)
            {
            case "circle":  ParseCircle(n, shape); break;

            case "path": ParsePath(n, shape); break;

            case "rect": ParseRect(n, shape); break;

            case "polygon": ParsePolygon(n, shape); break;

            default:        break;
            }

            ParseXML(n, shape);
        }
    }
示例#25
0
    void ParsePolygon(MegaXMLNode node, MegaShape shape)
    {
        MegaSpline spline = GetSpline(shape);

        spline.knots.Clear();
        spline.closed = true;

        char[] charSeparators = new char[] { ' ' };

        for (int i = 0; i < node.values.Count; i++)
        {
            MegaXMLValue val = node.values[i];

            switch (val.name)
            {
            case "points":

                string[] coordinates = val.value.Split(charSeparators, StringSplitOptions.RemoveEmptyEntries);

                for (int j = 0; j < coordinates.Length; j++)
                {
                    Vector3 p = ParseV2Split(coordinates[j], 0);

                    MegaKnot k = new MegaKnot();
                    k.p      = SwapAxis(new Vector3(p.x, 0.0f, p.y), shape.axis);
                    k.invec  = k.p;
                    k.outvec = k.p;
                    spline.knots.Add(k);
                }

                break;
            }
        }

        if (spline.closed)
        {
            Vector3 delta1 = spline.knots[0].outvec - spline.knots[0].p;
            spline.knots[0].invec = spline.knots[0].p - delta1;
        }
    }
示例#26
0
    public void ParseKnot(MegaXMLNode node, MegaShape shape, MegaSpline spline)
    {
        Vector3 p = Vector3.zero;
        Vector3 invec = Vector3.zero;
        Vector3 outvec = Vector3.zero;

        for ( int i = 0; i < node.values.Count; i++ )
        {
            MegaXMLValue val = node.values[i];

            //Debug.Log("Knot val " + val.name);
            switch ( val.name )
            {
                case "p": p = ParseV3Split(val.value, 0); break;
                case "i": invec = ParseV3Split(val.value, 0); break;
                case "o": outvec = ParseV3Split(val.value, 0); break;
                case "l": break;
            }
        }

        spline.AddKnot(p, invec, outvec);
    }
示例#27
0
    void ParseCircle(MegaXMLNode node, MegaShape shape)
    {
        MegaSpline spline = GetSpline(shape);

        float cx = 0.0f;
        float cy = 0.0f;
        float r  = 0.0f;

        for (int i = 0; i < node.values.Count; i++)
        {
            MegaXMLValue val = node.values[i];

            switch (val.name)
            {
            case "cx": cx = float.Parse(val.value); break;

            case "cy": cy = float.Parse(val.value); break;

            case "r": r = float.Parse(val.value); break;
            }
        }

        float vector = CIRCLE_VECTOR_LENGTH * r;

        spline.knots.Clear();
        for (int ix = 0; ix < 4; ++ix)
        {
            float   angle  = (Mathf.PI * 2.0f) * (float)ix / (float)4;
            float   sinfac = Mathf.Sin(angle);
            float   cosfac = Mathf.Cos(angle);
            Vector3 p      = new Vector3((cosfac * r) + cx, 0.0f, (sinfac * r) + cy);
            Vector3 rotvec = new Vector3(sinfac * vector, 0.0f, -cosfac * vector);
            //spline.AddKnot(p, p + rotvec, p - rotvec);
            AddKnot(spline, p, p + rotvec, p - rotvec, shape.axis);
        }

        spline.closed = true;
    }
示例#28
0
    public MegaXMLNode parseAttributes(String xmlTag, MegaXMLNode node)
    {
        int index = 0;
        int attrNameIndex = 0;
        int lastIndex = 0;

        while ( true )
        {
            index = xmlTag.IndexOf(BEGIN_QUOTE, lastIndex);
            if ( index < 0 || index > xmlTag.Length )
                break;

            attrNameIndex = xmlTag.LastIndexOf(SPACE, index);
            if ( attrNameIndex < 0 || attrNameIndex > xmlTag.Length )
                break;

            attrNameIndex++;
            String attrName = xmlTag.Substring(attrNameIndex, index - attrNameIndex);

            index += 2;

            lastIndex = xmlTag.IndexOf(QUOTE, index);
            if ( lastIndex < 0 || lastIndex > xmlTag.Length )
            {
                break;
            }

            int tagLength = lastIndex - index;
            String attrValue = xmlTag.Substring(index, tagLength);

            MegaXMLValue val = new MegaXMLValue();
            val.name = attrName;
            val.value = attrValue;
            node.values.Add(val);
        }

        return node;
    }
示例#29
0
    public void ParseNode(MegaXMLNode node)
    {
        MegaShapeOSMNode onode = new MegaShapeOSMNode();

        for (int i = 0; i < node.values.Count; i++)
        {
            MegaXMLValue val = node.values[i];

            switch (val.name)
            {
            case "id":
                //Debug.Log("id " + val.value);
                onode.id = ulong.Parse(val.value);
                break;

            case "lat": onode.pos.x = float.Parse(val.value); break;

            case "lon": onode.pos.z = float.Parse(val.value); break;
            }
        }

        osmnodes.Add(onode);
    }
示例#30
0
	public void ParseTag(MegaXMLNode node, MegaShapeOSMWay way)
	{
		MegaShapeOSMTag tag = null;

		for ( int i = 0; i < node.values.Count; i++ )
		{
			MegaXMLValue val = node.values[i];


			switch ( val.name )
			{
				case "k":
					tag = FindTagK(val.value);

					if ( tag == null )
					{
						tag = new MegaShapeOSMTag();
						tag.k = val.value;
						tags.Add(tag);
					}

					break;

				case "v":
					way.tags.Add(AddV(tag, val.value));
					break;
			}
		}
	}
示例#31
0
	public void ParseND(MegaXMLNode node, MegaShapeOSMWay way)
	{
		for ( int i = 0; i < node.values.Count; i++ )
		{
			MegaXMLValue val = node.values[i];

			switch ( val.name )
			{
				case "ref":	way.nodes.Add(ulong.Parse(val.value));	break;
			}
		}
	}
示例#32
0
	public void ParseWay(MegaXMLNode node)
	{
		MegaShapeOSMWay way = new MegaShapeOSMWay();

		way.name = "";

		for ( int i = 0; i < node.values.Count; i++ )
		{
			MegaXMLValue val = node.values[i];

			switch ( val.name )
			{
				case "id": way.id = ulong.Parse(val.value); break;
			}
		}

		foreach ( MegaXMLNode n in node.children )
		{
			switch ( n.tagName )
			{
				case "nd": ParseND(n, way); break;
				case "tag": ParseTag(n, way); break;
			}
		}

		osmways.Add(way);
	}
示例#33
0
	public void ParseNode(MegaXMLNode node)
	{
		MegaShapeOSMNode onode = new MegaShapeOSMNode();

		for ( int i = 0; i < node.values.Count; i++ )
		{
			MegaXMLValue val = node.values[i];

			switch ( val.name )
			{
				case "id":
					//Debug.Log("id " + val.value);
					onode.id = ulong.Parse(val.value);
					break;
				case "lat": onode.pos.x = float.Parse(val.value); break;
				case "lon": onode.pos.z = float.Parse(val.value); break;
			}
		}

		osmnodes.Add(onode);
	}
示例#34
0
	public void ParseOSM(MegaXMLNode node)
	{
		foreach ( MegaXMLNode n in node.children )
		{
			switch ( n.tagName )
			{
				case "node":	ParseNode(n);	break;
				case "way":		ParseWay(n);	break;
			}
		}
	}
示例#35
0
    void ParsePolygon(MegaXMLNode node, MegaShape shape)
    {
        MegaSpline spline = GetSpline(shape);

        spline.knots.Clear();
        spline.closed = true;

        char[] charSeparators = new char[] { ' ' };

        for ( int i = 0; i < node.values.Count; i++ )
        {
            MegaXMLValue val = node.values[i];

            switch ( val.name )
            {
                case "points":

                    string[] coordinates = val.value.Split(charSeparators, StringSplitOptions.RemoveEmptyEntries);

                    for ( int j = 0; j < coordinates.Length; j++ )
                    {
                        Vector3 p = ParseV2Split(coordinates[j], 0);

                        MegaKnot k = new MegaKnot();
                        k.p = SwapAxis(new Vector3(p.x, 0.0f, p.y), shape.axis);
                        k.invec = k.p;
                        k.outvec = k.p;
                        spline.knots.Add(k);
                    }

                    break;
            }
        }

        if ( spline.closed )
        {
            Vector3 delta1 = spline.knots[0].outvec - spline.knots[0].p;
            spline.knots[0].invec = spline.knots[0].p - delta1;
        }
    }
示例#36
0
    void ParseEllipse(MegaXMLNode node, MegaShape shape)
    {
        MegaSpline spline = GetSpline(shape);

        float cx = 0.0f;
        float cy = 0.0f;
        float rx = 0.0f;
        float ry = 0.0f;

        for (int i = 0; i < node.values.Count; i++)
        {
            MegaXMLValue val = node.values[i];

            switch (val.name)
            {
            case "cx": cx = float.Parse(val.value); break;

            case "cy": cy = float.Parse(val.value); break;

            case "rx": rx = float.Parse(val.value); break;

            case "ry": ry = float.Parse(val.value); break;
            }
        }

        ry = Mathf.Clamp(ry, 0.0f, float.MaxValue);
        rx = Mathf.Clamp(rx, 0.0f, float.MaxValue);

        float radius, xmult, ymult;

        if (ry < rx)
        {
            radius = rx;
            xmult  = 1.0f;
            ymult  = ry / rx;
        }
        else
        {
            if (rx < ry)
            {
                radius = ry;
                xmult  = rx / ry;
                ymult  = 1.0f;
            }
            else
            {
                radius = ry;
                xmult  = ymult = 1.0f;
            }
        }


        float vector = CIRCLE_VECTOR_LENGTH * radius;

        Vector3 mult = new Vector3(xmult, ymult, 1.0f);

        for (int ix = 0; ix < 4; ++ix)
        {
            float   angle  = 6.2831853f * (float)ix / 4.0f;
            float   sinfac = Mathf.Sin(angle);
            float   cosfac = Mathf.Cos(angle);
            Vector3 p      = new Vector3(cosfac * radius + cx, 0.0f, sinfac * radius + cy);
            Vector3 rotvec = new Vector3(sinfac * vector, 0.0f, -cosfac * vector);
            //spline.AddKnot(Vector3.Scale(p, mult), Vector3.Scale((p + rotvec), mult), Vector3.Scale((p - rotvec), mult));	//, tm);
            AddKnot(spline, Vector3.Scale(p, mult), Vector3.Scale((p + rotvec), mult), Vector3.Scale((p - rotvec), mult), shape.axis);                  //, tm);
        }

        spline.closed = true;
    }
示例#37
0
    void ParsePath(MegaXMLNode node, MegaShape shape)
    {
        Vector3 cp = Vector3.zero;
        Vector2 cP1;
        Vector2 cP2;

        char[] charSeparators = new char[] { ',', ' ' };

        MegaSpline spline = null;
        MegaKnot   k;

        string[] coord;

        for (int i = 0; i < node.values.Count; i++)
        {
            MegaXMLValue val = node.values[i];

            //Debug.Log("val name " + val.name);

            switch (val.name)
            {
            case "d":
#if UNITY_FLASH || UNITY_WP8 || UNITY_METRO
                string[] coordinates = null;                            //string.Split(val.value, @"(?=[MmLlCcSsZzHhVv])");
#else
                string[] coordinates = Regex.Split(val.value, @"(?=[MmLlCcSsZzHhVv])");
#endif

                for (int j = 0; j < coordinates.Length; j++)
                {
                    if (coordinates[j].Length > 0)
                    {
                        string v = coordinates[j].Substring(1);
                        if (v != null && v.Length > 0)
                        {
                            //v = v.Replace("-", ",-");

                            while (v.Length > 0 && (v[0] == ',' || v[0] == ' '))
                            {
                                v = v.Substring(1);
                            }
                        }

                        switch (coordinates[j][0])
                        {
                        case 'Z':
                        case 'z':
                            if (spline != null)
                            {
                                spline.closed = true;
#if false
                                Vector3 delta1 = spline.knots[0].outvec - spline.knots[0].p;
                                spline.knots[0].invec = spline.knots[0].p - delta1;

                                if (spline.knots[0].p == spline.knots[spline.knots.Count - 1].p)
                                {
                                    spline.knots.Remove(spline.knots[spline.knots.Count - 1]);
                                }
#else
                                int kc = spline.knots.Count - 1;
                                spline.knots[0].invec = spline.knots[kc].invec;
                                spline.knots.Remove(spline.knots[kc]);
#endif
                            }
                            break;

                        case 'M':
                            spline = GetSpline(shape);
                            spline.knots.Clear();

                            cp       = ParseV2Split(v, 0);
                            k        = new MegaKnot();
                            k.p      = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);
                            k.invec  = k.p;
                            k.outvec = k.p;
                            spline.knots.Add(k);
                            break;

                        case 'm':
                            spline = GetSpline(shape);
                            spline.knots.Clear();

                            //Debug.Log("v: " + v);
                            coord = v.Split(" "[0]);
                            //Debug.Log("m coords " + coord.Length);
                            //Debug.Log("v2 " + coord[0]);
                            for (int k0 = 0; k0 < coord.Length - 1; k0 = k0 + 1)
                            {
                                //Debug.Log("v2 " + coord[k0]);
                                Vector3 cp1 = ParseV2Split(coord[k0], 0);
                                //Debug.Log("cp1 " + cp1);

                                cp.x += cp1.x;                                                  //ParseV2Split(coord[k0], 0);	// ParseV2(coord, k0);
                                cp.y += cp1.y;

                                k        = new MegaKnot();
                                k.p      = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);
                                k.invec  = k.p;
                                k.outvec = k.p;
                                spline.knots.Add(k);
                            }

#if false
                            Vector3 cp1 = ParseV2Split(v, 0);
                            cp.x    += cp1.x;
                            cp.y    += cp1.y;
                            k        = new MegaKnot();
                            k.p      = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);
                            k.invec  = k.p;
                            k.outvec = k.p;
                            spline.knots.Add(k);
#endif
                            break;

                        case 'l':
                            //coord = v.Split(","[0]);
                            coord = v.Split(charSeparators, StringSplitOptions.RemoveEmptyEntries);
                            for (int k0 = 0; k0 < coord.Length; k0 = k0 + 2)
                            {
                                cp += ParseV2(coord, k0);
                            }

                            spline.knots[spline.knots.Count - 1].outvec = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);

                            k        = new MegaKnot();
                            k.p      = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);
                            k.invec  = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);
                            k.outvec = k.p - (k.invec - k.p);
                            spline.knots.Add(k);

                            break;

                        case 'c':
                            coord = v.Split(charSeparators, StringSplitOptions.RemoveEmptyEntries);

                            for (int k2 = 0; k2 < coord.Length; k2 += 6)
                            {
                                cP1 = cp + ParseV2(coord, k2);
                                cP2 = cp + ParseV2(coord, k2 + 2);
                                cp += ParseV2(coord, k2 + 4);

                                spline.knots[spline.knots.Count - 1].outvec = SwapAxis(new Vector3(cP1.x, 0.0f, cP1.y), shape.axis);

                                k        = new MegaKnot();
                                k.p      = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);
                                k.invec  = SwapAxis(new Vector3(cP2.x, 0.0f, cP2.y), shape.axis);
                                k.outvec = k.p - (k.invec - k.p);
                                spline.knots.Add(k);
                            }
                            break;

                        case 'L':
                            //coord = v.Split(","[0]);
                            coord = v.Split(charSeparators, StringSplitOptions.RemoveEmptyEntries);
                            //Debug.Log("v " + v);
                            //Debug.Log("coords " + coord.Length);
                            for (int k3 = 0; k3 < coord.Length; k3 = k3 + 2)
                            {
                                cp = ParseV2(coord, k3);
                            }

                            spline.knots[spline.knots.Count - 1].outvec = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);

                            k        = new MegaKnot();
                            k.p      = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);
                            k.invec  = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);
                            k.outvec = k.p - (k.invec - k.p);
                            spline.knots.Add(k);

                            break;

                        case 'v':
                            //Debug.Log("v: " + v);
                            coord = v.Split(","[0]);
                            for (int k4 = 0; k4 < coord.Length; k4++)
                            {
                                cp.y += float.Parse(coord[k4]);
                            }
                            spline.knots[spline.knots.Count - 1].outvec = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);

                            k        = new MegaKnot();
                            k.p      = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);
                            k.invec  = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);
                            k.outvec = k.p - (k.invec - k.p);
                            spline.knots.Add(k);

                            break;

                        case 'V':
                            //coord = v.Split(","[0]);
                            coord = v.Split(charSeparators, StringSplitOptions.RemoveEmptyEntries);

                            for (int k9 = 0; k9 < coord.Length; k9++)
                            {
                                cp.y = float.Parse(coord[k9]);
                            }

                            spline.knots[spline.knots.Count - 1].outvec = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);

                            k        = new MegaKnot();
                            k.p      = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);
                            k.invec  = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);
                            k.outvec = k.p - (k.invec - k.p);
                            spline.knots.Add(k);

                            break;

                        case 'h':
                            //coord = v.Split(","[0]);
                            coord = v.Split(charSeparators, StringSplitOptions.RemoveEmptyEntries);

                            for (int k5 = 0; k5 < coord.Length; k5++)
                            {
                                cp.x += float.Parse(coord[k5]);
                            }

                            spline.knots[spline.knots.Count - 1].outvec = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);

                            k        = new MegaKnot();
                            k.p      = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);
                            k.invec  = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);
                            k.outvec = k.p - (k.invec - k.p);
                            spline.knots.Add(k);

                            break;

                        case 'H':
                            coord = v.Split(","[0]);
                            for (int k6 = 0; k6 < coord.Length; k6++)
                            {
                                cp.x = float.Parse(coord[k6]);
                            }

                            spline.knots[spline.knots.Count - 1].outvec = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);

                            k        = new MegaKnot();
                            k.p      = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);
                            k.invec  = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);
                            k.outvec = k.p - (k.invec - k.p);
                            spline.knots.Add(k);

                            break;

                        case 'S':
                            //coord = v.Split(","[0]);
                            coord = v.Split(charSeparators, StringSplitOptions.RemoveEmptyEntries);

                            for (int k7 = 0; k7 < coord.Length; k7 = k7 + 4)
                            {
                                cp       = ParseV2(coord, k7 + 2);
                                cP1      = ParseV2(coord, k7);
                                k        = new MegaKnot();
                                k.p      = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);
                                k.invec  = SwapAxis(new Vector3(cP1.x, 0.0f, cP1.y), shape.axis);
                                k.outvec = k.p - (k.invec - k.p);
                                spline.knots.Add(k);
                            }
                            break;

                        case 's':
                            coord = v.Split(charSeparators, StringSplitOptions.RemoveEmptyEntries);

                            for (int k7 = 0; k7 < coord.Length; k7 = k7 + 4)
                            {
                                cP1 = cp + ParseV2(coord, k7);
                                cp += ParseV2(coord, k7 + 2);

                                k        = new MegaKnot();
                                k.p      = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);
                                k.invec  = SwapAxis(new Vector3(cP1.x, 0.0f, cP1.y), shape.axis);
                                k.outvec = k.p - (k.invec - k.p);
                                spline.knots.Add(k);
                            }
                            break;

                        case 'C':
                            //Debug.Log("v " + v);
                            coord = v.Split(charSeparators, StringSplitOptions.RemoveEmptyEntries);
                            //Debug.Log("crds " + coord.Length);
                            for (int k2 = 0; k2 < coord.Length; k2 += 6)
                            {
                                cP1 = ParseV2(coord, k2);
                                cP2 = ParseV2(coord, k2 + 2);
                                cp  = ParseV2(coord, k2 + 4);

                                spline.knots[spline.knots.Count - 1].outvec = SwapAxis(new Vector3(cP1.x, 0.0f, cP1.y), shape.axis);

                                k        = new MegaKnot();
                                k.p      = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);
                                k.invec  = SwapAxis(new Vector3(cP2.x, 0.0f, cP2.y), shape.axis);
                                k.outvec = k.p - (k.invec - k.p);
                                spline.knots.Add(k);
                            }
                            break;

                        default:
                            break;
                        }
                    }
                }
                break;
            }
        }
    }
示例#38
0
    void ParseCircle(MegaXMLNode node, MegaShape shape)
    {
        MegaSpline spline = GetSpline(shape);

        float cx = 0.0f;
        float cy = 0.0f;
        float r = 0.0f;

        for ( int i = 0; i < node.values.Count; i++ )
        {
            MegaXMLValue val = node.values[i];

            switch ( val.name )
            {
                case "cx": cx = float.Parse(val.value); break;
                case "cy": cy = float.Parse(val.value); break;
                case "r": r = float.Parse(val.value); break;
            }
        }

        float vector = CIRCLE_VECTOR_LENGTH * r;

        spline.knots.Clear();
        for ( int ix = 0; ix < 4; ++ix )
        {
            float angle = (Mathf.PI * 2.0f) * (float)ix / (float)4;
            float sinfac = Mathf.Sin(angle);
            float cosfac = Mathf.Cos(angle);
            Vector3 p = new Vector3((cosfac * r) + cx, 0.0f, (sinfac * r) + cy);
            Vector3 rotvec = new Vector3(sinfac * vector, 0.0f, -cosfac * vector);
            //spline.AddKnot(p, p + rotvec, p - rotvec);
            AddKnot(spline, p, p + rotvec, p - rotvec, shape.axis);
        }

        spline.closed = true;
    }
示例#39
0
    void ParseEllipse(MegaXMLNode node, MegaShape shape)
    {
        MegaSpline spline = GetSpline(shape);

        float cx = 0.0f;
        float cy = 0.0f;
        float rx = 0.0f;
        float ry = 0.0f;

        for ( int i = 0; i < node.values.Count; i++ )
        {
            MegaXMLValue val = node.values[i];

            switch ( val.name )
            {
                case "cx": cx = float.Parse(val.value); break;
                case "cy": cy = float.Parse(val.value); break;
                case "rx": rx = float.Parse(val.value); break;
                case "ry": ry = float.Parse(val.value); break;
            }
        }

        ry = Mathf.Clamp(ry, 0.0f, float.MaxValue);
        rx = Mathf.Clamp(rx, 0.0f, float.MaxValue);

        float radius, xmult, ymult;
        if ( ry < rx )
        {
            radius = rx;
            xmult = 1.0f;
            ymult = ry / rx;
        }
        else
        {
            if ( rx < ry )
            {
                radius = ry;
                xmult = rx / ry;
                ymult = 1.0f;
            }
            else
            {
                radius = ry;
                xmult = ymult = 1.0f;
            }
        }

        float vector = CIRCLE_VECTOR_LENGTH * radius;

        Vector3 mult = new Vector3(xmult, ymult, 1.0f);

        for ( int ix = 0; ix < 4; ++ix )
        {
            float angle = 6.2831853f * (float)ix / 4.0f;
            float sinfac = Mathf.Sin(angle);
            float cosfac = Mathf.Cos(angle);
            Vector3 p = new Vector3(cosfac * radius + cx, 0.0f, sinfac * radius + cy);
            Vector3 rotvec = new Vector3(sinfac * vector, 0.0f, -cosfac * vector);
            //spline.AddKnot(Vector3.Scale(p, mult), Vector3.Scale((p + rotvec), mult), Vector3.Scale((p - rotvec), mult));	//, tm);
            AddKnot(spline, Vector3.Scale(p, mult), Vector3.Scale((p + rotvec), mult), Vector3.Scale((p - rotvec), mult), shape.axis);	//, tm);
        }

        spline.closed = true;
    }
示例#40
0
    void ParseRect(MegaXMLNode node, MegaShape shape)
    {
        MegaSpline spline = GetSpline(shape);
        Vector3[] ppoints = new Vector3[4];

        float w = 0.0f;
        float h = 0.0f;
        float x = 0.0f;
        float y = 0.0f;

        for ( int i = 0; i < node.values.Count; i++ )
        {
            MegaXMLValue val = node.values[i];

            switch ( val.name )
            {
                case "x": x = float.Parse(val.value); break;
                case "y": y = float.Parse(val.value); break;
                case "width": w = float.Parse(val.value); break;
                case "height": h = float.Parse(val.value); break;
                case "transform": Debug.Log("SVG Transform not implemented yet");
                    break;
            }
        }

        ppoints[0] = new Vector3(x, 0.0f, y);
        ppoints[1] = new Vector3(x, 0.0f, y + h);
        ppoints[2] = new Vector3(x + w, 0.0f, y + h);
        ppoints[3] = new Vector3(x + w, 0.0f, y);

        spline.closed = true;
        spline.knots.Clear();
        //spline.AddKnot(ppoints[0], ppoints[0], ppoints[0]);
        //spline.AddKnot(ppoints[1], ppoints[1], ppoints[1]);
        //spline.AddKnot(ppoints[2], ppoints[2], ppoints[2]);
        //spline.AddKnot(ppoints[3], ppoints[3], ppoints[3]);
        AddKnot(spline, ppoints[0], ppoints[0], ppoints[0], shape.axis);
        AddKnot(spline, ppoints[1], ppoints[1], ppoints[1], shape.axis);
        AddKnot(spline, ppoints[2], ppoints[2], ppoints[2], shape.axis);
        AddKnot(spline, ppoints[3], ppoints[3], ppoints[3], shape.axis);
    }
示例#41
0
	public void ParseXML(MegaXMLNode node)
	{
		foreach ( MegaXMLNode n in node.children )
		{
			switch ( n.tagName )
			{
				case "osm": ParseOSM(n); break;
			}

			ParseXML(n);
		}
	}
示例#42
0
    public MegaXMLNode parseTag(String xmlTag)
    {
        MegaXMLNode node = new MegaXMLNode();

        int nameEnd = xmlTag.IndexOf(SPACE, 0);
        if ( nameEnd < 0 )
        {
            node.tagName = xmlTag;
            return node;
        }

        String tagName = xmlTag.Substring(0, nameEnd);
        node.tagName = tagName;

        String attrString = xmlTag.Substring(nameEnd, xmlTag.Length - nameEnd);
        return parseAttributes(attrString, node);
    }
示例#43
0
    void ParsePath(MegaXMLNode node, MegaShape shape)
    {
        Vector3 cp = Vector3.zero;
        Vector2 cP1;
        Vector2 cP2;

        char[] charSeparators = new char[] { ',', ' ' };

        MegaSpline spline = null;
        MegaKnot k;
        string[] coord;

        for ( int i = 0; i < node.values.Count; i++ )
        {
            MegaXMLValue val = node.values[i];

            switch ( val.name )
            {
                case "d":
        #if UNITY_FLASH
                    string[] coordinates = null;	//string.Split(val.value, @"(?=[MmLlCcSsZzHhVv])");
        #else
                    string[] coordinates = Regex.Split(val.value, @"(?=[MmLlCcSsZzHhVv])");
        #endif

                    for ( int j = 0; j < coordinates.Length; j++ )
                    {
                        if ( coordinates[j].Length > 0 )
                        {
                            string v = coordinates[j].Substring(1);
                            if ( v != null && v.Length > 0 )
                            {
                                v = v.Replace("-", ",-");

                                while ( v.Length > 0 && (v[0] == ',' || v[0] == ' ') )
                                    v = v.Substring(1);
                            }

                            switch ( coordinates[j][0] )
                            {
                                case 'Z':
                                case 'z':
                                    if ( spline != null )
                                    {
                                        spline.closed = true;
        #if false
                                        Vector3 delta1 = spline.knots[0].outvec - spline.knots[0].p;
                                        spline.knots[0].invec = spline.knots[0].p - delta1;

                                        if ( spline.knots[0].p == spline.knots[spline.knots.Count - 1].p )
                                            spline.knots.Remove(spline.knots[spline.knots.Count - 1]);
        #else
                                        int kc = spline.knots.Count - 1;
                                        spline.knots[0].invec = spline.knots[kc].invec;
                                        spline.knots.Remove(spline.knots[kc]);

        #endif
                                    }
                                    break;

                                case 'M':
                                    spline = GetSpline(shape);
                                    spline.knots.Clear();

                                    cp = ParseV2Split(v, 0);
                                    k = new MegaKnot();
                                    k.p = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);
                                    k.invec = k.p;
                                    k.outvec = k.p;
                                    spline.knots.Add(k);
                                    break;

                                case 'm':
                                    spline = GetSpline(shape);
                                    spline.knots.Clear();

                                    Vector3 cp1 = ParseV2Split(v, 0);
                                    cp.x += cp1.x;
                                    cp.y += cp1.y;
                                    k = new MegaKnot();
                                    k.p = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);
                                    k.invec = k.p;
                                    k.outvec = k.p;
                                    spline.knots.Add(k);
                                    break;

                                case 'l':
                                    coord = v.Split(","[0]);
                                    for ( int k0 = 0; k0 < coord.Length; k0 = k0 + 2 )
                                        cp += ParseV2(coord, k0);

                                    spline.knots[spline.knots.Count - 1].outvec = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);

                                    k = new MegaKnot();
                                    k.p = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);
                                    k.invec = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);
                                    k.outvec = k.p - (k.invec - k.p);
                                    spline.knots.Add(k);

                                    break;

                                case 'c':
                                    coord = v.Split(charSeparators, StringSplitOptions.RemoveEmptyEntries);

                                    for ( int k2 = 0; k2 < coord.Length; k2 += 6 )
                                    {
                                        cP1 = cp + ParseV2(coord, k2);
                                        cP2 = cp + ParseV2(coord, k2 + 2);
                                        cp += ParseV2(coord, k2 + 4);

                                        spline.knots[spline.knots.Count - 1].outvec = SwapAxis(new Vector3(cP1.x, 0.0f, cP1.y), shape.axis);

                                        k = new MegaKnot();
                                        k.p = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);
                                        k.invec = SwapAxis(new Vector3(cP2.x, 0.0f, cP2.y), shape.axis);
                                        k.outvec = k.p - (k.invec - k.p);
                                        spline.knots.Add(k);
                                    }
                                    break;

                                case 'L':
                                    coord = v.Split(","[0]);
                                    for ( int k3 = 0; k3 < coord.Length; k3 = k3 + 2 )
                                        cp = ParseV2(coord, k3);

                                    spline.knots[spline.knots.Count - 1].outvec = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);

                                    k = new MegaKnot();
                                    k.p = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);
                                    k.invec = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);
                                    k.outvec = k.p - (k.invec - k.p);
                                    spline.knots.Add(k);

                                    break;

                                case 'v':
                                    //Debug.Log("v: " + v);
                                    coord = v.Split(","[0]);
                                    for ( int k4 = 0; k4 < coord.Length; k4++ )
                                        cp.y += float.Parse(coord[k4]);
                                    spline.knots[spline.knots.Count - 1].outvec = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);

                                    k = new MegaKnot();
                                    k.p = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);
                                    k.invec = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);
                                    k.outvec = k.p - (k.invec - k.p);
                                    spline.knots.Add(k);

                                    break;

                                case 'V':
                                    coord = v.Split(","[0]);
                                    for ( int k9 = 0; k9 < coord.Length; k9++ )
                                        cp.y = float.Parse(coord[k9]);

                                    spline.knots[spline.knots.Count - 1].outvec = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);

                                    k = new MegaKnot();
                                    k.p = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);
                                    k.invec = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);
                                    k.outvec = k.p - (k.invec - k.p);
                                    spline.knots.Add(k);

                                    break;

                                case 'h':
                                    coord = v.Split(","[0]);
                                    for ( int k5 = 0; k5 < coord.Length; k5++ )
                                        cp.x += float.Parse(coord[k5]);

                                    spline.knots[spline.knots.Count - 1].outvec = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);

                                    k = new MegaKnot();
                                    k.p = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);
                                    k.invec = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);
                                    k.outvec = k.p - (k.invec - k.p);
                                    spline.knots.Add(k);

                                    break;

                                case 'H':
                                    coord = v.Split(","[0]);
                                    for ( int k6 = 0; k6 < coord.Length; k6++ )
                                        cp.x = float.Parse(coord[k6]);

                                    spline.knots[spline.knots.Count - 1].outvec = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);

                                    k = new MegaKnot();
                                    k.p = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);
                                    k.invec = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);
                                    k.outvec = k.p - (k.invec - k.p);
                                    spline.knots.Add(k);

                                    break;

                                case 'S':
                                    coord = v.Split(","[0]);
                                    for ( int k7 = 0; k7 < coord.Length; k7 = k7 + 4 )
                                    {
                                        cp = ParseV2(coord, k7 + 2);
                                        cP1 = ParseV2(coord, k7);
                                        k = new MegaKnot();
                                        k.p = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);
                                        k.invec = SwapAxis(new Vector3(cP1.x, 0.0f, cP1.y), shape.axis);
                                        k.outvec = k.p - (k.invec - k.p);
                                        spline.knots.Add(k);
                                    }
                                    break;

                                case 's':
                                    coord = v.Split(charSeparators, StringSplitOptions.RemoveEmptyEntries);

                                    for ( int k7 = 0; k7 < coord.Length; k7 = k7 + 4 )
                                    {
                                        cP1 = cp + ParseV2(coord, k7);
                                        cp += ParseV2(coord, k7 + 2);

                                        k = new MegaKnot();
                                        k.p = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);
                                        k.invec = SwapAxis(new Vector3(cP1.x, 0.0f, cP1.y), shape.axis);
                                        k.outvec = k.p - (k.invec - k.p);
                                        spline.knots.Add(k);
                                    }
                                    break;

                                case 'C':
                                    coord = v.Split(charSeparators, StringSplitOptions.RemoveEmptyEntries);

                                    for ( int k2 = 0; k2 < coord.Length; k2 += 6 )
                                    {
                                        cP1 = ParseV2(coord, k2);
                                        cP2 = ParseV2(coord, k2 + 2);
                                        cp = ParseV2(coord, k2 + 4);

                                        spline.knots[spline.knots.Count - 1].outvec = SwapAxis(new Vector3(cP1.x, 0.0f, cP1.y), shape.axis);

                                        k = new MegaKnot();
                                        k.p = SwapAxis(new Vector3(cp.x, 0.0f, cp.y), shape.axis);
                                        k.invec = SwapAxis(new Vector3(cP2.x, 0.0f, cP2.y), shape.axis);
                                        k.outvec = k.p - (k.invec - k.p);
                                        spline.knots.Add(k);
                                    }
                                    break;

                                default:
                                    break;
                            }
                        }
                    }
                    break;
            }
        }
    }