Hello, I did some searching on this and I'm still a little puzzled.
I wrote something that translates to the center of the screen rotates about 3 axes, then paints a rectangular panel in 3D space. I wanted to move this work inside a class that takes care of itself, which seemed to work until I moved the translate() statement inside the class.
The old draw loop in the main class:
void draw(){ background(0); pushMatrix(); translate(width / 2, height / 2, 100); // move to middle of screen myPanel.set_bearing(new float[] {PI * i / 30,PI * i / 30,PI * i / 30}); myPanel.paint(); popMatrix(); i++; }
Now instantiating a new version of the QuadForm myPanel passed the above translate() arguments in the constructor for later use each frame:
myPanel = new QuadForm(width / 2, height / 2, 100);
The new QuadForm.paint(), with translate(). It's important to note that the only change from the working version to the new version is translate(), which I have verified was passed the proper parameters.
void paint(){ fill(shapeColor); translate(cX, cY, cZ); // moving translate to QF causes failure to display rotateY(bearing[0]); // Transfer rotations to QF, no error rotateX(bearing[1]); rotateZ(bearing[2]);
beginShape(QUADS); for(int i = 0; i < template.length; i++){ vertex(template[i][0], template[i][1], template[i][2]); } endShape(); } }
Any clues as to why moving rotateX/Y/Z() inside the class should be fine but translate() is not?
This class represents an "endless" grid that is supposed to scroll under a player ship in a game. It rotates when the player turns. There's a strange thing that happens, though; processor usage shoots way up whenever the grid is at 45deg angles to the window edges! If I am drawing and throwing away the same number of lines per frame, why should the angle matter at all?