Android Open Source - Verlet Composite






From Project

Back to project page Verlet.

License

The source code is released under:

Copyright 2013 Devicement http://devicement.com/ Copyright 2013 Sub Protocol and other contributors http://subprotocol.com/ Permission is hereby granted, free of charge, to any person obtaining a co...

If you think the Android project Verlet listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.verletandroid.VerletCore;
/*ww  w. j a  v  a2  s  .  c o  m*/
import org.verletandroid.Graphics.IGraphics;
import org.verletandroid.VerletCore.Contraints.IConstraint;
import org.verletandroid.VerletCore.Contraints.PinConstraint;

import java.util.ArrayList;

/**
 * Created with IntelliJ IDEA.
 * User: George
 * Date: 28.04.13
 * Time: 22:32
 * To change this template use File | Settings | File Templates.
 */
public abstract class Composite {

    public ArrayList<Particle> getParticles() {
        return particles;
    }

    public void setParticles(ArrayList<Particle> particles) {
        this.particles = particles;
    }

    public ArrayList<IConstraint> getConstraints() {
        return constraints;
    }

    public void setConstraints(ArrayList<IConstraint> constraints) {
        this.constraints = constraints;
    }

    protected ArrayList<Particle> particles = new ArrayList<Particle>();
        protected ArrayList<IConstraint> constraints = new ArrayList<IConstraint>();

    public void draw(IGraphics graphics)
    {
        drawConstraints(graphics);
        drawParticles(graphics);
    }

    public void drawParticles(IGraphics graphics)
    {
        for(IEntity particle:particles) {
            particle.draw(graphics);
        }
    }

    public IEntity pin(int index, Vec2 _pos)
    {
        Vec2 pos = _pos != null ? _pos : particles.get(index).getPos();
        IConstraint pc = new PinConstraint(particles.get(index), pos);
        constraints.add(pc);
        return pc;
    }

    public IEntity pin(int index)
    {
        return pin(index, null);
    }

    public void drawConstraints(IGraphics graphics)
    {
        for(IEntity constraint:constraints) {
            constraint.draw(graphics);
        }
    }


}




Java Source Code List

com.northerneyes.VerletObjects.SpiderWeb.java
com.northerneyes.VerletObjects.Spider.java
com.northerneyes.VerletObjects.Tree.java
com.northerneyes.activities.MainActivity.java
com.northerneyes.activities.SampleList.java
org.verletandroid.Graphics.Graphics.java
org.verletandroid.Graphics.IGraphics.java
org.verletandroid.Graphics.IPixmap.java
org.verletandroid.Graphics.PixmapFormat.java
org.verletandroid.Graphics.Pixmap.java
org.verletandroid.Handlers.AccelerometerVerletHandler.java
org.verletandroid.Handlers.InputVerletHandler.java
org.verletandroid.Handlers.MultyTouchVerletHandler.java
org.verletandroid.VerletCore.Composite.java
org.verletandroid.VerletCore.IEntity.java
org.verletandroid.VerletCore.Particle.java
org.verletandroid.VerletCore.Utils.java
org.verletandroid.VerletCore.Vec2.java
org.verletandroid.VerletCore.Verlet.java
org.verletandroid.VerletCore.Contraints.AngleConstraint.java
org.verletandroid.VerletCore.Contraints.DistanceConstraint.java
org.verletandroid.VerletCore.Contraints.IConstraint.java
org.verletandroid.VerletCore.Contraints.PinConstraint.java
org.verletandroid.VerletCore.Objects.Cloth.java
org.verletandroid.VerletCore.Objects.LineSegments.java
org.verletandroid.VerletCore.Objects.Tire.java
org.verletandroid.componets.IUpdatable.java
org.verletandroid.componets.RenderView.java