Fix desynced hitboxes with animations
This commit is contained in:
		
							parent
							
								
									3f899ed746
								
							
						
					
					
						commit
						5eae8dee7a
					
				| @ -12,11 +12,11 @@ import electrosphere.game.client.player.ClientPlayerData; | |||||||
| import electrosphere.game.client.terrain.manager.ClientTerrainManager; | import electrosphere.game.client.terrain.manager.ClientTerrainManager; | ||||||
| import electrosphere.game.client.world.ClientWorldData; | import electrosphere.game.client.world.ClientWorldData; | ||||||
| import electrosphere.game.collision.CommonWorldData; | import electrosphere.game.collision.CommonWorldData; | ||||||
| import electrosphere.game.state.SimulationState.SimulationStateMachine; | import electrosphere.game.state.MacroSimulation; | ||||||
| import electrosphere.game.server.terrain.manager.ServerTerrainManager; | import electrosphere.game.server.terrain.manager.ServerTerrainManager; | ||||||
| import electrosphere.game.server.world.ServerWorldData; | import electrosphere.game.server.world.ServerWorldData; | ||||||
| import electrosphere.game.state.AttachUtils; | import electrosphere.game.state.AttachUtils; | ||||||
| import electrosphere.game.state.SimulationState; | import electrosphere.game.state.MicroSimulation; | ||||||
| import electrosphere.logger.LoggerInterface; | import electrosphere.logger.LoggerInterface; | ||||||
| import electrosphere.main.Globals; | import electrosphere.main.Globals; | ||||||
| import static electrosphere.main.Globals.loadingBox; | import static electrosphere.main.Globals.loadingBox; | ||||||
| @ -73,7 +73,6 @@ public class LoadingThread extends Thread { | |||||||
|                  |                  | ||||||
|                 MenuUtils.makeMenuDrawable(Globals.currentMenu); |                 MenuUtils.makeMenuDrawable(Globals.currentMenu); | ||||||
|                  |                  | ||||||
|                 SimulationState.simulationState = SimulationStateMachine.TITLE_MENU; |  | ||||||
|                 break; |                 break; | ||||||
|                  |                  | ||||||
|                  |                  | ||||||
| @ -131,6 +130,12 @@ public class LoadingThread extends Thread { | |||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|                  |                  | ||||||
|  |                 //initialize the "virtual" objects simulation | ||||||
|  |                 initMacroSimulation(); | ||||||
|  |                  | ||||||
|  |                 //initialize the "real" objects simulation | ||||||
|  |                 initMicroSimulation(); | ||||||
|  |                  | ||||||
|                 loadingBox.setDraw(false); |                 loadingBox.setDraw(false); | ||||||
|                  |                  | ||||||
|                 Globals.RENDER_FLAG_RENDER_SHADOW_MAP = true; |                 Globals.RENDER_FLAG_RENDER_SHADOW_MAP = true; | ||||||
| @ -141,7 +146,6 @@ public class LoadingThread extends Thread { | |||||||
|                  |                  | ||||||
|                 LoggerInterface.loggerEngine.INFO("Finished loading"); |                 LoggerInterface.loggerEngine.INFO("Finished loading"); | ||||||
|                  |                  | ||||||
|                 SimulationState.simulationState = SimulationStateMachine.MAIN_SIMULATION; |  | ||||||
|                 Globals.controlHandler.setHandlerState(ControlHandler.ControlsState.MAIN_GAME); |                 Globals.controlHandler.setHandlerState(ControlHandler.ControlsState.MAIN_GAME); | ||||||
|                 break; |                 break; | ||||||
|                  |                  | ||||||
| @ -195,6 +199,12 @@ public class LoadingThread extends Thread { | |||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|                  |                  | ||||||
|  |                 //initialize the "virtual" objects simulation | ||||||
|  |                 initMacroSimulation(); | ||||||
|  |                  | ||||||
|  |                 //initialize the "real" objects simulation | ||||||
|  |                 initMicroSimulation(); | ||||||
|  |                  | ||||||
|                 loadingBox.setDraw(false); |                 loadingBox.setDraw(false); | ||||||
|                  |                  | ||||||
|                 Globals.RENDER_FLAG_RENDER_SHADOW_MAP = true; |                 Globals.RENDER_FLAG_RENDER_SHADOW_MAP = true; | ||||||
| @ -205,7 +215,6 @@ public class LoadingThread extends Thread { | |||||||
|                  |                  | ||||||
|                 LoggerInterface.loggerEngine.INFO("Finished loading"); |                 LoggerInterface.loggerEngine.INFO("Finished loading"); | ||||||
|                  |                  | ||||||
|                 SimulationState.simulationState = SimulationStateMachine.MAIN_SIMULATION; |  | ||||||
|                 Globals.controlHandler.setHandlerState(ControlHandler.ControlsState.MAIN_GAME); |                 Globals.controlHandler.setHandlerState(ControlHandler.ControlsState.MAIN_GAME); | ||||||
|                 break; |                 break; | ||||||
|                  |                  | ||||||
| @ -406,6 +415,14 @@ public class LoadingThread extends Thread { | |||||||
|          |          | ||||||
|     } |     } | ||||||
|      |      | ||||||
|  |     static void initMacroSimulation(){ | ||||||
|  |         Globals.macroSimulation = new MacroSimulation(); | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |      | ||||||
|  |     static void initMicroSimulation(){ | ||||||
|  |         Globals.microSimulation = new MicroSimulation(); | ||||||
|  |     } | ||||||
|      |      | ||||||
|     static void creatingRandomEntities(){ |     static void creatingRandomEntities(){ | ||||||
| //        String unitCubeModelPath = Globals.assetManager.registerModel(ModelUtils.createUnitCube()); | //        String unitCubeModelPath = Globals.assetManager.registerModel(ModelUtils.createUnitCube()); | ||||||
|  | |||||||
| @ -47,29 +47,14 @@ public class HitboxUtils { | |||||||
|         Vector3f bonePosition = EntityUtils.getEntityActor(parent).getBonePosition(boneName); |         Vector3f bonePosition = EntityUtils.getEntityActor(parent).getBonePosition(boneName); | ||||||
|         worldPosition.set(bonePosition.x,bonePosition.y,bonePosition.z); |         worldPosition.set(bonePosition.x,bonePosition.y,bonePosition.z); | ||||||
|         Quaternionf rotation = new Quaternionf(parentRotation); |         Quaternionf rotation = new Quaternionf(parentRotation); | ||||||
| //        rotation.w = -rotation.w; |  | ||||||
| //        rotation.x = -rotation.x; |  | ||||||
| //        rotation.y = -rotation.y; |  | ||||||
| //        rotation.z = -rotation.z; |  | ||||||
| 
 |  | ||||||
| //        System.out.println(bonePosition); |  | ||||||
|          |          | ||||||
|         worldPosition = worldPosition.mul(positionScale); |         worldPosition = worldPosition.mul(positionScale); | ||||||
| 
 | 
 | ||||||
|         worldPosition = worldPosition.rotate(rotation); |         worldPosition = worldPosition.rotate(rotation); | ||||||
|                  |                  | ||||||
|          |          | ||||||
| //        Matrix4f rotationMatrix = new Matrix4f().rotate(parentRotation); |  | ||||||
| //        Vector4f rawRotatedOffset = rotationMatrix.transform(new Vector4f(worldPosition.x,worldPosition.y,worldPosition.z,1)); |  | ||||||
| //        worldPosition = new Vector3f(rawRotatedOffset.x,rawRotatedOffset.y,rawRotatedOffset.z); |  | ||||||
| 
 |  | ||||||
|         worldPosition.add(EntityUtils.getEntityPosition(parent)); |         worldPosition.add(EntityUtils.getEntityPosition(parent)); | ||||||
|          |          | ||||||
| 
 |  | ||||||
| //        System.out.println(worldPosition); |  | ||||||
| //         |  | ||||||
| //        System.out.println("parent rotation: " + new Vector3f(0,0,1).rotate(rotation)); |  | ||||||
| 
 |  | ||||||
|         ((Vector3f)hitbox.getData(EntityDataStrings.DATA_STRING_POSITION)).set(worldPosition); |         ((Vector3f)hitbox.getData(EntityDataStrings.DATA_STRING_POSITION)).set(worldPosition); | ||||||
|     } |     } | ||||||
|      |      | ||||||
| @ -88,6 +73,7 @@ public class HitboxUtils { | |||||||
|                         generatorType != receiverType |                         generatorType != receiverType | ||||||
|                         ){ |                         ){ | ||||||
|                     if(generatorType.equals(EntityDataStrings.COLLISION_ENTITY_DATA_TYPE_HURT)){ |                     if(generatorType.equals(EntityDataStrings.COLLISION_ENTITY_DATA_TYPE_HURT)){ | ||||||
|  | //                        Globals.microSimulation.freeze(); | ||||||
|                         EntityUtils.getEntityPosition(generatorParent).set(Globals.spawnPoint); |                         EntityUtils.getEntityPosition(generatorParent).set(Globals.spawnPoint); | ||||||
|                     } else if(receiverParent.equals(EntityDataStrings.COLLISION_ENTITY_DATA_TYPE_HURT)){ |                     } else if(receiverParent.equals(EntityDataStrings.COLLISION_ENTITY_DATA_TYPE_HURT)){ | ||||||
|                         EntityUtils.getEntityPosition(receiverParent).set(Globals.spawnPoint); |                         EntityUtils.getEntityPosition(receiverParent).set(Globals.spawnPoint); | ||||||
|  | |||||||
| @ -257,7 +257,7 @@ public class TerrainGen { | |||||||
|         float[][] rVal = new float[elevation.length][elevation[0].length]; |         float[][] rVal = new float[elevation.length][elevation[0].length]; | ||||||
|         for(int x = 0; x < DIMENSION-1; x++){ |         for(int x = 0; x < DIMENSION-1; x++){ | ||||||
|             for(int y = 0; y < DIMENSION-1; y++){ |             for(int y = 0; y < DIMENSION-1; y++){ | ||||||
|                 rVal[x][y] = elevation[x][y] + Utilities.random_Integer(0, (int)(elevation[x][y] / 4)); |                 rVal[x][y] = elevation[x][y] + Utilities.random_Integer(0, (int)(elevation[x][y] / verticalInterpolationRatio)); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         return rVal; |         return rVal; | ||||||
|  | |||||||
| @ -34,7 +34,7 @@ public class AttachUtils { | |||||||
|                     position = position.rotate(((Quaternionf)EntityUtils.getEntityRotation(parent))); |                     position = position.rotate(((Quaternionf)EntityUtils.getEntityRotation(parent))); | ||||||
|                     position.add(new Vector3f(EntityUtils.getEntityPosition(parent))); |                     position.add(new Vector3f(EntityUtils.getEntityPosition(parent))); | ||||||
|                     EntityUtils.getEntityPosition(currentEntity).set(position); |                     EntityUtils.getEntityPosition(currentEntity).set(position); | ||||||
|                     EntityUtils.getEntityRotation(currentEntity).add(EntityUtils.getEntityRotation(parent)).normalize(); |                     EntityUtils.getEntityRotation(currentEntity).set(EntityUtils.getEntityRotation(parent)).normalize(); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| package electrosphere.game.server.simulation; | package electrosphere.game.state; | ||||||
| 
 | 
 | ||||||
| import electrosphere.game.server.civilization.Civilization; | import electrosphere.game.server.civilization.Civilization; | ||||||
| import electrosphere.game.server.civilization.model.CivilizationMap; | import electrosphere.game.server.civilization.model.CivilizationMap; | ||||||
| @ -11,7 +11,7 @@ import electrosphere.util.Utilities; | |||||||
| import java.util.LinkedList; | import java.util.LinkedList; | ||||||
| import java.util.List; | import java.util.List; | ||||||
| 
 | 
 | ||||||
| public class Simulation { | public class MacroSimulation { | ||||||
|      |      | ||||||
|     List<Civilization> civilizationList = new LinkedList(); |     List<Civilization> civilizationList = new LinkedList(); | ||||||
|     List<Culture> cultureList = new LinkedList(); |     List<Culture> cultureList = new LinkedList(); | ||||||
| @ -19,13 +19,13 @@ public class Simulation { | |||||||
|     List<CreatureType> creatureList = new LinkedList(); |     List<CreatureType> creatureList = new LinkedList(); | ||||||
|     List<Character> characterList = new LinkedList(); |     List<Character> characterList = new LinkedList(); | ||||||
|      |      | ||||||
|     public Simulation(){ |     public MacroSimulation(){ | ||||||
|         init(); |         init(); | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     void init(){ |     void init(){ | ||||||
|         CreatureTypeMap creatureTypeMap = FileLoadingUtils.loadObjectFromAssetPath("Data/creatures.json", CreatureTypeMap.class); | //        CreatureTypeMap creatureTypeMap = FileLoadingUtils.loadObjectFromAssetPath("Data/creatures.json", CreatureTypeMap.class); | ||||||
|         CivilizationMap civilizationMap = FileLoadingUtils.loadObjectFromAssetPath("Data/civilization.json", CivilizationMap.class); | //        CivilizationMap civilizationMap = FileLoadingUtils.loadObjectFromAssetPath("Data/civilization.json", CivilizationMap.class); | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     public void simulate(){ |     public void simulate(){ | ||||||
							
								
								
									
										58
									
								
								src/main/java/electrosphere/game/state/MicroSimulation.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								src/main/java/electrosphere/game/state/MicroSimulation.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,58 @@ | |||||||
|  | package electrosphere.game.state; | ||||||
|  | 
 | ||||||
|  | import electrosphere.entity.Entity; | ||||||
|  | import electrosphere.entity.state.MovementTree; | ||||||
|  | import electrosphere.entity.types.creature.CreatureUtils; | ||||||
|  | import electrosphere.entity.types.hitbox.HitboxUtils; | ||||||
|  | import electrosphere.entity.types.item.ItemUtils; | ||||||
|  | import electrosphere.main.Globals; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * | ||||||
|  |  * @author amaterasu | ||||||
|  |  */ | ||||||
|  | public class MicroSimulation { | ||||||
|  |      | ||||||
|  |     boolean isReady = false; | ||||||
|  |      | ||||||
|  |     public MicroSimulation(){ | ||||||
|  |         isReady = true; | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     public void simulate(){ | ||||||
|  |         //make items play idle animation | ||||||
|  |         for(Entity item : Globals.entityManager.getItemEntities()){ | ||||||
|  |             ItemUtils.updateItemActorAnimation(item); | ||||||
|  |         } | ||||||
|  |         //simulate creature behavior trees | ||||||
|  |         for(Entity currentMoveable : Globals.entityManager.getMoveable()){ | ||||||
|  |             MovementTree behaviorTree = CreatureUtils.getEntityMovementTree(currentMoveable); | ||||||
|  |             behaviorTree.simulate(); | ||||||
|  |         } | ||||||
|  |         //update attached entity positions | ||||||
|  |         AttachUtils.updateAttachedEntityPositions(); | ||||||
|  |         //update hitbox positions | ||||||
|  |         for(Entity currentHitbox : Globals.hitboxManager.getAllHitboxes()){ | ||||||
|  |             HitboxUtils.updatePosition(currentHitbox); | ||||||
|  |         } | ||||||
|  |         //collide hitboxes | ||||||
|  |         for(Entity currentHitbox : Globals.hitboxManager.getAllHitboxes()){ | ||||||
|  |             if(isReady){ | ||||||
|  |                 HitboxUtils.collideEntities(currentHitbox); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     public boolean isReady(){ | ||||||
|  |         return isReady; | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     public void freeze(){ | ||||||
|  |         isReady = false; | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     public void unfreeze(){ | ||||||
|  |         isReady = true; | ||||||
|  |     } | ||||||
|  |      | ||||||
|  | } | ||||||
| @ -1,17 +0,0 @@ | |||||||
| package electrosphere.game.state; |  | ||||||
| 
 |  | ||||||
| /** |  | ||||||
|  * |  | ||||||
|  * @author amaterasu |  | ||||||
|  */ |  | ||||||
| public class SimulationState { |  | ||||||
|     public enum SimulationStateMachine { |  | ||||||
|         LOADING, |  | ||||||
|         TITLE_MENU, |  | ||||||
|         MAIN_SIMULATION, |  | ||||||
|         ARENA_SIMULATION, |  | ||||||
|     } |  | ||||||
|      |  | ||||||
|     public static SimulationStateMachine simulationState; |  | ||||||
|      |  | ||||||
| } |  | ||||||
| @ -17,8 +17,8 @@ public class LoggerInterface { | |||||||
|     public static Logger loggerEngine; |     public static Logger loggerEngine; | ||||||
|      |      | ||||||
|     public static void initLoggers(){ |     public static void initLoggers(){ | ||||||
|         loggerNetworking = new Logger(LogLevel.DEBUG); |         loggerNetworking = new Logger(LogLevel.WARNING); | ||||||
|         loggerFileIO = new Logger(LogLevel.ERROR); |         loggerFileIO = new Logger(LogLevel.WARNING); | ||||||
|         loggerGameLogic = new Logger(LogLevel.DEBUG); |         loggerGameLogic = new Logger(LogLevel.DEBUG); | ||||||
|         loggerRenderer = new Logger(LogLevel.WARNING); |         loggerRenderer = new Logger(LogLevel.WARNING); | ||||||
|         loggerEngine = new Logger(LogLevel.WARNING); |         loggerEngine = new Logger(LogLevel.WARNING); | ||||||
|  | |||||||
| @ -21,8 +21,10 @@ import electrosphere.game.client.world.ClientWorldData; | |||||||
| import electrosphere.game.collision.CommonWorldData; | import electrosphere.game.collision.CommonWorldData; | ||||||
| import electrosphere.game.state.AliveManager; | import electrosphere.game.state.AliveManager; | ||||||
| import electrosphere.engine.LoadingThread; | import electrosphere.engine.LoadingThread; | ||||||
|  | import electrosphere.game.state.MacroSimulation; | ||||||
| import electrosphere.game.server.terrain.manager.ServerTerrainManager; | import electrosphere.game.server.terrain.manager.ServerTerrainManager; | ||||||
| import electrosphere.game.server.world.ServerWorldData; | import electrosphere.game.server.world.ServerWorldData; | ||||||
|  | import electrosphere.game.state.MicroSimulation; | ||||||
| import electrosphere.menu.Menu; | import electrosphere.menu.Menu; | ||||||
| import electrosphere.net.client.ClientNetworking; | import electrosphere.net.client.ClientNetworking; | ||||||
| import electrosphere.net.server.Server; | import electrosphere.net.server.Server; | ||||||
| @ -84,6 +86,7 @@ public class Globals { | |||||||
|     //Controls Handler |     //Controls Handler | ||||||
|     // |     // | ||||||
|     public static ControlHandler controlHandler; |     public static ControlHandler controlHandler; | ||||||
|  |     public static boolean updateCamera = true; | ||||||
|      |      | ||||||
|      |      | ||||||
|     // |     // | ||||||
| @ -170,6 +173,12 @@ public class Globals { | |||||||
|     //manages all models loaded into memory |     //manages all models loaded into memory | ||||||
|     public static AssetManager assetManager; |     public static AssetManager assetManager; | ||||||
|      |      | ||||||
|  |     //macro simulation | ||||||
|  |     public static MacroSimulation macroSimulation; | ||||||
|  |      | ||||||
|  |     //micro simulation | ||||||
|  |     public static MicroSimulation microSimulation; | ||||||
|  |      | ||||||
|      |      | ||||||
|     //manages hitboxes |     //manages hitboxes | ||||||
|     public static HitboxManager hitboxManager; |     public static HitboxManager hitboxManager; | ||||||
|  | |||||||
| @ -14,8 +14,7 @@ import electrosphere.entity.types.hitbox.HitboxUtils; | |||||||
| import electrosphere.entity.types.item.ItemUtils; | import electrosphere.entity.types.item.ItemUtils; | ||||||
| import electrosphere.game.state.AttachUtils; | import electrosphere.game.state.AttachUtils; | ||||||
| import electrosphere.engine.LoadingThread; | import electrosphere.engine.LoadingThread; | ||||||
| import electrosphere.game.state.SimulationState; | import electrosphere.game.state.MicroSimulation; | ||||||
| import electrosphere.game.state.SimulationState.SimulationStateMachine; |  | ||||||
| import electrosphere.logger.LoggerInterface; | import electrosphere.logger.LoggerInterface; | ||||||
| import electrosphere.renderer.RenderingEngine; | import electrosphere.renderer.RenderingEngine; | ||||||
| import electrosphere.util.FileLoadingUtils; | import electrosphere.util.FileLoadingUtils; | ||||||
| @ -103,9 +102,6 @@ public class Main { | |||||||
|         //initialize logging interfaces |         //initialize logging interfaces | ||||||
|         LoggerInterface.initLoggers(); |         LoggerInterface.initLoggers(); | ||||||
|          |          | ||||||
|         //set simulation status to loading title menu |  | ||||||
|         SimulationState.simulationState = SimulationStateMachine.LOADING; |  | ||||||
|          |  | ||||||
|         //controls |         //controls | ||||||
|         initControlHandler(); |         initControlHandler(); | ||||||
|          |          | ||||||
| @ -170,7 +166,7 @@ public class Main { | |||||||
|             ///    I N P U T     C O N T R O L S |             ///    I N P U T     C O N T R O L S | ||||||
|             /// |             /// | ||||||
|             cameraSpeed = 2.5f * deltaTime; |             cameraSpeed = 2.5f * deltaTime; | ||||||
|             if (glfwGetKey(Globals.window, GLFW_KEY_ESCAPE) == GLFW_PRESS && SimulationState.simulationState == SimulationStateMachine.MAIN_SIMULATION) { |             if (glfwGetKey(Globals.window, GLFW_KEY_ESCAPE) == GLFW_PRESS && Globals.RENDER_FLAG_RENDER_SCREEN_FRAMEBUFFER_CONTENT) { | ||||||
|                 break; |                 break; | ||||||
|             } |             } | ||||||
|              |              | ||||||
| @ -190,26 +186,8 @@ public class Main { | |||||||
|             /// |             /// | ||||||
|             ///    C L I E N T    S I M U L A T I O N    S T U F F |             ///    C L I E N T    S I M U L A T I O N    S T U F F | ||||||
|             /// |             /// | ||||||
|             if(SimulationState.simulationState == SimulationStateMachine.MAIN_SIMULATION || SimulationState.simulationState == SimulationStateMachine.ARENA_SIMULATION){ |             if(Globals.microSimulation != null && Globals.microSimulation.isReady()){ | ||||||
|                 //make items play idle animation |                 Globals.microSimulation.simulate(); | ||||||
|                 for(Entity item : Globals.entityManager.getItemEntities()){ |  | ||||||
|                     ItemUtils.updateItemActorAnimation(item); |  | ||||||
|                 } |  | ||||||
|                 //simulate creature behavior trees |  | ||||||
|                 for(Entity currentMoveable : Globals.entityManager.getMoveable()){ |  | ||||||
|                     MovementTree behaviorTree = CreatureUtils.getEntityMovementTree(currentMoveable); |  | ||||||
|                     behaviorTree.simulate(); |  | ||||||
|                 } |  | ||||||
|                 //update attached entity positions |  | ||||||
|                 AttachUtils.updateAttachedEntityPositions(); |  | ||||||
|                 //update hitbox positions |  | ||||||
|                 for(Entity currentHitbox : Globals.hitboxManager.getAllHitboxes()){ |  | ||||||
|                     HitboxUtils.updatePosition(currentHitbox); |  | ||||||
|                 } |  | ||||||
|                 //collide hitboxes |  | ||||||
|                 for(Entity currentHitbox : Globals.hitboxManager.getAllHitboxes()){ |  | ||||||
|                     HitboxUtils.collideEntities(currentHitbox); |  | ||||||
|                 } |  | ||||||
|             } |             } | ||||||
|              |              | ||||||
|              |              | ||||||
| @ -231,7 +209,7 @@ public class Main { | |||||||
|             ///     C A M E R A      S T U F F |             ///     C A M E R A      S T U F F | ||||||
|             /// |             /// | ||||||
|             //poll mouse variables and update camera variables |             //poll mouse variables and update camera variables | ||||||
|             if(SimulationState.simulationState == SimulationStateMachine.MAIN_SIMULATION || SimulationState.simulationState == SimulationStateMachine.ARENA_SIMULATION){ |             if(Globals.RENDER_FLAG_RENDER_SCREEN_FRAMEBUFFER_CONTENT){ | ||||||
|                  |                  | ||||||
|                 updateMouseVariables(); |                 updateMouseVariables(); | ||||||
|                  |                  | ||||||
|  | |||||||
| @ -109,7 +109,6 @@ public class Actor { | |||||||
|         if(model != null){ |         if(model != null){ | ||||||
|             if(animation != null){ |             if(animation != null){ | ||||||
|                 model.playAnimation(animation); |                 model.playAnimation(animation); | ||||||
|                 model.incrementTime(0.001); |  | ||||||
|                 model.incrementTime(animationTime); |                 model.incrementTime(animationTime); | ||||||
|                 model.update_node_transform(model.root_anim_node); |                 model.update_node_transform(model.root_anim_node); | ||||||
|                 Bone currentBone = model.boneMap.get(boneName); |                 Bone currentBone = model.boneMap.get(boneName); | ||||||
| @ -125,4 +124,22 @@ public class Actor { | |||||||
|         return rVal; |         return rVal; | ||||||
|     } |     } | ||||||
|      |      | ||||||
|  |     public Matrix4f getBoneTransform(String boneName){ | ||||||
|  |         Matrix4f rVal = new Matrix4f(); | ||||||
|  |         Model model = Globals.assetManager.fetchModel(modelPath); | ||||||
|  |         if(model != null){ | ||||||
|  |             if(animation != null){ | ||||||
|  |                 model.playAnimation(animation); | ||||||
|  |                 model.incrementTime(animationTime); | ||||||
|  |                 model.update_node_transform(model.root_anim_node); | ||||||
|  |                 Bone currentBone = model.boneMap.get(boneName); | ||||||
|  |                 if(currentBone != null){ | ||||||
|  |                     rVal = currentBone.final_transform; | ||||||
|  | //                    currentBone.inverseBindPoseMatrix | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         return rVal; | ||||||
|  |     } | ||||||
|  |      | ||||||
| } | } | ||||||
|  | |||||||
| @ -94,7 +94,7 @@ public class RenderingEngine { | |||||||
| //        glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_TRUE); Allows you to make the background transparent | //        glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_TRUE); Allows you to make the background transparent | ||||||
| //        glfwWindowHint(GLFW_OPACITY, 23); | //        glfwWindowHint(GLFW_OPACITY, 23); | ||||||
|         //Creates the window reference object |         //Creates the window reference object | ||||||
|         Globals.window = glfwCreateWindow(screenWidth, screenHeight, "LearnOpenGL", NULL, NULL); |         Globals.window = glfwCreateWindow(screenWidth, screenHeight, "ORPG", NULL, NULL); | ||||||
|         //Errors for failure to create window (IE: No GUI mode on linux ?) |         //Errors for failure to create window (IE: No GUI mode on linux ?) | ||||||
|         if (Globals.window == NULL) { |         if (Globals.window == NULL) { | ||||||
|             LoggerInterface.loggerEngine.ERROR("Failed to make window.", new Exception("Renderer Creation Failure")); |             LoggerInterface.loggerEngine.ERROR("Failed to make window.", new Exception("Renderer Creation Failure")); | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| package electrosphere.util.worldviewer; | package electrosphere.util.worldviewer; | ||||||
| 
 | 
 | ||||||
| import com.google.gson.Gson; | import com.google.gson.Gson; | ||||||
| import electrosphere.game.server.simulation.Simulation; | import electrosphere.game.state.MacroSimulation; | ||||||
| import electrosphere.game.server.terrain.manager.ServerTerrainManager; | import electrosphere.game.server.terrain.manager.ServerTerrainManager; | ||||||
| import electrosphere.game.server.terrain.models.TerrainModel; | import electrosphere.game.server.terrain.models.TerrainModel; | ||||||
| import electrosphere.main.Globals; | import electrosphere.main.Globals; | ||||||
| @ -41,7 +41,7 @@ public class TerrainViewer { | |||||||
| //        Utilities.saveObjectToBakedJsonFile("/Config/testingTerrain.json", terrainModel); | //        Utilities.saveObjectToBakedJsonFile("/Config/testingTerrain.json", terrainModel); | ||||||
|         terrainModel = FileLoadingUtils.loadObjectFromAssetPath("/Config/testingTerrain.json", TerrainModel.class); |         terrainModel = FileLoadingUtils.loadObjectFromAssetPath("/Config/testingTerrain.json", TerrainModel.class); | ||||||
|          |          | ||||||
|         Simulation simulation = new Simulation(); |         MacroSimulation simulation = new MacroSimulation(); | ||||||
|          |          | ||||||
|         JFrame frame = new JFrame(); |         JFrame frame = new JFrame(); | ||||||
|         TerrainViewerJComponent jComponent = new TerrainViewerJComponent(terrainModel); |         TerrainViewerJComponent jComponent = new TerrainViewerJComponent(terrainModel); | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user