We are about to switch to a new forum software. Until then we have removed the registration on this forum.
//begin setup
void setup(){
size(600,400,P3D);
}//end setup
//camera positions
float px = 0;
float py = -100;
float pz = 0;
//camera velocity
float pxv = 0;
float pyv = 0;
float pzv = 0;
//for if I add robot mouse
//boolean entered = false;
//void mouseReleased(){entered=true;}
//key press storage
boolean[] keys = new boolean[355];
void keyPressed(){keys[keyCode]=true;}
void keyReleased(){keys[keyCode]=false;}
//begin draw
void draw(){
//environment
background(125,250,250);
box(10);
//movement
if(keys[UP]){
px+=sin(mouseX*0.02);
py+=cos(mouseX*0.02);
}
if(keys[DOWN]){
px-=sin(mouseX*0.02);
py-=cos(mouseX*0.02);
}
if(keys[LEFT]){
px+=sin((mouseX-75)*0.02);
py+=cos((mouseX-75)*0.02);
}
if(keys[RIGHT]){
px-=sin((mouseX-75)*0.02);
py-=cos((mouseX-75)*0.02);
}
if(keys[SHIFT]){
pz+=1;
}
if(keys[ENTER]){
pz-=1;
}
//camera
camera(px,py,pz,px+sin(mouseX*0.02),py+cos(mouseX*0.02),pz,0,0,1);
}//end draw
Here is my code ^^
It runs fine at the moment, but when I add a 3D array and render cubes with it, it slows the code WAY down. Why does it do that? I see all of these 3D programs that can load a gigantic amount of cubes, and they run fast.
I suspect that it has something to do with Processing's "cube();", but I'm not sure.
Answers
"a 3d array"? what? why don't you post the code that is running slow instead of posting some preliminary code. that way it's hard to help you.
what means slow? how many fps on what kind of a machine is it producing?
okay, here it is with the slow code ^^
It was running at 3 fps :( My OS is Windows 7
you are trying to draw 30 * 30 * 30=27000 cubes. that's a lot of cubes. so it's no wonder that it is running slow.
you could use a pshape. that should give you better performance. with pshape the cubes are pushed over to the graphicscard only at statup. with your current solution the cubes are pushed over in every frame.
check the cubicGridRetained example. it's filed under demos\performance.
How exactly would I use PShape in P3D?
did you check the example? it's all in there.
Okay :)
btw, the example wouldn't run, even with expanded memory...
What error did it gave? And to how much memory did you set it?
here's what it gave me with 686 megabytes of expanded memory:
I suspect that either your graphics card doesn't support all the required features or you need to update the drivers for it to do so. What hardware are you running this on?
I'm not too savvy with finding hardware stats, so how would I find out the stuff your asking for? :(