Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import toxi.geom.*;
- import toxi.geom.mesh.*;
- import toxi.processing.*;
- char[] fullKeyboard= new char[10 + 26 + 14 + 3]; //numbers + alphabet + extraneous
- int dim1 = 40;
- int dim2 = 120;
- float[] el = new float[dim1 * dim2];
- Terrain terrain = new Terrain(dim2, dim1, 6);
- TriangleMesh mesh;
- ToxiclibsSupport gfx;
- void setup() {
- size(1280, 960, P3D);
- fullKeyboard = fullKeyboardArray(fullKeyboard);
- }
- void draw() {
- background(200);
- lights();
- translate(width/2, height/2, 0);
- //if (keyPressed && key == 'e') {
- if (keyPressed) {
- for (int k = 0; k < fullKeyboard.length; k++) {
- if (key == fullKeyboard[k]) {
- if (k < 13) {
- for (int tempRow = 0; tempRow < 10; tempRow++) {
- for (int tempCol = 0; tempCol < 10; tempCol++) {
- el[dim2* tempRow *2 + 10 * k + tempCol] += .1;
- }
- }
- } else if (k > 12 && k < 25) {
- for (int tempRow = 0; tempRow < 10; tempRow++) {
- for (int tempCol = 0; tempCol < 20; tempCol++) {
- el[dim2 * 10 + dim2 * tempRow *2 + 10 * (k - 12) + tempCol] += .1;
- }
- }
- } else if (k < 37) {
- for (int tempRow = 0; tempRow < 10; tempRow++) {
- for (int tempCol = 0; tempCol < 10; tempCol++) {
- //el[dim2* tempRow * 3 + 10 * k + tempCol] += .5;
- }
- }
- }
- } else if (k < 49) {
- for (int tempRow = 0; tempRow < 10; tempRow++) {
- for (int tempCol = 0; tempCol < 10; tempCol++) {
- //el[dim2* tempRow * 4 + 10 * k + tempCol] += .5;
- }
- }
- }
- }
- }
- terrain.setElevation(el);
- mesh = new TriangleMesh();
- terrain.toMesh(mesh, -10);
- gfx = new ToxiclibsSupport(this);
- rotateX(mouseY*0.01);
- rotateY(mouseX*0.01);
- stroke(255);
- gfx.mesh(mesh);
- }
- char[] fullKeyboardArray(char[] fullKeyboard) {
- String inOrder = "1234567890-=qwertyuiop[]\rasdfghjkl;'#\r\\zxcvbnm,./";
- char c = inOrder.charAt(0);
- fullKeyboard = inOrder.toCharArray();
- fullKeyboard[27] = '\r';
- fullKeyboard[40] = '\r';
- printArray(fullKeyboard);
- return(fullKeyboard);
- }
- //Elevation elev = new Elevation(el, 5, k);
- //el = elev.elevation(float[] el);
Add Comment
Please, Sign In to add comment