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