# 3D terrain standalone display project

**URL:** <https://discourse.processing.org/t/3d-terrain-standalone-display-project/4162>\
**Category:** Project Guidance\
**Created:** [October 5, 2018, 3:19pm UTC](https://discourse.processing.org/t/3d-terrain-standalone-display-project/4162 "2018-10-05T15:19:26Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [October 6, 2018, 7:43am UTC](https://discourse.processing.org/t/3d-terrain-standalone-display-project/4162/5 "2018-10-06T07:43:42Z")

</div>

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**

```auto
[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**

```auto
#!/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**

```auto
// 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

---

_[View the full topic](https://discourse.processing.org/t/3d-terrain-standalone-display-project/4162)._
