3D terrain standalone display project

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

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/

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.

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 :slight_smile:

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

get zip

or see online

1 Like

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!

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

Thanks!

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

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


 size(500, 500, P3D);

i get easy 30 frames/s

latest rev here

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

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

https://www.aib42.net/article/raspi-autostart

Hope that helps!

I framed this project up over the weekend and it came out pretty rad! You can see it in motion here.

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!

3 Likes

Really cool! Love it =)

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 possibly try that??

2 Likes

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