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


C# MegaShape.InterpCurve3D方法代码示例

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


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

示例1: Deform

    Vector3 Deform(Vector3 p, MegaShape path, float percent, float off, Vector3 scale, float removeDof, Vector3 locoff, Vector3 sploff)
    {
        p = tm.MultiplyPoint3x4(p);
        p.x *= scale.x;
        p.y *= scale.y;
        p.z *= scale.z;

        p.z += off;
        p += locoff;
        float alpha = (p.z / path.splines[curve].length) + percent;
        float tw1 = 0.0f;

        Vector3 ps	= pathtm.MultiplyPoint(path.InterpCurve3D(curve, alpha, path.normalizedInterp, ref tw1) + sploff);
        Vector3 ps1	= pathtm.MultiplyPoint(path.InterpCurve3D(curve, alpha + (tangent * 0.001f), path.normalizedInterp) + sploff);

        if ( path.splines[curve].closed )
            alpha = Mathf.Repeat(alpha, 1.0f);
        else
            alpha = Mathf.Clamp01(alpha);

        if ( useTwist )
            tw = Quaternion.AngleAxis((twist * twistCrv.Evaluate(alpha)) + tw1, Vector3.forward);

        Vector3 relativePos = ps1 - ps;
        relativePos.y *= removeDof;

        Quaternion rotation = Quaternion.LookRotation(relativePos) * tw * meshrot;
        //wtm.SetTRS(ps, rotation, Vector3.one);
        MegaMatrix.SetTR(ref wtm, ps, rotation);

        wtm = mat * wtm;

        p.z = 0.0f;
        return wtm.MultiplyPoint3x4(p);
    }
开发者ID:Morac,项目名称:Orca6,代码行数:35,代码来源:MegaLoftLayerCloneSpline.cs

示例2: RenderGizmo

	static void RenderGizmo(MegaShape shape, GizmoType gizmoType)
	{
		if ( (gizmoType & GizmoType.Active) != 0 && Selection.activeObject == shape.gameObject )
		{
			if ( shape.splines == null || shape.splines.Count == 0 )
				return;

			DrawGizmos(shape, new Color(1.0f, 1.0f, 1.0f, 1.0f));
			Color col = Color.yellow;
			col.a = 0.5f;
			Gizmos.color = col;	//Color.yellow;
			CursorPos = shape.InterpCurve3D(shape.selcurve, shape.CursorPercent * 0.01f, true);
			Gizmos.DrawSphere(shape.transform.TransformPoint(CursorPos), shape.KnotSize * 0.01f);
			Handles.color = Color.white;

			if ( shape.handleType == MegaHandleType.Free )
			{
				int s = shape.selcurve;
				{
					for ( int p = 0; p < shape.splines[s].knots.Count; p++ )
					{
						if ( shape.drawKnots )	//&& s == shape.selcurve )
						{
							Gizmos.color = Color.green;
							Gizmos.DrawSphere(shape.transform.TransformPoint(shape.splines[s].knots[p].p), shape.KnotSize * 0.01f);
						}

						if ( shape.drawHandles )
						{
							Gizmos.color = Color.red;
							Gizmos.DrawSphere(shape.transform.TransformPoint(shape.splines[s].knots[p].invec), shape.KnotSize * 0.01f);
							Gizmos.DrawSphere(shape.transform.TransformPoint(shape.splines[s].knots[p].outvec), shape.KnotSize * 0.01f);
						}
					}
				}
			}
		}
		else
			DrawGizmos(shape, new Color(1.0f, 1.0f, 1.0f, 0.25f));

		if ( Camera.current )
		{
			Vector3 vis = Camera.current.WorldToScreenPoint(shape.transform.position);

			if ( vis.z > 0.0f )
			{
				Gizmos.DrawIcon(shape.transform.position, "MegaSpherify icon.png", false);
				Handles.Label(shape.transform.position, " " + shape.name);
			}
		}
	}
开发者ID:Gounemond,项目名称:BretarisDemo,代码行数:51,代码来源:MegaShapeEditor.cs

示例3: Deform

    Vector3 Deform(MegaShape path, float alpha, float off, Vector3 scale, float removeDof, Vector3 locoff, out Matrix4x4 omat, Vector3 sploff)
    {
        float tw1 = 0.0f;

        Vector3 ps	= pathtm.MultiplyPoint(path.InterpCurve3D(curve, alpha, path.normalizedInterp, ref tw1) + sploff);
        Vector3 ps1	= pathtm.MultiplyPoint(path.InterpCurve3D(curve, alpha + (tangent * 0.001f), path.normalizedInterp) + sploff);

        if ( path.splines[curve].closed )
            alpha = Mathf.Repeat(alpha, 1.0f);
        else
            alpha = Mathf.Clamp01(alpha);

        if ( useTwist )
            tw = meshrot * Quaternion.AngleAxis((twist * twistCrv.Evaluate(alpha)) + tw1, Vector3.forward);

        Vector3 relativePos = ps1 - ps;
        relativePos.y *= removeDof;

        Quaternion rotation = Quaternion.LookRotation(relativePos) * tw;
        wtm.SetTRS(ps, rotation, scale);

        omat = mat * wtm;

        return ps;
    }
开发者ID:Morac,项目名称:Orca6,代码行数:25,代码来源:MegaLoftLayerScatterSpline.cs

示例4: InitFromShape

    void InitFromShape(MegaShape shape)
    {
        float len = shape.splines[0].length;	// adjust by and pre stretch

        //Debug.Log("Length " + len + "m");
        float volume = len * 2.0f * Mathf.PI * radius;
        //Debug.Log("Volume " + volume + "m3");
        float totalmass = Density * volume;

        // Option for fill or set count, or count per unit
        len *= 0.75f;
        int nummasses = (int)(len / radius) + 1;
        //Debug.Log("Num Masses " + nummasses);

        float m = totalmass / (float)nummasses;

        if ( DampingRatio > 1.0f )
            DampingRatio = 1.0f;

        damp = (DampingRatio * 0.45f) * (2.0f * Mathf.Sqrt(m * spring));

        // The Max spring rate is based on m
        //float dmpratio = damp / (2.0f * Mathf.Sqrt(m * spring));
        //Debug.Log("Current Damp Ratio " + dmpratio);

        //float dmp = DampingRatio * (2.0f * Mathf.Sqrt(m * spring));
        //Debug.Log("TotalMass " + totalmass + "kg element mass " + m + "kg damp " + damp);

        // Mmm or should me move along iters by radius * 2
        RopeLength = 0.0f;

        if ( masses == null )
            masses = new List<MegaRopeMass>();

        transform.position = Vector3.zero;

        masses.Clear();
        //float ms = Mass / (float)(points + 1);

        float rlen = 0.0f;
        Vector3 lastpos = Vector3.zero;

        for ( int i = 0; i <= nummasses; i++ )
        {
            float alpha = (float)i / (float)nummasses;	//points;

            //Vector3 pos = shape.transform.localToWorldMatrix.MultiplyPoint(shape.InterpCurve3D(0, alpha, true));
            Vector3 pos = shape.transform.TransformPoint(shape.InterpCurve3D(0, alpha, true));

            if ( i != 0 )
            {
                rlen += Vector3.Distance(lastpos, pos);
                lastpos = pos;
            }
            MegaRopeMass rm = new MegaRopeMass(m, pos);
            masses.Add(rm);
        }

        if ( springs == null )
            springs = new List<MegaRopeSpring>();

        springs.Clear();

        if ( constraints == null )
            constraints = new List<MegaRopeConstraint>();

        constraints.Clear();

        for ( int i = 0; i < masses.Count - 1; i++ )
        {
            MegaRopeSpring spr = new MegaRopeSpring(i, i + 1, spring, damp, this);
            springs.Add(spr);

            //spr.restlen = (rlen / masses.Count);	// * 1.1f;
            RopeLength += spr.restlen;

            LengthConstraint lcon = new LengthConstraint(i, i + 1, spr.restlen);
            constraints.Add(lcon);
        }

        if ( stiffsprings )
        {
            int gap = 2;
            for ( int i = 0; i < masses.Count - gap; i++ )
            {
                float alpha = (float)i / (float)masses.Count;

                // BUG: For a curve shape, len for stuff springs should be sum of springs we span
                MegaRopeSpring spr = new MegaRopeSpring(i, i + gap, stiffspring * stiffnessCrv.Evaluate(alpha), stiffdamp * stiffnessCrv.Evaluate(alpha), this);

                //spr.restlen = (springs[i].restlen + springs[i + 1].restlen);	// * 1.1f;
                //spr.restlen = (RopeLength / masses.Count) * 2.0f;	//(springs[i].restlen + springs[i + gap].restlen) * 1.0f;

                // TODO: Add these for rope, not needed for chain
                springs.Add(spr);

                LengthConstraint lcon = new LengthConstraint(i, i + gap, spr.restlen);	//(RopeLength / masses.Count) * 2.0f);	//spr.restlen);
                constraints.Add(lcon);
            }
        }
//.........这里部分代码省略.........
开发者ID:Morac,项目名称:Orca6,代码行数:101,代码来源:MegaRope.cs

示例5: RenderGizmo

    static void RenderGizmo(MegaShape shape, GizmoType gizmoType)
    {
        //if ( (gizmoType & GizmoType.NotSelected) != 0 )
        {
            if ( (gizmoType & GizmoType.Active) != 0 )
            {
                if ( shape.splines == null || shape.splines.Count == 0 )
                    return;

                DrawGizmos(shape, new Color(1.0f, 1.0f, 1.0f, 1.0f));
                Color col = Color.yellow;
                col.a = 0.5f;
                Gizmos.color = col;	//Color.yellow;
                CursorPos = shape.InterpCurve3D(shape.selcurve, shape.CursorPercent * 0.01f, true);
                Gizmos.DrawSphere(shape.transform.TransformPoint(CursorPos), shape.KnotSize * 0.01f);
                Handles.color = Color.white;
                //Handles.Label(shape.transform.TransformPoint(CursorPos), "Cursor " + CursorPercent.ToString("0.00") + "% - " + CursorPos);

                if ( shape.handleType == MegaHandleType.Free )
                {
                    //for ( int s = 0; s < shape.splines.Count; s++ )
                    int s = shape.selcurve;
                    {
                        for ( int p = 0; p < shape.splines[s].knots.Count; p++ )
                        {
                            if ( shape.drawKnots )	//&& s == shape.selcurve )
                            {
                                Gizmos.color = Color.green;
                                Gizmos.DrawSphere(shape.transform.TransformPoint(shape.splines[s].knots[p].p), shape.KnotSize * 0.01f);
                            }

                            if ( shape.drawHandles )
                            {
                                Gizmos.color = Color.red;
                                Gizmos.DrawSphere(shape.transform.TransformPoint(shape.splines[s].knots[p].invec), shape.KnotSize * 0.01f);
                                Gizmos.DrawSphere(shape.transform.TransformPoint(shape.splines[s].knots[p].outvec), shape.KnotSize * 0.01f);
                            }
                        }
                    }
                }
            }
            else
                DrawGizmos(shape, new Color(1.0f, 1.0f, 1.0f, 0.25f));
        }
        Gizmos.DrawIcon(shape.transform.position, "MegaSpherify icon.png", false);
        Handles.Label(shape.transform.position, " " + shape.name);
    }
开发者ID:jsr2k1,项目名称:gato-book-test,代码行数:47,代码来源:MegaShapeEditor.cs


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