Guest User

Untitled

a guest
Feb 10th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. import toxi.geom.*;
  2. import toxi.geom.mesh.*;
  3. import toxi.processing.*;
  4.  
  5.  
  6. char[] fullKeyboard= new char[10 + 26 + 14 + 3]; //numbers + alphabet + extraneous
  7.  
  8. int dim1 = 40;
  9. int dim2 = 120;
  10.  
  11. float[] el = new float[dim1 * dim2];
  12.  
  13. Terrain terrain = new Terrain(dim2, dim1, 6);
  14.  
  15. TriangleMesh mesh;
  16. ToxiclibsSupport gfx;
  17.  
  18. void setup() {
  19. size(1280, 960, P3D);
  20. fullKeyboard = fullKeyboardArray(fullKeyboard);
  21. }
  22.  
  23. void draw() {
  24. background(200);
  25. lights();
  26. translate(width/2, height/2, 0);
  27. //if (keyPressed && key == 'e') {
  28. if (keyPressed) {
  29. for (int k = 0; k < fullKeyboard.length; k++) {
  30. if (key == fullKeyboard[k]) {
  31. if (k < 13) {
  32. for (int tempRow = 0; tempRow < 10; tempRow++) {
  33. for (int tempCol = 0; tempCol < 10; tempCol++) {
  34. el[dim2* tempRow *2 + 10 * k + tempCol] += .1;
  35. }
  36. }
  37. } else if (k > 12 && k < 25) {
  38. for (int tempRow = 0; tempRow < 10; tempRow++) {
  39. for (int tempCol = 0; tempCol < 20; tempCol++) {
  40. el[dim2 * 10 + dim2 * tempRow *2 + 10 * (k - 12) + tempCol] += .1;
  41. }
  42. }
  43. } else if (k < 37) {
  44. for (int tempRow = 0; tempRow < 10; tempRow++) {
  45. for (int tempCol = 0; tempCol < 10; tempCol++) {
  46. //el[dim2* tempRow * 3 + 10 * k + tempCol] += .5;
  47. }
  48. }
  49. }
  50. } else if (k < 49) {
  51. for (int tempRow = 0; tempRow < 10; tempRow++) {
  52. for (int tempCol = 0; tempCol < 10; tempCol++) {
  53. //el[dim2* tempRow * 4 + 10 * k + tempCol] += .5;
  54. }
  55. }
  56. }
  57. }
  58. }
  59. terrain.setElevation(el);
  60. mesh = new TriangleMesh();
  61. terrain.toMesh(mesh, -10);
  62. gfx = new ToxiclibsSupport(this);
  63. rotateX(mouseY*0.01);
  64. rotateY(mouseX*0.01);
  65. stroke(255);
  66. gfx.mesh(mesh);
  67. }
  68.  
  69. char[] fullKeyboardArray(char[] fullKeyboard) {
  70. String inOrder = "1234567890-=qwertyuiop[]\rasdfghjkl;'#\r\\zxcvbnm,./";
  71. char c = inOrder.charAt(0);
  72. fullKeyboard = inOrder.toCharArray();
  73. fullKeyboard[27] = '\r';
  74. fullKeyboard[40] = '\r';
  75. printArray(fullKeyboard);
  76. return(fullKeyboard);
  77. }
  78.  
  79.  
  80. //Elevation elev = new Elevation(el, 5, k);
  81. //el = elev.elevation(float[] el);
Add Comment
Please, Sign In to add comment