Toxiclibs - VerletPhysics2D, setWorldBounds - setting issues

edited April 2014 in Library Questions

hi guys, I am playing with Toxiclibs, trying to set basic samples of VerletParticle2D. Behavior of my particle is weird..most of the time the particle glues on the edge of the frame after 2 or 3 bounce..see the picture attached weird behaviour Moreover the behavior of the particle bounce are decreasing weirdly.. Is there any settings that I missed with the VerletPhysic2D ? thanks for the help

    package toxitest;

    import processing.core.PApplet;
    import toxi.physics2d.*;
    import toxi.physics2d.behaviors.*;
    import toxi.processing.ToxiclibsSupport;
    import toxi.geom.*;


    public class ToxiTest extends PApplet {


        private VerletPhysics2D physics;
        private ToxiclibsSupport gfx;
        VerletParticle2D pA;
        VerletParticle2D pB;


        public void setup() {
            size(800,800);
            smooth();

            physics = new VerletPhysics2D();
            physics.addBehavior(new GravityBehavior(new Vec2D(0.0f,0.1f)));
            physics.setWorldBounds(new Rect(0,0,width, height));
            //physics.setDrag(0.05f);
            //physics.setNumIterations(100);
            //physics.setTimeStep(1.0f);

            gfx = new ToxiclibsSupport(this);

            pA = new VerletParticle2D(new Vec2D(30,30));
            pA.addForce(new Vec2D(1.1f,0.0f));
            physics.addParticle(pA);

        }

        public void draw() {
            //background(0);
            physics.update();
            pA.update();
            gfx.ellipse(new Ellipse(pA.x,pA.y,pA.getWeight()*10,pA.getWeight()*10));
        }


    }
Sign In or Register to comment.