grid alignment visualization work
This commit is contained in:
		
							parent
							
								
									99dbf13dd1
								
							
						
					
					
						commit
						5e7a5ecf03
					
				| @ -1780,6 +1780,7 @@ Sorting imgui debug windows | ||||
| Grid alignment cursor | ||||
| Furniture spawner items triggers grid alignment cursor | ||||
| Grid aligned entity work | ||||
| Grid alignment visualization work | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -285,6 +285,16 @@ public class MenuGeneratorsInGame { | ||||
|         togglePhysicsObjectsButton.setMarginLeft(BUTTON_MARGIN); | ||||
|         scrollable.addChild(togglePhysicsObjectsButton); | ||||
| 
 | ||||
|         //toggle draw grid alignment data | ||||
|         Button toggleDrawGridAlignmentDataButton = Button.createButton("Toggle draw grid alignment data", new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){ | ||||
|             // Main.running = false; | ||||
|             Globals.userSettings.setGraphicsDebugDrawGridAlignment(!Globals.userSettings.getGraphicsDebugDrawGridAlignment()); | ||||
|             return false; | ||||
|         }}); | ||||
|         toggleDrawGridAlignmentDataButton.setMarginTop(BUTTON_MARGIN); | ||||
|         toggleDrawGridAlignmentDataButton.setMarginLeft(BUTTON_MARGIN); | ||||
|         scrollable.addChild(toggleDrawGridAlignmentDataButton); | ||||
| 
 | ||||
|         //label (toggle draw movement vectors) | ||||
|         Button toggleMovementVectorsButton = Button.createButton("Toggle draw movement vectors", new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){ | ||||
|             // Main.running = false; | ||||
|  | ||||
| @ -52,6 +52,7 @@ public class UserSettings { | ||||
|     boolean graphicsDebugDrawPhysicsObjects; | ||||
|     boolean graphicsDebugDrawMovementVectors; | ||||
|     boolean graphicsDebugDrawNavmesh; | ||||
|     boolean graphicsDebugDrawGridAlignment; | ||||
|     //debug network | ||||
|     boolean netRunNetMonitor; | ||||
| 
 | ||||
| @ -187,12 +188,30 @@ public class UserSettings { | ||||
|         this.graphicsPerformanceEnableFoliageManager = graphicsPerformanceEnableFoliageManager; | ||||
|     } | ||||
|      | ||||
|      | ||||
|      | ||||
|      | ||||
|      | ||||
|      | ||||
|      | ||||
|     /** | ||||
|      * Checks if should render the grid alignment data | ||||
|      * @return true if should render grid alignment data, false otherwise | ||||
|      */ | ||||
|     public boolean getGraphicsDebugDrawGridAlignment() { | ||||
|         return graphicsDebugDrawGridAlignment; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Sets whether to draw the grid alignment data or not | ||||
|      * @param graphicsDebugDrawGridAlignment true to render the data, false otherwise | ||||
|      */ | ||||
|     public void setGraphicsDebugDrawGridAlignment(boolean graphicsDebugDrawGridAlignment) { | ||||
|         this.graphicsDebugDrawGridAlignment = graphicsDebugDrawGridAlignment; | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Generates a default settings file | ||||
|  | ||||
| @ -11,12 +11,15 @@ import org.ode4j.ode.DCapsule; | ||||
| import org.ode4j.ode.DGeom; | ||||
| import org.ode4j.ode.DSphere; | ||||
| 
 | ||||
| import electrosphere.client.block.BlockChunkData; | ||||
| import electrosphere.client.entity.camera.CameraEntityUtils; | ||||
| import electrosphere.collision.CollisionEngine; | ||||
| import electrosphere.collision.PhysicsUtils; | ||||
| import electrosphere.collision.collidable.Collidable; | ||||
| import electrosphere.data.collidable.CollidableTemplate; | ||||
| import electrosphere.data.collidable.HitboxData; | ||||
| import electrosphere.data.common.CommonEntityType; | ||||
| import electrosphere.data.grident.GridAlignedData; | ||||
| import electrosphere.engine.Globals; | ||||
| import electrosphere.engine.assetmanager.AssetDataStrings; | ||||
| import electrosphere.entity.Entity; | ||||
| @ -24,6 +27,7 @@ import electrosphere.entity.EntityDataStrings; | ||||
| import electrosphere.entity.EntityUtils; | ||||
| import electrosphere.entity.state.hitbox.HitboxCollectionState; | ||||
| import electrosphere.entity.state.hitbox.HitboxCollectionState.HitboxState; | ||||
| import electrosphere.entity.types.common.CommonEntityUtils; | ||||
| import electrosphere.renderer.OpenGLState; | ||||
| import electrosphere.renderer.RenderPipelineState; | ||||
| import electrosphere.renderer.RenderingEngine; | ||||
| @ -230,6 +234,38 @@ public class DebugContentPipeline implements RenderPipeline { | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         // | ||||
|         //Draw grid alignment data | ||||
|         if(Globals.userSettings.getGraphicsDebugDrawGridAlignment()){ | ||||
|             Model physicsGraphicsModel = Globals.assetManager.fetchModel(AssetDataStrings.UNITCUBE); | ||||
|             for(Entity entity : Globals.clientSceneWrapper.getScene().getEntityList()){ | ||||
|                 CommonEntityType data = CommonEntityUtils.getCommonData(entity); | ||||
|                 if(data == null){ | ||||
|                     continue; | ||||
|                 } | ||||
|                 if(data.getGridAlignedData() != null){ | ||||
|                     GridAlignedData gridAlignedData = data.getGridAlignedData(); | ||||
|                     Texture texture = Globals.assetManager.fetchTexture("Textures/transparent_blue.png"); | ||||
|                     if(texture != null){ | ||||
|                         texture.bind(openGLState); | ||||
|                     } | ||||
|                     Vector3d position = EntityUtils.getPosition(entity); | ||||
|                     //calculate camera-modified vector3d | ||||
|                     Vector3d cameraModifiedPosition = new Vector3d(position).add(0,gridAlignedData.getLength() * BlockChunkData.BLOCK_SIZE_MULTIPLIER / 2.0f,0).sub(CameraEntityUtils.getCameraCenter(Globals.playerCamera)); | ||||
|                     modelTransformMatrix.identity(); | ||||
|                     modelTransformMatrix.translate(cameraModifiedPosition); | ||||
|                     modelTransformMatrix.rotate(EntityUtils.getRotation(entity)); | ||||
|                     modelTransformMatrix.scale( | ||||
|                         gridAlignedData.getWidth() * BlockChunkData.BLOCK_SIZE_MULTIPLIER, | ||||
|                         gridAlignedData.getHeight() * BlockChunkData.BLOCK_SIZE_MULTIPLIER, | ||||
|                         gridAlignedData.getLength() * BlockChunkData.BLOCK_SIZE_MULTIPLIER | ||||
|                     ); | ||||
|                     physicsGraphicsModel.setModelMatrix(modelTransformMatrix); | ||||
|                     physicsGraphicsModel.draw(renderPipelineState,openGLState); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         //update pipeline state to use mats again | ||||
|         renderPipelineState.setUseMaterial(true); | ||||
|          | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user