Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.foxycorndog.presto3d.graphics;
- import static org.lwjgl.opengl.GL11.*;
- public class PrestoGL
- {
- public static void drawCube(float x, float y, float z, int size)
- {
- glBegin(GL_QUADS);
- // Front face
- glNormal3f(0 , 0 , 1 );
- glVertex3f(x , y , z );
- glVertex3f(x + size, y , z );
- glVertex3f(x + size, y + size, z );
- glVertex3f(x , y + size, z );
- // Back face
- glNormal3f(0 , 0 , -1 );
- glVertex3f(x , y , z - size);
- glVertex3f(x , y + size, z - size);
- glVertex3f(x + size, y + size, z - size);
- glVertex3f(x + size, y , z - size);
- // Bottom face
- glNormal3f(0 , 1 , 0 );
- glVertex3f(x , y , z - size);
- glVertex3f(x + size, y , z - size);
- glVertex3f(x + size, y , z );
- glVertex3f(x , y , z );
- // Top face
- glNormal3f(0 , -1 , 0 );
- glVertex3f(x , y + size, z - size);
- glVertex3f(x , y + size, z );
- glVertex3f(x + size, y + size, z );
- glVertex3f(x + size, y + size, z - size);
- // Left face
- glNormal3f(-1 , 0 , 0 );
- glVertex3f(x , y , z );
- glVertex3f(x , y + size, z );
- glVertex3f(x , y + size, z - size);
- glVertex3f(x , y , z - size);
- // Right face
- glNormal3f(1 , 0 , 0 );
- glVertex3f(x + size, y , z );
- glVertex3f(x + size, y , z - size);
- glVertex3f(x + size, y + size, z - size);
- glVertex3f(x + size, y + size, z );
- glEnd();
- }
- public static float[] getCubeArray(float x, float y, float z, int size)
- {
- float array[] = null;
- array = new float[6 * 4];
- array = new float[]
- {
- // Front side
- x , y , z,
- x + size, y , z,
- x + size, y + size, z,
- x , y + size, z,
- // Back side
- x , y , z - size,
- x , y + size, z - size,
- x + size, y + size, z - size,
- x + size, y , z - size,
- // Bottom face
- x , y , z - size,
- x + size, y , z - size,
- x + size, y , z,
- x , y , z,
- // Top face
- x , y + size, z - size,
- x , y + size, z,
- x + size, y + size, z,
- x + size, y + size, z - size,
- // Left face
- x , y , z,
- x , y + size, z,
- x , y + size, z - size,
- x , y , z - size
- };
- return array;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement