I have a processing script with multiple 3D animated spheres in OpenGL. I am getting rid of the background() in order to pan or zoom the camera and have the trails of the spheres drawn on the canvas.
So, I would like to capture the drawing created as I already described, as a PDF file. However the options that I have already tried based on the create PDF file found here:
http://processing.org/reference/libraries/pdf/
do not seem to function.
Do you have any idea what can I do? It's more or less something like a print screen but with kind of huge resolution...
I have coded a simple autonomous agents 3D environment and I trigger some events based on a "counter" a variable that takes integer values from 0 to 180. There is a public class for the basics and some subclasses that define some additional parameters for each group of agents. Every agent is being represented as a 3D shere.
What I want to do is to create something like a trail of spheres (for each agent) that depicts its path while flying. Something like this but in 3D:
I have a 3D sketch and I added a
timeline slider using controlP5 configurations. However, it seems that the entire slider turns when I turn the camera...
How can I make it "lock" on a specific place on the canvas? What am I doin' wrong?
Here's part of the script with all arrangements for the slider marked in yellow:
import peasy.org.apache.commons.math.*; // imports all 3D related libraries
import peasy.*;
import peasy.org.apache.commons.math.geometry.*;
import processing.opengl.*;
import controlP5.*; // library for the slider - interface
ControlP5 controlP5;
Slider timeline_slider;
PeasyCam cam;
PMatrix3D currCameraMatrix;
PGraphics3D g3;
float worldSize = 300; // the space - rendered as a cube - limiting agents movement
StopWatchTimer sw; // a visual timer-clock implementation on canvas
work.Default(); // main-basic functions of (W) facility
retail.Default(); // main-basic functions of (R) facility
school.Default(); // main-basic functions of (S) facility
leisure.Default(); // main-basic functions of (L) facility
PVector vectorOfwork = new PVector(work.location.x, work.location.y, work.location.z); // creates a vector that connects all individual agents with the (W) facility
PVector vectorOfretail = new PVector(retail.location.x, retail.location.y, retail.location.z); // creates a vector that connects all individual agents with the (R) facility
PVector vectorOfschool = new PVector(school.location.x, school.location.y, school.location.z); // creates a vector that connects all individual agents with the (S) facility
PVector vectorOfleisure = new PVector(leisure.location.x, leisure.location.y, leisure.location.z); // creates a vector that connects all individual agents with the (L) facility
int i = 0; // i & j make sure that each agent returns to the family it belongs
I'm gonna need your help for this one. I have scripted a 3D environment with 7 different groups of autonomous agents flocking around. I use a public class and some subclasses for each of the different group of agents. I use an arrayList in order to create them; something like this:
for (int i = 0; i < 115; i++) {
if (i < 20) agents.add(new MW1 (150,150,150,color(255,0,0),i)); // Red
else if (i < 45) agents.add(new FW1 (100,100,100,color(0,255,0),i)); // Green
else if (i < 65) agents.add(new MW2 (200,200,200,color(0,255,255),i)); // Cyan
else if (i < 85) agents.add(new FnW2 (80,80,80,color(0,155,0),i)); // dark Green
else if (i < 95) agents.add(new MW3 (130,130,130,color(255,255,0),i)); // Yellow
else if (i < 105) agents.add(new FnW3 (60,60,60,color(255,0,255),i)); // Purple
else agents.add(new CS3 (10,10,10,color(0,0,255),i)); // Blue
}
btw the constructor of the superclass looks like this:
Capsule(float x, float y, float z, color c, int nam) { // the class constructor
acceleration = new PVector(0,0,0);
velocity = new PVector(0,0,0);
location = new PVector(x,y,z);
r = 6;
wandertheta = 0;
wanderphi = 0;
wanderpsi = 0;
maxspeed = 0.5;
maxforce = 0.05;
fillColor = c;
name = nam;
}
I would like to implement some 3D picking (at this point I do not care if only one agent or its entire group will be picked). I looked at some of the existing libraries that already exist, but I have no clue on how I should procceed or which one of them is the most suitable.
Any help would be much appreciated!
P.S. : if you need to see the entire code just tell me to add it here, it's just to long so I avoid it for now.
I didn't know how sould I search for this one that is why I am asking you here.
Let's say that we have a 3D processing environment (openGL or whatever).
Is it possible to draw a simple shape (a rectangle for example) so that will always "face" the camera no matter if you turn, move or rotate the camera? So that you always "see" a 2D rectangle and not any perspactive distortions of the shape...
If anyone know any way to do this or a relative example I 'll be glad to hear! :)
Is it possible to use a 3D picker (or the "picking library") for selecting separate autonomous agents created with an arryList (in 3D space)?
I have been trying to use the 3d picker with some simple 2D autonomous agents configurations and it does not seem to work, although it might be because of my own scripting mistakes. Are there any examples or references related to this subject?
Once again I need your help! I have included the source code below. It's a simple sketch that generates some wandering autonomous agents on a 2D canvas. At this point, there is 1 superclass called "Capsules"and 2 subclasses called MW1 and FW1.
I have succeeded in implementing inheritance and polymorphism (at least I think so) and I generate the agents using this part:
agents = new ArrayList<Capsule>();
for (int i = 0; i < 40; i++) {
if (i < 20) agents.add(new MW1(random(width),random(height),color(255,0,0),i));
and inside draw() I am able to call some functions included in the superclass. My question is: how can I apply a function (like arrive() for example) only for the MW1 agents and NOT all of them(?) Cause right now, any method I call, is being applied to all of them, no matter how many agents I create, through this:
work.Default(); //main-basic functions of (W) facility
retail.Default(); //main-basic functions of (R) facility
school.Default(); //main-basic functions of (S) facility
leisure.Default(); //main-basic functions of (L) facility
PVector vectorOfwork = new PVector(work.location.x, work.location.y); //creates a vector that connects all individual agents with the (W) facility
PVector vectorOfretail = new PVector(retail.location.x, work.location.y); //creates a vector that connects all individual agents with the (R) facility
PVector vectorOfschool = new PVector(school.location.x, school.location.y); //creates a vector that connects all individual agents with the (S) facility
PVector vectorOfleisure = new PVector(leisure.location.x, leisure.location.y); //creates a vector that connects all individual agents with the (L) facility
I have a simple time-counter that counts seconds and prints them on the panel. 180 sec. represent a day and between these seconds I trigger some events. Here is the general configuration:
...
int time; // a counter for time triggering events
int wait = 1000;
...
void setup() {
time = millis();//store the current time
...
void draw() {
...
//check the difference between now and the previously stored time is greater than the wait interval
if(millis() - time >= wait){
println(time/1000);//if it is, do something
time = millis();//also update the stored time
}
...
if (time/1000>30 && time/1000<90) {
"statement"
}
...etc
the thing is that AFTER the 180 sec. I want to go back to time/1000 = 0 and start counting from the beginning, in order to
loop the events.
Does anyone know how am I supposed to do that? I think I might use an
int day = 180 and an
int loop = 0 (representing the amount of days passed) but I 'm not sure... :(
Hey there! This is a simple timer that counts in seconds infinately. The this is that when it comes to print the seconds on the panel, it does this but in "millis". How can I fix it and print the elapsed time in "seonds"?
here is the code:
int time;
int wait = 1000;
void setup(){
time = millis();//store the current time
}
void draw(){
//check the difference between now and the previously stored time is greater than the wait interval
I have a simple script with a circle floating (wandering) in 2D space and one timer that counts hours till milliseconds throughout the animation. I tried to implement a
while function inside of which I wanted to make the sphere seek the "mouse" (mouse is the target) and come close to it
from the 30th till the 60th second.
while (sw.second()>=30 && sw.second()<=60) {
PVector mouse = new PVector(mouseX, mouseY);
vehicle.seek(mouse);
}
However, it seems that when the timer reaches the 30 sec. the canvas freezes and then it continues from the 60th second and beyond.
Any help? If you need the code or any other info just inform me.