diff --git a/assets/Data/creatures.json b/assets/Data/creatures.json index 47fbef0f..d7a1a634 100644 --- a/assets/Data/creatures.json +++ b/assets/Data/creatures.json @@ -7,32 +7,6 @@ { "creatureId" : "goblin", - "bodyParts" : [ - { - "name" : "Head", - "type" : "Head" - }, - { - "name" : "Torso", - "type" : "Torso" - }, - { - "name" : "ArmLeft", - "type" : "Arm" - }, - { - "name" : "ArmRight", - "type" : "Arm" - }, - { - "name" : "LegLeft", - "type" : "Leg" - }, - { - "name" : "LegRight", - "type" : "Leg" - } - ], "hitboxes" : [ { "type": "hurt", @@ -160,12 +134,6 @@ { "creatureId" : "CUBE_MAN", - "bodyParts" : [ - { - "name" : "CUBE", - "type" : "CUBE_MAN" - } - ], "hitboxes" : [], "tokens" : [ "BLENDER_TRANSFORM", @@ -210,16 +178,6 @@ { "creatureId" : "Deer", - "bodyParts" : [ - { - "name" : "Head", - "type" : "Head" - }, - { - "name" : "Torso", - "type" : "Torso" - } - ], "hitboxes" : [ { "type": "hurt", diff --git a/assets/Data/creatures/human.json b/assets/Data/creatures/human.json index 4a18932c..694534d2 100644 --- a/assets/Data/creatures/human.json +++ b/assets/Data/creatures/human.json @@ -2,32 +2,6 @@ "creatures" : [ { "creatureId" : "human", - "bodyParts" : [ - { - "name" : "Head", - "type" : "Head" - }, - { - "name" : "Torso", - "type" : "Torso" - }, - { - "name" : "ArmLeft", - "type" : "Arm" - }, - { - "name" : "ArmRight", - "type" : "Arm" - }, - { - "name" : "LegLeft", - "type" : "Leg" - }, - { - "name" : "LegRight", - "type" : "Leg" - } - ], "hitboxes" : [ { "type": "hurt", @@ -83,6 +57,20 @@ "TARGETABLE", "CAN_EQUIP" ], + "visualAttributes" : [ + { + "attributeId" : "hair", + "variants" : [ + { + "id" : "hairshort1", + "model" : "Models/hairshort1.fbx", + "meshes" : [ + "Hair" + ] + } + ] + } + ], "movementSystems" : [ { "type" : "GROUND", diff --git a/src/main/java/electrosphere/engine/LoadingThread.java b/src/main/java/electrosphere/engine/LoadingThread.java index e1821b9f..2ef5082a 100644 --- a/src/main/java/electrosphere/engine/LoadingThread.java +++ b/src/main/java/electrosphere/engine/LoadingThread.java @@ -627,7 +627,7 @@ public class LoadingThread extends Thread { Entity shorts = ItemUtils.spawnBasicItem("boots1"); EntityUtils.getPosition(shorts).set(new Vector3f(2,1,1)); - Entity hair = ItemUtils.spawnBasicItem("shirt1"); + Entity hair = ItemUtils.spawnBasicItem("hairshort1"); EntityUtils.getPosition(hair).set(new Vector3f(1,1,1)); // goblin = CreatureUtils.spawnBasicCreature("Goblin"); diff --git a/src/main/java/electrosphere/entity/EntityDataStrings.java b/src/main/java/electrosphere/entity/EntityDataStrings.java index 65560ecc..3707fd9a 100644 --- a/src/main/java/electrosphere/entity/EntityDataStrings.java +++ b/src/main/java/electrosphere/entity/EntityDataStrings.java @@ -37,6 +37,7 @@ public class EntityDataStrings { public static final String DATA_STRING_VELOCITY = "velocity"; public static final String DATA_STRING_ACCELERATION = "acceleration"; public static final String DATA_STRING_MAX_NATURAL_VELOCITY = "velocityMaxNatural"; + public static final String CREATURE_ATTRIBUTE_VARIANT = "creatureAttributeVariant"; /* All Camera Types diff --git a/src/main/java/electrosphere/entity/types/creature/CreatureUtils.java b/src/main/java/electrosphere/entity/types/creature/CreatureUtils.java index 69b1c191..49ffa49c 100644 --- a/src/main/java/electrosphere/entity/types/creature/CreatureUtils.java +++ b/src/main/java/electrosphere/entity/types/creature/CreatureUtils.java @@ -23,6 +23,8 @@ import electrosphere.game.collision.collidable.Collidable; import electrosphere.game.data.creature.type.AttackMove; import electrosphere.game.data.creature.type.CollidableTemplate; import electrosphere.game.data.creature.type.SprintSystem; +import electrosphere.game.data.creature.type.visualattribute.AttributeVariant; +import electrosphere.game.data.creature.type.visualattribute.VisualAttribute; import electrosphere.logger.LoggerInterface; import electrosphere.main.Globals; import electrosphere.main.Main; @@ -66,6 +68,7 @@ public class CreatureUtils { public static Entity spawnBasicCreature(String type){ CreatureType rawType = Globals.gameConfigCurrent.getCreatureTypeLoader().getCreature(type); Entity rVal = EntityUtils.spawnDrawableEntity(rawType.getModelPath()); + Actor creatureActor = EntityUtils.getActor(rVal); for(HitboxData hitboxdata : rawType.getHitboxes()){ if(hitboxdata.getType().equals("hit")){ Globals.hitboxManager.registerHitbox(HitboxUtils.spawnRegularHitbox(rVal, hitboxdata.getBone(), hitboxdata.getRadius())); @@ -161,6 +164,21 @@ public class CreatureUtils { break; } } + //variants + if(rawType.getVisualAttributes() != null){ + for(VisualAttribute attributeType : rawType.getVisualAttributes()){ + if(attributeType.getVariants() != null && attributeType.getVariants().size() > 0){ + AttributeVariant variant = attributeType.getVariants().get(0); + // attributeType.getAttributeId(); + // variant.getId(); + rVal.putData(EntityDataStrings.CREATURE_ATTRIBUTE_VARIANT + attributeType.getAttributeId(), variant.getId()); + Globals.assetManager.addModelPathToQueue(variant.getModel()); + for(String mesh : variant.getMeshes()){ + creatureActor.getMeshMask().queueMesh(variant.getModel(), mesh); + } + } + } + } //add all attack moves if(rawType.getAttackMoves() != null && rawType.getAttackMoves().size() > 0){ for(AttackMove attackMove : rawType.getAttackMoves()){ diff --git a/src/main/java/electrosphere/game/data/creature/type/BodyPart.java b/src/main/java/electrosphere/game/data/creature/type/BodyPart.java deleted file mode 100644 index e1ba7277..00000000 --- a/src/main/java/electrosphere/game/data/creature/type/BodyPart.java +++ /dev/null @@ -1,6 +0,0 @@ -package electrosphere.game.data.creature.type; - -public class BodyPart { - int bodyPartClass; - -} diff --git a/src/main/java/electrosphere/game/data/creature/type/CreatureType.java b/src/main/java/electrosphere/game/data/creature/type/CreatureType.java index 50babb54..7d062f23 100644 --- a/src/main/java/electrosphere/game/data/creature/type/CreatureType.java +++ b/src/main/java/electrosphere/game/data/creature/type/CreatureType.java @@ -2,14 +2,15 @@ package electrosphere.game.data.creature.type; import electrosphere.entity.types.hitbox.HitboxData; import electrosphere.game.data.creature.type.rotator.RotatorSystem; +import electrosphere.game.data.creature.type.visualattribute.VisualAttribute; import java.util.List; public class CreatureType { String creatureId; - List bodyParts; List hitboxes; List tokens; + List visualAttributes; List movementSystems; RotatorSystem rotatorSystem; CollidableTemplate collidable; @@ -22,10 +23,6 @@ public class CreatureType { return creatureId; } - public List getBodyParts() { - return bodyParts; - } - public List getHitboxes() { return hitboxes; } @@ -34,6 +31,10 @@ public class CreatureType { return tokens; } + public List getVisualAttributes(){ + return visualAttributes; + } + public String getModelPath() { return modelPath; } diff --git a/src/main/java/electrosphere/game/data/creature/type/visualattribute/AttributeVariant.java b/src/main/java/electrosphere/game/data/creature/type/visualattribute/AttributeVariant.java new file mode 100644 index 00000000..2ebcfad1 --- /dev/null +++ b/src/main/java/electrosphere/game/data/creature/type/visualattribute/AttributeVariant.java @@ -0,0 +1,22 @@ +package electrosphere.game.data.creature.type.visualattribute; + +import java.util.List; + +public class AttributeVariant { + String id; + String model; + List meshes; + + public String getId(){ + return id; + } + + public String getModel(){ + return model; + } + + public List getMeshes(){ + return meshes; + } + +} diff --git a/src/main/java/electrosphere/game/data/creature/type/visualattribute/VisualAttribute.java b/src/main/java/electrosphere/game/data/creature/type/visualattribute/VisualAttribute.java new file mode 100644 index 00000000..e7c473b6 --- /dev/null +++ b/src/main/java/electrosphere/game/data/creature/type/visualattribute/VisualAttribute.java @@ -0,0 +1,17 @@ +package electrosphere.game.data.creature.type.visualattribute; + +import java.util.List; + +public class VisualAttribute { + String attributeId; + List variants; + + public String getAttributeId(){ + return attributeId; + } + + public List getVariants(){ + return variants; + } + +} diff --git a/src/main/java/electrosphere/renderer/actor/Actor.java b/src/main/java/electrosphere/renderer/actor/Actor.java index c8f04cd3..8a3b7e6a 100644 --- a/src/main/java/electrosphere/renderer/actor/Actor.java +++ b/src/main/java/electrosphere/renderer/actor/Actor.java @@ -168,10 +168,10 @@ public class Actor { boolean hasDrawn = false; if(model != null){ applyAnimationMasks(model); - if(!meshMask.isEmpty()){ - meshMask.processMeshMaskQueue(); - model.setMeshMask(meshMask); - } + meshMask.processMeshMaskQueue(); + model.setMeshMask(meshMask); + // if(!meshMask.isEmpty()){ + // } // if(animation != null){ // model.playAnimation(animation); // model.incrementTime(0.001);