Commit a259c851 authored by Ant01n3's avatar Ant01n3

Ok.

parent d56143b2
......@@ -92,27 +92,37 @@ public class Boid extends AdjacencyListNode {
}
protected void checkNeighborhood(BoidParticle... particles) {
System.err.printf("Boid %s :%n", id);
if (particles != null) {
Iterator<Boid> it = getNeighborNodeIterator();
LinkedList<Boid> toRemove = null;
System.err.printf("Sees [ ");
for(BoidParticle p : particles) {
System.err.printf("%s ", p.getBoid().id);
}
System.err.printf("]%nHas Neighbors [ ");
while (it.hasNext()) {
boolean found = false;
Boid b = it.next();
for (BoidParticle p : particles)
for (BoidParticle p : particles) {
if (p.getId().equals(b.getParticle().getId())) {
found = true;
break;
}
}
System.err.printf("%s(%b)", b.id, found);
if (!found && !forces.isVisible(b.particle, this.getPosition())) {
if (toRemove == null)
toRemove = new LinkedList<Boid>();
System.err.printf("(del)");
toRemove.add(b);
}
}
System.err.printf("%n");
if (toRemove != null) {
for (Boid b : toRemove)
......@@ -121,13 +131,16 @@ public class Boid extends AdjacencyListNode {
toRemove.clear();
toRemove = null;
}
System.err.printf("adds link to [ ");
for (BoidParticle p : particles) {
if (getEdgeBetween(p.getBoid().getId()) == null)
if (getEdgeBetween(p.getBoid().getId()) == null) {
getGraph().addEdge(getEdgeId(this, p.getBoid()), getId(),
p.getBoid().getId());
System.err.printf("%s ", p.getBoid().id);
}
}
}
System.err.printf("]%n");
}
public static final String getEdgeId(Boid b1, Boid b2) {
......
......@@ -191,7 +191,7 @@ public class Context extends AdjacencyListGraph {
boidSpecies = new HashMap<String, BoidSpecies>();
//boidSpecies.put("default", new BoidSpecies(this, "default"));
getOrCreateSpecies("default");
space = new OctreeCellSpace(new Anchor(-2, -2, -2), new Anchor(2, 2, 2));
space = new OctreeCellSpace(new Anchor(-area, -area, -area), new Anchor(area, area, area));
pbox = new ParticleBox(maxParticlesPerCell, space, new BoidCellData());
}
......
......@@ -8,6 +8,7 @@ import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.Timer;
import org.graphstream.boids.BoidSpecies;
import org.graphstream.boids.Context;
import org.graphstream.ui.swingViewer.Viewer;
import org.graphstream.ui.swingViewer.util.Camera;
......@@ -83,7 +84,9 @@ public class GUI extends JFrame implements ActionListener
public static void main(String args[]) {
Context ctx = new Context();
GUI gui = new GUI(ctx);
BoidSpecies species = ctx.getDefaultSpecies();
species.angleOfView = 0;
for (int i = 0; i < 100; i++)
ctx.addNode(String.format("boid%03d", i));
......
......@@ -57,7 +57,7 @@ public class ParticleViewer extends JPanel implements ParticleBoxListener,
protected float near = 1f;
protected float radius = 1.03f, theta, phi;
protected float radius = 1.3f, theta, phi;
protected Point3 camera;
......@@ -67,7 +67,7 @@ public class ParticleViewer extends JPanel implements ParticleBoxListener,
protected Cube env;
protected Color background = new Color(0, 0, 0);
protected Color background = new Color(255, 255, 255);
// Constructors
......@@ -201,7 +201,7 @@ public class ParticleViewer extends JPanel implements ParticleBoxListener,
public void display(Buffer buffer) {
setView();
// displayEnv();
displayEnv();
displayParticles();
}
......
......@@ -479,6 +479,7 @@ public class SwingBuffer
public void display()
{
canvas.display();
canvas.swapBuffers();
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment