diff --git a/assets/Data/entity/items/materials/rocks.json b/assets/Data/entity/items/materials/rocks.json index 1a54261f..8c1191a6 100644 --- a/assets/Data/entity/items/materials/rocks.json +++ b/assets/Data/entity/items/materials/rocks.json @@ -34,7 +34,14 @@ ], "graphicsTemplate": { "model": { - "path" : "Models/items/materials/rock2.glb" + "path" : "Models/items/materials/rock2.glb", + "meshColorMap" : { + "Cube" : { + "x" : 0.71, + "y" : 0.43, + "z" : 0.13 + } + } } }, "collidable": { diff --git a/assets/Shaders/FragmentShader.fs b/assets/Shaders/FragmentShader.fs index ae0ba1bb..d8c99fa6 100644 --- a/assets/Shaders/FragmentShader.fs +++ b/assets/Shaders/FragmentShader.fs @@ -20,6 +20,11 @@ in vec4 FragPosLightSpace; uniform dvec3 viewPos; uniform Material material; +/** +The color to apply to the model +*/ +uniform vec3 color; + /** The output */ diff --git a/assets/Textures/items/rock2_256.png b/assets/Textures/items/rock2_256.png new file mode 100644 index 00000000..72fedcee Binary files /dev/null and b/assets/Textures/items/rock2_256.png differ diff --git a/src/main/java/electrosphere/entity/types/common/CommonEntityUtils.java b/src/main/java/electrosphere/entity/types/common/CommonEntityUtils.java index 99fc94d8..c950c8db 100644 --- a/src/main/java/electrosphere/entity/types/common/CommonEntityUtils.java +++ b/src/main/java/electrosphere/entity/types/common/CommonEntityUtils.java @@ -1,10 +1,12 @@ package electrosphere.entity.types.common; import java.util.Map; +import java.util.Map.Entry; import java.util.Set; import org.joml.Quaterniond; import org.joml.Vector3d; +import org.joml.Vector3f; import org.ode4j.ode.DBody; import electrosphere.client.interact.ClientInteractionEngine; @@ -175,6 +177,13 @@ public class CommonEntityUtils { } } } + if(graphicsTemplate.getModel() != null && graphicsTemplate.getModel().getMeshColorMap() != null){ + Actor creatureActor = EntityUtils.getActor(entity); + Map meshColorMap = graphicsTemplate.getModel().getMeshColorMap(); + for(Entry entry : meshColorMap.entrySet()){ + creatureActor.setUniformOnMesh(entry.getKey(), "color", entry.getValue()); + } + } } Actor creatureActor = EntityUtils.getActor(entity); diff --git a/src/main/java/electrosphere/game/data/graphics/GraphicsTemplate.java b/src/main/java/electrosphere/game/data/graphics/GraphicsTemplate.java index 96f518a3..b317b1d0 100644 --- a/src/main/java/electrosphere/game/data/graphics/GraphicsTemplate.java +++ b/src/main/java/electrosphere/game/data/graphics/GraphicsTemplate.java @@ -1,18 +1,10 @@ package electrosphere.game.data.graphics; -import java.util.List; -import java.util.Map; - /** * A graphics template for an entity */ public class GraphicsTemplate { - //a list of shader overrides - List shaderOverrideMeshList; - //??? TODO: investigate - Map shaderMap; - /** * The procedural model definition */ @@ -23,34 +15,34 @@ public class GraphicsTemplate { */ NonproceduralModel model; - public List getShaderOverrideMeshList(){ - return shaderOverrideMeshList; - } - - public Map getShaderMap(){ - return shaderMap; - } - - public void setShaderOverrideMeshList(List shaderOverrideMeshList) { - this.shaderOverrideMeshList = shaderOverrideMeshList; - } - - public void setShaderMap(Map shaderMap) { - this.shaderMap = shaderMap; - } - + /** + * Gets the procedural model + * @return The procedural model + */ public ProceduralModel getProceduralModel() { return proceduralModel; } + /** + * Gets the procedural model + * @param proceduralModel The procedural model + */ public void setProceduralModel(ProceduralModel proceduralModel) { this.proceduralModel = proceduralModel; } + /** + * Gets the non-procedural model + * @return The non-procedural model + */ public NonproceduralModel getModel() { return model; } + /** + * Sets the non-procedural model + * @param model The non-procedural model + */ public void setModel(NonproceduralModel model) { this.model = model; } diff --git a/src/main/java/electrosphere/game/data/graphics/NonproceduralModel.java b/src/main/java/electrosphere/game/data/graphics/NonproceduralModel.java index 1ac3e472..8877558a 100644 --- a/src/main/java/electrosphere/game/data/graphics/NonproceduralModel.java +++ b/src/main/java/electrosphere/game/data/graphics/NonproceduralModel.java @@ -2,6 +2,8 @@ package electrosphere.game.data.graphics; import java.util.Map; +import org.joml.Vector3f; + import electrosphere.game.data.creature.type.IdleData; /** @@ -24,6 +26,11 @@ public class NonproceduralModel { */ Map> uniforms; + /** + * The map of mesh to color to apply to that mesh + */ + Map meshColorMap; + /** * Gets the path of the model * @return The path of the model @@ -72,6 +79,21 @@ public class NonproceduralModel { this.uniforms = uniforms; } + /** + * Gets the map of mesh to color to apply to that mesh + * @return The map of mesh to color to apply to that mesh + */ + public Map getMeshColorMap() { + return meshColorMap; + } + + /** + * Sets the map of mesh to color to apply to that mesh + * @param meshColorMap The map of mesh to color to apply to that mesh + */ + public void setMeshColorMap(Map meshColorMap) { + this.meshColorMap = meshColorMap; + } }