Skip to content

Commit

Permalink
Fix #43 - Correcting the vertex winding order of faces generated by M…
Browse files Browse the repository at this point in the history
…odelBuilder
  • Loading branch information
sriharshachilakapati committed Jul 19, 2015
1 parent 5a58519 commit b7e87c9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ public void init()
GL3Context.enable(GL_BLEND);
GL3Context.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

GL3Context.cullFace(GL_FRONT_AND_BACK);
GL3Context.viewport(0, 0, Display.getWidth(), Display.getHeight());

setClearColor(clearColor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ public ModelBuilder createBox(float width, float height, float thickness)
{
// Front faces of the box
emitVertex(new Vector3(-width / 2, +height / 2, +thickness / 2), new Vector3(0, 0, 1), new Vector2(0, 0));
emitVertex(new Vector3(+width / 2, +height / 2, +thickness / 2), new Vector3(0, 0, 1), new Vector2(1, 0));
emitVertex(new Vector3(-width / 2, -height / 2, +thickness / 2), new Vector3(0, 0, 1), new Vector2(0, 1));
emitVertex(new Vector3(+width / 2, +height / 2, +thickness / 2), new Vector3(0, 0, 1), new Vector2(1, 0));
emitFace();
emitVertex(new Vector3(+width / 2, +height / 2, +thickness / 2), new Vector3(0, 0, 1), new Vector2(1, 0));
emitVertex(new Vector3(+width / 2, -height / 2, +thickness / 2), new Vector3(0, 0, 1), new Vector2(1, 1));
emitVertex(new Vector3(-width / 2, -height / 2, +thickness / 2), new Vector3(0, 0, 1), new Vector2(0, 1));
emitVertex(new Vector3(+width / 2, -height / 2, +thickness / 2), new Vector3(0, 0, 1), new Vector2(1, 1));
emitFace();

// Back faces of the box
Expand All @@ -93,12 +93,12 @@ public ModelBuilder createBox(float width, float height, float thickness)

// Left faces of the box
emitVertex(new Vector3(-width / 2, +height / 2, -thickness / 2), new Vector3(-1, 0, 0), new Vector2(0, 0));
emitVertex(new Vector3(-width / 2, +height / 2, +thickness / 2), new Vector3(-1, 0, 0), new Vector2(1, 0));
emitVertex(new Vector3(-width / 2, -height / 2, -thickness / 2), new Vector3(-1, 0, 0), new Vector2(0, 1));
emitVertex(new Vector3(-width / 2, +height / 2, +thickness / 2), new Vector3(-1, 0, 0), new Vector2(1, 0));
emitFace();
emitVertex(new Vector3(-width / 2, +height / 2, +thickness / 2), new Vector3(-1, 0, 0), new Vector2(1, 0));
emitVertex(new Vector3(-width / 2, -height / 2, +thickness / 2), new Vector3(-1, 0, 0), new Vector2(1, 1));
emitVertex(new Vector3(-width / 2, -height / 2, -thickness / 2), new Vector3(-1, 0, 0), new Vector2(0, 1));
emitVertex(new Vector3(-width / 2, -height / 2, +thickness / 2), new Vector3(-1, 0, 0), new Vector2(1, 1));
emitFace();

// Right faces of the box
Expand All @@ -113,12 +113,12 @@ public ModelBuilder createBox(float width, float height, float thickness)

// Top faces of the box
emitVertex(new Vector3(-width / 2, +height / 2, -thickness / 2), new Vector3(0, 1, 0), new Vector2(0, 0));
emitVertex(new Vector3(+width / 2, +height / 2, -thickness / 2), new Vector3(0, 1, 0), new Vector2(1, 0));
emitVertex(new Vector3(-width / 2, +height / 2, +thickness / 2), new Vector3(0, 1, 0), new Vector2(0, 1));
emitVertex(new Vector3(+width / 2, +height / 2, -thickness / 2), new Vector3(0, 1, 0), new Vector2(1, 0));
emitFace();
emitVertex(new Vector3(+width / 2, +height / 2, -thickness / 2), new Vector3(0, 1, 0), new Vector2(1, 0));
emitVertex(new Vector3(+width / 2, +height / 2, +thickness / 2), new Vector3(0, 1, 0), new Vector2(1, 1));
emitVertex(new Vector3(-width / 2, +height / 2, +thickness / 2), new Vector3(0, 1, 0), new Vector2(0, 1));
emitVertex(new Vector3(+width / 2, +height / 2, +thickness / 2), new Vector3(0, 1, 0), new Vector2(1, 1));
emitFace();

// Bottom faces of the box
Expand Down

0 comments on commit b7e87c9

Please sign in to comment.