Search in sources :

Example 6 with ModuleAwareAssetTypeManager

use of org.terasology.assets.module.ModuleAwareAssetTypeManager in project Terasology by MovingBlocks.

the class LwjglGraphics method registerCoreAssetTypes.

@Override
public void registerCoreAssetTypes(ModuleAwareAssetTypeManager assetTypeManager) {
    // cast lambdas explicitly to avoid inconsistent compiler behavior wrt. type inference
    assetTypeManager.registerCoreAssetType(Font.class, (AssetFactory<Font, FontData>) FontImpl::new, "fonts");
    assetTypeManager.registerCoreAssetType(Texture.class, (AssetFactory<Texture, TextureData>) (urn, assetType, data) -> (new OpenGLTexture(urn, assetType, data, this)), "textures", "fonts");
    assetTypeManager.registerCoreFormat(Texture.class, new PNGTextureFormat(Texture.FilterMode.NEAREST, path -> {
        if (path.getName(1).toString().equals(ModuleAssetDataProducer.OVERRIDE_FOLDER)) {
            return path.getName(3).toString().equals("textures");
        } else {
            return path.getName(2).toString().equals("textures");
        }
    }));
    assetTypeManager.registerCoreFormat(Texture.class, new PNGTextureFormat(Texture.FilterMode.LINEAR, path -> {
        if (path.getName(1).toString().equals(ModuleAssetDataProducer.OVERRIDE_FOLDER)) {
            return path.getName(3).toString().equals("fonts");
        } else {
            return path.getName(2).toString().equals("fonts");
        }
    }));
    assetTypeManager.registerCoreAssetType(Shader.class, (AssetFactory<Shader, ShaderData>) GLSLShader::new, "shaders");
    assetTypeManager.registerCoreAssetType(Material.class, (AssetFactory<Material, MaterialData>) GLSLMaterial::new, "materials");
    assetTypeManager.registerCoreAssetType(Mesh.class, (AssetFactory<Mesh, MeshData>) (urn, assetType, data) -> new OpenGLMesh(urn, assetType, bufferPool, data), "mesh");
    assetTypeManager.registerCoreAssetType(SkeletalMesh.class, (AssetFactory<SkeletalMesh, SkeletalMeshData>) (urn, assetType, data) -> new OpenGLSkeletalMesh(urn, assetType, data, bufferPool), "skeletalMesh");
    assetTypeManager.registerCoreAssetType(MeshAnimation.class, (AssetFactory<MeshAnimation, MeshAnimationData>) MeshAnimationImpl::new, "animations");
    assetTypeManager.registerCoreAssetType(Atlas.class, (AssetFactory<Atlas, AtlasData>) Atlas::new, "atlas");
    assetTypeManager.registerCoreAssetType(Subtexture.class, (AssetFactory<Subtexture, SubtextureData>) Subtexture::new);
}
Also used : RenderingSubsystemFactory(org.terasology.engine.subsystem.RenderingSubsystemFactory) MeshData(org.terasology.rendering.assets.mesh.MeshData) LoggerFactory(org.slf4j.LoggerFactory) Config(org.terasology.config.Config) LWJGLException(org.lwjgl.LWJGLException) ByteBuffer(java.nio.ByteBuffer) FontData(org.terasology.rendering.assets.font.FontData) Material(org.terasology.rendering.assets.material.Material) PNGTextureFormat(org.terasology.rendering.assets.texture.PNGTextureFormat) ImageIO(javax.imageio.ImageIO) Atlas(org.terasology.rendering.assets.atlas.Atlas) GL11(org.lwjgl.opengl.GL11) TextureUtil(org.terasology.rendering.assets.texture.TextureUtil) Context(org.terasology.context.Context) ModuleAwareAssetTypeManager(org.terasology.assets.module.ModuleAwareAssetTypeManager) BufferedImage(java.awt.image.BufferedImage) ShaderManager(org.terasology.rendering.ShaderManager) RenderingConfig(org.terasology.config.RenderingConfig) SubtextureData(org.terasology.rendering.assets.texture.subtexture.SubtextureData) GameState(org.terasology.engine.modes.GameState) ShaderData(org.terasology.rendering.assets.shader.ShaderData) Queues(com.google.common.collect.Queues) List(java.util.List) LwjglCanvasRenderer(org.terasology.rendering.nui.internal.LwjglCanvasRenderer) DisplayDevice(org.terasology.engine.subsystem.DisplayDevice) Font(org.terasology.rendering.assets.font.Font) Subtexture(org.terasology.rendering.assets.texture.subtexture.Subtexture) TextureData(org.terasology.rendering.assets.texture.TextureData) GameEngine(org.terasology.engine.GameEngine) ModuleAssetDataProducer(org.terasology.assets.module.ModuleAssetDataProducer) ShaderManagerLwjgl(org.terasology.rendering.ShaderManagerLwjgl) Texture(org.terasology.rendering.assets.texture.Texture) GameThread(org.terasology.engine.GameThread) org.lwjgl.opengl(org.lwjgl.opengl) MeshAnimationData(org.terasology.rendering.assets.animation.MeshAnimationData) Lists(com.google.common.collect.Lists) MaterialData(org.terasology.rendering.assets.material.MaterialData) Mesh(org.terasology.rendering.assets.mesh.Mesh) Shader(org.terasology.rendering.assets.shader.Shader) CanvasRenderer(org.terasology.rendering.nui.internal.CanvasRenderer) Logger(org.slf4j.Logger) MeshAnimationImpl(org.terasology.rendering.assets.animation.MeshAnimationImpl) SkeletalMeshData(org.terasology.rendering.assets.skeletalmesh.SkeletalMeshData) BlockingDeque(java.util.concurrent.BlockingDeque) AssetFactory(org.terasology.assets.AssetFactory) MeshAnimation(org.terasology.rendering.assets.animation.MeshAnimation) IOException(java.io.IOException) SkeletalMesh(org.terasology.rendering.assets.skeletalmesh.SkeletalMesh) FontImpl(org.terasology.rendering.assets.font.FontImpl) org.terasology.rendering.opengl(org.terasology.rendering.opengl) Consumer(java.util.function.Consumer) AtlasData(org.terasology.rendering.assets.atlas.AtlasData) PNGTextureFormat(org.terasology.rendering.assets.texture.PNGTextureFormat) Atlas(org.terasology.rendering.assets.atlas.Atlas) FontData(org.terasology.rendering.assets.font.FontData) SkeletalMeshData(org.terasology.rendering.assets.skeletalmesh.SkeletalMeshData) Mesh(org.terasology.rendering.assets.mesh.Mesh) SkeletalMesh(org.terasology.rendering.assets.skeletalmesh.SkeletalMesh) Material(org.terasology.rendering.assets.material.Material) SkeletalMesh(org.terasology.rendering.assets.skeletalmesh.SkeletalMesh) Shader(org.terasology.rendering.assets.shader.Shader) Texture(org.terasology.rendering.assets.texture.Texture) Font(org.terasology.rendering.assets.font.Font) MeshData(org.terasology.rendering.assets.mesh.MeshData) SkeletalMeshData(org.terasology.rendering.assets.skeletalmesh.SkeletalMeshData) ShaderData(org.terasology.rendering.assets.shader.ShaderData) AtlasData(org.terasology.rendering.assets.atlas.AtlasData) TextureData(org.terasology.rendering.assets.texture.TextureData) SubtextureData(org.terasology.rendering.assets.texture.subtexture.SubtextureData) MeshAnimation(org.terasology.rendering.assets.animation.MeshAnimation) MeshAnimationData(org.terasology.rendering.assets.animation.MeshAnimationData) MaterialData(org.terasology.rendering.assets.material.MaterialData) Subtexture(org.terasology.rendering.assets.texture.subtexture.Subtexture)

Example 7 with ModuleAwareAssetTypeManager

use of org.terasology.assets.module.ModuleAwareAssetTypeManager in project Terasology by MovingBlocks.

the class TerasologyEngine method initManagers.

private void initManagers() {
    changeStatus(TerasologyEngineStatus.INITIALIZING_MODULE_MANAGER);
    ModuleManager moduleManager = new ModuleManagerImpl(rootContext.get(Config.class));
    rootContext.put(ModuleManager.class, moduleManager);
    changeStatus(TerasologyEngineStatus.INITIALIZING_LOWLEVEL_OBJECT_MANIPULATION);
    ReflectFactory reflectFactory = new ReflectionReflectFactory();
    rootContext.put(ReflectFactory.class, reflectFactory);
    CopyStrategyLibrary copyStrategyLibrary = new CopyStrategyLibrary(reflectFactory);
    rootContext.put(CopyStrategyLibrary.class, copyStrategyLibrary);
    rootContext.put(TypeSerializationLibrary.class, new TypeSerializationLibrary(reflectFactory, copyStrategyLibrary));
    changeStatus(TerasologyEngineStatus.INITIALIZING_ASSET_TYPES);
    assetTypeManager = new ModuleAwareAssetTypeManager();
    rootContext.put(ModuleAwareAssetTypeManager.class, assetTypeManager);
    rootContext.put(AssetManager.class, assetTypeManager.getAssetManager());
}
Also used : ReflectionReflectFactory(org.terasology.reflection.reflect.ReflectionReflectFactory) ReflectionReflectFactory(org.terasology.reflection.reflect.ReflectionReflectFactory) ReflectFactory(org.terasology.reflection.reflect.ReflectFactory) ModuleManagerImpl(org.terasology.engine.module.ModuleManagerImpl) Config(org.terasology.config.Config) ModuleAwareAssetTypeManager(org.terasology.assets.module.ModuleAwareAssetTypeManager) CopyStrategyLibrary(org.terasology.reflection.copy.CopyStrategyLibrary) TypeSerializationLibrary(org.terasology.persistence.typeHandling.TypeSerializationLibrary) ModuleManager(org.terasology.engine.module.ModuleManager)

Example 8 with ModuleAwareAssetTypeManager

use of org.terasology.assets.module.ModuleAwareAssetTypeManager in project Terasology by MovingBlocks.

the class EntitySerializerTest method setupClass.

@BeforeClass
public static void setupClass() throws Exception {
    context = new ContextImpl();
    CoreRegistry.setContext(context);
    moduleManager = ModuleManagerFactory.create();
    context.put(ModuleManager.class, moduleManager);
    ModuleAwareAssetTypeManager assetTypeManager = new ModuleAwareAssetTypeManager();
    assetTypeManager.registerCoreAssetType(Prefab.class, (AssetFactory<Prefab, PrefabData>) PojoPrefab::new, "prefabs");
    assetTypeManager.switchEnvironment(moduleManager.getEnvironment());
    context.put(AssetManager.class, assetTypeManager.getAssetManager());
}
Also used : PrefabData(org.terasology.entitySystem.prefab.PrefabData) ModuleAwareAssetTypeManager(org.terasology.assets.module.ModuleAwareAssetTypeManager) ContextImpl(org.terasology.context.internal.ContextImpl) Prefab(org.terasology.entitySystem.prefab.Prefab) PojoPrefab(org.terasology.entitySystem.prefab.internal.PojoPrefab) BeforeClass(org.junit.BeforeClass)

Example 9 with ModuleAwareAssetTypeManager

use of org.terasology.assets.module.ModuleAwareAssetTypeManager in project Terasology by MovingBlocks.

the class BaseEntityRefTest method setupClass.

@BeforeClass
public static void setupClass() throws Exception {
    context = new ContextImpl();
    ModuleManager moduleManager = ModuleManagerFactory.create();
    context.put(ModuleManager.class, moduleManager);
    ModuleAwareAssetTypeManager assetTypeManager = new ModuleAwareAssetTypeManager();
    assetTypeManager.registerCoreAssetType(Prefab.class, (AssetFactory<Prefab, PrefabData>) PojoPrefab::new, "prefabs");
    assetTypeManager.switchEnvironment(moduleManager.getEnvironment());
    context.put(AssetManager.class, assetTypeManager.getAssetManager());
    CoreRegistry.setContext(context);
}
Also used : PrefabData(org.terasology.entitySystem.prefab.PrefabData) ModuleAwareAssetTypeManager(org.terasology.assets.module.ModuleAwareAssetTypeManager) ContextImpl(org.terasology.context.internal.ContextImpl) ModuleManager(org.terasology.engine.module.ModuleManager) Prefab(org.terasology.entitySystem.prefab.Prefab) PojoPrefab(org.terasology.entitySystem.prefab.internal.PojoPrefab) BeforeClass(org.junit.BeforeClass)

Example 10 with ModuleAwareAssetTypeManager

use of org.terasology.assets.module.ModuleAwareAssetTypeManager in project Terasology by MovingBlocks.

the class PojoEntityPoolTest method setupClass.

@BeforeClass
public static void setupClass() throws Exception {
    context = new ContextImpl();
    ModuleManager moduleManager = ModuleManagerFactory.create();
    context.put(ModuleManager.class, moduleManager);
    ModuleAwareAssetTypeManager assetTypeManager = new ModuleAwareAssetTypeManager();
    assetTypeManager.registerCoreAssetType(Prefab.class, (AssetFactory<Prefab, PrefabData>) PojoPrefab::new, "prefabs");
    assetTypeManager.switchEnvironment(moduleManager.getEnvironment());
    context.put(AssetManager.class, assetTypeManager.getAssetManager());
    CoreRegistry.setContext(context);
}
Also used : PrefabData(org.terasology.entitySystem.prefab.PrefabData) ModuleAwareAssetTypeManager(org.terasology.assets.module.ModuleAwareAssetTypeManager) ContextImpl(org.terasology.context.internal.ContextImpl) ModuleManager(org.terasology.engine.module.ModuleManager) Prefab(org.terasology.entitySystem.prefab.Prefab) PojoPrefab(org.terasology.entitySystem.prefab.internal.PojoPrefab) BeforeClass(org.junit.BeforeClass)

Aggregations

ModuleAwareAssetTypeManager (org.terasology.assets.module.ModuleAwareAssetTypeManager)13 ModuleManager (org.terasology.engine.module.ModuleManager)8 Prefab (org.terasology.entitySystem.prefab.Prefab)7 PrefabData (org.terasology.entitySystem.prefab.PrefabData)7 PojoPrefab (org.terasology.entitySystem.prefab.internal.PojoPrefab)7 ContextImpl (org.terasology.context.internal.ContextImpl)6 TypeSerializationLibrary (org.terasology.persistence.typeHandling.TypeSerializationLibrary)5 BeforeClass (org.junit.BeforeClass)4 AssetFactory (org.terasology.assets.AssetFactory)3 Config (org.terasology.config.Config)3 CopyStrategyLibrary (org.terasology.reflection.copy.CopyStrategyLibrary)3 ReflectFactory (org.terasology.reflection.reflect.ReflectFactory)3 MeshAnimation (org.terasology.rendering.assets.animation.MeshAnimation)3 MeshAnimationData (org.terasology.rendering.assets.animation.MeshAnimationData)3 MeshAnimationImpl (org.terasology.rendering.assets.animation.MeshAnimationImpl)3 Atlas (org.terasology.rendering.assets.atlas.Atlas)3 AtlasData (org.terasology.rendering.assets.atlas.AtlasData)3 Font (org.terasology.rendering.assets.font.Font)3 IOException (java.io.IOException)2 Logger (org.slf4j.Logger)2