move more state into rendering engine
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
This commit is contained in:
parent
4ec1ee18fa
commit
d5f2ccc4dc
@ -240,7 +240,7 @@ public class CameraEntityUtils {
|
|||||||
* @return The near clip
|
* @return The near clip
|
||||||
*/
|
*/
|
||||||
public static float getNearClip(Entity camera){
|
public static float getNearClip(Entity camera){
|
||||||
return Globals.nearClip;
|
return Globals.renderingEngine.getNearClip();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -262,7 +262,6 @@ public class UserSettings {
|
|||||||
}
|
}
|
||||||
Globals.WINDOW_WIDTH = Globals.userSettings.displayWidth;
|
Globals.WINDOW_WIDTH = Globals.userSettings.displayWidth;
|
||||||
Globals.WINDOW_HEIGHT = Globals.userSettings.displayHeight;
|
Globals.WINDOW_HEIGHT = Globals.userSettings.displayHeight;
|
||||||
Globals.verticalFOV = Globals.userSettings.graphicsFOV;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -194,10 +194,6 @@ public class Globals {
|
|||||||
//title bar dimensions
|
//title bar dimensions
|
||||||
public static int WINDOW_TITLE_BAR_HEIGHT = 0;
|
public static int WINDOW_TITLE_BAR_HEIGHT = 0;
|
||||||
|
|
||||||
public static float verticalFOV = 90;
|
|
||||||
public static float aspectRatio = 2.0f;
|
|
||||||
public static float nearClip = 0.01f;
|
|
||||||
|
|
||||||
//locations for shadow map specific variables
|
//locations for shadow map specific variables
|
||||||
public static int depthMapShaderProgramLoc = 0;
|
public static int depthMapShaderProgramLoc = 0;
|
||||||
|
|
||||||
|
|||||||
@ -143,8 +143,9 @@ public class RenderingEngine {
|
|||||||
public static int outputFramebuffer = 0;
|
public static int outputFramebuffer = 0;
|
||||||
|
|
||||||
//used in calculating projection matrix
|
//used in calculating projection matrix
|
||||||
static float aspectRatio = 1.0f;
|
float aspectRatio = 1.0f;
|
||||||
static float verticalFOV = 90.0f;
|
float verticalFOV = 90.0f;
|
||||||
|
float nearClip = 0.01f;
|
||||||
|
|
||||||
//matrices for drawing models
|
//matrices for drawing models
|
||||||
private Matrix4d viewMatrix = new Matrix4d();
|
private Matrix4d viewMatrix = new Matrix4d();
|
||||||
@ -401,7 +402,7 @@ public class RenderingEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//projection matrices
|
//projection matrices
|
||||||
nearVolumeProjectionMatrix.setPerspective((float)(Globals.verticalFOV * Math.PI /180.0f), (float)Globals.WINDOW_WIDTH / (float)Globals.WINDOW_HEIGHT, 0.1f, 100);
|
nearVolumeProjectionMatrix.setPerspective((float)(Globals.userSettings.getGraphicsFOV() * Math.PI /180.0f), (float)Globals.WINDOW_WIDTH / (float)Globals.WINDOW_HEIGHT, 0.1f, 100);
|
||||||
|
|
||||||
//
|
//
|
||||||
//Compositing textures and buffers
|
//Compositing textures and buffers
|
||||||
@ -471,10 +472,10 @@ public class RenderingEngine {
|
|||||||
//
|
//
|
||||||
// Projection and View matrix creation
|
// Projection and View matrix creation
|
||||||
//
|
//
|
||||||
verticalFOV = (float)(Globals.verticalFOV * Math.PI /180.0f);
|
this.verticalFOV = (float)(Globals.userSettings.getGraphicsFOV() * Math.PI /180.0f);
|
||||||
//set local aspect ratio and global aspect ratio at the same time
|
//set local aspect ratio and global aspect ratio at the same time
|
||||||
aspectRatio = Globals.aspectRatio = Globals.WINDOW_WIDTH / (float)Globals.WINDOW_HEIGHT;
|
this.aspectRatio = Globals.WINDOW_WIDTH / (float)Globals.WINDOW_HEIGHT;
|
||||||
this.projectionMatrix.setPerspective(verticalFOV, Globals.aspectRatio, Globals.nearClip, Globals.userSettings.getGraphicsViewDistance());
|
this.projectionMatrix.setPerspective(this.verticalFOV, this.aspectRatio, this.nearClip, Globals.userSettings.getGraphicsViewDistance());
|
||||||
this.viewMatrix.translation(new Vector3d(0.0f,0.0f,-3.0f));
|
this.viewMatrix.translation(new Vector3d(0.0f,0.0f,-3.0f));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -616,12 +617,12 @@ public class RenderingEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setFOV(float verticalFOV){
|
public static void setFOV(float verticalFOV){
|
||||||
RenderingEngine.verticalFOV = verticalFOV;
|
Globals.renderingEngine.verticalFOV = verticalFOV;
|
||||||
Globals.renderingEngine.calculateProjectionMatrix();
|
Globals.renderingEngine.calculateProjectionMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setAspectRatio(float aspectRatio){
|
public static void setAspectRatio(float aspectRatio){
|
||||||
RenderingEngine.aspectRatio = aspectRatio;
|
Globals.renderingEngine.aspectRatio = aspectRatio;
|
||||||
Globals.renderingEngine.calculateProjectionMatrix();
|
Globals.renderingEngine.calculateProjectionMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -629,9 +630,9 @@ public class RenderingEngine {
|
|||||||
* Calculates the projection matrix
|
* Calculates the projection matrix
|
||||||
*/
|
*/
|
||||||
public void calculateProjectionMatrix(){
|
public void calculateProjectionMatrix(){
|
||||||
float radVerticalFOV = (float)(RenderingEngine.verticalFOV * Math.PI /180.0f);
|
float radVerticalFOV = (float)(this.verticalFOV * Math.PI /180.0f);
|
||||||
float nearClip = 0.001f;
|
float nearClip = 0.001f;
|
||||||
this.projectionMatrix.setPerspective(radVerticalFOV, RenderingEngine.aspectRatio, nearClip, Globals.userSettings.getGraphicsViewDistance());
|
this.projectionMatrix.setPerspective(radVerticalFOV, this.aspectRatio, nearClip, Globals.userSettings.getGraphicsViewDistance());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -730,6 +731,14 @@ public class RenderingEngine {
|
|||||||
return lightDepthMatrix;
|
return lightDepthMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the near clip of the engine
|
||||||
|
* @return The near clip
|
||||||
|
*/
|
||||||
|
public float getNearClip(){
|
||||||
|
return this.nearClip;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tries to recapture the screen
|
* Tries to recapture the screen
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -271,8 +271,8 @@ public class ActorPanel extends BufferedStandardDrawableContainerElement impleme
|
|||||||
actor.applySpatialData(modelMatrix,new Vector3d(actorPosition));
|
actor.applySpatialData(modelMatrix,new Vector3d(actorPosition));
|
||||||
actor.draw(renderPipelineState,openGLState);
|
actor.draw(renderPipelineState,openGLState);
|
||||||
|
|
||||||
RenderingEngine.setFOV(Globals.verticalFOV);
|
RenderingEngine.setFOV(Globals.userSettings.getGraphicsFOV());
|
||||||
RenderingEngine.setAspectRatio(Globals.aspectRatio);
|
RenderingEngine.setAspectRatio(2.0f);
|
||||||
|
|
||||||
openGLState.glDepthTest(false);
|
openGLState.glDepthTest(false);
|
||||||
|
|
||||||
@ -364,11 +364,11 @@ public class ActorPanel extends BufferedStandardDrawableContainerElement impleme
|
|||||||
* Recalculates the model matrix
|
* Recalculates the model matrix
|
||||||
*/
|
*/
|
||||||
private void recalculateModelMatrix(){
|
private void recalculateModelMatrix(){
|
||||||
modelMatrix.identity();
|
this.modelMatrix.identity();
|
||||||
modelMatrix.translate(new Vector3d(actorPosition).sub(CameraEntityUtils.getCameraCenter(Globals.clientState.playerCamera)));
|
this.modelMatrix.translate(new Vector3d(actorPosition).sub(CameraEntityUtils.getCameraCenter(Globals.clientState.playerCamera)));
|
||||||
modelMatrix.rotate(actorRotation);
|
this.modelMatrix.rotate(actorRotation);
|
||||||
modelMatrix.scale(new Vector3d(actorScale));
|
this.modelMatrix.scale(new Vector3d(actorScale));
|
||||||
actor.applySpatialData(modelMatrix,new Vector3d(actorPosition));
|
actor.applySpatialData(this.modelMatrix,new Vector3d(actorPosition));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user