Exemple #1
0
 public ArrayList getEdgeParticles()
 {
     if (_edgePositions.Count == 0)
     {
         getEdgePositions();
     }
     if (_edgeParticles.Count == 0)
     {
         CircleParticle cp1 = new CircleParticle(0, 0, 1, false, 1, 0.3, 0, Color.Black, "edgeparticle");
         cp1.setCollidable(false);
         cp1.setVisible(false);
         APEngine.addParticle(cp1);
         CircleParticle cp2 = new CircleParticle(0, 0, 1, false, 1, 0.3, 0, Color.Black, "edgeparticle");
         cp2.setCollidable(false);
         cp2.setVisible(false);
         APEngine.addParticle(cp2);
         CircleParticle cp3 = new CircleParticle(0, 0, 1, false, 1, 0.3, 0, Color.Black, "edgeparticle");
         cp3.setCollidable(false);
         cp3.setVisible(false);
         APEngine.addParticle(cp3);
         CircleParticle cp4 = new CircleParticle(0, 0, 1, false, 1, 0.3, 0, Color.Black, "edgeparticle");
         cp4.setCollidable(false);
         cp4.setVisible(false);
         APEngine.addParticle(cp4);
         _edgeParticles.Add(cp1);
         _edgeParticles.Add(cp2);
         _edgeParticles.Add(cp3);
         _edgeParticles.Add(cp4);
         updateEdgeParticles();
     }
     return(_edgeParticles);
 }
Exemple #2
0
        public void update(double dt)
        {
            sp = Math.Max(-maxTorque, Math.Min(maxTorque, sp + av));
            double dx  = -curr.y;
            double dy  = curr.x;
            double len = Math.Sqrt(dx * dx + dy * dy);

            dx     = dx / len;
            dy     = dy / len;
            curr.x = curr.x + sp * dx;
            curr.y = curr.y + sp * dy;
            double ox = prev.x;
            double oy = prev.y;

            prev.x = curr.x;
            double px = prev.x;

            //= curr.x
            prev.y = curr.y;
            double py = prev.y;

            //= curr.y
            curr.x = curr.x + APEngine.getDamping() * (px - ox);
            curr.y = curr.y + APEngine.getDamping() * (py - oy);
            double clen = Math.Sqrt(curr.x * curr.x + curr.y * curr.y);
            double diff = (clen - wr) / clen;

            curr.x = curr.x - curr.x * diff;
            curr.y = curr.y - curr.y * diff;
        }
        protected Graphics getDefaultContainer()
        {
            if (APEngine.getDefaultContainer() == null)
            {
                String err = "";
                err += "You must set the defaultContainer property of the APEngine class ";
                err += "if you wish to use the default paint methods of the constraints";
                throw new Error1();
            }
            Graphics parentContainer = APEngine.getDefaultContainer();

            return(parentContainer);
        }
        public Graphics getDefaultContainer()
        {
            if (APEngine.getDefaultContainer() == null)
            {
                String err = "";
                err += "You must set the defaultContainer property of the APEngine class ";
                err += "if you wish to use the default paint methods of the particles";
                throw new Error1();
                //](err)
            }
            Graphics parentContainer = APEngine.getDefaultContainer();

            return(parentContainer);
        }
        public virtual void update(double dt2)
        {
            if (_fixed)
            {
                return;

                return;
            }
            addForce(APEngine.force);
            addMasslessForce(APEngine.masslessForce);
            temp.copy(curr);
            Vector nv = getVelocity().plus(forces.multEquals(dt2));

            curr.plusEquals(nv.multEquals(APEngine.getDamping()));
            prev.copy(temp);
            forces.setTo(0, 0);
        }
        public virtual void resolveCollision(Vector mtd, Vector vel, Vector n, double d, double o)
        {
            curr.plusEquals(mtd);
            switch (APEngine.getCollisionResponseMode())
            {
            case APEngine.STANDARD:
                setVelocity(vel);
                break;

            //   Exit Select
            case APEngine.SELECTIVE:
                if (!isColliding)
                {
                    setVelocity(vel);
                }
                isColliding = true;
                break;

            // Exit Select
            case APEngine.SIMPLE:
                break;
                // Exit Select
            }
        }