From 19761cabc47bac53292956f5f29d0a9c4104e7bd Mon Sep 17 00:00:00 2001 From: Kishan Tripathi Date: Fri, 4 Jun 2021 23:50:09 +0530 Subject: [PATCH] Update Readme, add more Documentation --- README.md | 9 ++++++++- src/main/java/PanoViewer/gui/PhotoSphere.java | 14 +++++++++----- src/main/java/PanoViewer/settings.java | 1 + 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 820e96e..afe2b72 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,9 @@ OpenGL based Image Viewer for 360 degrees Panoramic Images. -LICENSE : GPL \ No newline at end of file +LICENSE : GPL + +Minimum Requirements +Java Version 8+ +OpenGL version 4.0+ + +To run the jar file pass the path of an Image as argument. +Example - `java -jar PanoViewer.jar ` \ No newline at end of file diff --git a/src/main/java/PanoViewer/gui/PhotoSphere.java b/src/main/java/PanoViewer/gui/PhotoSphere.java index 10ab01b..dd4dbb7 100644 --- a/src/main/java/PanoViewer/gui/PhotoSphere.java +++ b/src/main/java/PanoViewer/gui/PhotoSphere.java @@ -43,8 +43,8 @@ public class PhotoSphere extends GLCanvas implements GLEventListener { private int rendering_program; private final Camera camera; private final FloatBuffer vals = Buffers.newDirectFloatBuffer(16); - private Matrix4f pMat = new Matrix4f(); - private Matrix4f vMat = new Matrix4f(); + private final Matrix4f pMat = new Matrix4f(); + private final Matrix4f vMat = new Matrix4f(); private final Matrix4f mvMat = new Matrix4f(); private final Matrix4f mMat = new Matrix4f(); private int mvLoc, projLoc; @@ -97,7 +97,7 @@ public void init(GLAutoDrawable glad) { setupVertices(glad.getGL().getGL4()); aspect = (float) getWidth() / (float) getHeight(); pMat.setPerspective((float) Math.toRadians(fov), aspect, 0.1f, 1000.0f); - vMat = camera.getViewMatrix(); + vMat.set(camera.getViewMatrix()); mMat.translation(sphereLoc); texture = new Texture(GL_TEXTURE_2D); } @@ -141,7 +141,6 @@ public void display(GLAutoDrawable glad) { gl.glEnable(GL_DEPTH_TEST); gl.glDepthFunc(GL_LEQUAL); -// gl.glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); gl.glActiveTexture(GL_TEXTURE0); texture.enable(gl); @@ -205,11 +204,16 @@ private void disableZoomPan() { this.removeMouseWheelListener(listener); } + /** + * Rotates the camera. + * @param yaw Yaw angle in radian. + * @param pitch Pitch angle in radian. + */ public void rotateCamera(double yaw, double pitch) { float newYaw = (float) (yaw * fov / IDEAL_FOV); float newPitch = (float) (pitch * fov / IDEAL_FOV); camera.rotate(newYaw, newPitch); - vMat = camera.getViewMatrix(); + vMat.set(camera.getViewMatrix()); repaint(); } diff --git a/src/main/java/PanoViewer/settings.java b/src/main/java/PanoViewer/settings.java index 2c2b1ab..4a3d4f5 100644 --- a/src/main/java/PanoViewer/settings.java +++ b/src/main/java/PanoViewer/settings.java @@ -15,6 +15,7 @@ public class settings { private static int wheelSenstivity = 5; private static int precision = 90; private static GLProfile gl; + /* Whether or not to flip the image when creating texture data. */ private static boolean invertImage; private settings() {