Search in sources :

Example 1 with MapTexture

use of com.bergerkiller.bukkit.common.map.MapTexture in project BKCommonLib by bergerhealer.

the class Pseudo3DImagePanel method paintComponent.

@Override
protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    MapTexture image = MapTexture.createEmpty(MapModelRenderTest.RES_WIDTH, MapModelRenderTest.RES_HEIGHT);
    image.draw(background, 0, 0);
    image.setBlendMode(MapBlendMode.OVERLAY);
    // new Vector3(-1.0, 1.0, -1.0));
    image.setLightOptions(0.0f, 1.0f, new Vector3(-1, 1, -1));
    System.out.println("{" + p3.x + ", " + p2.x + ", " + p3.y + "}");
    // Draws a 3D quad
    float scale = 16.0f;
    float yaw = (float) (p1.x - 128);
    float pitch = (float) (p1.y - 128);
    System.out.println("Yaw=" + yaw + " Pitch=" + pitch);
    BlockRenderOptions opt = BlockData.fromMaterial(Material.PLAYER_HEAD).getDefaultRenderOptions();
    System.out.println(opt);
    ItemStack item = ItemUtil.createItem(Material.GOLDEN_PICKAXE, 15, 1);
    ItemUtil.getMetaTag(item, true).putValue("Unbreakable", true);
    Model model = textures.getBlockModel(opt);
    Matrix4x4 transform = new Matrix4x4();
    // image.draw(textures.getItemTexture(item, 32, 32), 0, 0);
    transform.translate(p0.x, 0.0f, p0.y);
    transform.scale(scale);
    transform.rotateX(pitch);
    transform.rotateY(yaw);
    transform.translate(-8, -8, -8);
    // image.drawModel(textures.getBlockModel(Material.QUARTZ_BLOCK), transform);
    transform.translate(20, 0, 0);
    image.drawModel(model, transform);
    g.drawImage(image.toJavaImage(), 0, 0, null);
    int r = 8;
    g.setColor(Color.BLUE);
    g.fillOval((int) p0.x - r, (int) p0.y - r, r + r, r + r);
    g.fillOval((int) p1.x - r, (int) p1.y - r, r + r, r + r);
    g.fillOval((int) p2.x - r, (int) p2.y - r, r + r, r + r);
    g.fillOval((int) p3.x - r, (int) p3.y - r, r + r, r + r);
}
Also used : MapTexture(com.bergerkiller.bukkit.common.map.MapTexture) BlockRenderOptions(com.bergerkiller.bukkit.common.wrappers.BlockRenderOptions) Model(com.bergerkiller.bukkit.common.map.util.Model) Vector3(com.bergerkiller.bukkit.common.math.Vector3) ItemStack(org.bukkit.inventory.ItemStack) Matrix4x4(com.bergerkiller.bukkit.common.math.Matrix4x4)

Example 2 with MapTexture

use of com.bergerkiller.bukkit.common.map.MapTexture in project BKCommonLib by bergerhealer.

the class MapIsometricTest method renderSprite.

private MapTexture renderSprite(Model model) {
    MapTexture map = null;
    map = MapTexture.createEmpty(32, 43);
    // map.setBrushMask(mask);
    // map.fill(MapColorPalette.COLOR_RED);
    // map.setBrushMask(null);
    Matrix4x4 transform = new Matrix4x4();
    // transform.rotateOrigin(new Vector3f(8,8,8), new Vector3f(180, 0, 0));
    transform.translate(map.getWidth(), 0.0f, map.getWidth() - 1);
    transform.scale(1.45f, 1.0f, 1.71f);
    // pitch
    transform.rotateX(-45.0f);
    // yaw
    transform.rotateY(225.0f);
    // transform.rotateOrigin(new Vector3f(8,8,8), new Vector3f(0, 0, 0));
    // map.fill(MapColorPalette.COLOR_RED);
    map.setLightOptions(0.2f, 0.8f, new Vector3(-1.0, 1.0, -1.0));
    map.drawModel(model, transform);
    return map;
}
Also used : MapTexture(com.bergerkiller.bukkit.common.map.MapTexture) Vector3(com.bergerkiller.bukkit.common.math.Vector3) Matrix4x4(com.bergerkiller.bukkit.common.math.Matrix4x4)

Example 3 with MapTexture

use of com.bergerkiller.bukkit.common.map.MapTexture in project BKCommonLib by bergerhealer.

the class MapResourcePackTest method testLineDrawing.

@Ignore
@Test
public void testLineDrawing() {
    MapTexture texture = MapTexture.createEmpty(32, 32);
    texture.drawLine(1, 1, 30, 1, MapColorPalette.COLOR_RED);
    texture.drawLine(30, 3, 1, 3, MapColorPalette.COLOR_RED);
    texture.drawLine(1, 5, 1, 30, MapColorPalette.COLOR_RED);
    texture.drawLine(3, 30, 3, 5, MapColorPalette.COLOR_RED);
    texture.drawLine(5, 7, 28, 30, MapColorPalette.COLOR_RED);
    texture.drawLine(30, 28, 7, 5, MapColorPalette.COLOR_RED);
    texture.drawLine(5, 9, 10, 30, MapColorPalette.COLOR_RED);
    texture.drawLine(30, 10, 9, 5, MapColorPalette.COLOR_RED);
    MapDebugWindow.showMapForeverAutoScale(texture);
}
Also used : MapTexture(com.bergerkiller.bukkit.common.map.MapTexture) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 4 with MapTexture

use of com.bergerkiller.bukkit.common.map.MapTexture in project BKCommonLib by bergerhealer.

the class MapResourcePackTest method testFontDrawing.

@Ignore
@Test
public void testFontDrawing() {
    MapTexture texture = MapTexture.createEmpty(128, 128);
    texture.setSpacing(1);
    String text = "Hello, World\nHave a nice day\nPlease come again";
    Dimension size = texture.calcFontSize(MapFont.MINECRAFT, text);
    texture.drawRectangle(5, 5, size.width, size.height, MapColorPalette.COLOR_GREEN);
    texture.draw(MapFont.MINECRAFT, 5, 5, MapColorPalette.COLOR_RED, text);
    MapDebugWindow.showMapForeverAutoScale(texture);
}
Also used : MapTexture(com.bergerkiller.bukkit.common.map.MapTexture) Dimension(java.awt.Dimension) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 5 with MapTexture

use of com.bergerkiller.bukkit.common.map.MapTexture in project BKCommonLib by bergerhealer.

the class MapCanvasFunctionsTest method testDepthBuffer.

@Ignore
@Test
public void testDepthBuffer() {
    MapTexture map = MapTexture.createEmpty(64, 64);
    // Load the source textures
    MapResourcePack texturePack = MapResourcePack.VANILLA;
    // Test brush masks with depth buffer
    // map.setBrushMask(texturePack.getTexture("blocks/vine"));
    map.setDrawDepth(0);
    map.draw(texturePack.getTexture("blocks/brick"), 5, 5);
    assertFalse(map.hasMoreDepth());
    map.setDrawDepth(1);
    map.draw(texturePack.getTexture("blocks/coal_ore"), 12, 12);
    assertFalse(map.hasMoreDepth());
    map.setDrawDepth(0);
    map.clearRectangle(5, 5, 16, 16);
    assertTrue(map.hasMoreDepth());
    map.setDrawDepth(1);
    map.draw(texturePack.getTexture("blocks/coal_ore"), 12, 12);
    assertFalse(map.hasMoreDepth());
    map.setDrawDepth(3);
    map.draw(texturePack.getTexture("blocks/bookshelf"), 23, 23);
    assertFalse(map.hasMoreDepth());
    map.setDrawDepth(2);
    map.draw(texturePack.getTexture("blocks/grass_side"), 15, 18);
    assertFalse(map.hasMoreDepth());
    MapDebugWindow.showMapForever(map, 10);
}
Also used : MapTexture(com.bergerkiller.bukkit.common.map.MapTexture) MapResourcePack(com.bergerkiller.bukkit.common.map.MapResourcePack) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

MapTexture (com.bergerkiller.bukkit.common.map.MapTexture)13 Ignore (org.junit.Ignore)7 Test (org.junit.Test)7 MapResourcePack (com.bergerkiller.bukkit.common.map.MapResourcePack)4 Vector3 (com.bergerkiller.bukkit.common.math.Vector3)3 Model (com.bergerkiller.bukkit.common.map.util.Model)2 Face (com.bergerkiller.bukkit.common.map.util.Model.Element.Face)2 Matrix4x4 (com.bergerkiller.bukkit.common.math.Matrix4x4)2 BlockFace (org.bukkit.block.BlockFace)2 ItemStack (org.bukkit.inventory.ItemStack)2 MCSDGenCiede2000 (com.bergerkiller.bukkit.common.map.MCSDGenCiede2000)1 MCSDBubbleFormat (com.bergerkiller.bukkit.common.map.color.MCSDBubbleFormat)1 MCSDFlat (com.bergerkiller.bukkit.common.map.color.MCSDFlat)1 MapDebugWindow (com.bergerkiller.bukkit.common.map.util.MapDebugWindow)1 BlockRenderOptions (com.bergerkiller.bukkit.common.wrappers.BlockRenderOptions)1 Dimension (java.awt.Dimension)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1