Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy isn't this JOGL code translating properly?
    text
    copied!<pre><code> public Cube(int x, int y, int z, int x2, int y2, int z2){ int tmpX = x; int tmpY = y; int tmpZ = z; if(x &gt; x2){x = x2; x2 = tmpX;} if(y &gt; y2){y = y2; y2 = tmpY;} if(z &gt; z2){z = z2; z2 = tmpZ;} int centerX = x2 - x; int centerY = y2 - y; int centerZ = z2 - z; GL11.glTranslatef(centerX, centerY, centerZ); GL11.glRotatef(rot, 0f, 0f, 1f); GL11.glBegin(GL11.GL_QUADS); //front color(255, 0, 0); v3d(x, y, z); v3d(x, y2, z); v3d(x2, y2, z); v3d(x2, y, z); //top color(0, 255, 0); v3d(x, y, z); v3d(x2, y, z); v3d(x2, y, z2); v3d(x, y, z2); //back color(0, 0, 255); v3d(x2, y2, z2); v3d(x, y2, z2); v3d(x, y, z2); v3d(x2, y, z2); //bottom color(255, 255, 0); v3d(x, y2, z); v3d(x2, y2, z); v3d(x2, y2, z2); v3d(x, y2, z2); //left color(255, 0, 255); v3d(x, y, z); v3d(x, y2, z); v3d(x, y2, z2); v3d(x, y, z2); //right color(0, 255, 255); v3d(x2, y, z); v3d(x2, y2, z); v3d(x2, y2, z2); v3d(x2, y, z2); GL11.glEnd(); GL11.glRotatef(-rot, 0f, 0f, 1f); GL11.glTranslatef(-centerX, -centerY, -centerZ); rot += 0.75f; if(rot &gt; 360){ rot -= 360; } } </code></pre> <p>I don't get why this isn't rotating around the Z axis just around the cube object itself, instead it appears to be just rotating around 0,0,0 in the matrix.</p> <p>I also tried this for the centering code:</p> <pre><code> int xWidth = x2 - x; int yWidth = y2 - y; int zWidth = z2 - z; int centerX = x + (xWidth / 2); int centerY = y + (yWidth / 2); int centerZ = z + (zWidth / 2); </code></pre> <p>But the first one made more sense after testing some math (15 - 5 = 10, 15 + 7.5 = 12.5). Any ideas?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload