Hey folks,
I've managed to get a 3D sketch running on my xoom!
The camera moves from left to right, and then back again. There are two grids, one above and one below, each made up of about 200 lines, so the sketch is rendering about 400 lines in total. I'd say performance is ok, but it's not amazing, It doesn't feel like it's really using the hardware, it's probably running about 15-20FPS.
I've not seen any difference between using "
size(1280, 800, A3D)" and "
size(screenWidth, screenHeight, A3D)". This is a bit of a shame, because I know that you can make apps run in a fullscreen mode where the status bar "virtual-softkeys" are reduced to dots, and the rest of the icons are removed.
However, I'm thrilled to have got this far and I'm going to carry on an see what sensor stuff I can do next.
Code is below, if anyone can see anything that would obviously speed things up, let me know :)
Jim
- PVector campos, target_p;
- Grid topGrid, bottomGrid;
- int direction = 0;
-
- void setup()
- {
- size(screenWidth, screenHeight, A3D);
- bottomGrid = new Grid(10,101,255,-50.0);
- topGrid = new Grid(10,101,255,50.0);
-
- campos = new PVector(600,0,0);
- target_p = new PVector(0, 0, 0);
-
- }
- void draw()
- {
- background(0);
- lights();
- smooth();
-
- if (campos.y > 200) direction = 1;
- if (campos.y < -200) direction = 0;
- if (direction == 0) campos.y++;
- else campos.y--;
-
- camera(campos.x, campos.y, campos.z, campos.x-1, campos.y, campos.z, 0, 0, -1);
- topGrid.display();
- bottomGrid.display();
- }
- class Grid
- {
- float spacing;
- int gridSize;
- int gridStroke;
- float zpos;
- Grid(float c_spacing, int c_gridSize, int c_gridStroke, float c_zpos)
- {
- spacing = c_spacing;
- gridSize = c_gridSize;
- gridStroke = c_gridStroke;
- zpos = c_zpos;
- }
- void display()
- {
- for (int i = 0; i < gridSize; i++)
- {
- stroke(gridStroke-150);
- if (i%5 == 0) stroke(gridStroke-100);
- if (i == 0) stroke(gridStroke);
- line(-(gridSize*(spacing/2)), (i*spacing)-((gridSize/2)*spacing), zpos, (gridSize*(spacing/2)), (i*spacing)-((gridSize/2)*spacing), zpos);
- line((i*spacing)-((gridSize/2)*spacing),-(gridSize*(spacing/2)), zpos, (i*spacing)-((gridSize/2)*spacing),(gridSize*(spacing/2)), zpos);
- }
- stroke(0);
- }
- }