I'm making an animation in Processing. I have some random points moving randomly in the background and some points that go forming a solid. Since I need to view the animation in stereo, I have to render the left vision, save the frames and then make a movie out of them. I need to make this also for the right vision.
So I need to run the same animation with the same random points at least twice. This is possible using the random class and not the random() method. But the problem is that I also have a random call in the draw method, but if I change random() to random.nextInt() it doesn't work properly.
The problem is in the random used in the draw function.
I want the points in the background to keep moving in [-3, 3] in the same way for at least two runs.
If I use random() the number is choosed randomly every frame, but if I use rand.nextInt() for every frame I get the same numbers, (frame 1: 13 45 234 65 etc. frame 2: 13 45 234 65) and the points keep going away... Hope I explain myself, to see it just uncomment
k = randk.nextInt(numr-4);
Is there any way I can get the same movement twice? Do I need to put a noLoop() somewhere? Am I hopeless?
Hello, I've created an animation in OpenGL of random points forming a solid (cube, sphere, cone or cylinder). On the background I have some random points moving randomly. The points are little sphere cause my project is in 3D and should be in stereo vision soon.
The problem is that the code makes the animation slow, and when I add the library for stereo vision it gets even slower. Is there any way I can optimize it?
Here's the source:
import processing.opengl.*; String solidtype = "cube"; String particlestype = "s"; int spheredetail = 3; int xsize = 1000; int ysize = 1000; int zsize = 1000;
float stheta; float sphi; spheresup = (int)(4*PI*sradius*sradius*density); xsphere = new float[spheresup]; ysphere = new float[spheresup]; zsphere = new float[spheresup];
circocysup = (int)(PI*cyradius*cyradius*density); cysup = (int)(2*PI*cyradius*cyheight*density); float cytheta; float cyphi; float om; float r; float ucy; xcylinder = new float[cysup]; ycylinder = new float[cysup]; zcylinder = new float[cysup]; xcylinderbase = new float[circocysup]; ycylinderbase = new float[circocysup];
apotema = Math.sqrt((coradius*coradius)+(coheight*coheight)); cosup = (int)(PI*coradius*apotema*density); circocosup = (int)(PI*coradius*coradius*density); float cotheta; float cophi; float omco; float rco; float uco; float thisradius; xcone = new float[cosup]; ycone = new float[cosup]; zcone = new float[cosup]; xconebase = new float[circocosup]; yconebase = new float[circocosup]; zconebase = new float[circocosup];
qusup = (int)(6*side*side*density); int c; int q; qube = new PVector[qusup]; xcube = new float[qusup]; ycube = new float[qusup]; zcube = new float[qusup];
Hi,
I'm trying to adapt a stereo library created in processing 1.5 for processing 2.0, since my sketch is too slow in processing 1.5 but I'm having a hard time trying to figure out what to change since openGL libraries are changed.
Hi, I'm trying to export as an application with openGL but I get the "Could not copy source file" message and when I open the .exe file nothing happens.
I've tried with a simple source file and it works, but as soon as I add the import processing.opengl.*; line I get the same error message. In my application folder I have a lib folder with the opengl jar and others jars, plus a source folder with the pde file and some .ddl files.
I guess it's a problem with the libraries,what should I do?
Thanks, I've searched the forum but I haven't found a working solution for this problem.
Hi, I've created a cone made of random points on the surface, but I get too many points near the apex. How can I get a uniform distribution? Also I get a cone that looks like a diamond, but I want it positioned upside down, like this:
http://trialx.com/curetalk/wp-content/blogs.dir/7/files/2011/05/diseases/Cone-2.gif any tips on what I am doing wrong? Thanks.
The code here describes an animation. I have random points that go forming the cone when I press p.
import processing.opengl.*;
float vel = 5;
float velr = 1;
int nums = 1000;
int numr = 150;
int winsize = 600;
int ballsize = 5;
float radius = 200;
float coheight = 300;
PVector[] randomp = new PVector[numr];
PVector[] solidp = new PVector[nums];
float[] cothetas = new float[nums];
float[] cophis = new float[nums];
void setup() {
size(winsize, winsize, OPENGL);
smooth();
noStroke();
starttime = millis();
for(int i=0; i<numr; i++) {
randomp[i] = new PVector(random(-winsize/2, winsize/2), random(-winsize/2, winsize/2), random(-winsize/2, winsize/2));
}
for (int i=0; i<nums; i++) {
solidp[i] = new PVector(random(-winsize/2, winsize/2), random(-winsize/2, winsize/2), random(-winsize/2, winsize/2));