Skip to content

Commit 922ecc8

Browse files
committed
Added Mesh and Vertex class
1 parent c435917 commit 922ecc8

File tree

7 files changed

+119
-0
lines changed

7 files changed

+119
-0
lines changed

.settings/org.eclipse.jdt.core.prefs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
4+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5+
org.eclipse.jdt.core.compiler.compliance=1.7
6+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
8+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11+
org.eclipse.jdt.core.compiler.source=1.7

bin/com/naronco/pedopac/Game.class

0 Bytes
Binary file not shown.

bin/com/naronco/pedopac/Main.class

37 Bytes
Binary file not shown.

bin/com/naronco/pedopac/Mesh.class

1.71 KB
Binary file not shown.

bin/com/naronco/pedopac/Vertex.class

2.27 KB
Binary file not shown.

src/com/naronco/pedopac/Mesh.java

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.naronco.pedopac;
2+
3+
import static org.lwjgl.opengl.GL11.*;
4+
5+
public class Mesh {
6+
private int displayList;
7+
8+
public Mesh(Vertex[] vertices, int[] indices) {
9+
displayList = glGenLists(1);
10+
11+
glNewList(displayList, GL_COMPILE);
12+
glBegin(GL_TRIANGLES);
13+
14+
for (int index : indices) {
15+
Vertex vertex = vertices[index];
16+
glTexCoord2f(vertex.getUv().x, vertex.getUv().y);
17+
glNormal3f(vertex.getNormal().x, vertex.getNormal().y,
18+
vertex.getNormal().z);
19+
glColor4f(vertex.getColor().x, vertex.getColor().y,
20+
vertex.getColor().z, vertex.getColor().w);
21+
glVertex3f(vertex.getPosition().x, vertex.getPosition().y,
22+
vertex.getPosition().z);
23+
}
24+
25+
glEnd();
26+
glEndList();
27+
}
28+
29+
@Override
30+
protected void finalize() throws Throwable {
31+
glDeleteLists(displayList, 1);
32+
}
33+
34+
public void render() {
35+
glCallList(displayList);
36+
}
37+
}

src/com/naronco/pedopac/Vertex.java

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package com.naronco.pedopac;
2+
3+
import org.lwjgl.util.vector.*;
4+
5+
public class Vertex {
6+
private Vector3f position;
7+
private Vector2f uv;
8+
private Vector3f normal;
9+
private Vector4f color;
10+
11+
public Vertex(Vector3f position) {
12+
this.position = position;
13+
this.uv = new Vector2f(0, 0);
14+
this.normal = new Vector3f(0, 0, 1);
15+
this.color = new Vector4f(1, 1, 1, 1);
16+
}
17+
18+
public Vertex(Vector3f position, Vector2f uv) {
19+
this.position = position;
20+
this.uv = uv;
21+
this.normal = new Vector3f(0, 0, 1);
22+
this.color = new Vector4f(1, 1, 1, 1);
23+
}
24+
25+
public Vertex(Vector3f position, Vector2f uv, Vector3f normal) {
26+
this.position = position;
27+
this.uv = uv;
28+
this.normal = normal;
29+
this.color = new Vector4f(1, 1, 1, 1);
30+
}
31+
32+
public Vertex(Vector3f position, Vector2f uv, Vector3f normal,
33+
Vector4f color) {
34+
this.position = position;
35+
this.uv = uv;
36+
this.normal = normal;
37+
this.color = color;
38+
}
39+
40+
public void setPosition(Vector3f position) {
41+
this.position = position;
42+
}
43+
44+
public void setUv(Vector2f uv) {
45+
this.uv = uv;
46+
}
47+
48+
public void setNormal(Vector3f normal) {
49+
this.normal = normal;
50+
}
51+
52+
public void setColor(Vector4f color) {
53+
this.color = color;
54+
}
55+
56+
public Vector3f getPosition() {
57+
return position;
58+
}
59+
60+
public Vector2f getUv() {
61+
return uv;
62+
}
63+
64+
public Vector3f getNormal() {
65+
return normal;
66+
}
67+
68+
public Vector4f getColor() {
69+
return color;
70+
}
71+
}

0 commit comments

Comments
 (0)