use of org.lwjgl.opengl.GL11.glTranslatef in project BuildCraft by BuildCraft.
the class AdvDebuggerQuarry method render.
@Override
public void render(EntityPlayer player, float partialTicks) {
TileQuarry tile = tileReference.get();
if (tile == null || !tile.frameBox.isInitialized()) {
return;
}
List<ChunkPos> chunkPoses = new ArrayList<>(ChunkLoaderManager.getChunksToLoad(tile));
chunkPoses.sort(Comparator.comparingDouble(chunkPos -> -player.getPositionEyes(partialTicks).distanceTo(new Vec3d(chunkPos.getXStart() + 0.5 + (chunkPos.getXEnd() - chunkPos.getXStart()) / 2, player.getPositionEyes(partialTicks).y, chunkPos.getZStart() + 0.5 + (chunkPos.getZEnd() - chunkPos.getZStart()) / 2))));
GlStateManager.enableBlend();
BufferBuilder bb = Tessellator.getInstance().getBuffer();
bb.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
for (ChunkPos chunkPos : chunkPoses) {
DebugRenderHelper.renderAABB(bb, new AxisAlignedBB(chunkPos.getXStart() + 0.5D, tile.frameBox.min().getY() + 0.5D, chunkPos.getZStart() + 0.5D, chunkPos.getXEnd() + 0.5D, tile.frameBox.max().getY() + 0.5D, chunkPos.getZEnd() + 0.5D), COLOUR_CHUNK);
}
Tessellator.getInstance().draw();
GlStateManager.disableBlend();
}
use of org.lwjgl.opengl.GL11.glTranslatef in project LogisticsPipes by RS485.
the class GuiRequestTable method drawGuiContainerBackgroundLayer.
@Override
public void drawGuiContainerBackgroundLayer(float f, int i, int j) {
for (GuiButton sycleButton : sycleButtons) {
sycleButton.visible = _table.targetType != null;
}
GuiGraphics.drawGuiBackGround(mc, guiLeft, guiTop, right - (showRequest ? 0 : 105), bottom, zLevel, true);
drawRect(guiLeft + 162, guiTop + 23, guiLeft + 182, guiTop + 43, Color.BLACK);
drawRect(guiLeft + 164, guiTop + 25, guiLeft + 180, guiTop + 41, Color.DARKER_GREY);
if (showRequest) {
mc.fontRenderer.drawString(_title, guiLeft + 180 + mc.fontRenderer.getStringWidth(_title) / 2, guiTop + 6, 0x404040);
itemDisplay.renderPageNumber(right - 47, guiTop + 6);
if (buttonList.get(9) instanceof GuiCheckBox && ((GuiCheckBox) buttonList.get(9)).getState()) {
mc.fontRenderer.drawString("Popup", guiLeft + 225, bottom - 56, 0x404040);
} else {
mc.fontRenderer.drawString("Popup", guiLeft + 225, bottom - 56, Color.getValue(Color.GREY));
}
itemDisplay.renderAmount(getStackAmount());
// SearchInput
search.drawTextBox();
itemDisplay.renderSortMode(right - 103, bottom - 52);
itemDisplay.renderItemArea(zLevel);
}
for (int x = 0; x < 9; x++) {
for (int y = 0; y < 3; y++) {
GuiGraphics.drawSlotBackground(mc, guiLeft + (x * 18) + 19, guiTop + (y * 18) + 79);
}
}
for (int x = 0; x < 3; x++) {
for (int y = 0; y < 3; y++) {
GuiGraphics.drawSlotBackground(mc, guiLeft + (x * 18) + 19, guiTop + (y * 18) + 14);
}
}
mc.fontRenderer.drawString("Sort:", guiLeft + 136, guiTop + 55, 0xffffff);
GuiGraphics.drawSlotBackground(mc, guiLeft + 100, guiTop + 32);
GuiGraphics.drawSlotBackground(mc, guiLeft + 163, guiTop + 50);
drawRect(guiLeft + 75, guiTop + 38, guiLeft + 95, guiTop + 43, Color.DARKER_GREY);
for (int a = 0; a < 10; a++) {
drawRect(guiLeft + 97 - a, guiTop + 40 - a, guiLeft + 98 - a, guiTop + 41 + a, Color.DARKER_GREY);
}
for (int a = 0; a < 15; a++) {
drawRect(guiLeft + 164 + a, guiTop + 51 + a, guiLeft + 166 + a, guiTop + 53 + a, Color.DARKER_GREY);
drawRect(guiLeft + 164 + a, guiTop + 65 - a, guiLeft + 166 + a, guiTop + 67 - a, Color.DARKER_GREY);
}
GuiGraphics.drawPlayerInventoryBackground(mc, guiLeft + 20, guiTop + 150);
for (final Entry<Integer, Pair<IResource, LinkedLogisticsOrderList>> entry : _table.watchedRequests.entrySet()) {
if (!handledExtention.get(entry.getKey())) {
handledExtention.set(entry.getKey());
extentionControllerLeft.addExtention(new GuiExtention() {
private Map<Pair<Integer, Integer>, IOrderInfoProvider> ordererPosition = new HashMap<>();
private int height;
private int width = 4;
private GuiButton localControlledButton;
@Override
public void renderForground(int left, int top) {
if (!_table.watchedRequests.containsKey(entry.getKey())) {
extentionControllerLeft.removeExtention(this);
if (isFullyExtended() && localControlledButton != null) {
buttonList.remove(localControlledButton);
localControlledButton = null;
orderIdForButton = -1;
}
return;
}
ordererPosition.clear();
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240 / 1.0F, 240 / 1.0F);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_DEPTH_TEST);
RenderHelper.enableGUIStandardItemLighting();
ItemStack stack;
IResource resource = entry.getValue().getValue1();
String s;
if (resource != null) {
stack = resource.getDisplayItem().makeNormalStack();
itemRender.renderItemAndEffectIntoGUI(stack, left + 5, top + 5);
itemRender.renderItemOverlayIntoGUI(mc.fontRenderer, stack, left + 5, top + 5, "");
s = TextUtil.getThreeDigitFormattedNumber(stack.getCount(), false);
} else {
s = "List";
}
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
itemRender.zLevel = 0.0F;
// Draw number
mc.fontRenderer.drawStringWithShadow(s, left + 22 - mc.fontRenderer.getStringWidth(s), top + 14, 16777215);
if (isFullyExtended()) {
if (localControlledButton == null || orderIdForButton != entry.getKey()) {
if (localControlledButton != null) {
buttonList.remove(localControlledButton);
}
localControlledButton = new SmallGuiButton(100, guiLeft - 35, guiTop + 10, 30, 10, "more");
buttonList.add(localControlledButton);
orderIdForButton = entry.getKey();
}
List<IOrderInfoProvider> list = entry.getValue().getValue2().getList();
calculateSize(left, top, list);
String ident = String.format("ID: %d", entry.getKey());
mc.fontRenderer.drawStringWithShadow(ident, left + 25, top + 7, 16777215);
int x = left + 6;
int y = top + 25;
for (IOrderInfoProvider order : list) {
stack = order.getAsDisplayItem().makeNormalStack();
if (stack.getCount() <= 0) {
continue;
}
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_DEPTH_TEST);
RenderHelper.enableGUIStandardItemLighting();
itemRender.renderItemAndEffectIntoGUI(stack, x, y);
itemRender.renderItemOverlayIntoGUI(fontRenderer, stack, x, y, "");
s = TextUtil.getThreeDigitFormattedNumber(stack.getCount(), false);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
itemRender.zLevel = 0.0F;
// Draw number
mc.fontRenderer.drawStringWithShadow(s, x + 17 - mc.fontRenderer.getStringWidth(s), y + 9, 16777215);
ordererPosition.put(new Pair<>(x, y), order);
x += 18;
if (x > left + getFinalWidth() - 18) {
x = left + 6;
y += 18;
}
}
} else if (isExtending()) {
List<IOrderInfoProvider> list = entry.getValue().getValue2().getList();
calculateSize(left, top, list);
}
if (!isFullyExtended() && localControlledButton != null) {
buttonList.remove(localControlledButton);
localControlledButton = null;
orderIdForButton = -1;
}
RenderHelper.disableStandardItemLighting();
}
private void calculateSize(int left, int top, List<IOrderInfoProvider> list) {
int x = left + 6;
int y = 50;
int line = 1;
width = 4;
for (IOrderInfoProvider order : list) {
ItemStack stack = order.getAsDisplayItem().makeNormalStack();
if (stack.getCount() <= 0) {
continue;
}
if (line++ % (4 * 4) == 0) {
width++;
}
}
for (IOrderInfoProvider order : list) {
ItemStack stack = order.getAsDisplayItem().makeNormalStack();
if (stack.getCount() <= 0) {
continue;
}
x += 18;
if (x > left + getFinalWidth() - 18) {
x = left + 6;
y += 18;
}
}
height = y;
if (x == left + 6) {
height -= 18;
}
}
@Override
public int getFinalWidth() {
return Math.max(85, width * 18 + 8);
}
@Override
public int getFinalHeight() {
return Math.max(50, height);
}
@Override
public void handleMouseOverAt(int xPos, int yPos) {
if (isFullyExtended()) {
ordererPosition.keySet().stream().filter(key -> xPos >= key.getValue1() && xPos < key.getValue1() + 18 && yPos >= key.getValue2() && yPos < key.getValue2() + 18).forEach(key -> {
IOrderInfoProvider order = ordererPosition.get(key);
List<String> list = new ArrayList<>();
list.add(ChatColor.BLUE + "Request Type: " + ChatColor.YELLOW + order.getType().name());
list.add(ChatColor.BLUE + "Send to Router ID: " + ChatColor.YELLOW + order.getRouterId());
GuiGraphics.displayItemToolTip(new Object[] { xPos - 10, yPos, order.getAsDisplayItem().makeNormalStack(), true, list }, zLevel, guiLeft, guiTop, false);
});
} else if (entry.getValue() != null && entry.getValue().getValue1() != null && entry.getValue().getValue1().getDisplayItem() != null) {
List<String> list = new ArrayList<>();
list.add(ChatColor.BLUE + "Request ID: " + ChatColor.YELLOW + entry.getKey());
GuiGraphics.displayItemToolTip(new Object[] { xPos - 10, yPos, entry.getValue().getValue1().getDisplayItem().makeNormalStack(), true, list }, zLevel, guiLeft, guiTop, false);
}
}
});
}
}
super.renderExtentions();
}
use of org.lwjgl.opengl.GL11.glTranslatef in project LogisticsPipes by RS485.
the class RenderTickHandler method renderWorldLast.
// private static final ResourceLocation TEXTURE = new ResourceLocation("logisticspipes", "textures/blocks/pipes/White.png");
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void renderWorldLast(RenderWorldLastEvent worldEvent) {
// if (LogisticsRenderPipe.config.isUseNewRenderer()) {
if (displayPipeGhost()) {
Minecraft mc = Minecraft.getMinecraft();
EntityPlayer player = mc.player;
RayTraceResult box = mc.objectMouseOver;
if (box != null && box.typeOfHit == RayTraceResult.Type.BLOCK) {
ItemStack stack = FMLClientHandler.instance().getClient().player.inventory.mainInventory.get(FMLClientHandler.instance().getClient().player.inventory.currentItem);
CoreUnroutedPipe pipe = ((ItemLogisticsPipe) stack.getItem()).getDummyPipe();
World world = player.getEntityWorld();
EnumFacing side = box.sideHit;
BlockPos bPos = box.getBlockPos();
Block block = world.getBlockState(bPos).getBlock();
if (block == Blocks.SNOW_LAYER && block.isReplaceable(world, bPos)) {
side = EnumFacing.UP;
} else if (!block.isReplaceable(world, bPos)) {
bPos = bPos.offset(side);
}
boolean isFreeSpace = true;
ITubeOrientation orientation = null;
if (pipe instanceof CoreMultiBlockPipe) {
CoreMultiBlockPipe multipipe = (CoreMultiBlockPipe) pipe;
DoubleCoordinates placeAt = new DoubleCoordinates(bPos);
LPPositionSet<DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare>> globalPos = new LPPositionSet<>(DoubleCoordinatesType.class);
globalPos.add(new DoubleCoordinatesType<>(placeAt, CoreMultiBlockPipe.SubBlockTypeForShare.NON_SHARE));
LPPositionSet<DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare>> positions = multipipe.getSubBlocks();
orientation = multipipe.getTubeOrientation(player, bPos.getX(), bPos.getZ());
if (orientation != null) {
orientation.rotatePositions(positions);
positions.stream().map(pos -> pos.add(placeAt)).forEach(globalPos::add);
globalPos.addToAll(orientation.getOffset());
for (DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare> pos : globalPos) {
if (!player.getEntityWorld().mayPlace(LPBlocks.pipe, pos.getBlockPos(), false, side, player)) {
TileEntity tile = player.getEntityWorld().getTileEntity(pos.getBlockPos());
boolean canPlace = false;
if (tile instanceof LogisticsTileGenericSubMultiBlock) {
if (CoreMultiBlockPipe.canShare(((LogisticsTileGenericSubMultiBlock) tile).getSubTypes(), pos.getType())) {
canPlace = true;
}
}
if (!canPlace) {
isFreeSpace = false;
break;
}
}
}
} else {
return;
}
} else {
if (!player.getEntityWorld().mayPlace(LPBlocks.pipe, bPos, false, side, player)) {
isFreeSpace = false;
}
}
if (isFreeSpace) {
GlStateManager.pushMatrix();
double x;
double y;
double z;
if (orientation != null) {
x = bPos.getX() + orientation.getOffset().getXInt() - player.prevPosX - ((player.posX - player.prevPosX) * worldEvent.getPartialTicks());
y = bPos.getY() + orientation.getOffset().getYInt() - player.prevPosY - ((player.posY - player.prevPosY) * worldEvent.getPartialTicks());
z = bPos.getZ() + orientation.getOffset().getZInt() - player.prevPosZ - ((player.posZ - player.prevPosZ) * worldEvent.getPartialTicks());
} else {
x = bPos.getX() - player.prevPosX - ((player.posX - player.prevPosX) * worldEvent.getPartialTicks());
y = bPos.getY() - player.prevPosY - ((player.posY - player.prevPosY) * worldEvent.getPartialTicks());
z = bPos.getZ() - player.prevPosZ - ((player.posZ - player.prevPosZ) * worldEvent.getPartialTicks());
}
GL11.glTranslated(x + 0.001, y + 0.001, z + 0.001);
GlStateManager.enableBlend();
// GL11.glDepthMask(false);
GlStateManager.disableTexture2D();
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
mc.renderEngine.bindTexture(new ResourceLocation("logisticspipes", "textures/blocks/pipes/white.png"));
SimpleServiceLocator.cclProxy.getRenderState().reset();
SimpleServiceLocator.cclProxy.getRenderState().setAlphaOverride(0xff);
GlStateManager.enableTexture2D();
SimpleServiceLocator.cclProxy.getRenderState().setAlphaOverride(0x50);
SimpleServiceLocator.cclProxy.getRenderState().startDrawing(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
pipe.getHighlightRenderer().renderHighlight(orientation);
SimpleServiceLocator.cclProxy.getRenderState().draw();
SimpleServiceLocator.cclProxy.getRenderState().setAlphaOverride(0xff);
GlStateManager.disableBlend();
GlStateManager.depthMask(true);
GlStateManager.popMatrix();
}
}
}
// }
}
use of org.lwjgl.opengl.GL11.glTranslatef in project BuildCraft by BuildCraft.
the class GuiZonePlanner method drawForegroundLayer.
@SuppressWarnings("PointlessBitwiseExpression")
@Override
protected void drawForegroundLayer() {
camY += scaleSpeed;
scaleSpeed *= 0.7F;
int posX = (int) positionX;
int posZ = (int) positionZ;
int dimension = mc.world.provider.getDimension();
{
ChunkPos chunkPos = new ChunkPos(posX >> 4, posZ >> 4);
ZonePlannerMapChunk zonePlannerMapChunk = ZonePlannerMapDataClient.INSTANCE.getChunk(mc.world, new ZonePlannerMapChunkKey(chunkPos, dimension, container.tile.getLevel()));
BlockPos pos = null;
if (zonePlannerMapChunk != null) {
MapColourData data = zonePlannerMapChunk.getData(posX, posZ);
if (data != null) {
pos = new BlockPos(posX, data.posY, posZ);
}
}
if (pos != null && pos.getY() + 10 > camY) {
camY = Math.max(camY, pos.getY() + 10);
}
}
int x = guiLeft;
int y = guiTop;
if (lastSelected != null) {
String text = "X: " + lastSelected.getX() + " Y: " + lastSelected.getY() + " Z: " + lastSelected.getZ();
fontRenderer.drawString(text, x + 130, y + 130, 0x404040);
}
int offsetX = 8;
int offsetY = 9;
int sizeX = 213;
int sizeY = 100;
GlStateManager.pushMatrix();
GlStateManager.matrixMode(GL11.GL_PROJECTION);
GlStateManager.pushMatrix();
GlStateManager.loadIdentity();
ScaledResolution scaledResolution = new ScaledResolution(mc);
int viewportX = (x + offsetX) * scaledResolution.getScaleFactor();
int viewportY = mc.displayHeight - (sizeY + y + offsetY) * scaledResolution.getScaleFactor();
int viewportWidth = sizeX * scaledResolution.getScaleFactor();
int viewportHeight = sizeY * scaledResolution.getScaleFactor();
GL11.glEnable(GL11.GL_SCISSOR_TEST);
GL11.glScissor(viewportX, viewportY, viewportWidth, viewportHeight);
GlStateManager.clear(GL11.GL_DEPTH_BUFFER_BIT);
GL11.glDisable(GL11.GL_SCISSOR_TEST);
GlStateManager.viewport(viewportX, viewportY, viewportWidth, viewportHeight);
GlStateManager.scale(scaledResolution.getScaleFactor(), scaledResolution.getScaleFactor(), 1);
GLU.gluPerspective(70.0F, (float) sizeX / sizeY, 1F, 10000.0F);
GlStateManager.matrixMode(GL11.GL_MODELVIEW);
GlStateManager.loadIdentity();
RenderHelper.enableStandardItemLighting();
GlStateManager.enableRescaleNormal();
// look down
GlStateManager.rotate(90, 1, 0, 0);
GlStateManager.pushMatrix();
GlStateManager.translate(-positionX, -camY, -positionZ);
GlStateManager.disableBlend();
GlStateManager.disableAlpha();
GlStateManager.disableTexture2D();
int minScreenX = (x + offsetX) * scaledResolution.getScaleFactor();
int minScreenY = (scaledResolution.getScaledHeight() - (y + offsetY)) * scaledResolution.getScaleFactor();
int maxScreenX = (x + offsetX + sizeX) * scaledResolution.getScaleFactor();
int maxScreenY = (scaledResolution.getScaledHeight() - (y + offsetY + sizeY)) * scaledResolution.getScaleFactor();
int minChunkX = (posX >> 4) - 8;
int minChunkZ = (posZ >> 4) - 8;
int maxChunkX = (posX >> 4) + 8;
int maxChunkZ = (posZ >> 4) + 8;
// noinspection SuspiciousNameCombination
List<ChunkPos> chunkPosBounds = Stream.of(Pair.of(minScreenX, minScreenY), Pair.of(minScreenX, maxScreenY), Pair.of(maxScreenX, minScreenY), Pair.of(maxScreenX, maxScreenY)).map(p -> rayTrace(p.getLeft(), p.getRight())).filter(Objects::nonNull).map(ChunkPos::new).collect(Collectors.toList());
for (ChunkPos chunkPos : chunkPosBounds) {
if (chunkPos.x < minChunkX) {
minChunkX = chunkPos.x;
}
if (chunkPos.z < minChunkZ) {
minChunkZ = chunkPos.z;
}
if (chunkPos.x > maxChunkX) {
maxChunkX = chunkPos.x;
}
if (chunkPos.z > maxChunkZ) {
maxChunkZ = chunkPos.z;
}
}
minChunkX--;
minChunkZ--;
maxChunkX++;
maxChunkZ++;
for (int chunkX = minChunkX; chunkX <= maxChunkX; chunkX++) {
for (int chunkZ = minChunkZ; chunkZ <= maxChunkZ; chunkZ++) {
ZonePlannerMapRenderer.INSTANCE.getChunkGlList(new ZonePlannerMapChunkKey(new ChunkPos(chunkX, chunkZ), dimension, container.tile.getLevel())).ifPresent(GlStateManager::callList);
}
}
BlockPos found = null;
int foundColor = 0;
if (Mouse.getX() >= minScreenX && Mouse.getY() <= minScreenY && Mouse.getX() <= maxScreenX && Mouse.getY() >= maxScreenY) {
found = rayTrace(Mouse.getX(), Mouse.getY());
}
if (found != null) {
ZonePlannerMapChunk zonePlannerMapChunk = ZonePlannerMapDataClient.INSTANCE.getChunk(mc.world, new ZonePlannerMapChunkKey(new ChunkPos(found), mc.world.provider.getDimension(), container.tile.getLevel()));
if (zonePlannerMapChunk != null) {
MapColourData data = zonePlannerMapChunk.getData(found.getX(), found.getZ());
if (data != null) {
foundColor = data.colour;
}
}
}
if (found != null) {
GlStateManager.disableDepth();
GlStateManager.enableBlend();
GlStateManager.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
GlStateManager.glLineWidth(2);
int r = (int) (((foundColor >> 16) & 0xFF) * 0.7);
int g = (int) (((foundColor >> 8) & 0xFF) * 0.7);
int b = (int) (((foundColor >> 0) & 0xFF) * 0.7);
int a = 0x77;
ZonePlannerMapRenderer.INSTANCE.setColor(r << 16 | g << 8 | b << 0 | a << 24);
BufferBuilder builder = Tessellator.getInstance().getBuffer();
builder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
ZonePlannerMapRenderer.INSTANCE.drawBlockCuboid(builder, found.getX(), found.getY(), found.getZ());
Tessellator.getInstance().draw();
GlStateManager.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
GlStateManager.disableBlend();
GlStateManager.enableDepth();
}
GlStateManager.disableLighting();
GlStateManager.enableBlend();
for (int i = 0; i < container.tile.layers.length; i++) {
if (getPaintbrushBrush() != null && getPaintbrushBrush().colour.getMetadata() != i) {
continue;
}
ZonePlan layer = container.tile.layers[i];
if (getPaintbrushBrush() != null && getPaintbrushBrush().colour.getMetadata() == i && bufferLayer != null) {
layer = bufferLayer;
}
if (!layer.getChunkPoses().isEmpty()) {
Tessellator.getInstance().getBuffer().begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
for (int chunkX = minChunkX; chunkX <= maxChunkX; chunkX++) {
for (int chunkZ = minChunkZ; chunkZ <= maxChunkZ; chunkZ++) {
ChunkPos chunkPos = new ChunkPos(chunkX, chunkZ);
for (int blockX = chunkPos.getXStart(); blockX <= chunkPos.getXEnd(); blockX++) {
for (int blockZ = chunkPos.getZStart(); blockZ <= chunkPos.getZEnd(); blockZ++) {
if (!layer.get(blockX - container.tile.getPos().getX(), blockZ - container.tile.getPos().getZ())) {
continue;
}
int height;
ZonePlannerMapChunk zonePlannerMapChunk = ZonePlannerMapDataClient.INSTANCE.getChunk(mc.world, new ZonePlannerMapChunkKey(chunkPos, dimension, container.tile.getLevel()));
if (zonePlannerMapChunk != null) {
MapColourData data = zonePlannerMapChunk.getData(blockX, blockZ);
if (data != null) {
height = data.posY;
} else {
continue;
}
} else {
continue;
}
int color = EnumDyeColor.byMetadata(i).getColorValue();
int r = (color >> 16) & 0xFF;
int g = (color >> 8) & 0xFF;
int b = (color >> 0) & 0xFF;
int a = 0x55;
ZonePlannerMapRenderer.INSTANCE.setColor(r << 16 | g << 8 | b << 0 | a << 24);
ZonePlannerMapRenderer.INSTANCE.drawBlockCuboid(Tessellator.getInstance().getBuffer(), blockX, height + 0.1, blockZ, height, 0.6);
}
}
}
}
Tessellator.getInstance().draw();
}
}
GlStateManager.disableBlend();
GlStateManager.disableLighting();
GlStateManager.enableTexture2D();
lastSelected = found;
GlStateManager.popMatrix();
GlStateManager.disableRescaleNormal();
GlStateManager.matrixMode(GL11.GL_PROJECTION);
GlStateManager.viewport(0, 0, mc.displayWidth, mc.displayHeight);
GlStateManager.popMatrix();
GlStateManager.matrixMode(GL11.GL_MODELVIEW);
GlStateManager.popMatrix();
RenderHelper.disableStandardItemLighting();
GlStateManager.disableBlend();
}
use of org.lwjgl.opengl.GL11.glTranslatef in project runelite by runelite.
the class ModelViewer method main.
public static void main(String[] args) throws Exception {
Options options = new Options();
options.addOption(null, "npcdir", true, "npc directory");
options.addOption(null, "mapdir", true, "maps directory");
options.addOption(null, "objectdir", true, "objects directory");
options.addOption(null, "npc", true, "npc to render");
options.addOption(null, "object", true, "object to render");
options.addOption(null, "model", true, "model to render");
options.addOption(null, "map", true, "map region to render");
options.addOption(null, "kits", true, "kits to render");
CommandLineParser parser = new DefaultParser();
CommandLine cmd = parser.parse(options, args);
String npcdir = cmd.getOptionValue("npcdir");
String mapdir = cmd.getOptionValue("mapdir");
String objectdir = cmd.getOptionValue("objectdir");
NpcDefinition npcdef = null;
ObjectDefinition objdef = null;
List<ModelDefinition> models = new ArrayList<>();
Region region = null;
if (cmd.hasOption("model")) {
// render model
String model = cmd.getOptionValue("model");
ModelDefinition md = ModelManager.getModel(Integer.parseInt(model), null, null);
models.add(md);
}
if (cmd.hasOption("npc")) {
String npc = cmd.getOptionValue("npc");
try (FileInputStream fin = new FileInputStream(npcdir + "/" + npc + ".json")) {
npcdef = new Gson().fromJson(new InputStreamReader(fin), NpcDefinition.class);
}
for (int model : npcdef.models) {
ModelDefinition md = ModelManager.getModel(model, null, null);
models.add(md);
}
}
if (cmd.hasOption("object")) {
String obj = cmd.getOptionValue("object");
try (FileInputStream fin = new FileInputStream(objectdir + "/" + obj + ".json")) {
objdef = new Gson().fromJson(new InputStreamReader(fin), ObjectDefinition.class);
}
for (int model : objdef.getObjectModels()) {
ModelDefinition md = ModelManager.getModel(model, null, null);
models.add(md);
}
}
if (cmd.hasOption("map")) {
String map = cmd.getOptionValue("map");
String[] s = map.split(",");
int x = Integer.parseInt(s[0]), y = Integer.parseInt(s[1]);
region = new Region(x, y);
MapLoader mapLoader = new MapLoader();
LocationsLoader locationsLoader = new LocationsLoader();
try (FileInputStream fin = new FileInputStream(mapdir + "/m" + x + "_" + y + ".dat")) {
byte[] b = IOUtils.toByteArray(fin);
MapDefinition mapDef = mapLoader.load(x, y, b);
region.loadTerrain(mapDef);
}
try (FileInputStream fin = new FileInputStream(mapdir + "/l" + x + "_" + y + ".dat")) {
byte[] b = IOUtils.toByteArray(fin);
LocationsDefinition locDef = locationsLoader.load(x, y, b);
region.loadLocations(locDef);
} catch (FileNotFoundException ex) {
logger.info("No landscape file for {},{}", x, y);
}
loadUnderlays();
loadOverlays();
}
if (cmd.hasOption("kits")) {
String kits = cmd.getOptionValue("kits");
Integer[] kitIds = Arrays.stream(kits.split(",")).map(s -> Integer.parseInt(s)).toArray(Integer[]::new);
for (int kitId : kitIds) {
KitDefinition kit = KitManager.getKit(kitId);
for (int model : kit.modelIds) {
ModelDefinition md = ModelManager.getModel(model, null, null);
models.add(md);
}
}
}
Display.setDisplayMode(new DisplayMode(800, 600));
Display.setTitle("Model Viewer");
Display.setInitialBackground((float) Color.gray.getRed() / 255f, (float) Color.gray.getGreen() / 255f, (float) Color.gray.getBlue() / 255f);
Display.create();
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
double aspect = 1;
// near should be chosen as far into the scene as possible
double near = 1;
double far = 10000;
// 1 gives you a 90° field of view. It's tan(fov_angle)/2.
double fov = 1;
GL11.glFrustum(-aspect * near * fov, aspect * near * fov, -fov, fov, near, far);
GL11.glPopMatrix();
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glCullFace(GL11.GL_BACK);
GL11.glEnable(GL11.GL_CULL_FACE);
long last = 0;
Camera camera = new Camera();
while (!Display.isCloseRequested()) {
// Clear the screen and depth buffer
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
for (ModelDefinition def : models) {
short[] recolourToFind = null, recolourToReplace = null;
if (npcdef != null) {
recolourToFind = npcdef.recolorToFind;
recolourToReplace = npcdef.recolorToReplace;
}
if (objdef != null) {
recolourToFind = objdef.getRecolorToFind();
recolourToReplace = objdef.getRecolorToReplace();
}
drawModel(def, recolourToFind, recolourToReplace);
}
drawRegion(region);
Display.update();
// fps
Display.sync(50);
long delta = System.currentTimeMillis() - last;
last = System.currentTimeMillis();
camera.acceptInput(delta);
camera.apply();
}
Display.destroy();
}
Aggregations