hitbox debug rendering
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
This commit is contained in:
parent
7008e0aa25
commit
d08e02737f
BIN
assets/Textures/color/transparent_green.png
Normal file
BIN
assets/Textures/color/transparent_green.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 624 B |
BIN
assets/Textures/color/transparent_magenta.png
Normal file
BIN
assets/Textures/color/transparent_magenta.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 623 B |
BIN
assets/Textures/color/transparent_orange.png
Normal file
BIN
assets/Textures/color/transparent_orange.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 623 B |
BIN
assets/Textures/color/transparent_teal.png
Normal file
BIN
assets/Textures/color/transparent_teal.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 624 B |
BIN
assets/Textures/color/transparent_yellow.png
Normal file
BIN
assets/Textures/color/transparent_yellow.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 624 B |
@ -485,6 +485,11 @@ public class Globals {
|
|||||||
"Textures/ui/uiFrame2.png",
|
"Textures/ui/uiFrame2.png",
|
||||||
"Textures/ui/circle.png",
|
"Textures/ui/circle.png",
|
||||||
"Textures/ui/square.png",
|
"Textures/ui/square.png",
|
||||||
|
"Textures/color/transparent_green.png",
|
||||||
|
"Textures/color/transparent_magenta.png",
|
||||||
|
"Textures/color/transparent_orange.png",
|
||||||
|
"Textures/color/transparent_teal.png",
|
||||||
|
"Textures/color/transparent_yellow.png",
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -444,6 +444,10 @@ public class HitboxCollectionState {
|
|||||||
*/
|
*/
|
||||||
public void setActive(boolean state){
|
public void setActive(boolean state){
|
||||||
this.active = state;
|
this.active = state;
|
||||||
|
for(DGeom geom : this.geoms){
|
||||||
|
HitboxState shapeState = this.getShapeStatus(geom);
|
||||||
|
shapeState.setActive(state);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -20,6 +20,7 @@ import electrosphere.entity.state.hitbox.HitboxCollectionState;
|
|||||||
import electrosphere.entity.state.hitbox.HitboxCollectionState.HitboxState;
|
import electrosphere.entity.state.hitbox.HitboxCollectionState.HitboxState;
|
||||||
import electrosphere.entity.types.camera.CameraEntityUtils;
|
import electrosphere.entity.types.camera.CameraEntityUtils;
|
||||||
import electrosphere.game.data.collidable.CollidableTemplate;
|
import electrosphere.game.data.collidable.CollidableTemplate;
|
||||||
|
import electrosphere.game.data.collidable.HitboxData;
|
||||||
import electrosphere.renderer.OpenGLState;
|
import electrosphere.renderer.OpenGLState;
|
||||||
import electrosphere.renderer.RenderPipelineState;
|
import electrosphere.renderer.RenderPipelineState;
|
||||||
import electrosphere.renderer.RenderingEngine;
|
import electrosphere.renderer.RenderingEngine;
|
||||||
@ -75,12 +76,7 @@ public class DebugContentPipeline implements RenderPipeline {
|
|||||||
HitboxState shapeStatus = hitboxState.getShapeStatus(geom);
|
HitboxState shapeStatus = hitboxState.getShapeStatus(geom);
|
||||||
if((hitboxModel = Globals.assetManager.fetchModel("Models/basic/geometry/unitsphere.glb")) != null){
|
if((hitboxModel = Globals.assetManager.fetchModel("Models/basic/geometry/unitsphere.glb")) != null){
|
||||||
//set color based on collision status, type, etc
|
//set color based on collision status, type, etc
|
||||||
Texture texture = null;
|
Texture texture = Globals.assetManager.fetchTexture(getHitboxColor(shapeStatus,shapeStatus.getHitboxData()));
|
||||||
if(shapeStatus.getHadCollision()){
|
|
||||||
texture = Globals.assetManager.fetchTexture("Textures/transparent_red.png");
|
|
||||||
} else {
|
|
||||||
texture = Globals.assetManager.fetchTexture("Textures/transparent_grey.png");
|
|
||||||
}
|
|
||||||
if(texture != null){
|
if(texture != null){
|
||||||
texture.bind(openGLState);
|
texture.bind(openGLState);
|
||||||
}
|
}
|
||||||
@ -100,12 +96,7 @@ public class DebugContentPipeline implements RenderPipeline {
|
|||||||
HitboxState shapeStatus = hitboxState.getShapeStatus(geom);
|
HitboxState shapeStatus = hitboxState.getShapeStatus(geom);
|
||||||
if((hitboxModel = Globals.assetManager.fetchModel("Models/basic/geometry/unitcapsule.glb")) != null){
|
if((hitboxModel = Globals.assetManager.fetchModel("Models/basic/geometry/unitcapsule.glb")) != null){
|
||||||
//set color based on collision status, type, etc
|
//set color based on collision status, type, etc
|
||||||
Texture texture = null;
|
Texture texture = Globals.assetManager.fetchTexture(getHitboxColor(shapeStatus,shapeStatus.getHitboxData()));
|
||||||
if(shapeStatus.getHadCollision()){
|
|
||||||
texture = Globals.assetManager.fetchTexture("Textures/transparent_red.png");
|
|
||||||
} else {
|
|
||||||
texture = Globals.assetManager.fetchTexture("Textures/transparent_grey.png");
|
|
||||||
}
|
|
||||||
if(texture != null){
|
if(texture != null){
|
||||||
texture.bind(openGLState);
|
texture.bind(openGLState);
|
||||||
}
|
}
|
||||||
@ -184,12 +175,7 @@ public class DebugContentPipeline implements RenderPipeline {
|
|||||||
HitboxState shapeStatus = hitboxState.getShapeStatus(geom);
|
HitboxState shapeStatus = hitboxState.getShapeStatus(geom);
|
||||||
if((hitboxModel = Globals.assetManager.fetchModel("Models/basic/geometry/unitsphere.glb")) != null){
|
if((hitboxModel = Globals.assetManager.fetchModel("Models/basic/geometry/unitsphere.glb")) != null){
|
||||||
//set color based on collision status, type, etc
|
//set color based on collision status, type, etc
|
||||||
Texture texture = null;
|
Texture texture = Globals.assetManager.fetchTexture(getHitboxColor(shapeStatus,shapeStatus.getHitboxData()));
|
||||||
if(shapeStatus.getHadCollision()){
|
|
||||||
texture = Globals.assetManager.fetchTexture("Textures/transparent_red.png");
|
|
||||||
} else {
|
|
||||||
texture = Globals.assetManager.fetchTexture("Textures/transparent_grey.png");
|
|
||||||
}
|
|
||||||
if(texture != null){
|
if(texture != null){
|
||||||
texture.bind(openGLState);
|
texture.bind(openGLState);
|
||||||
}
|
}
|
||||||
@ -209,12 +195,7 @@ public class DebugContentPipeline implements RenderPipeline {
|
|||||||
HitboxState shapeStatus = hitboxState.getShapeStatus(geom);
|
HitboxState shapeStatus = hitboxState.getShapeStatus(geom);
|
||||||
if((hitboxModel = Globals.assetManager.fetchModel("Models/basic/geometry/unitcapsule.glb")) != null){
|
if((hitboxModel = Globals.assetManager.fetchModel("Models/basic/geometry/unitcapsule.glb")) != null){
|
||||||
//set color based on collision status, type, etc
|
//set color based on collision status, type, etc
|
||||||
Texture texture = null;
|
Texture texture = Globals.assetManager.fetchTexture(getHitboxColor(shapeStatus,shapeStatus.getHitboxData()));
|
||||||
if(shapeStatus.getHadCollision()){
|
|
||||||
texture = Globals.assetManager.fetchTexture("Textures/transparent_red.png");
|
|
||||||
} else {
|
|
||||||
texture = Globals.assetManager.fetchTexture("Textures/transparent_grey.png");
|
|
||||||
}
|
|
||||||
if(texture != null){
|
if(texture != null){
|
||||||
texture.bind(openGLState);
|
texture.bind(openGLState);
|
||||||
}
|
}
|
||||||
@ -348,4 +329,42 @@ public class DebugContentPipeline implements RenderPipeline {
|
|||||||
Globals.profiler.endCpuSample();
|
Globals.profiler.endCpuSample();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the color texture to use to draw a hitbox
|
||||||
|
* @param shapeStatus The hitbox status
|
||||||
|
* @param data The hitbox data
|
||||||
|
* @return The texture path to use
|
||||||
|
*/
|
||||||
|
private String getHitboxColor(HitboxState shapeStatus, HitboxData data){
|
||||||
|
switch(data.getType()){
|
||||||
|
case HitboxData.HITBOX_TYPE_BLOCK_CONNECTED: {
|
||||||
|
if(shapeStatus.getHadCollision()){
|
||||||
|
return "Textures/color/transparent_yellow.png";
|
||||||
|
}
|
||||||
|
if(shapeStatus.isActive()){
|
||||||
|
return "Textures/transparent_blue.png";
|
||||||
|
}
|
||||||
|
return "Textures/transparent_grey.png";
|
||||||
|
}
|
||||||
|
case HitboxData.HITBOX_TYPE_HIT:
|
||||||
|
case HitboxData.HITBOX_TYPE_HIT_CONNECTED: {
|
||||||
|
if(shapeStatus.getHadCollision()){
|
||||||
|
return "Textures/color/transparent_yellow.png";
|
||||||
|
}
|
||||||
|
if(shapeStatus.isActive()){
|
||||||
|
return "Textures/transparent_red.png";
|
||||||
|
}
|
||||||
|
return "Textures/transparent_grey.png";
|
||||||
|
}
|
||||||
|
case HitboxData.HITBOX_TYPE_HURT:
|
||||||
|
case HitboxData.HITBOX_TYPE_HURT_CONNECTED: {
|
||||||
|
if(shapeStatus.getHadCollision()){
|
||||||
|
return "Textures/color/transparent_yellow.png";
|
||||||
|
}
|
||||||
|
return "Textures/transparent_grey.png";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "Textures/transparent_grey.png";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user