public void OnSceneGUI() { if (Event.current.type == EventType.Repaint) { ObiRope rope = cursor.GetComponent <ObiRope>(); ObiDistanceConstraintBatch distanceBatch = rope.DistanceConstraints.GetFirstBatch(); Handles.color = Color.yellow; int constraint = rope.GetConstraintIndexAtNormalizedCoordinate(cursor.normalizedCoord); Vector3 pos1 = rope.GetParticlePosition(distanceBatch.springIndices[constraint * 2]); Vector3 pos2 = rope.GetParticlePosition(distanceBatch.springIndices[constraint * 2 + 1]); if (cursor.direction) { Handles.DrawWireDisc(pos1, pos2 - pos1, rope.thickness * 2); Vector3 direction = pos2 - pos1; if (direction != Vector3.zero) { Handles.ArrowHandleCap(0, pos1, Quaternion.LookRotation(direction), 0.2f, EventType.Repaint); } } else { Handles.DrawWireDisc(pos2, pos1 - pos2, rope.thickness * 2); Vector3 direction = pos1 - pos2; if (direction != Vector3.zero) { Handles.ArrowHandleCap(0, pos2, Quaternion.LookRotation(direction), 0.2f, EventType.Repaint); } } } }
public override void OnEnable() { base.OnEnable(); rope = (ObiRope)target; particlePropertyNames.AddRange(new string[] { "Tear Resistance" }); }
void Start() { // Get all needed components and interconnect them: rope = GetComponent <ObiRope>(); path = GetComponent <ObiCurve>(); rope.Solver = solver; rope.ropePath = path; //rope.section = section; GetComponent <MeshRenderer>().material = material; // Calculate rope start/end and direction in local space: Vector3 localStart = transform.InverseTransformPoint(start.position); Vector3 localEnd = transform.InverseTransformPoint(end.position); Vector3 direction = (localEnd - localStart).normalized; // Generate rope path: path.controlPoints.Clear(); path.controlPoints.Add(new ObiCurve.ControlPoint(localStart - direction, Vector3.up)); path.controlPoints.Add(new ObiCurve.ControlPoint(localStart, Vector3.up)); path.controlPoints.Add(new ObiCurve.ControlPoint(localEnd, Vector3.up)); path.controlPoints.Add(new ObiCurve.ControlPoint(localEnd + direction, Vector3.up)); // Setup the simulation: StartCoroutine(Setup()); }
public void OnEnable() { actor = (ObiRope)target; ropeBlueprint = serializedObject.FindProperty("m_RopeBlueprint"); collisionMaterial = serializedObject.FindProperty("m_CollisionMaterial"); selfCollisions = serializedObject.FindProperty("m_SelfCollisions"); surfaceCollisions = serializedObject.FindProperty("m_SurfaceCollisions"); distanceConstraintsEnabled = serializedObject.FindProperty("_distanceConstraintsEnabled"); stretchingScale = serializedObject.FindProperty("_stretchingScale"); stretchCompliance = serializedObject.FindProperty("_stretchCompliance"); maxCompression = serializedObject.FindProperty("_maxCompression"); bendConstraintsEnabled = serializedObject.FindProperty("_bendConstraintsEnabled"); bendCompliance = serializedObject.FindProperty("_bendCompliance"); maxBending = serializedObject.FindProperty("_maxBending"); plasticYield = serializedObject.FindProperty("_plasticYield"); plasticCreep = serializedObject.FindProperty("_plasticCreep"); tearingEnabled = serializedObject.FindProperty("tearingEnabled"); tearResistanceMultiplier = serializedObject.FindProperty("tearResistanceMultiplier"); tearRate = serializedObject.FindProperty("tearRate"); }
private static void DrawGizmos(ObiRope actor, GizmoType gizmoType) { Handles.color = Color.white; if (actor.ropeBlueprint != null) { ObiPathHandles.DrawPathHandle(actor.ropeBlueprint.path, actor.transform.localToWorldMatrix, actor.ropeBlueprint.thickness, 20, false); } }
public override void OnEnable() { base.OnEnable(); rope = (ObiRope)target; chainLinks = serializedObject.FindProperty("chainLinks"); particlePropertyNames.AddRange(new string[] { "Tear Resistance" }); }
public void UpdateCursor() { rope = GetComponent <ObiRope>(); m_CursorElement = null; if (rope.isLoaded) { float elmMu; m_CursorElement = rope.GetElementAt(cursorMu, out elmMu); } }
private void Awake() { rope = GetComponent <ObiRope>(); rope.OnElementsGenerated += Actor_OnElementsGenerated; if (rope.elements != null && rope.elements.Count > 0) { Actor_OnElementsGenerated(rope); } }
static void CreateObiRope() { GameObject c = new GameObject("Obi Rope"); Undo.RegisterCreatedObjectUndo(c, "Create Obi Rope"); ObiRope rope = c.AddComponent <ObiRope>(); ObiCatmullRomCurve path = c.AddComponent <ObiCatmullRomCurve>(); ObiSolver solver = c.AddComponent <ObiSolver>(); rope.Solver = solver; rope.section = Resources.Load <ObiRopeSection>("DefaultRopeSection"); rope.ropePath = path; }
static void CreateObiRope() { GameObject c = new GameObject("Obi Rope"); Undo.RegisterCreatedObjectUndo(c, "Create Obi Rope"); ObiRope rope = c.AddComponent <ObiRope>(); ObiCurve path = c.AddComponent <ObiCurve>(); ObiSolver solver = c.AddComponent <ObiSolver>(); c.AddComponent <ObiRopeExtrudedRenderer>(); rope.Solver = solver; rope.ropePath = path; }
public void UpdateSource() { rope = GetComponent <ObiRope>(); m_SourceIndex = -1; if (rope.isLoaded) { float elmMu; var elm = rope.GetElementAt(sourceMu, out elmMu); if (elm != null && rope.solver != null) { m_SourceIndex = elmMu < 0.5f ? elm.particle1 : elm.particle2; } } }
public void Awake() { rope = GetComponent <ObiRope>(); }
public void Awake() { cursor = GetComponent <ObiRopeCursor>(); rope = GetComponent <ObiRope>(); }