Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Repaired Camera3rdPerson and ExampleFrame (3D Math Tutorial #6) world

projections and camera translations.
  • Loading branch information...
commit cf7438608930c339411b403f2eab4c77638a42dd 1 parent fa7f378
Westin Miller authored
7 3D Graphics/JOGL Beginner/src/com/pi/gl/graphics/Camera3rdPerson.java
View
@@ -9,7 +9,7 @@
private static final float yawMilli = .1f;
private static final float pitchMilli = .1f;
- private float pitch = 45, yaw = 0;
+ private float pitch = 45, yaw = 0, centerDist = 500;
private boolean u, l, d, r;
private long lastMoveProc = -1;
@@ -43,11 +43,12 @@ public void translate(GL2 gl) {
else if (d)
modPitch(-passed * pitchMilli);
if (l)
- modYaw(passed * yawMilli);
- else if (r)
modYaw(-passed * yawMilli);
+ else if (r)
+ modYaw(passed * yawMilli);
}
lastMoveProc = System.currentTimeMillis();
+ gl.glTranslatef(0, 0, -centerDist);
gl.glRotatef(pitch, 1, 0, 0);
gl.glRotatef(360 - yaw, 0, 1, 0);
}
5 3D Graphics/JOGL Beginner/src/com/pi/gl/graphics/RenderLoop.java
View
@@ -20,8 +20,7 @@ public RenderLoop(DisplayManager displayManager) {
this.displayManager = displayManager;
float[][] hMap;
try {
- hMap = MeshLoader.loadHeightMap(new File("heightmap.png"), 0,
- 255);
+ hMap = MeshLoader.loadHeightMap(new File("heightmap.png"), 0, 255);
} catch (Exception e) {
hMap = new float[50][50];
}
@@ -47,7 +46,7 @@ public void display(GLAutoDrawable drawable) {
gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
gl.glLoadIdentity();
gl.glOrtho(drawable.getWidth() / -2, drawable.getWidth() / 2,
- drawable.getHeight() / 2, drawable.getHeight() / -2, -500, 500);
+ drawable.getHeight() / -2, drawable.getHeight() / 2, 50, 1000);
gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
gl.glLoadIdentity();
displayManager.getCamera().translate(gl);
2  3D Graphics/JOGL Beginner/tut/3 - World Projection and The First Triangle
View
@@ -12,7 +12,7 @@ In our case we will be adding it to the display function of the render loop. Th
[CODE] // Define the world projection
gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
gl.glLoadIdentity();
- gl.glOrtho(drawable.getWidth()/-2, drawable.getWidth()/2, drawable.getHeight()/2, drawable.getHeight()/-2, -500, 500);
+ gl.glOrtho(drawable.getWidth()/-2, drawable.getWidth()/2, drawable.getHeight()/-2, drawable.getHeight()/2, 50, 1000);
gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
gl.glLoadIdentity();[/CODE]
11 3D Graphics/JOGL Beginner/tut/4 - Camera 3rd Person
View
@@ -17,7 +17,7 @@ public class Camera3rdPerson implements KeyListener {
private static final float yawMilli = .1f;
private static final float pitchMilli = .1f;
- private float pitch = 45, yaw = 0;
+ private float pitch = 45, yaw = 0, centerDist = 500;
private boolean u, l, d, r;
private long lastMoveProc = -1;
@@ -47,15 +47,16 @@ public class Camera3rdPerson implements KeyListener {
if (lastMoveProc != -1) {
long passed = System.currentTimeMillis() - lastMoveProc;
if (u)
- modPitch(passed * pitchMilli);
- else if (d)
modPitch(-passed * pitchMilli);
+ else if (d)
+ modPitch(passed * pitchMilli);
if (l)
- modYaw(passed * yawMilli);
- else if (r)
modYaw(-passed * yawMilli);
+ else if (r)
+ modYaw(passed * yawMilli);
}
lastMoveProc = System.currentTimeMillis();
+ gl.glTranslatef(0, 0, -centerDist);
gl.glRotatef(pitch, 1, 0, 0);
gl.glRotatef(360 - yaw, 0, 1, 0);
}
Please sign in to comment.
Something went wrong with that request. Please try again.