3D terrain standalone display project

i tested on a

DEBIAN stretch
Linux version 4.14.70-v7+
Raspberry Pi 3 Model B Plus Rev 1.3

using processing 3.4 and
/home/pi/sketchbook/from_PC/flying_terrain/
flying_terrain.pde
and do the above suggested
processing[File][export application] ( to linux)
and get 4 subdirs (application. linux64 linux32 linux-arm64 linux-armv6hf )

for the autostart i use:
if not exist make sub dir
home/pi/.config/autostart/

there in make a file
myautostart.desktop

[Desktop Entry]
Type=Application
Name=my_auto_start
Exec=lxterminal -e /home/pi/.config/autostart/start_processing
Icon=/usr/local/lib/processing/lib/icons/pde-256.png
Comment=start after timedelay
Terminal=true
X-KeepTerminal=false
Categories=Application;

make a bash file
start_processing

#!/bin/bash
# /home/pi/.config/autostart/start_processing
# this will not do anything unless called by a .desktop file

echo '10s'
env sleep 5
echo '5s'
env sleep 5
#...

cd /home/pi/sketchbook/from_PC/flying_terrain/application.linux-armv6hf/
bash flying_terrain

# wait for operator to close window
read -p "press enter to close terminal window"

and make that executable
chmod +x start_processing

just tested.
the code runs much slower as on my old PC
flying_terrain.pde

// from https://www.youtube.com/watch?v=IKB1hWWedMk
//_______________________________________________________________
int cols, rows;
int scl = 20;
int w = 1400, h = 1600;
float flying  =0.0;
float xoff, yoff;
float[][] terrain;

//_______________________________________________________________
void setup() {
  size(600, 600, P3D);
  cols=w/scl;
  rows=h/scl;
  terrain = new float[cols][rows];
}

//_______________________________________________________________
void draw() {
  make_terrain();

  background(0, 0, 80);
  stroke(120);
  fill(100,100,100); // noFill();

  translate(width/2, height/2);
  rotateX(PI/3);
  translate(-w/2, -h/2);

  draw_terrain();
}


//_______________________________________________________________
void make_terrain() {
  flying -= 0.1;
  yoff = flying;
  for (int y = 0; y < rows; y++) {
    xoff = 0;
    for (int x=0; x<cols; x++) {
      terrain[x][y]=map(noise(xoff, yoff), 0.0, 1.0, -50.0, 50.0);
      xoff += 0.2;
    }
    yoff +=0.2;
  }
}
//_______________________________________________________________
void draw_terrain() {
  for (int y = 0; y < rows-1; y++) {
    beginShape(TRIANGLE_STRIP);
    for ( int x = 0; x < cols; x++) {
      // 100,100,100 GREY, 100,200,100 GREEN; when terrain higher NO GREEN
      fill(100,150-int(terrain[x][y]),100);
      vertex(x*scl,y*scl,terrain[x][y]);
      vertex(x*scl,(y+1)*scl,terrain[x][y+1]);
    }
    endShape();
  }


}

you see, i added a auto color fill

1 Like