Points leaving trail in 3D [solved]

edited October 2013 in Questions about Code

taking up on an old discussion from the old forum by kiyuenc named

Points leaving trail in 3D

http://forum.processing.org/one/topic/points-leaving-trail-in-3d.html

for some unknown reason, background didn't work you need to use

  fill(0, 0, 0, 7);
  noStroke();
  rect(-2000, -2000, width+2000, height+2000);

instead.

this doesn't work with peasy cam of course, so when you rotate the cam, it gets distorted.

Whole sketch :

import peasy.*;
ArrayList agentCollection;

PeasyCam KCam;
Box box = new Box();

PVector location;
PVector speed;

// --------------------------------------------------------

void setup() {
  //
  size(600, 600, P3D);
  smooth();
  KCam = new PeasyCam(this, 800);

  agentCollection = new ArrayList();


  for (int i = 0; i < 20 ; i++) {
    speed = new PVector(random(-1, 1), random(-1, 1), random(-1, 1));
    agentCollection.add(new agent(speed));
  }
  background(0);
}

void draw() {



  for (int i = 0; i < agentCollection.size(); i++) {
    agent thisagent = (agent) agentCollection.get(i);
    thisagent.run();
  }
  //
  fill(0, 0, 0, 7);
  noStroke();
  rect(-2000, -2000, width+2000, height+2000);
  //
  box.display();
}

// ===============================================================

class agent {

  //Global variables
  PVector location = new PVector();
  PVector speed;

  //constructor

  agent(PVector speed) {
    this.speed = speed;
  }

  void run() {
    update();
    display();
  }


  void update() {
    location.add(speed);
  }

  void display() {
    stroke(0, 0, 255);
    strokeWeight(10);
    fill(0);
    point(location.x, location.y, location.z);
  }
}

// ===============================================================

class Box {
  int boxsize = 300;

  void display() {
    strokeWeight(1);
    stroke(255);
    noFill();
    box(boxsize);
  }
}
// ===============================================================
Tagged:

Comments

Sign In or Register to comment.