erdmann
Ex Member
camera position
Nov 30th , 2009, 12:02pm
hello, i am new in processing. i have a problem concerning my camera position. i want to circle it around my object by using the mouse or keyboard. i have a center point (x, y, z) and radius. and want the camera to recognize the past positions of my object. here is my code: import processing.opengl.*; Essen e[] = new Essen[1]; Kacken k[] = new Kacken[1]; Schlafen s[] = new Schlafen[1]; color white = color(255, 255, 255, 80); color red = color(255, 0, 0, 50); color green = color(0, 255, 0, 50); color blue = color(0, 0, 255, 50); color back = color(95, 95, 95); void setup () { size (700, 700, P3D); background (back); stroke (white); smooth(); noLoop(); for (int i=0; i < e.length; i++) { float x = random (250, 450); float y = random (250, 450); float z = random (250, 450); e[i] = new Essen (x, y, z); } for (int i=0; i < k.length; i++) { float x = random (250, 450); float y = random (250, 450); float z = random (250, 450); k[i] = new Kacken (x, y, z); } for (int i=0; i < s.length; i++) { float x = random (250, 450); float y = random (250, 450); float z = random (250, 450); s[i] = new Schlafen (x, y, z); } } void draw () { //background (back); smooth(); for (int i=0; i < e.length; i++) { e[i].move (); point (e[i].position.x, e[i].position.y, e[i].position.z); } for (int i=0; i < k.length; i++) { k[i].move (); point (k[i].position.x, k[i].position.y, k[i].position.z); } for (int i=0; i < k.length; i++) { s[i].move (); point (s[i].position.x, s[i].position.y, s[i].position.z); } for (int i=0; i < e.length; i++) { e[i].move (); stroke(red); line(e[i].position.x, e[i].position.y, e[i].position.z, k[i].position.x, k[i].position.y, k[i].position.z); stroke(green); line(k[i].position.x, k[i].position.y, k[i].position.z, s[i].position.x, s[i].position.y, s[i].position.z); stroke(blue); line(s[i].position.x, s[i].position.y, s[i].position.z, e[i].position.x, e[i].position.y, e[i].position.z); } } void mousePressed() { loop(); } TAG 1 class Essen { PVector position; PVector target; Essen (float theX, float theY, float theZ) { position = new PVector (theX, theY, theZ); target = new PVector (); newTarget (); } void move () { PVector step = new PVector (); step.set (position); step.sub (target); step.div (40); position.sub (step); if (position.dist (target) < 3) { newTarget (); } } void newTarget () { target.x = random (250, 450); target.y = random (250, 450); target.z = random (250, 450); } } TAG 2 class Kacken { PVector position; PVector target; Kacken (float theX, float theY, float theZ) { position = new PVector (theX, theY, theZ); target = new PVector (); newTarget (); } void move () { PVector step = new PVector (); step.set (position); step.sub (target); step.div (40); position.sub (step); if (position.dist (target) < 3) { newTarget (); } } void newTarget () { target.x = random (250, 450); target.y = random (250, 450); target.z = random (250, 450); } } TAG3 class Schlafen { PVector position; PVector target; Schlafen (float theX, float theY, float theZ) { position = new PVector (theX, theY, theZ); target = new PVector (); newTarget (); } void move () { PVector step = new PVector (); step.set (position); step.sub (target); step.div (40); position.sub (step); if (position.dist (target) < 3) { newTarget (); } } void newTarget () { target.x = random (250, 450); target.y = random (250, 450); target.z = random (250, 450); } } thanks for your help