Search in sources :

Example 11 with Material

use of org.terasology.rendering.assets.material.Material in project Terasology by MovingBlocks.

the class HeadlessGraphics method registerCoreAssetTypes.

@Override
public void registerCoreAssetTypes(ModuleAwareAssetTypeManager assetTypeManager) {
    assetTypeManager.registerCoreAssetType(Font.class, (AssetFactory<Font, FontData>) FontImpl::new, "fonts");
    assetTypeManager.registerCoreAssetType(Texture.class, (AssetFactory<Texture, TextureData>) HeadlessTexture::new, "textures", "fonts");
    assetTypeManager.registerCoreFormat(Texture.class, new PNGTextureFormat(Texture.FilterMode.NEAREST, path -> path.getName(2).toString().equals("textures")));
    assetTypeManager.registerCoreFormat(Texture.class, new PNGTextureFormat(Texture.FilterMode.LINEAR, path -> path.getName(2).toString().equals("fonts")));
    assetTypeManager.registerCoreAssetType(Shader.class, (AssetFactory<Shader, ShaderData>) HeadlessShader::new, "shaders");
    assetTypeManager.registerCoreAssetType(Material.class, (AssetFactory<Material, MaterialData>) HeadlessMaterial::new, "materials");
    assetTypeManager.registerCoreAssetType(Mesh.class, (AssetFactory<Mesh, MeshData>) HeadlessMesh::new, "mesh");
    assetTypeManager.registerCoreAssetType(SkeletalMesh.class, (AssetFactory<SkeletalMesh, SkeletalMeshData>) HeadlessSkeletalMesh::new, "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 : PNGTextureFormat(org.terasology.rendering.assets.texture.PNGTextureFormat) EngineSubsystem(org.terasology.engine.subsystem.EngineSubsystem) RenderingSubsystemFactory(org.terasology.engine.subsystem.RenderingSubsystemFactory) Texture(org.terasology.rendering.assets.texture.Texture) MeshData(org.terasology.rendering.assets.mesh.MeshData) HeadlessMaterial(org.terasology.engine.subsystem.headless.assets.HeadlessMaterial) HeadlessDisplayDevice(org.terasology.engine.subsystem.headless.device.HeadlessDisplayDevice) HeadlessTexture(org.terasology.engine.subsystem.headless.assets.HeadlessTexture) MeshAnimationData(org.terasology.rendering.assets.animation.MeshAnimationData) FontData(org.terasology.rendering.assets.font.FontData) Material(org.terasology.rendering.assets.material.Material) MaterialData(org.terasology.rendering.assets.material.MaterialData) Mesh(org.terasology.rendering.assets.mesh.Mesh) Shader(org.terasology.rendering.assets.shader.Shader) PNGTextureFormat(org.terasology.rendering.assets.texture.PNGTextureFormat) CanvasRenderer(org.terasology.rendering.nui.internal.CanvasRenderer) Atlas(org.terasology.rendering.assets.atlas.Atlas) HeadlessSkeletalMesh(org.terasology.engine.subsystem.headless.assets.HeadlessSkeletalMesh) HeadlessShader(org.terasology.engine.subsystem.headless.assets.HeadlessShader) Context(org.terasology.context.Context) ModuleAwareAssetTypeManager(org.terasology.assets.module.ModuleAwareAssetTypeManager) MeshAnimationImpl(org.terasology.rendering.assets.animation.MeshAnimationImpl) SkeletalMeshData(org.terasology.rendering.assets.skeletalmesh.SkeletalMeshData) ShaderManager(org.terasology.rendering.ShaderManager) AssetFactory(org.terasology.assets.AssetFactory) MeshAnimation(org.terasology.rendering.assets.animation.MeshAnimation) SubtextureData(org.terasology.rendering.assets.texture.subtexture.SubtextureData) SkeletalMesh(org.terasology.rendering.assets.skeletalmesh.SkeletalMesh) FontImpl(org.terasology.rendering.assets.font.FontImpl) ShaderData(org.terasology.rendering.assets.shader.ShaderData) HeadlessCanvasRenderer(org.terasology.engine.subsystem.headless.renderer.HeadlessCanvasRenderer) HeadlessRenderingSubsystemFactory(org.terasology.engine.subsystem.headless.renderer.HeadlessRenderingSubsystemFactory) HeadlessMesh(org.terasology.engine.subsystem.headless.assets.HeadlessMesh) ShaderManagerHeadless(org.terasology.engine.subsystem.headless.renderer.ShaderManagerHeadless) 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) AtlasData(org.terasology.rendering.assets.atlas.AtlasData) 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) HeadlessSkeletalMesh(org.terasology.engine.subsystem.headless.assets.HeadlessSkeletalMesh) SkeletalMesh(org.terasology.rendering.assets.skeletalmesh.SkeletalMesh) HeadlessMesh(org.terasology.engine.subsystem.headless.assets.HeadlessMesh) HeadlessMaterial(org.terasology.engine.subsystem.headless.assets.HeadlessMaterial) Material(org.terasology.rendering.assets.material.Material) HeadlessSkeletalMesh(org.terasology.engine.subsystem.headless.assets.HeadlessSkeletalMesh) SkeletalMesh(org.terasology.rendering.assets.skeletalmesh.SkeletalMesh) Shader(org.terasology.rendering.assets.shader.Shader) HeadlessShader(org.terasology.engine.subsystem.headless.assets.HeadlessShader) Texture(org.terasology.rendering.assets.texture.Texture) HeadlessTexture(org.terasology.engine.subsystem.headless.assets.HeadlessTexture) 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 12 with Material

use of org.terasology.rendering.assets.material.Material in project Terasology by MovingBlocks.

the class LwjglCanvasRenderer method drawText.

@Override
public void drawText(String text, Font font, HorizontalAlign hAlign, VerticalAlign vAlign, Rect2i absoluteRegion, Color color, Color shadowColor, float alpha, boolean underlined) {
    TextCacheKey key = new TextCacheKey(text, font, absoluteRegion.width(), hAlign, color, shadowColor, underlined);
    usedText.add(key);
    Map<Material, Mesh> fontMesh = cachedText.get(key);
    List<String> lines = TextLineBuilder.getLines(font, text, absoluteRegion.width());
    if (fontMesh != null) {
        for (Mesh mesh : fontMesh.values()) {
            if (mesh.isDisposed()) {
                fontMesh = null;
                break;
            }
        }
    }
    if (fontMesh == null) {
        fontMesh = fontMeshBuilder.createTextMesh(font, lines, absoluteRegion.width(), hAlign, color, shadowColor, underlined);
        cachedText.put(key, fontMesh);
    }
    Vector2i offset = new Vector2i(absoluteRegion.minX(), absoluteRegion.minY());
    offset.y += vAlign.getOffset(lines.size() * font.getLineHeight(), absoluteRegion.height());
    fontMesh.entrySet().stream().filter(entry -> entry.getKey().isRenderable()).forEach(entry -> {
        entry.getKey().bindTextures();
        entry.getKey().setFloat4(CROPPING_BOUNDARIES_PARAM, requestedCropRegion.minX(), requestedCropRegion.maxX(), requestedCropRegion.minY(), requestedCropRegion.maxY());
        entry.getKey().setFloat2("offset", offset.x, offset.y);
        entry.getKey().setFloat("alpha", alpha);
        entry.getValue().render();
    });
}
Also used : FloatBuffer(java.nio.FloatBuffer) AssetManager(org.terasology.assets.management.AssetManager) Vector3f(org.terasology.math.geom.Vector3f) FrameBufferObject(org.terasology.rendering.opengl.FrameBufferObject) GL11.glDisable(org.lwjgl.opengl.GL11.glDisable) FontMeshBuilder(org.terasology.rendering.assets.font.FontMeshBuilder) GL11.glOrtho(org.lwjgl.opengl.GL11.glOrtho) GL11.glTranslatef(org.lwjgl.opengl.GL11.glTranslatef) Material(org.terasology.rendering.assets.material.Material) Map(java.util.Map) GL11(org.lwjgl.opengl.GL11) TeraMath(org.terasology.math.TeraMath) TextLineBuilder(org.terasology.rendering.nui.TextLineBuilder) GL11.glLoadMatrix(org.lwjgl.opengl.GL11.glLoadMatrix) Display(org.lwjgl.opengl.Display) Context(org.terasology.context.Context) GL_PROJECTION(org.lwjgl.opengl.GL11.GL_PROJECTION) GL_SRC_ALPHA(org.lwjgl.opengl.GL11.GL_SRC_ALPHA) GL_DEPTH_TEST(org.lwjgl.opengl.GL11.GL_DEPTH_TEST) Set(java.util.Set) MeshBuilder(org.terasology.rendering.assets.mesh.MeshBuilder) GL11.glLoadIdentity(org.lwjgl.opengl.GL11.glLoadIdentity) Sets(com.google.common.collect.Sets) GL11.glPopMatrix(org.lwjgl.opengl.GL11.glPopMatrix) BufferUtils(org.lwjgl.BufferUtils) Objects(java.util.Objects) List(java.util.List) AABB(org.terasology.math.AABB) Font(org.terasology.rendering.assets.font.Font) TextureRegion(org.terasology.rendering.assets.texture.TextureRegion) GL11.glPushMatrix(org.lwjgl.opengl.GL11.glPushMatrix) ResourceUrn(org.terasology.assets.ResourceUrn) GL_MODELVIEW(org.lwjgl.opengl.GL11.GL_MODELVIEW) HorizontalAlign(org.terasology.rendering.nui.HorizontalAlign) VerticalAlign(org.terasology.rendering.nui.VerticalAlign) MatrixUtils(org.terasology.math.MatrixUtils) Rect2f(org.terasology.math.geom.Rect2f) ScaleMode(org.terasology.rendering.nui.ScaleMode) Rect2i(org.terasology.math.geom.Rect2i) Matrix4f(org.terasology.math.geom.Matrix4f) Mesh(org.terasology.rendering.assets.mesh.Mesh) BaseQuat4f(org.terasology.math.geom.BaseQuat4f) GL11.glClear(org.lwjgl.opengl.GL11.glClear) Assets(org.terasology.utilities.Assets) GL11.glMatrixMode(org.lwjgl.opengl.GL11.glMatrixMode) GL11.glEnable(org.lwjgl.opengl.GL11.glEnable) Iterator(java.util.Iterator) Vector2i(org.terasology.math.geom.Vector2i) Vector2f(org.terasology.math.geom.Vector2f) Maps(com.google.common.collect.Maps) ShaderProgramFeature(org.terasology.rendering.assets.shader.ShaderProgramFeature) LwjglFrameBufferObject(org.terasology.rendering.opengl.LwjglFrameBufferObject) GL11.glBlendFunc(org.lwjgl.opengl.GL11.glBlendFunc) GL11.glScalef(org.lwjgl.opengl.GL11.glScalef) GL_ONE_MINUS_SRC_ALPHA(org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA) Border(org.terasology.math.Border) Quat4f(org.terasology.math.geom.Quat4f) BaseVector2i(org.terasology.math.geom.BaseVector2i) Color(org.terasology.rendering.nui.Color) GL_BLEND(org.lwjgl.opengl.GL11.GL_BLEND) Mesh(org.terasology.rendering.assets.mesh.Mesh) Material(org.terasology.rendering.assets.material.Material) Vector2i(org.terasology.math.geom.Vector2i) BaseVector2i(org.terasology.math.geom.BaseVector2i)

Example 13 with Material

use of org.terasology.rendering.assets.material.Material in project Terasology by MovingBlocks.

the class FontFormat method parsePage.

private void parsePage(FontDataBuilder builder, Name moduleName, String pageInfo) throws IOException {
    Matcher pageMatcher = pagePattern.matcher(pageInfo);
    if (pageMatcher.matches()) {
        int pageId = Integer.parseInt(pageMatcher.group(1));
        Name textureName = new Name(pageMatcher.group(2).substring(0, pageMatcher.group(2).lastIndexOf('.')));
        Optional<Material> material = assetManager.getAsset(new ResourceUrn(moduleName, new Name("font"), textureName), Material.class);
        if (!material.isPresent()) {
            throw new IOException("Failed to load font - unable to resolve font page '" + textureName + "'");
        } else {
            builder.addPage(pageId, assetManager.getAsset(new ResourceUrn(moduleName, textureName), Texture.class).get(), material.get());
        }
    } else {
        throw new IOException("Failed to load font - invalid page line '" + pageInfo + "'");
    }
}
Also used : Matcher(java.util.regex.Matcher) Material(org.terasology.rendering.assets.material.Material) IOException(java.io.IOException) ResourceUrn(org.terasology.assets.ResourceUrn) Name(org.terasology.naming.Name)

Example 14 with Material

use of org.terasology.rendering.assets.material.Material 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 15 with Material

use of org.terasology.rendering.assets.material.Material in project Terasology by MovingBlocks.

the class HeadlessEnvironment method setupAssetManager.

@Override
protected AssetManager setupAssetManager() {
    ModuleAwareAssetTypeManager assetTypeManager = new ModuleAwareAssetTypeManager();
    // cast lambdas explicitly to avoid inconsistent compiler behavior wrt. type inference
    assetTypeManager.registerCoreAssetType(Prefab.class, (AssetFactory<Prefab, PrefabData>) PojoPrefab::new, false, "prefabs");
    assetTypeManager.registerCoreAssetType(BlockShape.class, (AssetFactory<BlockShape, BlockShapeData>) BlockShapeImpl::new, "shapes");
    assetTypeManager.registerCoreAssetType(BlockSounds.class, (AssetFactory<BlockSounds, BlockSoundsData>) BlockSounds::new, "blockSounds");
    assetTypeManager.registerCoreAssetType(BlockTile.class, (AssetFactory<BlockTile, TileData>) BlockTile::new, "blockTiles");
    assetTypeManager.registerCoreAssetType(BlockFamilyDefinition.class, (AssetFactory<BlockFamilyDefinition, BlockFamilyDefinitionData>) BlockFamilyDefinition::new, "blocks");
    assetTypeManager.registerCoreAssetType(StaticSound.class, NullSound::new, "sounds");
    assetTypeManager.registerCoreAssetType(StreamingSound.class, NullStreamingSound::new, "music");
    DefaultBlockFamilyFactoryRegistry blockFamilyFactoryRegistry = new DefaultBlockFamilyFactoryRegistry();
    blockFamilyFactoryRegistry.setBlockFamilyFactory("horizontal", new HorizontalBlockFamilyFactory());
    blockFamilyFactoryRegistry.setBlockFamilyFactory("alignToSurface", new AttachedToSurfaceFamilyFactory());
    assetTypeManager.registerCoreFormat(BlockFamilyDefinition.class, new BlockFamilyDefinitionFormat(assetTypeManager.getAssetManager(), blockFamilyFactoryRegistry));
    assetTypeManager.registerCoreAssetType(UISkin.class, (AssetFactory<UISkin, UISkinData>) UISkin::new, "skins");
    assetTypeManager.registerCoreAssetType(BehaviorTree.class, (AssetFactory<BehaviorTree, BehaviorTreeData>) BehaviorTree::new, false, "behaviors");
    assetTypeManager.registerCoreAssetType(UIElement.class, (AssetFactory<UIElement, UIData>) UIElement::new, "ui");
    assetTypeManager.registerCoreAssetType(Font.class, (AssetFactory<Font, FontData>) FontImpl::new, "fonts");
    assetTypeManager.registerCoreAssetType(Texture.class, (AssetFactory<Texture, TextureData>) HeadlessTexture::new, "textures", "fonts");
    assetTypeManager.registerCoreFormat(Texture.class, new PNGTextureFormat(Texture.FilterMode.NEAREST, path -> path.getName(2).toString().equals("textures")));
    assetTypeManager.registerCoreFormat(Texture.class, new PNGTextureFormat(Texture.FilterMode.LINEAR, path -> path.getName(2).toString().equals("fonts")));
    assetTypeManager.registerCoreAssetType(Shader.class, (AssetFactory<Shader, ShaderData>) HeadlessShader::new, "shaders");
    assetTypeManager.registerCoreAssetType(Material.class, (AssetFactory<Material, MaterialData>) HeadlessMaterial::new, "materials");
    assetTypeManager.registerCoreAssetType(Mesh.class, (AssetFactory<Mesh, MeshData>) HeadlessMesh::new, "mesh");
    assetTypeManager.registerCoreAssetType(SkeletalMesh.class, (AssetFactory<SkeletalMesh, SkeletalMeshData>) HeadlessSkeletalMesh::new, "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);
    assetTypeManager.switchEnvironment(context.get(ModuleManager.class).getEnvironment());
    context.put(ModuleAwareAssetTypeManager.class, assetTypeManager);
    context.put(AssetManager.class, assetTypeManager.getAssetManager());
    return assetTypeManager.getAssetManager();
}
Also used : PNGTextureFormat(org.terasology.rendering.assets.texture.PNGTextureFormat) TypeSerializationLibrary(org.terasology.persistence.typeHandling.TypeSerializationLibrary) MeshData(org.terasology.rendering.assets.mesh.MeshData) UIElement(org.terasology.rendering.nui.asset.UIElement) HeadlessMaterial(org.terasology.engine.subsystem.headless.assets.HeadlessMaterial) CelestialSystem(org.terasology.world.sun.CelestialSystem) AssetManager(org.terasology.assets.management.AssetManager) Time(org.terasology.engine.Time) Config(org.terasology.config.Config) BehaviorTreeData(org.terasology.logic.behavior.asset.BehaviorTreeData) BlockTile(org.terasology.world.block.tiles.BlockTile) FontData(org.terasology.rendering.assets.font.FontData) Material(org.terasology.rendering.assets.material.Material) PNGTextureFormat(org.terasology.rendering.assets.texture.PNGTextureFormat) NullStreamingSound(org.terasology.audio.nullAudio.NullStreamingSound) PrefabData(org.terasology.entitySystem.prefab.PrefabData) EngineTime(org.terasology.engine.EngineTime) WorldAtlas(org.terasology.world.block.tiles.WorldAtlas) Path(java.nio.file.Path) TileData(org.terasology.world.block.tiles.TileData) AudioManager(org.terasology.audio.AudioManager) Set(java.util.Set) ReadWriteStorageManager(org.terasology.persistence.internal.ReadWriteStorageManager) BlockShapeImpl(org.terasology.world.block.shapes.BlockShapeImpl) UISkinData(org.terasology.rendering.nui.skin.UISkinData) NullAudioManager(org.terasology.audio.nullAudio.NullAudioManager) EntitySystemSetupUtil(org.terasology.engine.bootstrap.EntitySystemSetupUtil) AttachedToSurfaceFamilyFactory(org.terasology.world.block.family.AttachedToSurfaceFamilyFactory) CollisionGroupTypeHandler(org.terasology.persistence.typeHandling.extensionTypes.CollisionGroupTypeHandler) HeadlessMesh(org.terasology.engine.subsystem.headless.assets.HeadlessMesh) BlockFamilyDefinitionFormat(org.terasology.world.block.loader.BlockFamilyDefinitionFormat) ModuleManagerFactory(org.terasology.testUtil.ModuleManagerFactory) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) NullWorldAtlas(org.terasology.world.block.tiles.NullWorldAtlas) Subtexture(org.terasology.rendering.assets.texture.subtexture.Subtexture) Mockito.mock(org.mockito.Mockito.mock) BlockManager(org.terasology.world.block.BlockManager) Prefab(org.terasology.entitySystem.prefab.Prefab) UISkin(org.terasology.rendering.nui.skin.UISkin) Mesh(org.terasology.rendering.assets.mesh.Mesh) Shader(org.terasology.rendering.assets.shader.Shader) NetworkSystemImpl(org.terasology.network.internal.NetworkSystemImpl) BlockFamilyDefinition(org.terasology.world.block.loader.BlockFamilyDefinition) BlockTypeHandler(org.terasology.persistence.typeHandling.extensionTypes.BlockTypeHandler) PojoPrefab(org.terasology.entitySystem.prefab.internal.PojoPrefab) Name(org.terasology.naming.Name) ModuleManager(org.terasology.engine.module.ModuleManager) ShrinkWrap(org.jboss.shrinkwrap.api.ShrinkWrap) StaticSound(org.terasology.audio.StaticSound) MeshAnimationImpl(org.terasology.rendering.assets.animation.MeshAnimationImpl) SkeletalMeshData(org.terasology.rendering.assets.skeletalmesh.SkeletalMeshData) DefaultCelestialSystem(org.terasology.world.sun.DefaultCelestialSystem) StreamingSound(org.terasology.audio.StreamingSound) IOException(java.io.IOException) FontImpl(org.terasology.rendering.assets.font.FontImpl) EngineEntityManager(org.terasology.entitySystem.entity.internal.EngineEntityManager) BasicCelestialModel(org.terasology.world.sun.BasicCelestialModel) NetworkSystem(org.terasology.network.NetworkSystem) AtlasData(org.terasology.rendering.assets.atlas.AtlasData) DependencyResolver(org.terasology.module.DependencyResolver) LoggerFactory(org.slf4j.LoggerFactory) ComponentSystemManager(org.terasology.engine.ComponentSystemManager) HeadlessTexture(org.terasology.engine.subsystem.headless.assets.HeadlessTexture) WorldTime(org.terasology.world.time.WorldTime) Block(org.terasology.world.block.Block) Atlas(org.terasology.rendering.assets.atlas.Atlas) BlockShape(org.terasology.world.block.shapes.BlockShape) HeadlessSkeletalMesh(org.terasology.engine.subsystem.headless.assets.HeadlessSkeletalMesh) DefaultBlockFamilyFactoryRegistry(org.terasology.world.block.family.DefaultBlockFamilyFactoryRegistry) UIData(org.terasology.rendering.nui.asset.UIData) BlockFamilyTypeHandler(org.terasology.persistence.typeHandling.extensionTypes.BlockFamilyTypeHandler) BlockShapeData(org.terasology.world.block.shapes.BlockShapeData) ModuleAwareAssetTypeManager(org.terasology.assets.module.ModuleAwareAssetTypeManager) BiomeManager(org.terasology.world.biomes.BiomeManager) WorldProvider(org.terasology.world.WorldProvider) SubtextureData(org.terasology.rendering.assets.texture.subtexture.SubtextureData) ModuleEnvironment(org.terasology.module.ModuleEnvironment) BehaviorTree(org.terasology.logic.behavior.asset.BehaviorTree) FileSystem(java.nio.file.FileSystem) ShaderData(org.terasology.rendering.assets.shader.ShaderData) LoadPrefabs(org.terasology.engine.modes.loadProcesses.LoadPrefabs) CollisionGroup(org.terasology.physics.CollisionGroup) Font(org.terasology.rendering.assets.font.Font) TextureData(org.terasology.rendering.assets.texture.TextureData) BlockFamily(org.terasology.world.block.family.BlockFamily) ShrinkWrapFileSystems(org.jboss.shrinkwrap.api.nio.file.ShrinkWrapFileSystems) HorizontalBlockFamilyFactory(org.terasology.world.block.family.HorizontalBlockFamilyFactory) Texture(org.terasology.rendering.assets.texture.Texture) MeshAnimationData(org.terasology.rendering.assets.animation.MeshAnimationData) ModuleRegistry(org.terasology.module.ModuleRegistry) CollisionGroupManager(org.terasology.physics.CollisionGroupManager) MaterialData(org.terasology.rendering.assets.material.MaterialData) PathManager(org.terasology.engine.paths.PathManager) ResolutionResult(org.terasology.module.ResolutionResult) BlockManagerImpl(org.terasology.world.block.internal.BlockManagerImpl) WorldTimeImpl(org.terasology.world.time.WorldTimeImpl) HeadlessShader(org.terasology.engine.subsystem.headless.assets.HeadlessShader) Logger(org.slf4j.Logger) AssetFactory(org.terasology.assets.AssetFactory) MeshAnimation(org.terasology.rendering.assets.animation.MeshAnimation) NullSound(org.terasology.audio.nullAudio.NullSound) SkeletalMesh(org.terasology.rendering.assets.skeletalmesh.SkeletalMesh) Mockito.when(org.mockito.Mockito.when) StorageManager(org.terasology.persistence.StorageManager) WorldInfo(org.terasology.world.internal.WorldInfo) BlockSounds(org.terasology.world.block.sounds.BlockSounds) BlockFamilyDefinitionData(org.terasology.world.block.loader.BlockFamilyDefinitionData) BlockSoundsData(org.terasology.world.block.sounds.BlockSoundsData) NullStreamingSound(org.terasology.audio.nullAudio.NullStreamingSound) UIElement(org.terasology.rendering.nui.asset.UIElement) BlockFamilyDefinitionFormat(org.terasology.world.block.loader.BlockFamilyDefinitionFormat) UISkin(org.terasology.rendering.nui.skin.UISkin) UISkinData(org.terasology.rendering.nui.skin.UISkinData) SkeletalMeshData(org.terasology.rendering.assets.skeletalmesh.SkeletalMeshData) BlockTile(org.terasology.world.block.tiles.BlockTile) DefaultBlockFamilyFactoryRegistry(org.terasology.world.block.family.DefaultBlockFamilyFactoryRegistry) HeadlessSkeletalMesh(org.terasology.engine.subsystem.headless.assets.HeadlessSkeletalMesh) SkeletalMesh(org.terasology.rendering.assets.skeletalmesh.SkeletalMesh) Shader(org.terasology.rendering.assets.shader.Shader) HeadlessShader(org.terasology.engine.subsystem.headless.assets.HeadlessShader) HeadlessTexture(org.terasology.engine.subsystem.headless.assets.HeadlessTexture) Texture(org.terasology.rendering.assets.texture.Texture) Font(org.terasology.rendering.assets.font.Font) ShaderData(org.terasology.rendering.assets.shader.ShaderData) TileData(org.terasology.world.block.tiles.TileData) BlockFamilyDefinitionData(org.terasology.world.block.loader.BlockFamilyDefinitionData) TextureData(org.terasology.rendering.assets.texture.TextureData) MeshAnimation(org.terasology.rendering.assets.animation.MeshAnimation) AttachedToSurfaceFamilyFactory(org.terasology.world.block.family.AttachedToSurfaceFamilyFactory) Prefab(org.terasology.entitySystem.prefab.Prefab) PojoPrefab(org.terasology.entitySystem.prefab.internal.PojoPrefab) NullSound(org.terasology.audio.nullAudio.NullSound) WorldAtlas(org.terasology.world.block.tiles.WorldAtlas) NullWorldAtlas(org.terasology.world.block.tiles.NullWorldAtlas) Atlas(org.terasology.rendering.assets.atlas.Atlas) PrefabData(org.terasology.entitySystem.prefab.PrefabData) BehaviorTreeData(org.terasology.logic.behavior.asset.BehaviorTreeData) BlockShape(org.terasology.world.block.shapes.BlockShape) ModuleAwareAssetTypeManager(org.terasology.assets.module.ModuleAwareAssetTypeManager) FontData(org.terasology.rendering.assets.font.FontData) HeadlessMesh(org.terasology.engine.subsystem.headless.assets.HeadlessMesh) Mesh(org.terasology.rendering.assets.mesh.Mesh) HeadlessSkeletalMesh(org.terasology.engine.subsystem.headless.assets.HeadlessSkeletalMesh) SkeletalMesh(org.terasology.rendering.assets.skeletalmesh.SkeletalMesh) HeadlessMaterial(org.terasology.engine.subsystem.headless.assets.HeadlessMaterial) Material(org.terasology.rendering.assets.material.Material) BehaviorTree(org.terasology.logic.behavior.asset.BehaviorTree) BlockShapeData(org.terasology.world.block.shapes.BlockShapeData) UIData(org.terasology.rendering.nui.asset.UIData) MeshData(org.terasology.rendering.assets.mesh.MeshData) SkeletalMeshData(org.terasology.rendering.assets.skeletalmesh.SkeletalMeshData) AtlasData(org.terasology.rendering.assets.atlas.AtlasData) BlockSounds(org.terasology.world.block.sounds.BlockSounds) BlockSoundsData(org.terasology.world.block.sounds.BlockSoundsData) SubtextureData(org.terasology.rendering.assets.texture.subtexture.SubtextureData) HorizontalBlockFamilyFactory(org.terasology.world.block.family.HorizontalBlockFamilyFactory) MeshAnimationData(org.terasology.rendering.assets.animation.MeshAnimationData) MaterialData(org.terasology.rendering.assets.material.MaterialData) BlockFamilyDefinition(org.terasology.world.block.loader.BlockFamilyDefinition) Subtexture(org.terasology.rendering.assets.texture.subtexture.Subtexture)

Aggregations

Material (org.terasology.rendering.assets.material.Material)15 Mesh (org.terasology.rendering.assets.mesh.Mesh)7 EntityRef (org.terasology.entitySystem.entity.EntityRef)4 Vector3f (org.terasology.math.geom.Vector3f)4 MaterialData (org.terasology.rendering.assets.material.MaterialData)4 Shader (org.terasology.rendering.assets.shader.Shader)4 IOException (java.io.IOException)3 AssetFactory (org.terasology.assets.AssetFactory)3 ResourceUrn (org.terasology.assets.ResourceUrn)3 AssetManager (org.terasology.assets.management.AssetManager)3 ModuleAwareAssetTypeManager (org.terasology.assets.module.ModuleAwareAssetTypeManager)3 Context (org.terasology.context.Context)3 LocationComponent (org.terasology.logic.location.LocationComponent)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 FloatBuffer (java.nio.FloatBuffer)2