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;
}
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);
}
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());
}
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);
}
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());
}
Aggregations