From e6d1f98246d2957bc3f64b4a50ccc6d8b9efd560 Mon Sep 17 00:00:00 2001 From: Ziga Patacko Koderman Date: Wed, 23 Sep 2015 17:45:01 +0200 Subject: [PATCH] fixed everything --- .gitignore | 0 LICENSE | 0 README.md | 0 lib/javadrone-api-1.3.jar | Bin lib/log4j-1.2.17.jar | Bin lib/lwjgl.jar | Bin reader_joystick.py | 0 reader_oculus.py | 0 res/batt_off.png | Bin res/batt_on.png | Bin res/font.ttf | Bin res/grid.png | Bin res/h.png | Bin res/logo.png | Bin res/logo2.png | Bin res/off.png | Bin res/on.png | Bin res/roll.png | Bin res/rotate.png | Bin res/speed.png | Bin shaders/fragmentShader.txt | 0 shaders/vertexShaderLeft.txt | 0 shaders/vertexShaderLeft.txt~ | 45 ++++++++++++++++++ shaders/vertexShaderRight.txt | 0 shaders/vertexShaderRight.txt~ | 45 ++++++++++++++++++ src/com/sourcegasm/riftvision/Main.java | 0 .../riftvision/control/ControlModes.java | 0 .../riftvision/control/DroneController.java | 0 .../riftvision/control/ExpoController.java | 0 .../riftvision/control/MainController.java | 6 ++- .../riftvision/control/YawController.java | 0 .../sourcegasm/riftvision/game/LapTimer.java | 0 src/com/sourcegasm/riftvision/math/Euler.java | 0 .../riftvision/math/Quaternion.java | 0 .../riftvision/opengl/MeshMaker.java | 0 .../sourcegasm/riftvision/opengl/Model.java | 0 .../riftvision/opengl/OpenGLWindow.java | 2 +- .../riftvision/opengl/ShaderUtils.java | 0 .../riftvision/opengl/TextureLoader.java | 0 .../riftvision/opengl/Utilities.java | 0 .../riftvision/render/OSDRender.java | 0 .../riftvision/render/OculusLayerRender.java | 0 .../riftvision/render/RenderManager.java | 0 .../riftvision/render/SBSBufferedImage.java | 0 .../riftvision/sensors/JoyStickSensors.java | 1 + .../riftvision/sensors/LowPassFilter.java | 0 .../riftvision/sensors/OculusSensors.java | 0 47 files changed, 96 insertions(+), 3 deletions(-) mode change 100644 => 100755 .gitignore mode change 100644 => 100755 LICENSE mode change 100644 => 100755 README.md mode change 100644 => 100755 lib/javadrone-api-1.3.jar mode change 100644 => 100755 lib/log4j-1.2.17.jar mode change 100644 => 100755 lib/lwjgl.jar mode change 100644 => 100755 reader_joystick.py mode change 100644 => 100755 reader_oculus.py mode change 100644 => 100755 res/batt_off.png mode change 100644 => 100755 res/batt_on.png mode change 100644 => 100755 res/font.ttf mode change 100644 => 100755 res/grid.png mode change 100644 => 100755 res/h.png mode change 100644 => 100755 res/logo.png mode change 100644 => 100755 res/logo2.png mode change 100644 => 100755 res/off.png mode change 100644 => 100755 res/on.png mode change 100644 => 100755 res/roll.png mode change 100644 => 100755 res/rotate.png mode change 100644 => 100755 res/speed.png mode change 100644 => 100755 shaders/fragmentShader.txt mode change 100644 => 100755 shaders/vertexShaderLeft.txt create mode 100755 shaders/vertexShaderLeft.txt~ mode change 100644 => 100755 shaders/vertexShaderRight.txt create mode 100755 shaders/vertexShaderRight.txt~ mode change 100644 => 100755 src/com/sourcegasm/riftvision/Main.java mode change 100644 => 100755 src/com/sourcegasm/riftvision/control/ControlModes.java mode change 100644 => 100755 src/com/sourcegasm/riftvision/control/DroneController.java mode change 100644 => 100755 src/com/sourcegasm/riftvision/control/ExpoController.java mode change 100644 => 100755 src/com/sourcegasm/riftvision/control/MainController.java mode change 100644 => 100755 src/com/sourcegasm/riftvision/control/YawController.java mode change 100644 => 100755 src/com/sourcegasm/riftvision/game/LapTimer.java mode change 100644 => 100755 src/com/sourcegasm/riftvision/math/Euler.java mode change 100644 => 100755 src/com/sourcegasm/riftvision/math/Quaternion.java mode change 100644 => 100755 src/com/sourcegasm/riftvision/opengl/MeshMaker.java mode change 100644 => 100755 src/com/sourcegasm/riftvision/opengl/Model.java mode change 100644 => 100755 src/com/sourcegasm/riftvision/opengl/OpenGLWindow.java mode change 100644 => 100755 src/com/sourcegasm/riftvision/opengl/ShaderUtils.java mode change 100644 => 100755 src/com/sourcegasm/riftvision/opengl/TextureLoader.java mode change 100644 => 100755 src/com/sourcegasm/riftvision/opengl/Utilities.java mode change 100644 => 100755 src/com/sourcegasm/riftvision/render/OSDRender.java mode change 100644 => 100755 src/com/sourcegasm/riftvision/render/OculusLayerRender.java mode change 100644 => 100755 src/com/sourcegasm/riftvision/render/RenderManager.java mode change 100644 => 100755 src/com/sourcegasm/riftvision/render/SBSBufferedImage.java mode change 100644 => 100755 src/com/sourcegasm/riftvision/sensors/JoyStickSensors.java mode change 100644 => 100755 src/com/sourcegasm/riftvision/sensors/LowPassFilter.java mode change 100644 => 100755 src/com/sourcegasm/riftvision/sensors/OculusSensors.java diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/lib/javadrone-api-1.3.jar b/lib/javadrone-api-1.3.jar old mode 100644 new mode 100755 diff --git a/lib/log4j-1.2.17.jar b/lib/log4j-1.2.17.jar old mode 100644 new mode 100755 diff --git a/lib/lwjgl.jar b/lib/lwjgl.jar old mode 100644 new mode 100755 diff --git a/reader_joystick.py b/reader_joystick.py old mode 100644 new mode 100755 diff --git a/reader_oculus.py b/reader_oculus.py old mode 100644 new mode 100755 diff --git a/res/batt_off.png b/res/batt_off.png old mode 100644 new mode 100755 diff --git a/res/batt_on.png b/res/batt_on.png old mode 100644 new mode 100755 diff --git a/res/font.ttf b/res/font.ttf old mode 100644 new mode 100755 diff --git a/res/grid.png b/res/grid.png old mode 100644 new mode 100755 diff --git a/res/h.png b/res/h.png old mode 100644 new mode 100755 diff --git a/res/logo.png b/res/logo.png old mode 100644 new mode 100755 diff --git a/res/logo2.png b/res/logo2.png old mode 100644 new mode 100755 diff --git a/res/off.png b/res/off.png old mode 100644 new mode 100755 diff --git a/res/on.png b/res/on.png old mode 100644 new mode 100755 diff --git a/res/roll.png b/res/roll.png old mode 100644 new mode 100755 diff --git a/res/rotate.png b/res/rotate.png old mode 100644 new mode 100755 diff --git a/res/speed.png b/res/speed.png old mode 100644 new mode 100755 diff --git a/shaders/fragmentShader.txt b/shaders/fragmentShader.txt old mode 100644 new mode 100755 diff --git a/shaders/vertexShaderLeft.txt b/shaders/vertexShaderLeft.txt old mode 100644 new mode 100755 diff --git a/shaders/vertexShaderLeft.txt~ b/shaders/vertexShaderLeft.txt~ new file mode 100755 index 0000000..ad6f203 --- /dev/null +++ b/shaders/vertexShaderLeft.txt~ @@ -0,0 +1,45 @@ +#version 400 core + +layout(location = 0) in vec3 coordinates; +layout(location = 1) in vec2 textureCoordinates; + +out vec2 pass_textureCoordinates; + +vec4 Distort(vec4 p, float BarrelPower) { + float CALIBRATION2 = -0.068731; + float paramA = -0.007715; + float paramC = -0.25; + float paramD = 1.0 - paramA - CALIBRATION2 - paramC; + + + vec2 v = p.xy / p.w; + // Convert to polar coords: + float radius = length(v); + if (radius > 0) { + float theta = atan(v.y, v.x); + + // Distort: + radius = (paramA * radius * radius * radius + CALIBRATION2 * radius * radius + paramC * radius + paramD) + * radius * 0.77; + + // Convert back to Cartesian: + v.x = radius * cos(theta); + v.y = radius * sin(theta); + p.xy = v.xy * p.w; + } + return p; +} + +void main() { + vec4 P = vec4(coordinates, 1); + P.x += 0.45; + + vec4 newPos = Distort(P, 0.9); + newPos.x -= 0.5; + //newPos.y += 0.03; + + newPos.x += 0.03; + + gl_Position = newPos; + pass_textureCoordinates = textureCoordinates; +} diff --git a/shaders/vertexShaderRight.txt b/shaders/vertexShaderRight.txt old mode 100644 new mode 100755 diff --git a/shaders/vertexShaderRight.txt~ b/shaders/vertexShaderRight.txt~ new file mode 100755 index 0000000..5590bd9 --- /dev/null +++ b/shaders/vertexShaderRight.txt~ @@ -0,0 +1,45 @@ +#version 400 core + +layout(location = 0) in vec3 coordinates; +layout(location = 1) in vec2 textureCoordinates; + +out vec2 pass_textureCoordinates; + +vec4 Distort(vec4 p, float BarrelPower) { + float CALIBRATION2 = -0.068731; + float paramA = -0.007715; + float paramC = -0.25; + float paramD = 1.0 - paramA - CALIBRATION2 - paramC; + + + vec2 v = p.xy / p.w; + // Convert to polar coords: + float radius = length(v); + if (radius > 0) { + float theta = atan(v.y, v.x); + + // Distort: + radius = (paramA * radius * radius * radius + CALIBRATION2 * radius * radius + paramC * radius + paramD) + * radius * 0.77; + + // Convert back to Cartesian: + v.x = radius * cos(theta); + v.y = radius * sin(theta); + p.xy = v.xy * p.w; + } + return p; +} + +void main() { + vec4 P = vec4(coordinates, 1); + P.x -= 0.45; + + vec4 newPos = Distort(P, 0.9); + newPos.x += 0.5; + //newPos.y += 0.03; + + newPos.x += 0.03; + + gl_Position = newPos; + pass_textureCoordinates = textureCoordinates; +} diff --git a/src/com/sourcegasm/riftvision/Main.java b/src/com/sourcegasm/riftvision/Main.java old mode 100644 new mode 100755 diff --git a/src/com/sourcegasm/riftvision/control/ControlModes.java b/src/com/sourcegasm/riftvision/control/ControlModes.java old mode 100644 new mode 100755 diff --git a/src/com/sourcegasm/riftvision/control/DroneController.java b/src/com/sourcegasm/riftvision/control/DroneController.java old mode 100644 new mode 100755 diff --git a/src/com/sourcegasm/riftvision/control/ExpoController.java b/src/com/sourcegasm/riftvision/control/ExpoController.java old mode 100644 new mode 100755 diff --git a/src/com/sourcegasm/riftvision/control/MainController.java b/src/com/sourcegasm/riftvision/control/MainController.java old mode 100644 new mode 100755 index 297e2ac..68e10f2 --- a/src/com/sourcegasm/riftvision/control/MainController.java +++ b/src/com/sourcegasm/riftvision/control/MainController.java @@ -145,8 +145,10 @@ public void stopController() { } catch (final IOException e) { e.printStackTrace(); } - thread.stop(); - thread = null; + if(thread != null){ + thread.stop(); + thread = null; + } } public DroneController getDroneController() { diff --git a/src/com/sourcegasm/riftvision/control/YawController.java b/src/com/sourcegasm/riftvision/control/YawController.java old mode 100644 new mode 100755 diff --git a/src/com/sourcegasm/riftvision/game/LapTimer.java b/src/com/sourcegasm/riftvision/game/LapTimer.java old mode 100644 new mode 100755 diff --git a/src/com/sourcegasm/riftvision/math/Euler.java b/src/com/sourcegasm/riftvision/math/Euler.java old mode 100644 new mode 100755 diff --git a/src/com/sourcegasm/riftvision/math/Quaternion.java b/src/com/sourcegasm/riftvision/math/Quaternion.java old mode 100644 new mode 100755 diff --git a/src/com/sourcegasm/riftvision/opengl/MeshMaker.java b/src/com/sourcegasm/riftvision/opengl/MeshMaker.java old mode 100644 new mode 100755 diff --git a/src/com/sourcegasm/riftvision/opengl/Model.java b/src/com/sourcegasm/riftvision/opengl/Model.java old mode 100644 new mode 100755 diff --git a/src/com/sourcegasm/riftvision/opengl/OpenGLWindow.java b/src/com/sourcegasm/riftvision/opengl/OpenGLWindow.java old mode 100644 new mode 100755 index 5ad3555..5b667d1 --- a/src/com/sourcegasm/riftvision/opengl/OpenGLWindow.java +++ b/src/com/sourcegasm/riftvision/opengl/OpenGLWindow.java @@ -90,8 +90,8 @@ public void init() { glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); + //window = glfwCreateWindow(width, height, "RiftVision", glfwGetMonitors().get(1), NULL); window = glfwCreateWindow(width, height, "RiftVision", glfwGetPrimaryMonitor(), NULL); - if (window == NULL) { System.err.println("Could not create our Window!"); } diff --git a/src/com/sourcegasm/riftvision/opengl/ShaderUtils.java b/src/com/sourcegasm/riftvision/opengl/ShaderUtils.java old mode 100644 new mode 100755 diff --git a/src/com/sourcegasm/riftvision/opengl/TextureLoader.java b/src/com/sourcegasm/riftvision/opengl/TextureLoader.java old mode 100644 new mode 100755 diff --git a/src/com/sourcegasm/riftvision/opengl/Utilities.java b/src/com/sourcegasm/riftvision/opengl/Utilities.java old mode 100644 new mode 100755 diff --git a/src/com/sourcegasm/riftvision/render/OSDRender.java b/src/com/sourcegasm/riftvision/render/OSDRender.java old mode 100644 new mode 100755 diff --git a/src/com/sourcegasm/riftvision/render/OculusLayerRender.java b/src/com/sourcegasm/riftvision/render/OculusLayerRender.java old mode 100644 new mode 100755 diff --git a/src/com/sourcegasm/riftvision/render/RenderManager.java b/src/com/sourcegasm/riftvision/render/RenderManager.java old mode 100644 new mode 100755 diff --git a/src/com/sourcegasm/riftvision/render/SBSBufferedImage.java b/src/com/sourcegasm/riftvision/render/SBSBufferedImage.java old mode 100644 new mode 100755 diff --git a/src/com/sourcegasm/riftvision/sensors/JoyStickSensors.java b/src/com/sourcegasm/riftvision/sensors/JoyStickSensors.java old mode 100644 new mode 100755 index a5fec45..e5df00b --- a/src/com/sourcegasm/riftvision/sensors/JoyStickSensors.java +++ b/src/com/sourcegasm/riftvision/sensors/JoyStickSensors.java @@ -98,6 +98,7 @@ public void startReceiving() { e14.printStackTrace(); } } else if (Integer.parseInt(mami_array[5].trim()) == 1) { + System.out.println("asdf"); droneController.setControlMode(droneController.getNextMode()); } else if (Integer.parseInt(mami_array[4].trim()) == 1) { droneController.setControlMode(droneController.getPreviousMode()); diff --git a/src/com/sourcegasm/riftvision/sensors/LowPassFilter.java b/src/com/sourcegasm/riftvision/sensors/LowPassFilter.java old mode 100644 new mode 100755 diff --git a/src/com/sourcegasm/riftvision/sensors/OculusSensors.java b/src/com/sourcegasm/riftvision/sensors/OculusSensors.java old mode 100644 new mode 100755