Shape.getVertexY returning always same data ?
in
Programming Questions
•
17 days ago
Hello,
I'm making some test with a cube I created, I'm trying to detect the side facing bottom or top or ...
But when I use the getVertex or getVerterX/Y/Z I always get the same value from the vertices even if my cube is moving and rotating.
My cube :
- void createCube() {
- s = createShape();
- s.beginShape(QUAD);
- s.fill(col, alpha);
- //bottom
- s.vertex(-size/2, -size/2, size/2);
- s.vertex(size/2, -size/2, size/2);
- s.vertex(size/2, -size/2, -size/2);
- s.vertex(-size/2, -size/2, -size/2);
- //left
- s.vertex(-size/2, -size/2, -size/2);
- s.vertex(-size/2, -size/2, size/2);
- s.vertex(-size/2, size/2, size/2);
- s.vertex(-size/2, size/2, -size/2);
- //top
- s.vertex(-size/2, size/2, -size/2);
- s.vertex(size/2, size/2, -size/2);
- s.vertex(size/2, size/2, size/2);
- s.vertex(-size/2, size/2, size/2);
- //front
- s.vertex(-size/2, size/2, size/2);
- s.vertex(-size/2, -size/2, size/2);
- s.vertex(size/2, -size/2, size/2);
- s.vertex(size/2, size/2, size/2);
- //right
- s.vertex(size/2, size/2, size/2);
- s.vertex(size/2, -size/2, size/2);
- s.vertex(size/2, -size/2, -size/2);
- s.vertex(size/2, size/2, -size/2);
- //back
- s.vertex(size/2, size/2, -size/2);
- s.vertex(size/2, -size/2, -size/2);
- s.vertex(-size/2, -size/2, -size/2);
- s.vertex(-size/2, size/2, -size/2);
- s.endShape();
- }
- void update()
- {
- translate.add(speed);
- position.add(translate);
- }
- void display() {
- pushMatrix();
- s.translate(translate.x/frameRate,translate.y/frameRate,translate.z/frameRate);
- translate.set(0,0,0);
- s.rotateX(rot.x/frameRate);s.rotateY(rot.y/frameRate);s.rotateZ(rot.z/frameRate);
- rot.set(0,0,0);
- shape(s);
- popMatrix();
- }
What am I doing wrong ?
Best regards,
E.D
1