Getting PShape vertex coordinates relative to scene

Hi all :slight_smile:

The problem:
I’m trying to get set of 3 groups of 3 floats that the relationship between them is a representation of equilateral triangle in a limited space (each number 0.0->0.1).
x1,y1,z1 x2,y2,z2, x3,y3,z3

I want those 3 numbers to be randomly generated within those compounds.
That means the triangle can be any size or angle within the bounding box, but always equilateral.

Code approach
I’m trying to create a PShape in 3d space and rotate it, and then get the new vertex locations. But when I’m using getVertex I keep getting the original vertex locations.

s = createShape();
  s.beginShape();
  s.rotateX(map(mouseY, 0, width, TWO_PI, 0));

  s.vertex(0, 0, 100);
  s.vertex(100,0, 0);
  s.vertex(0, 100, 0);
  s.endShape(CLOSE);
  
  for (int i = 0; i < s.getVertexCount(); i++) {
    PVector v = s.getVertex(i);
    System.out.println(v.x+" "+v.y);
  }

Here v.x and v.y stay the same after rotation, so I assume that getVertex is relative to PShape and not the scene.

Any idea on how I could get the vertex’s coordinates relative to the 3d space/scene?

1 Like

when you use this without “s.” you can use modelX, modelY, modelZ to get those

1 Like