当前位置: 首页>>代码示例>>C#>>正文


C# MegaShape类代码示例

本文整理汇总了C#中MegaShape的典型用法代码示例。如果您正苦于以下问题:C# MegaShape类的具体用法?C# MegaShape怎么用?C# MegaShape使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MegaShape类属于命名空间,在下文中一共展示了MegaShape类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ParseShape

	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;
			}
		}
	}
开发者ID:Gounemond,项目名称:BretarisDemo,代码行数:28,代码来源:MegaShapeSXL.cs

示例2: ParseSpline

	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);
	}
开发者ID:Gounemond,项目名称:BretarisDemo,代码行数:28,代码来源:MegaShapeSXL.cs

示例3: Export

    public static string Export(MegaShape shape, int x, int y, float strokewidth, Color col)
    {
        string file = "";

        Color32 c = col;

        file += "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
        file += "<!-- MegaShapes SVG Exporter v1.0 -->\n";
        file += "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n";
        file += "<svg version=\"1.1\" id=\"" + shape.name + "\" x=\"0px\" y=\"0px\" width=\"640.0px\" height=\"480.0px\">\n";

        for ( int i = 0; i < shape.splines.Count; i++ )
        {
            MegaSpline spline = shape.splines[i];

            file += "<path d=\"";

            MegaKnot k1;
            MegaKnot k = spline.knots[0];

            k1 = k;
            file += "M" + k.p[x] + "," + -k.p[y];
            //Vector3 cp = k.p;

            for ( int j = 1; j < spline.knots.Count; j++ )
            {
                k = spline.knots[j];

                Vector3 po = k1.outvec;	// - cp;	// - k1.p;
                Vector3 pi = k.invec;	// - cp;	// - k.p;
                Vector3 kp = k.p;	// - cp;
                kp[y] = -kp[y];
                po[y] = -po[y];
                pi[y] = -pi[y];

                file += "C" + po[x] + "," + po[y];
                file += " " + pi[x] + "," + pi[y];
                file += " " + kp[x] + "," + kp[y];

                k1 = k;
            }

            if ( spline.closed )
            {
                file += "z\"";
            }

            file += " fill=\"none\"";
            file += " stroke=\"#" + c.r.ToString("x") + c.g.ToString("x") + c.b.ToString("x") + "\"";
            file += " stroke-width=\"" + strokewidth + "\"";
            file += "/>\n";
        }

        file += "</svg>\n";

        return file;
    }
开发者ID:Morac,项目名称:Orca6,代码行数:57,代码来源:MegaShapeSVG.cs

示例4: BuildObjectLinks

    void BuildObjectLinks(MegaShape path)
    {
        float len = path.splines[curve].length;

        if ( LinkSize < 0.1f )
            LinkSize = 0.1f;

        // Assume z axis for now
        float linklen = (linkOff1.y - linkOff.y) * linkScale.x * LinkSize;

        int lc = (int)(len / linklen);

        if ( lc != linkcount )
            InitLinkObjects(path);

        Quaternion linkrot1 = Quaternion.identity;

        linkrot1 = Quaternion.Euler(rotate);

        float spos = start * 0.01f;
        Vector3 poff = linkPivot * linkScale.x * LinkSize;
        float lastalpha = spos;
        Vector3 pos = Vector3.zero;

        Matrix4x4 pmat = Matrix4x4.TRS(poff, linkrot1, Vector3.one);

        Vector3 lrot = Vector3.zero;
        Quaternion frot = Quaternion.identity;
        Random.seed = seed;
        for ( int i = 0; i < linkcount; i++ )
        {
            float alpha = ((float)(i + 1) / (float)linkcount) + spos;
            Quaternion lq = GetLinkQuat(alpha, lastalpha, out pos, path);
            lastalpha = alpha;

            Quaternion lr = Quaternion.Euler(lrot);
            frot = lq * linkrot1 * lr;

            if ( linkobjs[i] )
            {
                Matrix4x4 lmat = Matrix4x4.TRS(pos, lq, Vector3.one) * pmat;

                linkobjs[i].localPosition = lmat.GetColumn(3);
                linkobjs[i].localRotation = frot;
                linkobjs[i].localScale = linkScale * LinkSize;
            }

            if ( randRot )
            {
                float r = Random.Range(0.0f, 1.0f);
                lrot = (int)(r * (int)(360.0f / MegaUtils.LargestValue1(linkRot))) * linkRot;
            }
            else
                lrot += linkRot;
        }
    }
开发者ID:Morac,项目名称:Orca6,代码行数:56,代码来源:MegaTracks.cs

示例5: ParseXML

	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);
		}
	}
开发者ID:Gounemond,项目名称:BretarisDemo,代码行数:12,代码来源:MegaShapeSXL.cs

示例6: LoadXML

    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);
    }
开发者ID:jsr2k1,项目名称:gato-book-test,代码行数:12,代码来源:MegaShapeSVG.cs

示例7: NewSpline

    public MegaSpline NewSpline(MegaShape shape)
    {
        if ( shape.splines.Count == 0 )
        {
            MegaSpline newspline = new MegaSpline();
            shape.splines.Add(newspline);
        }

        MegaSpline spline = shape.splines[0];

        spline.knots.Clear();
        spline.closed = false;
        return spline;
    }
开发者ID:Morac,项目名称:Orca6,代码行数:14,代码来源:MegaDrawLoft.cs

示例8: AddTarget

    public MegaPathTarget AddTarget(MegaShape shape, int curve, float weight)
    {
        MegaPathTarget target = new MegaPathTarget();

        target.shape = shape;
        target.Weight = weight;
        target.curve = curve;
        target.modifier = 1.0f;
        target.offset = 0.0f;

        Targets.Add(target);

        return target;
    }
开发者ID:Morac,项目名称:Orca6,代码行数:14,代码来源:MegaShapeFollow.cs

示例9: GetSpline

    MegaSpline GetSpline(MegaShape shape)
    {
        MegaSpline spline;

        if ( splineindex < shape.splines.Count )
            spline = shape.splines[splineindex];
        else
        {
            spline = new MegaSpline();
            shape.splines.Add(spline);
        }

        splineindex++;
        return spline;
    }
开发者ID:jsr2k1,项目名称:gato-book-test,代码行数:15,代码来源:MegaShapeSVG.cs

示例10: importData

    public void importData(string svgdata, MegaShape shape, float scale, bool clear, int start)
    {
        LoadXML(svgdata, shape, clear, start);
        for ( int i = start; i < splineindex; i++ )
        {
            float area = shape.splines[i].Area();
            if ( area < 0.0f )
                shape.splines[i].reverse = false;
            else
                shape.splines[i].reverse = true;
        }

        //shape.Centre(0.01f, new Vector3(-1.0f, 1.0f, 1.0f));
        shape.Centre(scale, new Vector3(-1.0f, 1.0f, 1.0f), start);
        shape.CalcLength();	//10);
    }
开发者ID:jsr2k1,项目名称:gato-book-test,代码行数:16,代码来源:MegaShapeSVG.cs

示例11: ParseXML

    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);
        }
    }
开发者ID:jsr2k1,项目名称:gato-book-test,代码行数:17,代码来源:MegaShapeSVG.cs

示例12: BuildObjectLinks

    void BuildObjectLinks(MegaShape path)
    {
        float len = path.splines[curve].length;

        if ( LinkSize < 0.1f )
            LinkSize = 0.1f;

        // Assume z axis for now
        float linklen = (linkOff1.y - linkOff.y) * linkScale.x * LinkSize;

        int lc = (int)(len / linklen);

        if ( lc != linkcount )
            InitLinkObjects(path);

        Quaternion linkrot1 = Quaternion.identity;

        linkrot1 = Quaternion.Euler(rotate);

        float spos = start * 0.01f;
        Vector3 poff = linkPivot * linkScale.x * LinkSize;
        float lastalpha = spos;
        Vector3 pos = Vector3.zero;

        Matrix4x4 pmat = Matrix4x4.TRS(poff, linkrot1, Vector3.one);

        Quaternion frot = Quaternion.identity;
        for ( int i = 0; i < linkcount; i++ )
        {
            float alpha = ((float)(i + 1) / (float)linkcount) + spos;
            Quaternion lq = GetLinkQuat(alpha, lastalpha, out pos, path);
            lastalpha = alpha;

            frot = lq * linkrot1;

            if ( linkobjs[i] )
            {
                Matrix4x4 lmat = Matrix4x4.TRS(pos, lq, Vector3.one) * pmat;

                linkobjs[i].localPosition = lmat.GetColumn(3);
                linkobjs[i].localRotation = frot;
                linkobjs[i].localScale = linkScale * LinkSize;
            }
        }
    }
开发者ID:jsr2k1,项目名称:videojocjj,代码行数:45,代码来源:MegaTracks.cs

示例13: ParseKnot

    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);
    }
开发者ID:Morac,项目名称:Orca6,代码行数:22,代码来源:MegaShapeSXL.cs

示例14: ClearAnim

	void ClearAnim(MegaShape shape)
	{
		MegaSpline spline = shape.splines[shape.selcurve];

		if ( spline.splineanim != null )
		{
			spline.splineanim.Init(spline);
		}
	}
开发者ID:Gounemond,项目名称:BretarisDemo,代码行数:9,代码来源:MegaShapeEditor.cs

示例15: AnimationKeyFrames

	// Animation keyframe stuff
	// Need system to grab state of curve
	void AnimationKeyFrames(MegaShape shape)
	{
		MegaSpline spline = shape.splines[shape.selcurve];

		shape.showanimations = EditorGUILayout.Foldout(shape.showanimations, "Animations");

		if ( shape.showanimations )
		{
			shape.keytime = EditorGUILayout.FloatField("Key Time", shape.keytime);
			if ( shape.keytime < 0.0f )
				shape.keytime = 0.0f;

			spline.splineanim.Enabled = EditorGUILayout.BeginToggleGroup("Enabled", spline.splineanim.Enabled);
			EditorGUILayout.BeginHorizontal();
			//if ( spline.splineanim == null )
			//{
			//}
			//else
			{
				//if ( GUILayout.Button("Create") )
				//{
					//spline.splineanim = new MegaSplineAnim();
					//spline.splineanim.Init(spline);
				//}

				if ( GUILayout.Button("Add Key") )
				{
					AddKeyFrame(shape, shape.keytime);
				}

				if ( GUILayout.Button("Clear") )
				{
					ClearAnim(shape);
				}

				//if ( GUILayout.Button("Delete") )
				//{
				//	spline.splineanim = null;
				//}
			}

			EditorGUILayout.EndHorizontal();
			//if ( spline.splineanim == null )
			//	return;

			// Need to show each keyframe
			if ( spline.splineanim != null )
			{
				//EditorGUILayout.LabelField("Frames " + spline.splineanim.knots[0].)
				int nk = spline.splineanim.NumKeys();

				float mt = 0.0f;
				for ( int i = 0; i < nk; i++ )
				{
					EditorGUILayout.BeginHorizontal();

					mt = spline.splineanim.GetKeyTime(i);

					EditorGUILayout.LabelField("" + i, GUILayout.MaxWidth(20));	//" + " Time: " + mt);
					float t = EditorGUILayout.FloatField("", mt, GUILayout.MaxWidth(100));

					if ( t != mt )
						spline.splineanim.SetKeyTime(spline, i, t);

					if ( GUILayout.Button("Delete", GUILayout.MaxWidth(50)) )
						spline.splineanim.RemoveKey(i);

					if ( GUILayout.Button("Update", GUILayout.MaxWidth(50)) )
						spline.splineanim.UpdateKey(spline, i);

					if ( GUILayout.Button("Get", GUILayout.MaxWidth(50)) )
					{
						spline.splineanim.GetKey(spline, i);
						EditorUtility.SetDirty(target);
					}

					EditorGUILayout.EndHorizontal();
				}

				shape.MaxTime = mt;

				float at = EditorGUILayout.Slider("T", shape.testtime, 0.0f, mt);
				if ( at != shape.testtime )
				{
					shape.testtime = at;
					if ( !shape.animate )
					{
						for ( int s = 0; s < shape.splines.Count; s++ )
						{
							if ( shape.splines[s].splineanim != null && shape.splines[s].splineanim.Enabled )
							{
								shape.splines[s].splineanim.GetState1(shape.splines[s], at);
								shape.splines[s].CalcLength();	//(10);	// could use less here
							}
						}
					}
				}
			}
//.........这里部分代码省略.........
开发者ID:Gounemond,项目名称:BretarisDemo,代码行数:101,代码来源:MegaShapeEditor.cs


注:本文中的MegaShape类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。