|
Author |
Topic: 3d arrays (Read 824 times) |
|
christian
|
3d arrays
« on: Nov 7th, 2003, 12:32am » |
|
hi architects i am not that used to coding as id like to be so- i try to store drawn cubes in arrays. i thought to use the box() method instead of using vertices since i believed it was easier this way. but i cant get it. maybe someone could give me at least some tips? thanks christian ps heres my lousy try Box[] boxen; float[] spectrum; float wertX, wertY, wertZ, R,G,B; int anzahl=0; float bin1, bin2, bin3, bin4, bin5, bin6, bin7, bin8; double dB; float x,y,z; void setup(){ size(800,600); background(0); stroke(0.1); } void loop(){ getSpectrum();//BESTIMMT DEN INPUT: SPEKTRUM (8BINS) UND DEN LEVEL (dB) dB = liveInput.getLevel(); boxen = new Box(x, y, z); } public class Box{ int xNum; int yNum; int zNum; int rNum;int gNum; int bNum; int pxNum; int pyNum; int pzNum; int rxNum; int ryNum; int rzNum; float[][][] korper=new float[xNum][yNum][zNum]; float[][][] farben=new float[rNum][gNum][bNum]; float[][][] position=new float[pxNum][pyNum][pzNum]; float[][][] rotation=new float[rxNum][ryNum][rzNum]; Box(float x, float y, float z){ x = xNum; y = yNum; z = zNum; } void setFarben(int r,int g,int b){ r = (int)rNum; g = (int)gNum; b = (int)bNum; } void setPosition(float px,float py, float pz){ px = pxNum; py = pyNum; pz = pzNum; } void setRotation(float rx, float ry, float rz){ rx = rxNum; ry = ryNum; rz = rzNum; } public void draw(){ rotateX(rx); rotateY(ry); rotateZ(rz); translate(px, py, pz); fill(r, g, b); box(x, y, z); if(y<width-50){ px+= dB*5; py = 50; bBreite = bin1; bHoehe = bin2; bTiefe = bin3; } if(y>width-50){ px=50; py+= 50; } } } public void stop(){ BJSyn.stop(); super.stop(); }
|
« Last Edit: Nov 7th, 2003, 12:33am by christian » |
|
|
|
|
benelek
|
Re: 3d arrays
« Reply #1 on: Nov 7th, 2003, 6:00am » |
|
i believe the initial problem is that you're defined the variable boxen as an array of objects, but within loop() you're treating it as an instance of the object you've defined. also, you don't seem to have defined how many Box objects the boxen array should hold. here's the correct structure for defining an array of objects: Code:Box[] boxen = new Box[10]; //array holding 10 Box objects. for(int b=0; b<boxen.length; b++) { boxen[i] = new Box(x, y, z); //define each Box within the boxen array. } |
| you also seem to be putting some lines in the wrong order. for instance, in the constructor for the Box object you've used x=xNum where you should have used xNum=x. besides which, you're trying to define the integer xNum with the float x...
|
|
|
|
|