Alterscape
Junior Member
Offline
Posts: 64
NY
Re: Afterimages
Reply #7 - Oct 30th , 2005, 1:53am
I'm trying to get postpop's suggestion working in OpenGL mode. Here's draw my code: import processing.core.*; import processing.opengl.*; import damkjer.ocd.*; public class MBlurTest extends PApplet { //time management stuff private long tO;//time at last frame private long tN;//time at this frame private long tT;//total time since start private long dt;//delta time (new time - old time) //camera stuff private Camera myCamera; //trig object private FastTrig ft = new FastTrig(720); public void setup() { size(800,600,OPENGL); framerate(30); noStroke(); //time management initialization stuff tO = System.currentTimeMillis(); tT = 0; //myCamera = new Camera(this,0,0,-300); myCamera = new Camera(this,0,0,-600); myCamera.feed(); background(0); } public void draw() { updateTime(); lights(); pushMatrix(); fill(0,0,255,255); float x = (float)(100 * ft.sine(tT/40)); float y = (float)(100 * ft.cosine(tT/40)); translate(x,y,(float)0); sphere(15); popMatrix(); /* fill(255,0,0); beginShape(QUADS); vertex(-50,-50,-295); vertex(50,-50,-295); vertex(-50,-50,-295); vertex(-50,50,-295); endShape();*/ pushMatrix(); fill(255,0,0,8); translate(0,0,-290); box(100); popMatrix(); } private void updateTime(){ tN = System.currentTimeMillis(); dt = (tN - tO); tO = tN; tT += dt; } } FastTrig is a utility class I wrote that just calculates sine, cosine, and tan to a given resolution (720 ticks in a circle, in this example) and stores it in an array for faster trig calculations. What happens is that, if you comment out the line that draws the transparent box in the foreground, the sphere moves around in a circle, tracing out a path (but not fading, obviously). If you leave the box(100); line in, the sphere is drawn in its' initial position and then the box is drawn over top of it; the box slowly becomes more opaque and obscures the sphere, but you don't see the sphere's motion beyond that first point. I tried the rect(0,0,width,height) solution from the example you posted, but that didn't work for me either.. thoughts?