here is my idea with test data
maybe one of the gurus can take a look if he usage of QuadStrip is correct?
// use peasy cam
// imports
import peasy.*;
// -------------------------------------------------------------------------------
// consts
// colors
final color RED = color(255, 0, 0);
final color GREEN = color(0, 255, 0);
final color BLUE = color(0, 0, 255);
final color BLUE2 = color(64, 124, 188);
final color GREEN2 = #12E300;
final color BLACK = color(0);
final color WHITE = color(255);
final color LIGHTGRAY = color(185, 180, 180);
final color YELLOW = color(245, 250, 13);
final color YELLOW2 = #E6F523;
final color PINK = #eebbcc;
final color VIOLET = #A146FF;
final color LIGHT_BLUE_COLOR = color(173, 216, 230); //
// -------------------------------------------------------------------------------
// objects, vars, etc.
//peasyCam
PeasyCam peasyCam;
// Tool class for PVectors
ToolsPVector toolsPVector = new ToolsPVector();
// The main list
ArrayList<Track> listTracks = new ArrayList();
float[][] list = { // !!!!! * -1 !!!!!!!!!!!!!!!!!
{ 0, 0, 0, 11, 12, 13, 14, 44, 66, 88, 44, 33, 22, 11, 0, 0, 0 },
{ 0, 0, 0, 11, 12, 13, 14, 44, 66, 90, 44, 33, 22, 11, 0, 0, 0 },
{ 0, 0, 0, 11, 12, 13, 88, 88, 77, 92, 44, 33, 22, 11, 0, 0, 0 },
{ 0, 0, 0, 11, 12, 13, 88, 88, 77, 94, 44, 33, 22, 11, 0, 0, 0 },
{ 0, 0, 0, 11, 12, 13, 14, 44, 66, 98, 44, 33, 22, 11, 0, 0, 0 },
{ 0, 0, 0, 11, 12, 13, 14, 44, 66, 90, 44, 33, 22, 11, 0, 0, 0 },
{ 0, 0, 0, 11, 12, 13, 14, 44, 66, 88, 44, 33, 22, 11, 0, 0, 0 },
{ 0, 0, 0, 11, 12, 13, 14, 44, 66, 88, 44, 33, 22, 11, 0, 0, 0 },
{ 0, 0, 0, 11, 12, 13, 14, 44, 66, 90, 44, 33, 22, 11, 0, 0, 0 },
{ 0, 0, 0, 11, 12, 13, 14, 44, 77, 92, 44, 33, 22, 11, 0, 0, 0 },
{ 0, 0, 0, 11, 12, 13, 14, 44, 77, 94, 44, 33, 22, 11, 0, 0, 0 },
{ 0, 0, 0, 11, 12, 13, 14, 44, 66, 98, 44, 33, 22, 11, 0, 0, 0 },
{ 0, 0, 0, 11, 12, 13, 14, 44, 66, 90, 44, 33, 22, 11, 0, 0, 0 },
{ 0, 0, 0, 11, 12, 13, 14, 44, 66, 88, 44, 33, 22, 11, 0, 0, 0 }
};
// -------------------------------------------------------------------------------------------------
// Two core functions
void setup() {
size(1300, 990, P3D);
avoidClipping();
peasyCam = new PeasyCam(this, width/2, 0, 0, 900);
//peasyCam.setViewport(0, 0, 400, 400);
// all elements should have the same length
int normalLength = list[0].length;
for (int i=0; i<list.length; i++) {
if (normalLength!=list[i].length)
println ("Error 2344");
println(list[i].length);
Track tr=new Track();
for (int i2=0; i2<list[i].length; i2++) {
tr.listPVectors.add(new PVector( i*8 + width/2, -1 * list [i][i2], i2*8));
}
listTracks.add(tr);
}
}
void draw() {
background (0);
lights();
if (keyPressed) {
// spheres
for (Track tr : listTracks) {
tr.displayAsSpheres();
}
} else {
// full landscape
stroke(0, 0, 222);
noStroke();
beginShape(QUAD_STRIP);
//
for (int i=0; i<listTracks.size()-1; i++) {
Track tr1 = listTracks.get(i);
Track tr2 = listTracks.get(i+1);
for (int i2=0; i2<tr1.listPVectors.size()-1; i2++) {
toolsPVector.vertexPV(GREEN, tr1.listPVectors.get( i2 ));
toolsPVector.vertexPV(GREEN, tr1.listPVectors.get( i2+1 ));
toolsPVector.vertexPV(GREEN, tr2.listPVectors.get( i2 ));
toolsPVector.vertexPV(GREEN, tr2.listPVectors.get( i2+1 ));
}//for
}//for
endShape();
// red sphere on mouse
for (Track tr : listTracks) {
tr.displayAsSpheresWhenMouse();
}
}// else
}
// ---------------------------------------------------------------------------------
// Other functions
void avoidClipping() {
// avoid clipping (at camera):
// https : //
// forum.processing.org/two/discussion/4128/quick-q-how-close-is-too-close-why-when-do-3d-objects-disappear
perspective(PI/3.0, (float) width/height, 1, 1000000);
} //func
// ============================================================================
// classes
class Track {
// one ridge / column
ArrayList<PVector> listPVectors = new ArrayList();
float scx, scy;
void displayAsSpheres() {
for ( PVector pv : listPVectors) {
pushMatrix();
translate(pv.x, pv.y, pv.z);
fill(255, 0, 0);
noStroke();
sphere( 7 ) ;
popMatrix();
}
}
void displayAsSpheresWhenMouse() {
for ( PVector pv : listPVectors) {
pushMatrix();
translate(pv.x, pv.y, pv.z);
scx=screenX(0, 0, 0);
scy=screenY(0, 0, 0);
if (dist(mouseX, mouseY, scx, scy) < 17) {
fill(255, 0, 0);
noStroke();
sphere( 3 ) ;
}
popMatrix();
if (dist(mouseX, mouseY, scx, scy) < 17) {
return;
}
}
}
} //
// ============================================================================
class ToolsPVector {
// not a class for an object like a car but a class that collects Tools - FOR 3D -----------!!!!
void linePV ( PVector pv1, PVector pv2) {
line(pv1.x, pv1.y, pv1.z,
pv2.x, pv2.y, pv2.z);
}//func
void pointPV ( PVector pv) {
point(pv.x, pv.y, pv.z);
}//func
void spherePV (PVector pv) {
pushMatrix();
translate(pv.x, pv.y, pv.z);
noStroke();
fill(255, 0, 0);
sphere(7);
popMatrix();
}//func
void myColumn(PVector pv) {
pushMatrix();
translate (pv.x, pv.y, pv.z );
box ( 12, 77, 18); // column
popMatrix();
}
void myText(String txt_, PVector pv) {
pushMatrix();
fill(WHITE);
translate (pv.x, pv.y-44, pv.z );
// box ( 12, 77, 18); // column
textMode(SHAPE);
text(txt_, 0, 0);
popMatrix();
}
void vertexPV(color col_, PVector pv_) {
fill(col_);
vertex(pv_.x, pv_.y, pv_.z);
}
//
} //class
//