use of org.terasology.assets.ResourceUrn in project Terasology by MovingBlocks.
the class TextureAssetResolverTest method testNoiseTextures.
@Test
public void testNoiseTextures() {
int size = 256;
ResourceUrn textureUriForWhiteNoise = TextureUtil.getTextureUriForWhiteNoise(size, 123354, 0, 255);
String simpleString = textureUriForWhiteNoise.toString();
Optional<Texture> tex = Assets.getTexture(simpleString);
assertTrue(tex.isPresent());
assertTrue(tex.get().getWidth() == size);
assertTrue(tex.get().getHeight() == size);
}
use of org.terasology.assets.ResourceUrn in project Terasology by MovingBlocks.
the class TextureAssetResolverTest method testColorTextures.
@Test
public void testColorTextures() {
Random r = new FastRandom(123456);
for (int i = 0; i < 10; i++) {
int rgba = r.nextInt();
Color red = new Color(rgba);
ResourceUrn textureUriForColor = TextureUtil.getTextureUriForColor(red);
String simpleString = textureUriForColor.toString();
Optional<Texture> tex = Assets.getTexture(simpleString);
assertTrue(tex.isPresent());
ByteBuffer dataBuffer = tex.get().getData().getBuffers()[0];
int firstPixel = dataBuffer.asIntBuffer().get(0);
Assert.assertEquals(rgba, firstPixel);
}
}
use of org.terasology.assets.ResourceUrn in project Terasology by MovingBlocks.
the class TextureUtilTest method testColorTransformedToTextureUri.
@Test
public void testColorTransformedToTextureUri() throws Exception {
ResourceUrn assetUri = TextureUtil.getTextureUriForColor(Color.RED);
assertEquals(TerasologyConstants.ENGINE_MODULE, assetUri.getModuleName());
assertEquals(new Name("color"), assetUri.getResourceName());
assertEquals(new Name("ff0000ff"), assetUri.getFragmentName());
int red = 0x12;
int green = 0x3;
int blue = 0xc4;
int alpha = 0xe;
assetUri = TextureUtil.getTextureUriForColor(new Color(red, green, blue, alpha));
assertEquals(TerasologyConstants.ENGINE_MODULE, assetUri.getModuleName());
assertEquals(new Name("color"), assetUri.getResourceName());
assertEquals(new Name("1203c40e"), assetUri.getFragmentName());
}
use of org.terasology.assets.ResourceUrn in project Terasology by MovingBlocks.
the class TextureUtilTest method testColorTransformedToAssetUriTransformedToColor.
@Test
public void testColorTransformedToAssetUriTransformedToColor() throws Exception {
Color expectedColor = Color.RED;
ResourceUrn assetUri = TextureUtil.getTextureUriForColor(expectedColor);
Color actualColor = TextureUtil.getColorForColorName(assetUri.getFragmentName().toLowerCase());
assertEquals(expectedColor, actualColor);
int red = 0x12;
int green = 0x3;
int blue = 0xc4;
int alpha = 0xe;
expectedColor = new Color(red, green, blue, alpha);
assetUri = TextureUtil.getTextureUriForColor(expectedColor);
actualColor = TextureUtil.getColorForColorName(assetUri.getFragmentName().toLowerCase());
assertEquals(expectedColor, actualColor);
}
use of org.terasology.assets.ResourceUrn in project Terasology by MovingBlocks.
the class EntityAwareWorldProviderTest method createPrefabWithString.
private Prefab createPrefabWithString(String urn, String text, AssetManager assetManager) {
PrefabData prefabData = new PrefabData();
prefabData.addComponent(new StringComponent(text));
return assetManager.loadAsset(new ResourceUrn(urn), prefabData, Prefab.class);
}
Aggregations