foliage data editing ui
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
f0179f8507
commit
cb1f2ec1be
@ -705,6 +705,7 @@ public class FoliageCellManager {
|
||||
public void evictAll(){
|
||||
this.recursivelyDestroy(this.chunkTree.getRoot());
|
||||
this.chunkTree.clear();
|
||||
this.chunkTree.getRoot().setData(FoliageCell.generateTerrainCell(new Vector3i(0,0,0), chunkTree.getMaxLevel()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -19,9 +19,12 @@ import electrosphere.engine.assetmanager.queue.QueuedTexture.QueuedTextureType;
|
||||
import electrosphere.entity.ClientEntityUtils;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityCreationUtils;
|
||||
import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.EntityTags;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.state.foliage.AmbientFoliage;
|
||||
import electrosphere.entity.types.EntityTypes.EntityType;
|
||||
import electrosphere.entity.types.common.CommonEntityUtils;
|
||||
import electrosphere.game.data.foliage.type.FoliageType;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
import electrosphere.renderer.actor.instance.TextureInstancedActor;
|
||||
@ -123,6 +126,21 @@ public class FoliageModel {
|
||||
*/
|
||||
protected static final String fragmentPath = "Shaders/entities/foliage/foliage.fs";
|
||||
|
||||
/**
|
||||
* Name of the mesh to apply uniforms to
|
||||
*/
|
||||
public static final String MESH_NAME = "Plane";
|
||||
|
||||
/**
|
||||
* Name of the uniform for the tip color
|
||||
*/
|
||||
public static final String UNIFORM_TIP_COLOR = "tipColor";
|
||||
|
||||
/**
|
||||
* Name of the uniform for the base color
|
||||
*/
|
||||
public static final String UNIFORM_BASE_COLOR = "baseColor";
|
||||
|
||||
/**
|
||||
* Used for generating foliage cells
|
||||
*/
|
||||
@ -155,6 +173,10 @@ public class FoliageModel {
|
||||
//get type
|
||||
String foliageTypeName = foliageTypesSupported.get(0);
|
||||
FoliageType foliageType = Globals.gameConfigCurrent.getFoliageMap().getFoliage(foliageTypeName);
|
||||
CommonEntityUtils.setCommonData(rVal, foliageType);
|
||||
CommonEntityUtils.setEntityType(rVal, EntityType.FOLIAGE);
|
||||
CommonEntityUtils.setEntitySubtype(rVal, foliageType.getId());
|
||||
rVal.putData(EntityDataStrings.FOLIAGE_TYPE, foliageType);
|
||||
|
||||
//create cell and buffer
|
||||
ByteBuffer buffer = BufferUtils.createByteBuffer(MAX_TEXTURE_HEIGHT * TARGET_WIDTH_OF_IMAGE * SINGLE_FOLIAGE_DATA_SIZE_BYTES);
|
||||
@ -228,8 +250,8 @@ public class FoliageModel {
|
||||
|
||||
//apply grass uniforms if present in definition
|
||||
if(foliageType.getGrassData() != null){
|
||||
actor.setUniformOnMesh("Plane", "baseColor", foliageType.getGrassData().getBaseColor());
|
||||
actor.setUniformOnMesh("Plane", "tipColor", foliageType.getGrassData().getTipColor());
|
||||
actor.setUniformOnMesh(FoliageModel.MESH_NAME, FoliageModel.UNIFORM_BASE_COLOR, foliageType.getGrassData().getBaseColor());
|
||||
actor.setUniformOnMesh(FoliageModel.MESH_NAME, FoliageModel.UNIFORM_TIP_COLOR, foliageType.getGrassData().getTipColor());
|
||||
}
|
||||
}
|
||||
if(toDelete != null){
|
||||
|
||||
@ -0,0 +1,69 @@
|
||||
package electrosphere.client.ui.menu.debug.entity;
|
||||
|
||||
import electrosphere.client.terrain.foliage.FoliageModel;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityTags;
|
||||
import electrosphere.entity.types.common.CommonEntityUtils;
|
||||
import electrosphere.game.data.foliage.type.FoliageType;
|
||||
import electrosphere.game.data.foliage.type.GrassData;
|
||||
import electrosphere.renderer.actor.instance.TextureInstancedActor;
|
||||
import imgui.ImGui;
|
||||
|
||||
/**
|
||||
* Tab for foliage-related data
|
||||
*/
|
||||
public class ImGuiEntityFoliageTab {
|
||||
|
||||
/**
|
||||
* Grass Color (tip)
|
||||
*/
|
||||
static float[] grassColorTip = new float[3];
|
||||
|
||||
/**
|
||||
* Grass Color (base)
|
||||
*/
|
||||
static float[] grassColorBase = new float[3];
|
||||
|
||||
/**
|
||||
* Client scene entity view
|
||||
*/
|
||||
protected static void drawFoliageView(boolean show, Entity detailViewEntity){
|
||||
if(show && ImGui.collapsingHeader("Foliage Data")){
|
||||
FoliageType foliageData = (FoliageType)CommonEntityUtils.getCommonData(detailViewEntity);
|
||||
ImGui.indent();
|
||||
if(detailViewEntity != null && foliageData != null){
|
||||
|
||||
if(foliageData.getGrassData() != null && ImGui.collapsingHeader("Grass Data")){
|
||||
GrassData grassData = foliageData.getGrassData();
|
||||
|
||||
if(ImGui.sliderFloat3("Color (Tip)", grassColorTip, 0, 1)){
|
||||
grassData.getTipColor().set(grassColorTip[0],grassColorTip[1],grassColorTip[2]);
|
||||
for(Entity foliageEntity : Globals.clientScene.getEntitiesWithTag(EntityTags.DRAW_FOLIAGE_PASS)){
|
||||
if(TextureInstancedActor.getTextureInstancedActor(foliageEntity) != null){
|
||||
TextureInstancedActor actor = TextureInstancedActor.getTextureInstancedActor(foliageEntity);
|
||||
actor.setUniformOnMesh(FoliageModel.MESH_NAME, FoliageModel.UNIFORM_TIP_COLOR, grassData.getTipColor());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(ImGui.sliderFloat3("Color (Base)", grassColorBase, 0, 1)){
|
||||
grassData.getBaseColor().set(grassColorBase[0],grassColorBase[1],grassColorBase[2]);
|
||||
for(Entity foliageEntity : Globals.clientScene.getEntitiesWithTag(EntityTags.DRAW_FOLIAGE_PASS)){
|
||||
if(TextureInstancedActor.getTextureInstancedActor(foliageEntity) != null){
|
||||
TextureInstancedActor actor = TextureInstancedActor.getTextureInstancedActor(foliageEntity);
|
||||
actor.setUniformOnMesh(FoliageModel.MESH_NAME, FoliageModel.UNIFORM_BASE_COLOR, grassData.getBaseColor());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(ImGui.button("Regenerate All Grass")){
|
||||
Globals.foliageCellManager.evictAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGui.unindent();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -21,10 +21,12 @@ import electrosphere.entity.state.equip.ClientEquipState;
|
||||
import electrosphere.entity.state.foliage.AmbientFoliage;
|
||||
import electrosphere.entity.state.hitbox.HitboxCollectionState;
|
||||
import electrosphere.entity.state.server.ServerPlayerViewDirTree;
|
||||
import electrosphere.entity.types.common.CommonEntityUtils;
|
||||
import electrosphere.entity.types.creature.CreatureUtils;
|
||||
import electrosphere.entity.types.foliage.FoliageUtils;
|
||||
import electrosphere.entity.types.item.ItemUtils;
|
||||
import electrosphere.game.data.creature.type.equip.EquipPoint;
|
||||
import electrosphere.game.data.foliage.type.FoliageType;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
import electrosphere.renderer.actor.ActorAnimationMask;
|
||||
import electrosphere.renderer.actor.instance.InstancedActor;
|
||||
@ -65,6 +67,7 @@ public class ImGuiEntityMacros {
|
||||
private static boolean showLinkedEntitiesTab = false;//show linked entities
|
||||
private static boolean showServerViewDirTab = false; //show server view dir
|
||||
private static boolean showPhysicsTab = false; //show physics values
|
||||
private static boolean showFoliageTab = false; //show foliage data
|
||||
private static boolean showDebugActionsTab = false; //show debug actions
|
||||
|
||||
/**
|
||||
@ -176,6 +179,9 @@ public class ImGuiEntityMacros {
|
||||
if(HitboxCollectionState.hasHitboxState(detailViewEntity) && ImGui.checkbox("Hitbox State", showHitboxTab)){
|
||||
showHitboxTab = !showHitboxTab;
|
||||
}
|
||||
if(CommonEntityUtils.getCommonData(detailViewEntity) instanceof FoliageType && ImGui.checkbox("Foliage Data", showFoliageTab)){
|
||||
showFoliageTab = !showFoliageTab;
|
||||
}
|
||||
if(ImGui.checkbox("Debug Actions", showDebugActionsTab)){
|
||||
showDebugActionsTab = !showDebugActionsTab;
|
||||
}
|
||||
@ -191,6 +197,7 @@ public class ImGuiEntityMacros {
|
||||
ImGuiEntityMacros.drawLinkedEntities();
|
||||
ImGuiEntityMacros.drawServerViewDir();
|
||||
ImGuiEntityPhysicsTab.drawPhysicsView(showPhysicsTab, detailViewEntity);
|
||||
ImGuiEntityFoliageTab.drawFoliageView(showFoliageTab, detailViewEntity);
|
||||
ImGuiEntityDebugActions.drawDebugActions(showDebugActionsTab, detailViewEntity);
|
||||
ImGuiEntityMacros.drawDataView();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user