Problem with java class with pushMatrix() and popMatrix() sentences inside.
in
Programming Questions
•
1 year ago
Hello , Im having problems witch my sketch . I have used that class definition in eclipse :
package misketch2;
import processing.opengl.*;
import processing.core.*;
public class Ficha {
PApplet parent;
final int ancho_casilla = 200/8;
public Ficha(PApplet p){
parent=p;
}
public void mover2d( int posx , int posy){
parent.pushMatrix();
Cilindro((ancho_casilla-4), 40, 20);
parent.translate(posx,posy);
parent.popMatrix();
}
public void mover3d (int posx, int posy, int posz){
parent.pushMatrix();
parent.translate(posx,posy,posz);
parent.popMatrix();
}
public void dibujar(){
Cilindro((ancho_casilla-4), 40, 20);
}
public void rotar(){
parent.pushMatrix();
parent.rotateX(4.7F);
parent.popMatrix();
}
And then I do something like that in my draw() function on the main class:
Ficha ficha1 = new Ficha(this);
ficha1.dibujar();
ficha1.rotar();
rotateX(rotX + distY);
ficha1.mover2d(width/2,height/2);
The thing that I want to know is why all works fine except all the callings to the pushMatrix(), translate senteces from inside the class methods,etc.
Does anyone know why it happens that?
package misketch2;
import processing.opengl.*;
import processing.core.*;
public class Ficha {
PApplet parent;
final int ancho_casilla = 200/8;
public Ficha(PApplet p){
parent=p;
}
public void mover2d( int posx , int posy){
parent.pushMatrix();
Cilindro((ancho_casilla-4), 40, 20);
parent.translate(posx,posy);
parent.popMatrix();
}
public void mover3d (int posx, int posy, int posz){
parent.pushMatrix();
parent.translate(posx,posy,posz);
parent.popMatrix();
}
public void dibujar(){
Cilindro((ancho_casilla-4), 40, 20);
}
public void rotar(){
parent.pushMatrix();
parent.rotateX(4.7F);
parent.popMatrix();
}
And then I do something like that in my draw() function on the main class:
Ficha ficha1 = new Ficha(this);
ficha1.dibujar();
ficha1.rotar();
rotateX(rotX + distY);
ficha1.mover2d(width/2,height/2);
The thing that I want to know is why all works fine except all the callings to the pushMatrix(), translate senteces from inside the class methods,etc.
Does anyone know why it happens that?
1