Skip to content

Latest commit

 

History

89 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Verlet Physic Engine

How to use

Verlet Objects can be instantiated by using the static methods from the Verlet class

  • Create a Scene Object
Scene scene = Verlet.createScene();
  • Add Constraint Objects to your Scene
// (xPos, yPos, constraintRadius)
Constraint circleConstraint = new CircleAreaConstraint(0, 0, 200);
scene.addConstraint(circleConstraint);
  • Add Sphere Objects to your Scene
// (xPos, yPos, sphereRadius)
Sphere sphere = Verlet.createSphere(-75, 25, 10);
scene.addSphere(sphere);
  • Create a Solver in order to run the Simulation
Solver solver = Verlet.createSolver(scene);
  • Instantiate a JPanel which will render your Scene
VerletPanel panel = new VerletPanel(scene);

// Assuming there is a JFrame present
frame.add(panel);
  • Setup runtime
public void tick() {
  // Steps the entire simulation. Parameter decides how far it steps
  solver.step(0.02f);

  // Renders the new Scene onto the panel
  panel.repaint();
}

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages