block item no texture

This commit is contained in:
austin 2025-04-26 21:27:22 -04:00
parent 9fe9670248
commit 208f21e445
7 changed files with 42 additions and 12 deletions

View File

@ -1,3 +1,3 @@
#maven.buildNumber.plugin properties file #maven.buildNumber.plugin properties file
#Sat Apr 26 19:41:37 EDT 2025 #Sat Apr 26 21:15:56 EDT 2025
buildNumber=621 buildNumber=622

View File

@ -17,7 +17,6 @@
+ bug fixes + bug fixes
- Terrain edits do not save - Terrain edits do not save
- Panel does not draw its decoration if target framebuffer is the framebuffer of the window (maybe window isnt drawings its content framebuffer?)
- Window does not play nice with its minWidth/minHeight being set differently - Window does not play nice with its minWidth/minHeight being set differently
+ unreproducible bugs + unreproducible bugs

View File

@ -1559,6 +1559,7 @@ Fix inventory item tooltip not clearing
More item icons More item icons
Toolbar preview ui element Toolbar preview ui element
Fab tool can place fabs Fab tool can place fabs
Fix block items not having texture

View File

@ -10,21 +10,39 @@ import electrosphere.renderer.texture.Texture;
*/ */
public class BlockTextureAtlas { public class BlockTextureAtlas {
//A map of voxel id -> coordinates in the atlas texture for its texture /**
* The id is not in the atlas
*/
public static final int MISSING = -1;
/**
* A map of voxel id -> coordinates in the atlas texture for its texture
*/
Map<Integer,Integer> typeCoordMap = new HashMap<Integer,Integer>(); Map<Integer,Integer> typeCoordMap = new HashMap<Integer,Integer>();
/**
//the actual texture * the actual texture
*/
Texture specular; Texture specular;
//the normal texture /**
* the normal texture
*/
Texture normal; Texture normal;
//the width in pixels of a single texture in the atlas /**
* the width in pixels of a single texture in the atlas
*/
public static final int ATLAS_ELEMENT_DIM = 256; public static final int ATLAS_ELEMENT_DIM = 256;
//the width in pixels of the whole atlas texture
/**
* the width in pixels of the whole atlas texture
*/
public static final int ATLAS_DIM = 8192; public static final int ATLAS_DIM = 8192;
//number of textures per row in the atlas
/**
* number of textures per row in the atlas
*/
public static final int ELEMENTS_PER_ROW = ATLAS_DIM / ATLAS_ELEMENT_DIM; public static final int ELEMENTS_PER_ROW = ATLAS_DIM / ATLAS_ELEMENT_DIM;
/** /**
@ -74,7 +92,7 @@ public class BlockTextureAtlas {
* @return the index in the atlas of the texture of the provided voxel type * @return the index in the atlas of the texture of the provided voxel type
*/ */
public int getVoxelTypeOffset(int voxelTypeId){ public int getVoxelTypeOffset(int voxelTypeId){
return typeCoordMap.containsKey(voxelTypeId) ? typeCoordMap.get(voxelTypeId) : -1; return typeCoordMap.containsKey(voxelTypeId) ? typeCoordMap.get(voxelTypeId) : MISSING;
} }
} }

View File

@ -9,7 +9,6 @@ import electrosphere.controls.ControlHandler.ControlsState;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.engine.signal.Signal.SignalType; import electrosphere.engine.signal.Signal.SignalType;
import electrosphere.game.data.block.BlockFab; import electrosphere.game.data.block.BlockFab;
import electrosphere.logger.LoggerInterface;
import electrosphere.renderer.ui.elements.Window; import electrosphere.renderer.ui.elements.Window;
import electrosphere.renderer.ui.elementtypes.ContainerElement.YogaAlignment; import electrosphere.renderer.ui.elementtypes.ContainerElement.YogaAlignment;
import electrosphere.renderer.ui.elementtypes.ContainerElement.YogaFlexDirection; import electrosphere.renderer.ui.elementtypes.ContainerElement.YogaFlexDirection;

View File

@ -156,6 +156,13 @@ public class InitialAssetLoading {
//construct texture atlas from buffered image //construct texture atlas from buffered image
Globals.blockTextureAtlas.setSpecular(atlasQueuedTexture.getTexture()); Globals.blockTextureAtlas.setSpecular(atlasQueuedTexture.getTexture());
Globals.blockTextureAtlas.setNormal(atlasQueuedTexture.getTexture()); Globals.blockTextureAtlas.setNormal(atlasQueuedTexture.getTexture());
//update block item models based on atlas values
for(BlockType blockType : Globals.gameConfigCurrent.getBlockData().getTypes()){
String typeId = "block:" + blockType.getName();
Item item = Globals.gameConfigCurrent.getItemMap().getItem(typeId);
item.getGraphicsTemplate().getModel().getUniforms().get(RenderUtils.MESH_NAME_BLOCK_SINGLE).put("blockAtlasIndex",Globals.blockTextureAtlas.getVoxelTypeOffset(blockType.getId()));
}
} }
/** /**

View File

@ -6,6 +6,8 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import electrosphere.client.block.BlockChunkData;
import electrosphere.client.block.cells.BlockTextureAtlas;
import electrosphere.controls.cursor.CursorState; import electrosphere.controls.cursor.CursorState;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.engine.assetmanager.AssetDataStrings; import electrosphere.engine.assetmanager.AssetDataStrings;
@ -14,6 +16,7 @@ import electrosphere.game.data.common.CommonEntityType;
import electrosphere.game.data.common.item.SpawnItemDescription; import electrosphere.game.data.common.item.SpawnItemDescription;
import electrosphere.game.data.graphics.GraphicsTemplate; import electrosphere.game.data.graphics.GraphicsTemplate;
import electrosphere.game.data.graphics.NonproceduralModel; import electrosphere.game.data.graphics.NonproceduralModel;
import electrosphere.logger.LoggerInterface;
import electrosphere.renderer.RenderUtils; import electrosphere.renderer.RenderUtils;
/** /**
@ -142,6 +145,9 @@ public class Item extends CommonEntityType {
//set uniforms for the model //set uniforms for the model
Map<String,Map<String,Object>> meshUniformMap = new HashMap<String,Map<String,Object>>(); Map<String,Map<String,Object>> meshUniformMap = new HashMap<String,Map<String,Object>>();
Map<String,Object> uniforms = new HashMap<String,Object>(); Map<String,Object> uniforms = new HashMap<String,Object>();
if(Globals.blockTextureAtlas.getVoxelTypeOffset(blockType.getId()) == BlockTextureAtlas.MISSING && blockType.getId() != BlockChunkData.BLOCK_TYPE_EMPTY){
LoggerInterface.loggerEngine.WARNING("Block type " + blockType.getId() + " missing in BlockTextureAtlas");
}
uniforms.put("blockAtlasIndex",Globals.blockTextureAtlas.getVoxelTypeOffset(blockType.getId())); uniforms.put("blockAtlasIndex",Globals.blockTextureAtlas.getVoxelTypeOffset(blockType.getId()));
meshUniformMap.put(RenderUtils.MESH_NAME_BLOCK_SINGLE,uniforms); meshUniformMap.put(RenderUtils.MESH_NAME_BLOCK_SINGLE,uniforms);
modelData.setUniforms(meshUniformMap); modelData.setUniforms(meshUniformMap);