# 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:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![stirman](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/stirman/32/1321_2.png) [@stirman](https://discourse.processing.org/u/stirman)
#### Post date: [October 5, 2018, 3:19pm UTC](https://discourse.processing.org/t/3d-terrain-standalone-display-project/4162/1 "2018-10-05T15:19:26Z")

</div>

Hey friends, I have an idea… but could use a little wisdom of the crowd to get me going in the right direction. I would like to create a 3d terrain flyover similar to [this](https://www.youtube.com/watch?v=IKB1hWWedMk) but on a small standalone, framed display with a couple knobs/switches to control speed, noise levels, etc.

I think my two options would be an Arduino on a Rasberry Pi, but I’m having trouble figuring out if either could boot directly into a Processing sketch. So, a couple questions…

1. Can either boot and run a Processing sketch without intervention?

2. Is one better than the other to power a small (maybe 7") display and wire up hardware controls to control the sketch?

Is this project possible?

Many thanks in advance!

---

<div class="post-metadata">

### Author: ![ScottGrogin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/scottgrogin/32/1689_2.png) [@ScottGrogin](https://discourse.processing.org/u/ScottGrogin)
#### Post date: [October 5, 2018, 5:46pm UTC](https://discourse.processing.org/t/3d-terrain-standalone-display-project/4162/2 "2018-10-05T17:46:44Z")

</div>

I know processing lets you export sketches to applications. I know the pi has options that will let run programs on startup.  
[https://www.dexterindustries.com/howto/run-a-program-on-your-raspberry-pi-at-startup/](https://www.dexterindustries.com/howto/run-a-program-on-your-raspberry-pi-at-startup/)

---

<div class="post-metadata">

### Author: ![jb4x](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jb4x/32/789_2.png) [@jb4x](https://discourse.processing.org/u/jb4x)
#### Post date: [October 5, 2018, 6:02pm UTC](https://discourse.processing.org/t/3d-terrain-standalone-display-project/4162/3 "2018-10-05T18:02:53Z")

</div>

For screen that big I think an Arduino is not the best solution. Plus you don’t have access the the core of processing with an Arduino.

So I would say that a Raspberry Pi is the way to go. I know for sure you can run a program on start so you can launch processing but I don’t think you’ll be able to launch the sketch.

Another alternative is to create a Java app with the processing core and that way you’ll be able to launch it on start.

---

<div class="post-metadata">

### Author: ![stirman](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/stirman/32/1321_2.png) [@stirman](https://discourse.processing.org/u/stirman)
#### Post date: [October 5, 2018, 8:15pm UTC](https://discourse.processing.org/t/3d-terrain-standalone-display-project/4162/4 "2018-10-05T20:15:46Z")

</div>

Great to know, glad I asked. I’ll do some research on Raspberry Pi setups and post an update here when the project gets off the ground!

Thanks again 🙂

---

<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

---

<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, 8:55am UTC](https://discourse.processing.org/t/3d-terrain-standalone-display-project/4162/6 "2018-10-06T08:55:59Z")

</div>

![](https://yyz2.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/3/39dc89b1834627af23831381cd4dc668ca9b655b.jpeg)

[get zip](http://kll.engineering-news.org/kllfusion01/downloads/flying_terrain.zip)

or see [online](https://editor.p5js.org/kll/sketches/S1myrBI5X)

---

<div class="post-metadata">

### Author: ![stirman](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/stirman/32/1321_2.png) [@stirman](https://discourse.processing.org/u/stirman)
#### Post date: [October 8, 2018, 6:30pm UTC](https://discourse.processing.org/t/3d-terrain-standalone-display-project/4162/7 "2018-10-08T18:30:08Z")

</div>

This is great! Just got my Pi and display delivered over the weekend, so I’m going to try and get this up and running on the Pi this week. I’ll post updates/questions here… thanks all!

---

<div class="post-metadata">

### Author: ![stirman](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/stirman/32/1321_2.png) [@stirman](https://discourse.processing.org/u/stirman)
#### Post date: [October 11, 2018, 8:42pm UTC](https://discourse.processing.org/t/3d-terrain-standalone-display-project/4162/8 "2018-10-11T20:42:39Z")

</div>

Welp, I got everything set up and I was able to get this sketch running on the Pi.

BUT, it’s SOOOO slow, like maybe 2 or 3 frames per second. Is this just a hardware limitation, or does anyone know of a way to speed things up with the code, or by configuring the Pi?!

- Pi 3 B+
- Raspberry Pi 7" Touchscreen Display

 ![38%20PM](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/5/59c6c154c78bf6debe78ad787694d88c78268188.jpeg)

Thanks!

---

<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 12, 2018, 1:50am UTC](https://discourse.processing.org/t/3d-terrain-standalone-display-project/4162/9 "2018-10-12T01:50:45Z")

</div>

what is your configuration, how you get that fullscreen anyhow?  
in normal

```auto
int scl = 20;
int w = 1200, h = 1200;

 size(500, 500, P3D);

```

i get easy 30 frames/s

 ![snap-039](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/f/f59759c333c758150d12acb214b27dcf9040730d.jpeg)

latest rev [here](http://kll.engineering-news.org/kllfusion01/downloads/flying_terrain_slider.zip)

---

<div class="post-metadata">

### Author: ![quydan](https://avatars.discourse-cdn.com/v4/letter/q/e9c0ed/32.png) [@quydan](https://discourse.processing.org/u/quydan)
#### Post date: [April 7, 2019, 2:45pm UTC](https://discourse.processing.org/t/3d-terrain-standalone-display-project/4162/10 "2019-04-07T14:45:27Z")

</div>

I do not know how to make a bash file? please help me

---

<div class="post-metadata">

### Author: ![stirman](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/stirman/32/1321_2.png) [@stirman](https://discourse.processing.org/u/stirman)
#### Post date: [April 14, 2019, 7:54pm UTC](https://discourse.processing.org/t/3d-terrain-standalone-display-project/4162/11 "2019-04-14T19:54:13Z")

</div>

Here are some instructions to make your Processing sketch run on boot…

[https://www.aib42.net/article/raspi-autostart](https://www.aib42.net/article/raspi-autostart)

Hope that helps!

---

<div class="post-metadata">

### Author: ![stirman](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/stirman/32/1321_2.png) [@stirman](https://discourse.processing.org/u/stirman)
#### Post date: [August 19, 2019, 6:03pm UTC](https://discourse.processing.org/t/3d-terrain-standalone-display-project/4162/12 "2019-08-19T18:03:08Z")

</div>

I framed this project up over the weekend and it came out pretty rad! You can see it in motion [here](https://www.instagram.com/p/B1VIJf8JzkG/).

Quick question though, I export the sketch so it can run when the Pi powers on, using a desktop and autostart file, but the exported version runs choppy, while running it _from_ the Processing IDE is smooth as butter. Any idea why that might be?

Thanks for all the help here, fun project!

 ![vz0vo74VQx2SokZqeBcIeA](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/2/208a3b383714ce56856113ab6a634708c0e19e62.jpeg)

 ![dCUhjW70Sr20RaxZLWNZ2w](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/9/98b0e86933719959a44fcfe6fb3df4580595d50e.jpeg)

---

<div class="post-metadata">

### Author: ![jb4x](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jb4x/32/789_2.png) [@jb4x](https://discourse.processing.org/u/jb4x)
#### Post date: [August 19, 2019, 7:56pm UTC](https://discourse.processing.org/t/3d-terrain-standalone-display-project/4162/13 "2019-08-19T19:56:08Z")

</div>

Really cool! Love it =)

---

<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: [August 20, 2019, 3:38am UTC](https://discourse.processing.org/t/3d-terrain-standalone-display-project/4162/14 "2019-08-20T03:38:33Z")

</div>

nice,  
for your question, i posted in a other topic the full procedure for processing sketch autostart at boot for raspberry raspbian,  
not using any export,  
using the command line start of processing …  
[https://github.com/processing/processing/wiki/Command-Line](https://github.com/processing/processing/wiki/Command-Line) possibly try that??

---

<div class="post-metadata">

### Author: ![stirman](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/stirman/32/1321_2.png) [@stirman](https://discourse.processing.org/u/stirman)
#### Post date: [August 20, 2019, 3:15pm UTC](https://discourse.processing.org/t/3d-terrain-standalone-display-project/4162/15 "2019-08-20T15:15:23Z")

</div>

Nice, I’ll give that a try… thank you!
