Fix rendering bug
This commit is contained in:
parent
dd51345a5a
commit
3388325838
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,6 +7,7 @@
|
||||
/launcher/launcher.exe
|
||||
|
||||
/dependency-reduced-pom.xml
|
||||
/nb-configuration.xml
|
||||
|
||||
/Telephone-*.jar
|
||||
/hs_err_pid*
|
||||
|
||||
@ -196,7 +196,9 @@ public class ControlHandler {
|
||||
*/
|
||||
if(controls.containsKey(DATA_STRING_INPUT_CODE_MOVEMENT_FORWARD)){
|
||||
if(controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_FORWARD).isIsKey() && glfwGetKey(Globals.window, controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_FORWARD).getKeyValue()) == GLFW_PRESS){
|
||||
CreatureUtils.setMovementVector(Globals.playerCharacter, new Vector3f(-cameraEyeVector.x,0,-cameraEyeVector.z).normalize());
|
||||
Vector3f newFacingVector = new Vector3f(-cameraEyeVector.x,0,-cameraEyeVector.z).normalize();
|
||||
CreatureUtils.setMovementVector(Globals.playerCharacter, newFacingVector);
|
||||
System.out.println("Movement vector: " + newFacingVector);
|
||||
if(movementTree.getState()==MovementTreeState.IDLE || movementTree.getState()==MovementTreeState.SLOWDOWN){
|
||||
movementTree.start();
|
||||
}
|
||||
|
||||
@ -240,6 +240,8 @@ public class LoadingThread extends Thread {
|
||||
|
||||
loadingBox.setDraw(false);
|
||||
|
||||
RenderUtils.recaptureScreen();
|
||||
|
||||
Globals.RENDER_FLAG_RENDER_SHADOW_MAP = true;
|
||||
Globals.RENDER_FLAG_RENDER_SCREEN_FRAMEBUFFER_CONTENT = true;
|
||||
Globals.RENDER_FLAG_RENDER_SCREEN_FRAMEBUFFER = true;
|
||||
|
||||
@ -61,7 +61,7 @@ public class CameraEntityUtils {
|
||||
}
|
||||
|
||||
public static Matrix4f getCameraViewMatrix(Entity camera){
|
||||
Vector3f cameraCenter = new Vector3f(getCameraCenter(camera)).add(0,1,0);
|
||||
Vector3f cameraCenter = new Vector3f(0,1,0);
|
||||
Vector3f cameraEye = new Vector3f(cameraCenter).add(getCameraEye(camera));
|
||||
Vector3f cameraUp = new Vector3f(0,1.0f,0);
|
||||
// System.out.println("eye: " + cameraEye);
|
||||
|
||||
@ -26,7 +26,7 @@ public class ClientFunctions {
|
||||
// if(skyboxPos != null && playerCameraPos != null){
|
||||
// skyboxPos.set(playerCameraPos);
|
||||
// }
|
||||
EntityUtils.getPosition(Globals.skybox).set(EntityUtils.getPosition(Globals.playerCharacter)).mul(0.01f);
|
||||
EntityUtils.getPosition(Globals.skybox).set(EntityUtils.getPosition(Globals.playerCharacter));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package electrosphere.game.collision;
|
||||
|
||||
import electrosphere.collision.dispatch.CollisionWorld.ClosestConvexResultCallback;
|
||||
import electrosphere.collision.dispatch.CollisionWorld.LocalConvexResult;
|
||||
import electrosphere.collision.broadphase.BroadphaseInterface;
|
||||
import electrosphere.collision.broadphase.BroadphasePair;
|
||||
import electrosphere.collision.broadphase.BroadphaseProxy;
|
||||
@ -9,22 +11,16 @@ import electrosphere.collision.broadphase.OverlappingPairCache;
|
||||
import electrosphere.collision.dispatch.CollisionDispatcher;
|
||||
import electrosphere.collision.dispatch.CollisionObject;
|
||||
import electrosphere.collision.dispatch.CollisionWorld.ClosestConvexResultCallback;
|
||||
import electrosphere.collision.dispatch.CollisionWorld.ConvexResultCallback;
|
||||
import electrosphere.collision.dispatch.CollisionWorld.LocalConvexResult;
|
||||
import electrosphere.collision.dispatch.DefaultCollisionConfiguration;
|
||||
import electrosphere.collision.narrowphase.ManifoldPoint;
|
||||
import electrosphere.collision.narrowphase.PersistentManifold;
|
||||
import electrosphere.collision.shapes.BoxShape;
|
||||
import electrosphere.collision.shapes.CollisionShape;
|
||||
import electrosphere.collision.shapes.SphereShape;
|
||||
import electrosphere.dynamics.DiscreteDynamicsWorld;
|
||||
import electrosphere.dynamics.DynamicsWorld;
|
||||
import electrosphere.dynamics.InternalTickCallback;
|
||||
import electrosphere.dynamics.RigidBody;
|
||||
import electrosphere.dynamics.RigidBodyConstructionInfo;
|
||||
import electrosphere.dynamics.constraintsolver.SequentialImpulseConstraintSolver;
|
||||
import electrosphere.linearmath.DefaultMotionState;
|
||||
import electrosphere.linearmath.Transform;
|
||||
import electrosphere.util.ObjectArrayList;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityDataStrings;
|
||||
@ -32,7 +28,6 @@ import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.state.movement.Impulse;
|
||||
import electrosphere.entity.types.hitbox.HitboxData;
|
||||
import electrosphere.game.collision.collidable.Collidable;
|
||||
import electrosphere.game.server.world.ServerWorldData;
|
||||
import static electrosphere.main.Main.deltaTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -138,6 +138,7 @@ public class Globals {
|
||||
|
||||
public static int WINDOW_WIDTH = 1920;
|
||||
public static int WINDOW_HEIGHT = 1080;
|
||||
public static float FOV = 90;
|
||||
|
||||
//matrices for drawing models
|
||||
public static Matrix4f viewMatrix = new Matrix4f();
|
||||
|
||||
@ -6,12 +6,12 @@ import java.util.concurrent.Semaphore;
|
||||
|
||||
public class ByteStreamUtils {
|
||||
|
||||
static ByteBuffer integerCompactor;
|
||||
static ByteBuffer integerCompactor = ByteBuffer.allocate(8);
|
||||
static Semaphore bufferLock = new Semaphore(1);
|
||||
|
||||
static {
|
||||
integerCompactor = ByteBuffer.allocate(8);
|
||||
}
|
||||
// static {
|
||||
// integerCompactor = ByteBuffer.allocate(8);
|
||||
// }
|
||||
|
||||
public static int popIntFromByteQueue(List<Byte> queue){
|
||||
int rVal = -1;
|
||||
|
||||
@ -73,6 +73,7 @@ public class Actor {
|
||||
|
||||
public void draw(){
|
||||
Model model = Globals.assetManager.fetchModel(modelPath);
|
||||
boolean hasDrawn = false;
|
||||
if(model != null){
|
||||
if(animation != null){
|
||||
model.playAnimation(animation);
|
||||
@ -86,10 +87,13 @@ public class Actor {
|
||||
Texture overrideTextureObject = Globals.assetManager.fetchTexture(textureOverride);
|
||||
if(overrideTextureObject != null){
|
||||
overrideTextureObject.bind();
|
||||
hasDrawn = true;
|
||||
model.draw(true, true, false, false, true, true, true);
|
||||
}
|
||||
}
|
||||
model.draw(true, true, false, true, true, true, true);
|
||||
if(!hasDrawn){
|
||||
model.draw(true, true, false, true, true, true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -88,9 +88,6 @@ public class RenderingEngine {
|
||||
|
||||
|
||||
public void createOpenglContext(){
|
||||
//Sets the variables that control the window sizing
|
||||
int screenWidth = Globals.WINDOW_WIDTH;
|
||||
int screenHeight = Globals.WINDOW_HEIGHT;
|
||||
//Initializes opengl
|
||||
glfwInit();
|
||||
//Gives hints to glfw to control how opengl will be used
|
||||
@ -100,7 +97,7 @@ public class RenderingEngine {
|
||||
// glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_TRUE); Allows you to make the background transparent
|
||||
// glfwWindowHint(GLFW_OPACITY, 23);
|
||||
//Creates the window reference object
|
||||
Globals.window = glfwCreateWindow(screenWidth, screenHeight, "ORPG", NULL, NULL);
|
||||
Globals.window = glfwCreateWindow(Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT, "ORPG", NULL, NULL);
|
||||
//Errors for failure to create window (IE: No GUI mode on linux ?)
|
||||
if (Globals.window == NULL) {
|
||||
LoggerInterface.loggerEngine.ERROR("Failed to make window.", new Exception("Renderer Creation Failure"));
|
||||
@ -148,7 +145,7 @@ public class RenderingEngine {
|
||||
//
|
||||
Globals.projectionMatrix = new Matrix4f();
|
||||
Globals.viewMatrix = new Matrix4f();
|
||||
float FOV = (float)(120.0f * Math.PI /180.0f);
|
||||
float FOV = (float)(Globals.FOV * Math.PI /180.0f);
|
||||
Globals.projectionMatrix.setPerspective(FOV, 1.0f, 0.1f, view_Range);
|
||||
Globals.viewMatrix.translation(new Vector3f(0.0f,0.0f,-3.0f));
|
||||
}
|
||||
@ -176,7 +173,6 @@ public class RenderingEngine {
|
||||
|
||||
//bind default FBO
|
||||
glBindFramebuffer(GL_FRAMEBUFFER,0);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
@ -253,7 +249,7 @@ public class RenderingEngine {
|
||||
Actor currentActor = EntityUtils.getActor(currentEntity);
|
||||
//calculate and apply model transform
|
||||
modelTransformMatrix.identity();
|
||||
modelTransformMatrix.translate(new Vector3f(EntityUtils.getPosition(currentEntity)));
|
||||
modelTransformMatrix.translate(new Vector3f(EntityUtils.getPosition(currentEntity)).sub(CameraEntityUtils.getCameraCenter(Globals.playerCamera)));
|
||||
modelTransformMatrix.rotate(EntityUtils.getRotation(currentEntity));
|
||||
modelTransformMatrix.scale(EntityUtils.getScale(currentEntity));
|
||||
currentActor.applyModelMatrix(modelTransformMatrix);
|
||||
@ -281,6 +277,7 @@ public class RenderingEngine {
|
||||
//bind screen fbo
|
||||
screenFramebuffer.bind();
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glViewport(0, 0, Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT);
|
||||
|
||||
///
|
||||
/// R E N D E R I N G S T U F F
|
||||
@ -305,7 +302,7 @@ public class RenderingEngine {
|
||||
// }
|
||||
//calculate and apply model transform
|
||||
modelTransformMatrix.identity();
|
||||
modelTransformMatrix.translate(new Vector3f(EntityUtils.getPosition(currentEntity)));
|
||||
modelTransformMatrix.translate(new Vector3f(EntityUtils.getPosition(currentEntity)).sub(CameraEntityUtils.getCameraCenter(Globals.playerCamera)));
|
||||
modelTransformMatrix.rotate(EntityUtils.getRotation(currentEntity));
|
||||
modelTransformMatrix.scale(EntityUtils.getScale(currentEntity));
|
||||
currentActor.applyModelMatrix(modelTransformMatrix);
|
||||
@ -334,7 +331,7 @@ public class RenderingEngine {
|
||||
if((hitboxModel = Globals.assetManager.fetchModel("Models/unitsphere.fbx")) != null){
|
||||
Vector3f position = EntityUtils.getPosition(currentHitbox);
|
||||
modelTransformMatrix.identity();
|
||||
modelTransformMatrix.translate(new Vector3f(position));
|
||||
modelTransformMatrix.translate(new Vector3f(position).sub(CameraEntityUtils.getCameraCenter(Globals.playerCamera)));
|
||||
// modelTransformMatrix.translate(-0.25f, 0.0f, 0.5f); //center sphere
|
||||
modelTransformMatrix.scale(data.getRadius() * 2);
|
||||
hitboxModel.modelMatrix = modelTransformMatrix;
|
||||
@ -344,7 +341,7 @@ public class RenderingEngine {
|
||||
if((hitboxModel = Globals.assetManager.fetchModel("Models/unitsphere_1.fbx")) != null){
|
||||
Vector3f position = EntityUtils.getPosition(currentHitbox);
|
||||
modelTransformMatrix.identity();
|
||||
modelTransformMatrix.translate(new Vector3f(position));
|
||||
modelTransformMatrix.translate(new Vector3f(position).sub(CameraEntityUtils.getCameraCenter(Globals.playerCamera)));
|
||||
// modelTransformMatrix.translate(-0.25f, 0.0f, 0.5f); //center sphere
|
||||
modelTransformMatrix.scale(data.getRadius() * 2);
|
||||
hitboxModel.modelMatrix = modelTransformMatrix;
|
||||
@ -355,7 +352,7 @@ public class RenderingEngine {
|
||||
if((hitboxModel = Globals.assetManager.fetchModel("Models/unitsphere_grey.fbx")) != null){
|
||||
Vector3f position = EntityUtils.getPosition(currentHitbox);
|
||||
modelTransformMatrix.identity();
|
||||
modelTransformMatrix.translate(new Vector3f(position));
|
||||
modelTransformMatrix.translate(new Vector3f(position).sub(CameraEntityUtils.getCameraCenter(Globals.playerCamera)));
|
||||
// modelTransformMatrix.translate(-0.25f, 0.0f, 0.5f); //center sphere
|
||||
modelTransformMatrix.scale(data.getRadius() * 2);
|
||||
hitboxModel.modelMatrix = modelTransformMatrix;
|
||||
@ -374,7 +371,7 @@ public class RenderingEngine {
|
||||
if((physicsGraphicsModel = Globals.assetManager.fetchModel("Models/unitcylinder.fbx")) != null){
|
||||
Vector3f position = EntityUtils.getPosition(physicsEntity);
|
||||
modelTransformMatrix.identity();
|
||||
modelTransformMatrix.translate(new Vector3f(position).add(template.getOffsetX(),template.getOffsetY(),template.getOffsetZ()));
|
||||
modelTransformMatrix.translate(new Vector3f(position).add(template.getOffsetX(),template.getOffsetY(),template.getOffsetZ()).sub(CameraEntityUtils.getCameraCenter(Globals.playerCamera)));
|
||||
// modelTransformMatrix.translate(template.getOffsetX(),template.getOffsetY(),template.getOffsetZ()); //center sphere
|
||||
modelTransformMatrix.scale(template.getDimension1(),template.getDimension2(),template.getDimension3());
|
||||
physicsGraphicsModel.modelMatrix = modelTransformMatrix;
|
||||
@ -390,7 +387,7 @@ public class RenderingEngine {
|
||||
Vector3f scale = EntityUtils.getScale(physicsEntity);
|
||||
Quaternionf rotation = EntityUtils.getRotation(physicsEntity);
|
||||
modelTransformMatrix.identity();
|
||||
modelTransformMatrix.translate(new Vector3f(position));
|
||||
modelTransformMatrix.translate(new Vector3f(position).sub(CameraEntityUtils.getCameraCenter(Globals.playerCamera)));
|
||||
modelTransformMatrix.rotate(rotation);
|
||||
// modelTransformMatrix.translate(template.getOffsetX(),template.getOffsetY(),template.getOffsetZ()); //center sphere
|
||||
modelTransformMatrix.scale(scale);
|
||||
@ -403,7 +400,7 @@ public class RenderingEngine {
|
||||
Vector3f scale = EntityUtils.getScale(physicsEntity);
|
||||
Quaternionf rotation = EntityUtils.getRotation(physicsEntity);
|
||||
modelTransformMatrix.identity();
|
||||
modelTransformMatrix.translate(new Vector3f(position));
|
||||
modelTransformMatrix.translate(new Vector3f(position).sub(CameraEntityUtils.getCameraCenter(Globals.playerCamera)));
|
||||
modelTransformMatrix.rotate(rotation);
|
||||
// modelTransformMatrix.translate(template.getOffsetX(),template.getOffsetY(),template.getOffsetZ()); //center sphere
|
||||
modelTransformMatrix.scale(scale);
|
||||
@ -438,6 +435,9 @@ public class RenderingEngine {
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glViewport(0, 0, Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT);
|
||||
|
||||
|
||||
|
||||
//render full screen quad
|
||||
@ -452,7 +452,7 @@ public class RenderingEngine {
|
||||
|
||||
static void renderUI(){
|
||||
Matrix4f modelTransformMatrix = new Matrix4f();
|
||||
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
for(Widget currentWidget : Globals.widgetManager.getWidgetList()){
|
||||
if(currentWidget.isDraw()){
|
||||
currentWidget.draw();
|
||||
@ -473,6 +473,7 @@ public class RenderingEngine {
|
||||
static void renderBlackBackground(){
|
||||
//render full screen quad
|
||||
glUseProgram(screenTextureShaders.shaderProgram);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glBindVertexArray(screenTextureVAO);
|
||||
Texture blackTexture = Globals.assetManager.fetchTexture(Globals.blackTexture);
|
||||
if(blackTexture != null){
|
||||
|
||||
Loading…
Reference in New Issue
Block a user