Skip to content

Commit

Permalink
keep removing stuff from visualization panel
Browse files Browse the repository at this point in the history
  • Loading branch information
palasjir committed Dec 27, 2017
1 parent 3d2754e commit 54ed9c2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
10 changes: 8 additions & 2 deletions src/main/java/palasjir/viewer/coordinates/Camera.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import java.awt.Point;

import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
import palasjir.viewer.coordinates.GLSphericalCoordinates;


public class Camera {

Expand Down Expand Up @@ -72,6 +70,10 @@ public void zoom(double distance) {
updateView();
}

public void setupProjection(float fovy, int w, int h, float near, float far) {
this.setupProjection(fovy, aspect(w, h), near, far);
}

public void setupProjection(float fovy, float aspectRatio, float near, float far) {
this.aspectRatio = aspectRatio;
this.fovy = fovy;
Expand Down Expand Up @@ -109,4 +111,8 @@ public Mat4 mvp(Mat4 model) {
return new Mat4(projection.multiply(view).multiply(model));
}

private float aspect(int w, int h) {
return (float) w / (float) h;
}

}
11 changes: 5 additions & 6 deletions src/main/java/palasjir/viewer/ui/VisualizationPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) {
viewPortWidth = w;
viewPortHeight = h;
gl.glViewport(0, 0, w, h);
camera.setupProjection(45f, aspect(w, h), 1, 500);
camera.setupProjection(45f, w, h, 1, 500);
frameBufferId = initFrameBuffer(gl);
}

Expand Down Expand Up @@ -146,7 +146,10 @@ private void initShaderPrograms(GL4 gl) {
}

private void initRayCastingProgram(GL4 gl) {
rayProgram = new ShaderProgramHelper("raycasting.vert", "raycasting.frag");
rayProgram = new ShaderProgramHelper(
"raycasting.vert",
"raycasting.frag"
);
rayProgram.init(gl);
st.attachShaderProgram(gl, rayProgram.program(), true);
screenSizeLoc = st.getUniformLocation(gl, "screenSize");
Expand Down Expand Up @@ -386,8 +389,4 @@ private void activateFrameBuffer(GL gl, int frameBufferId) {
gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}

private float aspect(int w, int h) {
return (float) w / (float) h;
}

}

0 comments on commit 54ed9c2

Please sign in to comment.