public override void Action() { var mb = SplinePathMeshBuilder.Create(); mb.Spline = (CurvySplineBase)Toolbar.Selection[0]; Selection.activeGameObject = mb.gameObject; Undo.RegisterCreatedObjectUndo(Selection.activeGameObject, "Create Mesh Builder"); }
public CurvyMeshSegmentInfo(SplinePathMeshBuilder mb, float tf, float distance, Vector3 scale) { Target = mb.Spline; TF = tf; mDistance = distance; Vector3 p = (mb.FastInterpolation) ? Target.InterpolateFast(TF) : Target.Interpolate(TF); if (mb.UseWorldPosition) Matrix = Matrix4x4.TRS(mb.Transform.InverseTransformPoint(p), Target.GetOrientationFast(TF), scale); else Matrix = Matrix4x4.TRS(Target.Transform.InverseTransformPoint(p), Target.GetOrientationFast(TF), scale); }
// this method is called by SplinePathMeshBuilder to get the mesh scale for a certain tf Vector3 SplineMesh_OnGetScale(SplinePathMeshBuilder sender, float tf) { if (insideMesh) { // determine the scale we want at the sphere's position float spherePos = Walker.Spline.TFToDistance(Walker.TF); float scalePos = Walker.Spline.TFToDistance(tf); float delta = spherePos - scalePos; float d=Mathf.Abs(delta); float s=0; if (d<=sphereRadius){ s = Mathf.Cos(d / sphereRadius); } return Vector3.one + Vector3.one*s; } return Vector3.one; }
public CurvyMeshSegmentInfo(SplinePathMeshBuilder mb, float tf, float distance, Vector3 scale) { Target = mb.Spline; TF = tf; mDistance = distance; Vector3 p = (mb.FastInterpolation) ? Target.InterpolateFast(TF) : Target.Interpolate(TF); if (mb.UseWorldPosition) { Matrix = Matrix4x4.TRS(mb.Transform.InverseTransformPoint(p), Target.GetOrientationFast(TF), scale); } else { Matrix = Matrix4x4.TRS(Target.transform.InverseTransformPoint(p), Target.GetOrientationFast(TF), scale); } }
// this method is called by SplinePathMeshBuilder to get the mesh scale for a certain tf Vector3 SplineMesh_OnGetScale(SplinePathMeshBuilder sender, float tf) { if (insideMesh) { // determine the scale we want at the sphere's position float spherePos = Walker.Spline.TFToDistance(Walker.TF); float scalePos = Walker.Spline.TFToDistance(tf); float delta = spherePos - scalePos; float d = Mathf.Abs(delta); float s = 0; if (d <= sphereRadius) { s = Mathf.Cos(d / sphereRadius); } return(Vector3.one + Vector3.one * s); } return(Vector3.one); }
public static void CreateMeshBuilder() { var path = SplinePathMeshBuilder.Create(); var prim = GameObject.CreatePrimitive(PrimitiveType.Plane); #if UNITY_3_5_7 prim.active = false; #else prim.SetActive(false); #endif path.GetComponent <MeshRenderer>().sharedMaterial = prim.GetComponent <MeshRenderer>().sharedMaterial; DestroyImmediate(prim); if (Selection.activeGameObject) { CurvySplineBase spl = Selection.activeGameObject.GetComponent <CurvySplineBase>(); if (spl) { path.Spline = spl; } } Selection.activeGameObject = path.gameObject; }