예제 #1
0
        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);
                    }
                }
            }
        }
예제 #2
0
        public override void OnEnable()
        {
            base.OnEnable();
            rope = (ObiRope)target;

            particlePropertyNames.AddRange(new string[] { "Tear Resistance" });
        }
예제 #3
0
        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());
        }
예제 #4
0
        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");
        }
예제 #5
0
 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);
     }
 }
예제 #6
0
        public override void OnEnable()
        {
            base.OnEnable();
            rope       = (ObiRope)target;
            chainLinks = serializedObject.FindProperty("chainLinks");

            particlePropertyNames.AddRange(new string[] { "Tear Resistance" });
        }
예제 #7
0
 public void UpdateCursor()
 {
     rope            = GetComponent <ObiRope>();
     m_CursorElement = null;
     if (rope.isLoaded)
     {
         float elmMu;
         m_CursorElement = rope.GetElementAt(cursorMu, out elmMu);
     }
 }
예제 #8
0
        private void Awake()
        {
            rope = GetComponent <ObiRope>();

            rope.OnElementsGenerated += Actor_OnElementsGenerated;
            if (rope.elements != null && rope.elements.Count > 0)
            {
                Actor_OnElementsGenerated(rope);
            }
        }
예제 #9
0
        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;
        }
예제 #10
0
        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;
        }
예제 #11
0
 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;
         }
     }
 }
예제 #12
0
 public void Awake()
 {
     rope = GetComponent <ObiRope>();
 }
예제 #13
0
 public void Awake()
 {
     cursor = GetComponent <ObiRopeCursor>();
     rope   = GetComponent <ObiRope>();
 }