Trying to use modelX() but built a spiral galaxy of points

sorry, not sure this is of any help,
but i wanted just to be sure that a mix of

  • translate
  • rotate
  • shear

together with saved modelXYZ works.

give it a try (v03)

i know it looks messy

// https://discourse.processing.org/t/trying-to-use-modelx-but-built-a-spiral-galaxy-of-points/6064/4
// v02 summary line cyan
// v03 show PVector data also on canvas, plus cleanup

int make=0, makemax = 10;
PVector[] remember;

//______________________________________
void setup() {
  size(500, 500, P3D);
  info_print();
  remember = new PVector[makemax];
  tumble(true);                           // make / draw axis and points and boxes ( and remember )
  for ( int i=0; i<make; i++) println("i "+i+" "+remember[i]);
  println(" white line connects modelXYZ memory points / cyan line Begin End");
  println(" green points and box's draw relative at 0,0,0 after translate/rotate/shear");
}

//______________________________________
void remember_it() {
  remember[make]= new PVector(modelX(0, 0, 0), modelY(0, 0, 0), modelZ(0, 0, 0));
  //println("make "+make);
  make++;
}


void a_point(boolean mem) {  //__________________points + box and optional remember
  point(0, 0, 0); 
  box(10);
  if (mem) remember_it();
}

//______________________________________ 
void tumble(boolean mem) {                         //_ aka drunken_monkey_in_space
  //_______________________________________________axis
  noFill();
  stroke(200, 0, 0); 
  line(0, 0, 0, 30, 0, 0);
  stroke(200, 200, 0); 
  line(0, 0, 0, 0, 30, 0);
  stroke(200, 0, 200); 
  line(0, 0, 0, 0, 0, 30);
  //_______________________________________________ in 3D
  stroke(0, 200, 0); 
  strokeWeight(1);
  pushMatrix();
  // start
  a_point(mem);//_______________[0]
  translate(50, 60, 0);
  a_point(mem);//_______________[1]
  rotateX(PI/4);
  a_point(mem);//_______________[2]
  translate(50, 0, 0);
  shearX(PI/4);
  a_point(mem);//_______________[3]
  translate(0, 0, -30);
  a_point(mem);//_______________[4]
  // end
  popMatrix();
}

void show_remembered_points_as_lines() {
  strokeWeight(1);
  stroke(255);                           // show lines for all steps in  white 
  for (int i =0; i<make-1; i++) line(remember[i].x, remember[i].y, remember[i].z, remember[i+1].x, remember[i+1].y, remember[i+1].z);
  stroke(0, 200, 200);                   // to show a summary we make a cyan line from NULL to END
  line(0, 0, 0, remember[make-1].x, remember[make-1].y, remember[make-1].z);
}

void show_remembered_points_as_text() {
  fill(0, 200, 200); 
  textSize(15);   // text color
  for  (int i = 0; i<make; i++) text("i "+i+" PVector["+int(remember[i].x)+","+int(remember[i].y)+","+int(remember[i].z)+"]", 10, 20+20*i);
}
//______________________________________
void draw_object() {                         //_________________called by / from inside PTZ
  show_remembered_points_as_lines();         // from array of PVector of modelXYZ's
  tumble(false);                             // draw axis and points ( not remember again ) using original translate,rotate,shear... and a BOX each
}

//______________________________________ DRAW
void draw() {
  background(0, 0, 80);
  show_remembered_points_as_text();
  PTZ();
}







//_____________________________________ PTZ tab
int mode = 0;
float Zmag = 5;
int Zaxis=-10;                                                       
float Xmag, Ymag = 0;
float newXmag, newYmag = 0; 
int newZmag = 0;
int zoomf = 3;
float newxpos, newypos = 0;       // for PAN
float xposd, yposd = 0;           // for PAN

//_________________________________________________________________ ROTATE / TILDE and MOVE / PAN
void mousePressed() {
  if      (mouseButton == LEFT) { 
    mode=1;
  }  // ORBIT
  else if (mouseButton == RIGHT) { 
    mode=2;
  }  // PAN
  // else if (mouseButton == CENTER) { mode=3; }  // zoom mouse wheel works same , presssed or not
}

//_________________________________________________________________ mouse PT end
void mouseReleased() { 
  mode = 0;
}

//_________________________________________________________________ mouseWheel ZOOM
void mouseWheel(MouseEvent event) {
  int newZmag = event.getCount();                                     // +- 1
  //if (Zmag > 10) { Zmag += newZmag * 5; } else { Zmag += newZmag; }// from 1 to 11 go in step 1 else in step 5 
  Zmag += newZmag*0.3;
  //println("Zmag: "+nf(Zmag, 1, 2));
}

void keyPressed() {
  if ( keyCode == UP   )  Ymag -= 0.1 ;
  if ( keyCode == DOWN )  Ymag += 0.1 ;
  if ( keyCode == RIGHT)  Xmag -= 0.1 ;
  if ( keyCode == LEFT )  Xmag += 0.1 ;
  if ( keyCode == 16 )    Zmag -= 0.5 ;
  if ( keyCode == 11 )    Zmag += 0.5 ;
  //println("key: "+key); println("keyCode: "+keyCode);
}
//_________________________________________________________________ Pan Tilde Zoom
void PTZ() {
  pushMatrix(); 
  translate(width/2, height/2, Zaxis);
  // get new mouse operation  
  if ( mode == 2 ) {                              // PAN ( right mouse button pressed)
    xposd = (mouseX-float(width/2));
    yposd = (mouseY-float(height/2));
  }  
  newxpos = xposd;// xposd=0;
  newypos = yposd;// yposd = 0; 
  translate(newxpos, newypos, 0);          // move object
  if ( mode == 1 ) {  // ORBIT ( left mouse button pressed)
    newXmag = mouseX/float(width) * TWO_PI;
    newYmag = mouseY/float(height) * TWO_PI;

    float diff = Xmag-newXmag;
    if (abs(diff) >  0.01)   Xmag -= diff/4.0;
    diff = Ymag-newYmag;
    if (abs(diff) >  0.01)   Ymag -= diff/4.0;
  }
  rotateX(-Ymag);   
  rotateY(-Xmag);   
  scale(Zmag);
  draw_object();                                // THE OBJECT  see main tab
  popMatrix();
}

//_______________________________________________ SETUP PRINT INFO
void info_print() {
  println("PTZ info:");
  println("key UP DOWN RIGHT LEFT -> rotate // key PAGE UP DOWN -> zoom");
  println("mouse LEFT press drag up down right left -> rotate // mouse RIGHT press -> move // mouse WHEEL turn -> zoom");
  println("_data_");
}