We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › Storing and Retrieving 3d Coordinates
Page Index Toggle Pages: 1
Storing and Retrieving 3d Coordinates (Read 601 times)
Storing and Retrieving 3d Coordinates
Mar 16th, 2010, 8:32pm
 
Storing and Retrieving moving Coordinates


     The following code represents a product that would display all of your parallel identities’ that exist and a few of their chosen attributes.  It would cross-reference them with your current attributes and then drawn lines connecting the shared attributes.

Each identity is represented as a solar system, with each attribute represented as one of the white ellipses revolving around the solar systems center.

Ultimately I would like to create a surface or shape from the lines, but first I am trying to understand how I might go about storing and retrieving the x, y, and z coordinates of each attribute.

Is this even possible?

Thanks, Sonder


import processing.opengl.*;
import peasy.*;



PFont font;
float xPos;
float yPos;
//-------------------------------------------------->>Universe Variables
float posX;
float posY;
float deg;
float x2, y2;
int numUniverse = 8;
PeasyCam cam, cam2;

Universe [] parallels = new Universe[numUniverse];
float degree;
float x, y, rot, v;

float[] attX = new float [numUniverse];
float[] attY = new float [numUniverse];
float[] attZ = new float [numUniverse];

float attx, atty, attz;
//-------------------------------------------------->>

//-------------------------------------------------->>
String[] uni1 = {
 "Aaron", "1985", "24", "architect", "earth", "Aaron6", "Aaron7", "Aaron8", "Aaron9"};

String[] uni2 = {
 "Aaron Norton", "2130", "24", "astronaunt", "Phobos(Mars)", "Aaron6", "Aaron7", "Aaron8", "Aaron9"};
String[] uni3 = {
 "Sondergaard", "1960", "30", "cigarette entrpreneur", "Post Apoc. earth", "Aaron6", "Aaron7", "Aaron8", "Aaron9"};
String[] uni4 = {
 "Sonder Barnes", "1920", "30", "Wyndham-Matson", "Facist Earth", "Aaron6", "Aaron7", "Aaron8", "Aaron9"};
String[] uni5 = {
 "Aaron Eldritch", "2242", "48", "Chew-Z grower", "Prox System", "Aaron6", "Aaron7", "Aaron8", "Aaron9"};
String[] uni6 = {
 "Aaron Deckard", "1985", "36", "Bounty Hunter", "Post Fall-Off earth", "Aaron6", "Aaron7", "Aaron8", "Aaron9"};
String[] uni7 = {
 "Captain Aaron Harris", "2000", "100", "Selene Captain", "Moon Colony", "Aaron6", "Aaron7", "Aaron8", "Aaron9"};
String[] uni8 = {
 "Aaron Bownan", "1945", "56", "Lunar Shuttle Captain", "Discovery One", "Aaron6", "Aaron7", "Aaron8", "Aaron9"};
String[] uni9 = {
 "Aaron", "1985", "24", "architect", "earth", "Aaron6", "Aaron7", "Aaron8", "Aaron9"};
//String[] att9 = {"Aaron", "1985", "24", "architect", "earth", "Aaron6", "Aaron7", "Aaron8", "Aaron9"};  

String[][] alluni = {
 uni1, uni2, uni3, uni4, uni5, uni6, uni7, uni8, uni9};




void setup() {
 


 size (1200, 800, OPENGL);
 cam = new PeasyCam(this, width/2, height/2, 0, 500);

 cam.setMinimumDistance(500);
 cam.setMaximumDistance(10000);


 background(0);
 smooth();
 degree = 0;

 frameRate(15);
   x = random(-width/3, width/3);
   y = random(-height/3, height/3);
 for (int i = 0; i < numUniverse; i++) {
   deg = random(1,360);

   rot = random(1,360);
   v = random(-.75,.75);
   parallels[i] = new Universe(deg, x, y, rot, v, alluni[i]);
   
   x = x+ 200;
   y = y + 200;

 }
println(attx);
println(atty);
println(attz);
 //------------------------------------------------------------------------------
-------------------->>

 //------------------------------------------------------------------------------
---------------->>
 font = loadFont("HelveticaNeue-Light-48.vlw");
 textFont(font);

}

void draw() {

 background(0,0,0,75);



 pushMatrix();
 translate(width/2, height/2);

 for (int i = 0;  i<numUniverse; i++) {


   parallels[i].universe();

   //println(parallels.length);
   

 }

 popMatrix();

}

class Universe {

 int numRings = 8;
 Ring [] identity = new Ring[numRings];
 
 String[] att;
 float r, a, s, t, p, o;
 float d, xPos, yPos, rotation, vel;
 Universe (float deg, float x, float y, float rot, float v, String[] u){
   vel = v;
   xPos = x;
   yPos = y;
   rotation = rot;
   r = 10;
   a = 0;
   s = 1;
   t = 40;
   att = u;
   
   for (int i = 0; i < numRings; i++) {
     
     String info = att[i];

     d = random(-deg, deg);
     identity[i] = new Ring(s, r, a, d, t, info);
     r = r+10;
     s = s+.1;
     t = t-2;

   }

 }


 void universe() {



   pushMatrix();
   rotateY(radians(rotation));
   rotateX(radians(rotation));
   float path = 2*(dist(0, 0, xPos, yPos));
   noFill();
   strokeWeight(2);
   stroke(255,0,255,25);
   ellipse(0,0, path, path);
   stroke(0,255,255, 25);
   line(0,0, xPos, yPos);
   translate(xPos, yPos);
   
   for (int i = 0;  i<numRings; i++) {


     identity [i].display();
     //if(i == 1) {
       //name
       

   }

   attx = modelX(0, 0, 0);
   atty = modelY(0, 0, 0);
   attz = modelZ(0, 0, 0);
   
   popMatrix();
    rotation = rotation + vel;
 }

}

class Ring {  

 float speed;
 float radius;
 float angle;
 float degree;
 float trans;
 String data;

 Ring (float s, float r, float a, float d, float t, String i){
   speed = s;
   radius = r;
   angle = a;
   degree = d;
   trans = t;
   data = i;
 }

 void display() {

   pushMatrix();
   x2 = radius*cos(radians(angle));
   y2 = radius*sin(radians(angle));
   rotateY(radians(degree));
   rotateX(radians(degree));
   noFill();
   //fill(255, 255, 255, 10);
   strokeWeight(2);
   stroke(255, 255, 255, trans);
   float distance2 = 2*(dist(0, 0, x2, y2));
   ellipse(0, 0, distance2, distance2 );
   strokeWeight(2);
   stroke(255,255,255,75);
   //line(x2, y2-5, x2, y2+5);
   //line(x2-5, y2, x2+5, y2);
   fill(255);
   strokeWeight(1);
   stroke(255,255,255,trans);
   line (x2, y2, 0, 0);
   ellipse(x2, y2, 3, 3);
   PFont font;
   textSize(5);
   text(data, x2-5, y2-5);

   popMatrix();

   angle = angle + speed;

   
   //centerX = modelX(0,0,0);

 }

}
Page Index Toggle Pages: 1