Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ecumene.opengl;
- import org.lwjgl.opengl.GL11;
- import org.lwjgl.util.vector.Vector2f;
- import org.lwjgl.util.vector.Vector3f;
- import org.lwjgl.util.vector.Vector4f;
- import ecumene.data.Color;
- /**
- * Contains data to be processed per-vertex, like color,
- * position, texture coordinates, and normals
- *
- * @author Ecumene
- */
- public class Vertex {
- /**The vertex's location*/
- public Vector4f position;
- /**The vertex's uv*/
- public Vector2f textureUV;
- /**The vertex's color*/
- public Color color;
- /**The vertex's normal*/
- public Vector3f normal;
- /**
- * Initializes the vertex with all possible information
- *
- * @param position The vertex's position
- * @param textureUV The vertex's texture coordinate
- * @param normal The vertex's normal
- * @param color The vertex's color
- */
- public Vertex(Vector4f position, Vector2f textureUV, Color color, Vector3f normal){
- this.position = position;
- this.textureUV = textureUV;
- this.color = color;
- this.normal = normal;
- }
- /**
- * Initializes the vertex with no normal
- *
- * @param position The vertex's position
- * @param textureUV The vertex's texture coordinate
- * @param color The vertex's color
- */
- public Vertex(Vector4f position, Vector2f textureUV, Color color){
- this(position, textureUV, color, new Vector3f(0, 0, 0));
- }
- /**
- * Initializes the vertex with no normal, or texture coordinate
- *
- * @param position The vertex's position
- * @param color The vertex's color
- */
- public Vertex(Vector4f position, Color color){
- this(position, new Vector2f(0, 0), color, new Vector3f(0, 0, 0));
- }
- /**
- * Initializes the vertex with no normal, color, or texture coordinate,
- * just a position.
- *
- * @param position The vertex's position
- */
- public Vertex(Vector4f position){
- this(position, new Vector2f(0, 0), new Color(1, 1, 1, 1), new Vector3f(0, 0, 0));
- }
- /**
- * Draws the vertex using OpenGL 1.0
- * @deprecated Because OpenGL 1.0 is very old
- */
- @Deprecated
- public static void draw(Vertex vert){
- GL11.glVertex4f(vert.position.x, vert.position.y, vert.position.z, vert.position.w);
- GL11.glColor4f(vert.color.getRed(), vert.color.getGreen(), vert.color.getBlue(), vert.color.getAlpha());
- GL11.glNormal3f(vert.normal.x, vert.normal.y, vert.normal.z);
- GL11.glTexCoord2f(vert.textureUV.x, vert.textureUV.y);
- }
- /**
- * Draws the vertex using OpenGL 1.0
- * @deprecated Because OpenGL 1.0 is very old
- */
- @Deprecated
- public void draw(){
- GL11.glVertex4f(position.x, position.y, position.z, position.w);
- GL11.glColor4f(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
- GL11.glNormal3f(normal.x, normal.y, normal.z);
- GL11.glTexCoord2f(textureUV.x, textureUV.y);
- }
- /**
- * Draws the given vertices using OpenGL 1.0
- * @deprecated Because OpenGL 1.0 is very old
- */
- @Deprecated
- public static void drawAll(Vertex[] model, int mode){
- GL11.glBegin(mode);
- for(Vertex vert : model){
- GL11.glVertex4f(vert.position.x, vert.position.y, vert.position.z, vert.position.w);
- GL11.glColor4f(vert.color.getRed(), vert.color.getGreen(), vert.color.getBlue(), vert.color.getAlpha());
- GL11.glNormal3f(vert.normal.x, vert.normal.y, vert.normal.z);
- GL11.glTexCoord2f(vert.textureUV.x, vert.textureUV.y);
- }
- GL11.glEnd();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement