Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
kiyuenc
kiyuenc's Profile
1
Posts
1
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
Points leaving trail in 3D
[2 Replies]
02-Oct-2013 03:52 PM
Forum:
Programming Questions
Hey guys I'm very new to processing, I just sketched some points moving in 3D I want them to leave a trail behind but I'm not sure how to code it.
I think this is the basic concept:
I need to get all PVector of the points moving then put them in Arraylist.
Then from the Array list of PVector I can loop to draw points.
Later on I want to use the points as a attractor to other agents.
This sounds easy but very hard as I only have limited amount of processing knowledge.
Someone please help!
Thanks in advance.
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));
}
}
void draw(){
background(255);
box.display();
for(int i = 0; i < agentCollection.size(); i++){
agent thisagent = (agent) agentCollection.get(i);
thisagent.run();
}
}
class agent{
//Global varaiables
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);
strokeWeight(10);
fill(0);
point(location.x,location.y,location.z);
}
}
class Box {
int boxsize = 300;
void display() {
strokeWeight(1);
stroke(0);
noFill();
box(boxsize);
}
}
«Prev
Next »
Moderate user : kiyuenc
Forum