procedurally generated block item types
This commit is contained in:
parent
0961b42e26
commit
c2523b21bf
@ -1304,6 +1304,7 @@ Disable client fluid draw cell loading gate
|
|||||||
Properly differentiate local/world bone attach point calculation
|
Properly differentiate local/world bone attach point calculation
|
||||||
Floating origin implementation for collision engine
|
Floating origin implementation for collision engine
|
||||||
Improve initial asset loading performance
|
Improve initial asset loading performance
|
||||||
|
PoseModel creation for basic shape types
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -165,7 +165,7 @@ public class ClientFluidManager {
|
|||||||
lock.lock();
|
lock.lock();
|
||||||
for(FluidChunkGenQueueItem queueItem : fluidChunkGenerationQueue){
|
for(FluidChunkGenQueueItem queueItem : fluidChunkGenerationQueue){
|
||||||
Model fluidModel = FluidChunkModelGeneration.generateFluidModel(queueItem.getData());
|
Model fluidModel = FluidChunkModelGeneration.generateFluidModel(queueItem.getData());
|
||||||
Globals.assetManager.registerModelToSpecificString(fluidModel, queueItem.getPromisedHash());
|
Globals.assetManager.registerModelWithPath(fluidModel, queueItem.getPromisedHash());
|
||||||
}
|
}
|
||||||
fluidChunkGenerationQueue.clear();
|
fluidChunkGenerationQueue.clear();
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
|||||||
@ -353,7 +353,7 @@ public class ClientTerrainManager {
|
|||||||
lock.acquireUninterruptibly();
|
lock.acquireUninterruptibly();
|
||||||
for(TerrainChunkGenQueueItem queueItem : terrainChunkGenerationQueue){
|
for(TerrainChunkGenQueueItem queueItem : terrainChunkGenerationQueue){
|
||||||
Model terrainModel = TransvoxelModelGeneration.generateTerrainModel(queueItem.getData(), queueItem.getAtlas());
|
Model terrainModel = TransvoxelModelGeneration.generateTerrainModel(queueItem.getData(), queueItem.getAtlas());
|
||||||
Globals.assetManager.registerModelToSpecificString(terrainModel, queueItem.getPromisedHash());
|
Globals.assetManager.registerModelWithPath(terrainModel, queueItem.getPromisedHash());
|
||||||
if(queueItem.notifyTarget != null){
|
if(queueItem.notifyTarget != null){
|
||||||
queueItem.notifyTarget.alertToGeneration();
|
queueItem.notifyTarget.alertToGeneration();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -83,6 +83,7 @@ import electrosphere.server.datacell.EntityDataCellMapper;
|
|||||||
import electrosphere.server.datacell.RealmManager;
|
import electrosphere.server.datacell.RealmManager;
|
||||||
import electrosphere.server.db.DatabaseController;
|
import electrosphere.server.db.DatabaseController;
|
||||||
import electrosphere.server.pathfinding.NavMeshManager;
|
import electrosphere.server.pathfinding.NavMeshManager;
|
||||||
|
import electrosphere.server.poseactor.PoseModel;
|
||||||
import electrosphere.server.saves.Save;
|
import electrosphere.server.saves.Save;
|
||||||
import electrosphere.server.simulation.MacroSimulation;
|
import electrosphere.server.simulation.MacroSimulation;
|
||||||
import electrosphere.server.simulation.MicroSimulation;
|
import electrosphere.server.simulation.MicroSimulation;
|
||||||
@ -642,9 +643,9 @@ public class Globals {
|
|||||||
//create font manager
|
//create font manager
|
||||||
fontManager = new FontManager();
|
fontManager = new FontManager();
|
||||||
fontManager.loadFonts();
|
fontManager.loadFonts();
|
||||||
assetManager.registerModelToSpecificString(RenderUtils.createBitmapCharacter(), AssetDataStrings.BITMAP_CHARACTER_MODEL);
|
assetManager.registerModelWithPath(RenderUtils.createBitmapCharacter(), AssetDataStrings.BITMAP_CHARACTER_MODEL);
|
||||||
//particle billboard model
|
//particle billboard model
|
||||||
assetManager.registerModelToSpecificString(RenderUtils.createParticleModel(), AssetDataStrings.MODEL_PARTICLE);
|
assetManager.registerModelWithPath(RenderUtils.createParticleModel(), AssetDataStrings.MODEL_PARTICLE);
|
||||||
//initialize required windows
|
//initialize required windows
|
||||||
WindowUtils.initBaseWindows();
|
WindowUtils.initBaseWindows();
|
||||||
//init default shaderProgram
|
//init default shaderProgram
|
||||||
@ -655,9 +656,9 @@ public class Globals {
|
|||||||
//init fluid shader program
|
//init fluid shader program
|
||||||
FluidChunkModelGeneration.fluidChunkShaderProgram = VisualShader.loadSpecificShader("/Shaders/entities/fluid2/fluid2.vs", "/Shaders/entities/fluid2/fluid2.fs");
|
FluidChunkModelGeneration.fluidChunkShaderProgram = VisualShader.loadSpecificShader("/Shaders/entities/fluid2/fluid2.vs", "/Shaders/entities/fluid2/fluid2.fs");
|
||||||
//init models
|
//init models
|
||||||
assetManager.registerModelToSpecificString(RenderUtils.createUnitsphere(), AssetDataStrings.UNITSPHERE);
|
assetManager.registerModelWithPath(RenderUtils.createUnitsphere(), AssetDataStrings.UNITSPHERE);
|
||||||
assetManager.registerModelToSpecificString(RenderUtils.createUnitCylinder(), AssetDataStrings.UNITCYLINDER);
|
assetManager.registerModelWithPath(RenderUtils.createUnitCylinder(), AssetDataStrings.UNITCYLINDER);
|
||||||
assetManager.registerModelToSpecificString(RenderUtils.createUnitCube(), AssetDataStrings.UNITCUBE);
|
assetManager.registerModelWithPath(RenderUtils.createUnitCube(), AssetDataStrings.UNITCUBE);
|
||||||
assetManager.addModelPathToQueue("Models/basic/geometry/SmallCube.fbx");
|
assetManager.addModelPathToQueue("Models/basic/geometry/SmallCube.fbx");
|
||||||
assetManager.addModelPathToQueue("Models/basic/geometry/unitcapsule.glb");
|
assetManager.addModelPathToQueue("Models/basic/geometry/unitcapsule.glb");
|
||||||
assetManager.addModelPathToQueue("Models/basic/geometry/unitplane.fbx");
|
assetManager.addModelPathToQueue("Models/basic/geometry/unitplane.fbx");
|
||||||
@ -666,6 +667,13 @@ public class Globals {
|
|||||||
assetManager.addShaderToQueue("Shaders/core/plane/plane.vs", "Shaders/core/plane/plane.fs");
|
assetManager.addShaderToQueue("Shaders/core/plane/plane.vs", "Shaders/core/plane/plane.fs");
|
||||||
solidPlaneModelID = assetManager.registerModel(RenderUtils.createInWindowPanel("Shaders/ui/plainBox/plainBox.vs", "Shaders/ui/plainBox/plainBox.fs"));
|
solidPlaneModelID = assetManager.registerModel(RenderUtils.createInWindowPanel("Shaders/ui/plainBox/plainBox.vs", "Shaders/ui/plainBox/plainBox.fs"));
|
||||||
|
|
||||||
|
//init pose models for basic shapes
|
||||||
|
PoseModel emptyPoseModel = PoseModel.createEmpty();
|
||||||
|
assetManager.registerPoseModelWithPath(emptyPoseModel, AssetDataStrings.POSE_EMPTY);
|
||||||
|
assetManager.registerPoseModelWithPath(emptyPoseModel, AssetDataStrings.UNITSPHERE);
|
||||||
|
assetManager.registerPoseModelWithPath(emptyPoseModel, AssetDataStrings.UNITCYLINDER);
|
||||||
|
assetManager.registerPoseModelWithPath(emptyPoseModel, AssetDataStrings.UNITCUBE);
|
||||||
|
|
||||||
//image panel
|
//image panel
|
||||||
ImagePanel.imagePanelModelPath = assetManager.registerModel(RenderUtils.createPlaneModel("Shaders/core/imagepanel/imagepanel.vs", "Shaders/core/imagepanel/imagepanel.fs"));
|
ImagePanel.imagePanelModelPath = assetManager.registerModel(RenderUtils.createPlaneModel("Shaders/core/imagepanel/imagepanel.vs", "Shaders/core/imagepanel/imagepanel.fs"));
|
||||||
|
|
||||||
|
|||||||
@ -23,6 +23,7 @@ public class AssetDataStrings {
|
|||||||
public static final String UNITCUBE = "unitCube";
|
public static final String UNITCUBE = "unitCube";
|
||||||
public static final String MODEL_PARTICLE = "particleModel";
|
public static final String MODEL_PARTICLE = "particleModel";
|
||||||
public static final String TEXTURE_PARTICLE = "particleTexture";
|
public static final String TEXTURE_PARTICLE = "particleTexture";
|
||||||
|
public static final String POSE_EMPTY = "poseEmpty";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UI textures
|
* UI textures
|
||||||
|
|||||||
@ -264,10 +264,6 @@ public class AssetManager {
|
|||||||
public void registerModelWithPath(Model m, String path){
|
public void registerModelWithPath(Model m, String path){
|
||||||
modelsLoadedIntoMemory.put(path, m);
|
modelsLoadedIntoMemory.put(path, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerModelToSpecificString(Model m, String s){
|
|
||||||
modelsLoadedIntoMemory.put(s,m);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deregisterModelPath(String path){
|
public void deregisterModelPath(String path){
|
||||||
modelsLoadedIntoMemory.remove(path);
|
modelsLoadedIntoMemory.remove(path);
|
||||||
@ -341,6 +337,16 @@ public class AssetManager {
|
|||||||
}
|
}
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a (presumably generated in code) pose model to a given path in the asset manager
|
||||||
|
* Used particularly if you have a specific path you want to relate to a specific pose model (eg basic shapes)
|
||||||
|
* @param m The pose model to register
|
||||||
|
* @param path The path to register the pose model to
|
||||||
|
*/
|
||||||
|
public void registerPoseModelWithPath(PoseModel m, String path){
|
||||||
|
poseModelsLoadedIntoMemory.put(path, m);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -102,8 +102,9 @@ public class Config {
|
|||||||
config.biomeMap = BiomeTypeMap.loadBiomeFile("Data/game/biomes.json");
|
config.biomeMap = BiomeTypeMap.loadBiomeFile("Data/game/biomes.json");
|
||||||
config.samplerDefinitions = SamplerFile.readSamplerDefinitionFiles("Data/game/voxel");
|
config.samplerDefinitions = SamplerFile.readSamplerDefinitionFiles("Data/game/voxel");
|
||||||
|
|
||||||
//create furniture items
|
//create procedural item types
|
||||||
ItemDataMap.loadSpawnItems(config.itemMap, config.objectTypeLoader);
|
ItemDataMap.loadSpawnItems(config.itemMap, config.objectTypeLoader);
|
||||||
|
ItemDataMap.generateBlockItems(config.itemMap, config.blockData);
|
||||||
|
|
||||||
//validate
|
//validate
|
||||||
ConfigValidator.valdiate(config);
|
ConfigValidator.valdiate(config);
|
||||||
|
|||||||
@ -2,8 +2,12 @@ package electrosphere.game.data.item;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import electrosphere.engine.assetmanager.AssetDataStrings;
|
||||||
|
import electrosphere.game.data.block.BlockType;
|
||||||
import electrosphere.game.data.common.CommonEntityType;
|
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.NonproceduralModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data on a given item
|
* Data on a given item
|
||||||
@ -84,7 +88,7 @@ public class Item extends CommonEntityType {
|
|||||||
if(description.getGraphicsTemplate() != null){
|
if(description.getGraphicsTemplate() != null){
|
||||||
rVal.setGraphicsTemplate(description.getGraphicsTemplate());
|
rVal.setGraphicsTemplate(description.getGraphicsTemplate());
|
||||||
} else {
|
} else {
|
||||||
throw new Error("Need to implement handling for when no graphics template is providedd!");
|
throw new Error("Need to implement handling for when no graphics template is provided!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -100,6 +104,42 @@ public class Item extends CommonEntityType {
|
|||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates item data from a block type
|
||||||
|
* @param description The block type
|
||||||
|
* @return The item data
|
||||||
|
*/
|
||||||
|
public static Item createBlockItem(BlockType blockType){
|
||||||
|
Item rVal = new Item();
|
||||||
|
rVal.setId(blockType.getName());
|
||||||
|
|
||||||
|
|
||||||
|
if(blockType.getTexture() != null){
|
||||||
|
rVal.iconPath = blockType.getTexture();
|
||||||
|
} else {
|
||||||
|
rVal.iconPath = Item.DEFAULT_ITEM_ICON_PATH;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NonproceduralModel modelData = new NonproceduralModel();
|
||||||
|
modelData.setPath(AssetDataStrings.UNITCUBE);
|
||||||
|
GraphicsTemplate blockItemGraphicsTemplate = new GraphicsTemplate();
|
||||||
|
blockItemGraphicsTemplate.setModel(modelData);
|
||||||
|
rVal.setGraphicsTemplate(blockItemGraphicsTemplate);
|
||||||
|
|
||||||
|
|
||||||
|
//set usage
|
||||||
|
ItemUsage usage = new ItemUsage();
|
||||||
|
usage.setBlockId(blockType.getId());
|
||||||
|
rVal.setSecondaryUsage(usage);
|
||||||
|
|
||||||
|
|
||||||
|
//attach common tokens
|
||||||
|
rVal.setTokens(Arrays.asList(DEFAULT_TOKENS));
|
||||||
|
|
||||||
|
return rVal;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the idle animation for the item
|
* the idle animation for the item
|
||||||
* @return
|
* @return
|
||||||
|
|||||||
@ -9,6 +9,8 @@ import java.util.Set;
|
|||||||
|
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
import electrosphere.entity.types.item.ItemUtils;
|
import electrosphere.entity.types.item.ItemUtils;
|
||||||
|
import electrosphere.game.data.block.BlockData;
|
||||||
|
import electrosphere.game.data.block.BlockType;
|
||||||
import electrosphere.game.data.common.CommonEntityMap;
|
import electrosphere.game.data.common.CommonEntityMap;
|
||||||
import electrosphere.game.data.common.CommonEntityType;
|
import electrosphere.game.data.common.CommonEntityType;
|
||||||
import electrosphere.util.FileUtils;
|
import electrosphere.util.FileUtils;
|
||||||
@ -130,4 +132,17 @@ public class ItemDataMap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads all block types as items
|
||||||
|
* @param itemDataMap The item data map
|
||||||
|
* @param blockData The data on all block types
|
||||||
|
*/
|
||||||
|
public static void generateBlockItems(ItemDataMap itemDataMap, BlockData blockData){
|
||||||
|
for(BlockType blockType : blockData.getTypes()){
|
||||||
|
Item spawnItem = Item.createBlockItem(blockType);
|
||||||
|
//create spawn items
|
||||||
|
itemDataMap.putType(spawnItem.getId(), spawnItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,6 +10,11 @@ public class ItemUsage {
|
|||||||
*/
|
*/
|
||||||
String spawnEntityId;
|
String spawnEntityId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If defined, this item will place the block type on use
|
||||||
|
*/
|
||||||
|
Integer blockId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the spawn entity id of the item usage
|
* Gets the spawn entity id of the item usage
|
||||||
* @return The spawn entity id
|
* @return The spawn entity id
|
||||||
@ -26,6 +31,24 @@ public class ItemUsage {
|
|||||||
this.spawnEntityId = spawnEntityId;
|
this.spawnEntityId = spawnEntityId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the block type id of the item usage
|
||||||
|
* @return The block type id
|
||||||
|
*/
|
||||||
|
public Integer getBlockId() {
|
||||||
|
return blockId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the block type id of the item usage
|
||||||
|
* @param spawnEntityId The block type id
|
||||||
|
*/
|
||||||
|
public void setBlockId(Integer blockId) {
|
||||||
|
this.blockId = blockId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,7 @@ import electrosphere.game.data.creature.type.CreatureData;
|
|||||||
import electrosphere.game.data.creature.type.block.BlockVariant;
|
import electrosphere.game.data.creature.type.block.BlockVariant;
|
||||||
import electrosphere.game.data.item.Item;
|
import electrosphere.game.data.item.Item;
|
||||||
import electrosphere.game.data.item.ItemUsage;
|
import electrosphere.game.data.item.ItemUsage;
|
||||||
|
import electrosphere.logger.LoggerInterface;
|
||||||
import electrosphere.net.parser.net.message.InventoryMessage;
|
import electrosphere.net.parser.net.message.InventoryMessage;
|
||||||
import electrosphere.net.server.ServerConnectionHandler;
|
import electrosphere.net.server.ServerConnectionHandler;
|
||||||
import electrosphere.server.datacell.Realm;
|
import electrosphere.server.datacell.Realm;
|
||||||
@ -86,6 +87,10 @@ public class PlayerActions {
|
|||||||
Vector3d spawnPos = new Vector3d(message.getviewTargetX(),message.getviewTargetY(),message.getviewTargetZ());
|
Vector3d spawnPos = new Vector3d(message.getviewTargetX(),message.getviewTargetY(),message.getviewTargetZ());
|
||||||
CommonEntityUtils.serverSpawnBasicObject(playerRealm, spawnPos, secondaryUsage.getSpawnEntityId());
|
CommonEntityUtils.serverSpawnBasicObject(playerRealm, spawnPos, secondaryUsage.getSpawnEntityId());
|
||||||
}
|
}
|
||||||
|
if(secondaryUsage.getBlockId() != null){
|
||||||
|
Vector3d spawnPos = new Vector3d(message.getviewTargetX(),message.getviewTargetY(),message.getviewTargetZ());
|
||||||
|
LoggerInterface.loggerEngine.WARNING("Spawn block type " + secondaryUsage.getBlockId() + " at " + spawnPos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -40,6 +40,12 @@ public class PoseModel {
|
|||||||
Map<String, Animation> animMap;
|
Map<String, Animation> animMap;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Private constructor for static creation methods
|
||||||
|
*/
|
||||||
|
private PoseModel(){
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* @param path Path on disk to this posemodel
|
* @param path Path on disk to this posemodel
|
||||||
@ -104,6 +110,21 @@ public class PoseModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
* @param path Path on disk to this posemodel
|
||||||
|
* @param scene The AI Scene parsed from the file on disk
|
||||||
|
*/
|
||||||
|
public static PoseModel createEmpty(){
|
||||||
|
PoseModel rVal = new PoseModel();
|
||||||
|
rVal.bones = new ArrayList<Bone>();
|
||||||
|
rVal.boneMap = new HashMap<String, Bone>();
|
||||||
|
rVal.nodeMap = new HashMap<String, AnimNode>();
|
||||||
|
rVal.animations = new ArrayList<Animation>();
|
||||||
|
rVal.animMap = new HashMap<String, Animation>();
|
||||||
|
return rVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies an animation to a certain set of bones
|
* Applies an animation to a certain set of bones
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user