Search in sources :

Example 26 with ResourceUrn

use of org.terasology.gestalt.assets.ResourceUrn in project Terasology by MovingBlocks.

the class ShaderManagerLwjgl method addShaderProgram.

public GLSLMaterial addShaderProgram(String title, String providingModule) {
    String uri = providingModule + ":" + title;
    Optional<? extends Shader> shader = Assets.getShader(uri);
    checkState(shader.isPresent(), "Failed to resolve %s", uri);
    shader.get().recompile();
    GLSLMaterial material = (GLSLMaterial) Assets.generateAsset(new ResourceUrn(providingModule + ":prog." + title), new MaterialData(shader.get()), Material.class);
    progamaticShaders.add(material);
    return material;
}
Also used : GLSLMaterial(org.terasology.engine.rendering.opengl.GLSLMaterial) Material(org.terasology.engine.rendering.assets.material.Material) MaterialData(org.terasology.engine.rendering.assets.material.MaterialData) ResourceUrn(org.terasology.gestalt.assets.ResourceUrn) GLSLMaterial(org.terasology.engine.rendering.opengl.GLSLMaterial)

Example 27 with ResourceUrn

use of org.terasology.gestalt.assets.ResourceUrn in project Terasology by MovingBlocks.

the class PreviewWorldScreen method genTexture.

private void genTexture() {
    int imgWidth = 384;
    int imgHeight = 384;
    ByteBuffer buffer = ByteBuffer.allocateDirect(imgWidth * imgHeight * Integer.BYTES);
    ByteBuffer[] data = new ByteBuffer[] { buffer };
    ResourceUrn uri = new ResourceUrn("engine:terrainPreview");
    TextureData texData = new TextureData(imgWidth, imgHeight, data, Texture.WrapMode.CLAMP, Texture.FilterMode.LINEAR);
    texture = Assets.generateAsset(uri, texData, Texture.class);
    previewImage = find("preview", UIImage.class);
    previewImage.setImage(texture);
}
Also used : TextureData(org.terasology.engine.rendering.assets.texture.TextureData) ResourceUrn(org.terasology.gestalt.assets.ResourceUrn) UIImage(org.terasology.nui.widgets.UIImage) ByteBuffer(java.nio.ByteBuffer) Texture(org.terasology.engine.rendering.assets.texture.Texture)

Example 28 with ResourceUrn

use of org.terasology.gestalt.assets.ResourceUrn in project Terasology by MovingBlocks.

the class ComponentMetadataTest method testOwnsReferencesPopulated.

@Test
public void testOwnsReferencesPopulated() {
    Reflections reflections = new Reflections(getClass().getClassLoader());
    EntitySystemLibrary entitySystemLibrary = new EntitySystemLibrary(context, new TypeHandlerLibraryImpl(reflections));
    ComponentLibrary lib = entitySystemLibrary.getComponentLibrary();
    lib.register(new ResourceUrn("unittest:owner"), OwnerComponent.class);
    ComponentMetadata<OwnerComponent> metadata = lib.getMetadata(OwnerComponent.class);
    assertTrue(metadata.isReferenceOwner());
}
Also used : OwnerComponent(org.terasology.unittest.stubs.OwnerComponent) TypeHandlerLibraryImpl(org.terasology.engine.persistence.typeHandling.TypeHandlerLibraryImpl) ResourceUrn(org.terasology.gestalt.assets.ResourceUrn) Reflections(org.reflections.Reflections) Test(org.junit.jupiter.api.Test)

Example 29 with ResourceUrn

use of org.terasology.gestalt.assets.ResourceUrn in project Terasology by MovingBlocks.

the class PojoEntityManagerTest method setup.

@BeforeEach
public void setup() {
    NetworkSystem networkSystem = mock(NetworkSystem.class);
    when(networkSystem.getMode()).thenReturn(NetworkMode.NONE);
    context.put(NetworkSystem.class, networkSystem);
    EntitySystemSetupUtil.addReflectionBasedLibraries(context);
    EntitySystemSetupUtil.addEntityManagementRelatedClasses(context);
    entityManager = (PojoEntityManager) context.get(EntityManager.class);
    PrefabData protoPrefab = new PrefabData();
    protoPrefab.addComponent(new StringComponent("Test"));
    prefab = Assets.generateAsset(new ResourceUrn("unittest:myprefab"), protoPrefab, Prefab.class);
}
Also used : PrefabData(org.terasology.engine.entitySystem.prefab.PrefabData) StringComponent(org.terasology.unittest.stubs.StringComponent) NetworkSystem(org.terasology.engine.network.NetworkSystem) ResourceUrn(org.terasology.gestalt.assets.ResourceUrn) Prefab(org.terasology.engine.entitySystem.prefab.Prefab) PojoPrefab(org.terasology.engine.entitySystem.prefab.internal.PojoPrefab) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 30 with ResourceUrn

use of org.terasology.gestalt.assets.ResourceUrn in project Terasology by MovingBlocks.

the class FieldMetadataTest method testOwnsAnnotationProcessed.

@Test
public void testOwnsAnnotationProcessed() throws NoSuchMethodException {
    ComponentMetadata<OwnerComponent> classMetadata = new ComponentMetadata<>(new ResourceUrn("unittest:owner"), OwnerComponent.class, factory, copyStrategyLibrary);
    ComponentFieldMetadata metadata = classMetadata.getField("child");
    assertTrue(metadata.isOwnedReference());
}
Also used : OwnerComponent(org.terasology.unittest.stubs.OwnerComponent) ResourceUrn(org.terasology.gestalt.assets.ResourceUrn) Test(org.junit.jupiter.api.Test)

Aggregations

ResourceUrn (org.terasology.gestalt.assets.ResourceUrn)90 Test (org.junit.jupiter.api.Test)19 Name (org.terasology.gestalt.naming.Name)12 BeforeEach (org.junit.jupiter.api.BeforeEach)11 BlockFamilyDefinitionData (org.terasology.engine.world.block.loader.BlockFamilyDefinitionData)10 IOException (java.io.IOException)9 AssetManager (org.terasology.gestalt.assets.management.AssetManager)9 EntityRef (org.terasology.engine.entitySystem.entity.EntityRef)8 Prefab (org.terasology.engine.entitySystem.prefab.Prefab)8 PrefabData (org.terasology.engine.entitySystem.prefab.PrefabData)7 Command (org.terasology.engine.logic.console.commandSystem.annotations.Command)7 BlockUri (org.terasology.engine.world.block.BlockUri)7 AssetDataFile (org.terasology.gestalt.assets.format.AssetDataFile)7 Texture (org.terasology.engine.rendering.assets.texture.Texture)5 BlockManagerImpl (org.terasology.engine.world.block.internal.BlockManagerImpl)5 BlockFamilyDefinition (org.terasology.engine.world.block.loader.BlockFamilyDefinition)5 NullWorldAtlas (org.terasology.engine.world.block.tiles.NullWorldAtlas)5 ExtraBlockDataManager (org.terasology.engine.world.chunks.blockdata.ExtraBlockDataManager)5 StringComponent (org.terasology.unittest.stubs.StringComponent)5 ByteBuffer (java.nio.ByteBuffer)4