Exemplo n.º 1
0
 public void clear()
 {
     Destroy(_bob);
     Destroy(_line);
     _pendulum = null;
 }
Exemplo n.º 2
0
        private VisualPendulum(Vector3 position_, Vector3 equilibrium_position_, float mass_, float gravity_, float dt_, bool show_lines_)
        {
            _line_width = 0.02f;
            _draw_lines = show_lines_;

            Vector3 static_position = new Vector3(0f, 0f, position_.z);
            float radius = (0.5f * mass_);

            SPL.Particle point_a = SPL.StaticParticle.make(static_position, radius);
            SPL.Particle point_b = SPL.VerletParticle.make(position_, Vector3.zero, mass_, radius, gravity_, dt_);
            SPL.IConstraint fixed_distance = SPL.FixedDistanceConstraint.make(point_a, point_b);
            _pendulum = SPL.Pendulum.make(point_a, point_b, equilibrium_position_, render, fixed_distance);

            _bob = (GameObject)GameObject.Instantiate(GameObject.Find("Bob Template"));
            _line = (GameObject)GameObject.Instantiate(GameObject.Find("Line Template"));
            _bob.transform.parent = GameObject.Find("Scene Objects").transform;
            _line.transform.parent = GameObject.Find("Scene Objects").transform;
            _line_renderer = _line.AddComponent<LineRenderer>();
            _line_renderer.material = Resources.Load<Material>("Line");
            _line_renderer.SetWidth(_line_width, _line_width);

            render(point_a, point_b);
        }