@Override protected Collection<GroupObject> getModel(Block block, int metadata) { List<GroupObject> result = new ArrayList<GroupObject>(); if (renderFrameInItem(block, metadata)) { result.addAll(super.getModel(block, metadata)); } String controllerName = getControllerInItemName(block, metadata); if (controllerName != null) { result.add(controller.get(controllerName + "Active")); } if (renderAllTanksInItem(block, metadata)) { for (GroupObject groupObject : tanks) { result.add(groupObject); } } else if (renderOneTankInItem(block, metadata)) { result.add(tanks[TankSlot.FRONT_LEFT.ordinal()]); } return result; }
@Override public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { setFacingDir(ForgeDirection.SOUTH); TechneUtil.vt = this.vt; IIcon icon = getModelIcon(block, metadata); Tessellator.instance.startDrawingQuads(); Tessellator.instance.setColorOpaque_F(1, 1, 1); Tessellator.instance.addTranslation(0, -0.47f, 0); for (GroupObject go : getModel(block, metadata)) { if (go instanceof GroupObjectWithIcon) { TechneUtil.renderWithIcon(go, ((GroupObjectWithIcon) go).getControllerTexture(), renderer.overrideBlockTexture, Tessellator.instance, null, 0, 0, 0, vt, true); } else { TechneUtil.renderWithIcon(go, icon, renderer.overrideBlockTexture, Tessellator.instance, null, 0, 0, 0, vt, true); } } Tessellator.instance.addTranslation(0, 0.47f, 0); Tessellator.instance.draw(); TechneUtil.vt = null; }
@Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { Tessellator tes = Tessellator.instance; IIcon icon = renderer.hasOverrideBlockTexture() ? renderer.overrideBlockTexture : block.getIcon(0, 0); tes.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z)); tes.setColorOpaque_F(1, 1, 1); tes.addTranslation(x, y, z + 1); for (GroupObject go : model.groupObjects) { for (Face f : go.faces) { Vertex n = f.faceNormal; tes.setNormal(n.x, n.y, n.z); for (int i = 0; i < f.vertices.length; i++) { Vertex vert = f.vertices[i]; TextureCoordinate t = f.textureCoordinates[i]; if (!renderer.hasOverrideBlockTexture()) { tes.addVertexWithUV(vert.x, vert.y, vert.z, icon.getInterpolatedU(t.u * 16), icon.getInterpolatedV(t.v * 16)); } else { tes.addVertexWithUV(vert.x, vert.y, vert.z, icon.getInterpolatedU((t.u * 64) % 16), icon.getInterpolatedV((t.v * 64) % 16)); } } } } tes.addTranslation(-x, -y, -z - 1); return true; }
public static Collection<CustomPartedModel> loadObjModelParts(WavefrontObject obj) { List<CustomPartedModel> ret = new ArrayList(); for(GroupObject go : obj.groupObjects) { ret.add(new CustomPartedModel(obj, go.name)); } return ret; }
/** * Use this to convert TechneModel to it's static representation */ @SuppressWarnings("unchecked") public static Map<String, GroupObject> bakeModel(TechneModel model, float scale, Matrix4f m, boolean rotateYFirst) { Map<String, ModelRenderer> parts = (Map<String, ModelRenderer>) ObfuscationReflectionHelper.getPrivateValue(TechneModel.class, model, "parts"); Map<String, GroupObject> res = Maps.newHashMap(); for (Map.Entry<String, ModelRenderer> e : parts.entrySet()) { GroupObject obj = bakeModel(e.getValue(), model, scale, m, rotateYFirst).get(0); res.put(e.getKey(), obj); } return res; }
public static void renderInventoryBlock(Collection<GroupObject> model, IIcon icon, Block block, int metadata, RenderBlocks rb) { tes.startDrawingQuads(); tes.setColorOpaque_F(1, 1, 1); tes.addTranslation(0, -0.47f, 0); renderWithIcon(model, icon, rb.overrideBlockTexture, tes, vt); tes.addTranslation(0, 0.47f, 0); tes.draw(); resetVT(); }
public static void renderInventoryBlock(GroupObject model, Block block, int metadata, RenderBlocks rb) { IIcon icon = getIconFor(block, metadata); tes.startDrawingQuads(); tes.setColorOpaque_F(1, 1, 1); tes.addTranslation(0, -0.47f, 0); renderWithIcon(model, icon, rb.overrideBlockTexture, tes, null, 0, 0, 0, vt, true); tes.addTranslation(0, 0.47f, 0); tes.draw(); resetVT(); }
public static boolean renderWorldBlock(Collection<GroupObject> model, IIcon icon, IBlockAccess world, int x, int y, int z, Block block, RenderBlocks rb) { if (icon == null) { return false; } tes.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z)); tes.setColorOpaque_F(1, 1, 1); tes.addTranslation(x + .5F, y + 0.0375f, z + .5F); renderWithIcon(model, icon, rb.overrideBlockTexture, tes, world, x, y, z, vt); tes.addTranslation(-x - .5F, -y - 0.0375f, -z - .5F); resetVT(); return true; }
public static boolean renderWorldBlock(GroupObject model, IBlockAccess world, int x, int y, int z, Block block, RenderBlocks rb) { IIcon icon = getIconFor(block, world, x, y, z); tes.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z)); tes.setColorOpaque_F(1, 1, 1); tes.addTranslation(x + .5F, y + 0.0375f, z + .5F); renderWithIcon(model, icon, rb.overrideBlockTexture, tes, world, x, y, z, vt, true); tes.addTranslation(-x - .5F, -y - 0.0375f, -z - .5F); resetVT(); return true; }
public RendererIHopper(@Nonnull RendererFrameworkMachine frameRenderer) { this.frameRenderer = frameRenderer; GroupObject controllerActive = new GroupObjectWithIcon(frameRenderer.getControllerPart(5), BlockIHopper.getBlock()); GroupObject controllerPassive = new GroupObjectWithIcon(frameRenderer.getControllerPart(6), BlockIHopper.getBlock()); frameRenderer.registerController(BlockIHopper.getBlock().getControllerModelName(), controllerActive, controllerPassive); }
public RendererCobbleworks(@Nonnull RendererFrameworkMachine frameRenderer) { this.frameRenderer = frameRenderer; GroupObject controllerActive = new GroupObjectWithIcon(frameRenderer.getControllerPart(1), BlockCobbleworks.getBlock()); GroupObject controllerPassive = new GroupObjectWithIcon(frameRenderer.getControllerPart(2), BlockCobbleworks.getBlock()); frameRenderer.registerController(BlockCobbleworks.getBlock().getControllerModelName(), controllerActive, controllerPassive); }
public RendererWaterworks(@Nonnull RendererFrameworkMachine frameRenderer) { this.frameRenderer = frameRenderer; GroupObject controllerActive = new GroupObjectWithIcon(frameRenderer.getControllerPart(3), BlockWaterworks.getBlock()); GroupObject controllerPassive = new GroupObjectWithIcon(frameRenderer.getControllerPart(2), BlockWaterworks.getBlock()); frameRenderer.registerController(BlockWaterworks.getBlock().getControllerModelName(), controllerActive, controllerPassive); }
public RendererTcom(@Nonnull RendererFrameworkMachine frameRenderer) { this.frameRenderer = frameRenderer; @SuppressWarnings("null") GroupObject controllerPassive = new GroupObjectWithIcon(frameRenderer.getControllerPart(4), BlockTcom.blockTcom); frameRenderer.registerController(BlockTcom.blockTcom.getControllerModelName(), controllerPassive, controllerPassive); }
@SuppressWarnings("unchecked") @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { T te = (T) world.getTileEntity(x, y, z); if (te != null) { setFacingDir(te.getFacingDir()); overlay.setTile(te); } TechneUtil.vt = this.vt; IIcon icon = getModelIcon(world, x, y, z, block); Tessellator.instance.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z)); Tessellator.instance.setColorOpaque_F(1, 1, 1); Tessellator.instance.addTranslation(x + .5F, y + 0.0375f, z + .5F); for (GroupObject go : getModel(world, x, y, z)) { if (go instanceof GroupObjectWithIcon) { TechneUtil.renderWithIcon(go, ((GroupObjectWithIcon) go).getControllerTexture(), renderer.overrideBlockTexture, Tessellator.instance, world, x, y, z, vt, true); } else { TechneUtil.renderWithIcon(go, icon, renderer.overrideBlockTexture, Tessellator.instance, world, x, y, z, vt, true); } } Tessellator.instance.addTranslation(-x - .5F, -y - 0.0375f, -z - .5F); TechneUtil.vt = null; if (renderer.overrideBlockTexture == null) { ccr.renderBlock(world, block, x, y, z, overlay); } return true; }
public TechneModelRenderer(Map<String, GroupObject> model, int renderId) { this(model, renderId, null); }
public TechneModelRenderer(Map<String, GroupObject> model, int renderId, VertexTransform vt) { this.model = model; this.renderId = renderId; this.vt = vt; }
protected Collection<GroupObject> getModel(Block block, int metadata) { return model.values(); }
protected Collection<GroupObject> getModel(IBlockAccess world, int x, int y, int z) { return model.values(); }
public static List<GroupObject> bakeModel(ModelRenderer model, TechneModel supermodel) { return bakeModel(model, supermodel, 1); }
public static List<GroupObject> bakeModel(ModelRenderer model, TechneModel supermodel, float scale) { return bakeModel(model, supermodel, scale, new Matrix4f()); }
public static List<GroupObject> bakeModel(ModelRenderer model, TechneModel supermodel, float scale, Matrix4f matrix) { return bakeModel(model, supermodel, scale, matrix, false); }
public static Map<String, GroupObject> bakeModel(TechneModel model) { return bakeModel(model, 1); }
public static Map<String, GroupObject> bakeModel(TechneModel model, float scale) { return bakeModel(model, scale, new Matrix4f()); }
public static Map<String, GroupObject> bakeModel(TechneModel model, float scale, Matrix4f m) { return bakeModel(model, scale, m, false); }
public static Map<String, GroupObject> getModel(String modid, String modelPath) { TechneModel tm = (TechneModel) modelLoader.loadInstance(new ResourceLocation(modid.toLowerCase(Locale.US), modelPath + ".tcn")); return TechneUtil.bakeModel(tm, 1f / 16, new Matrix4f().scale(new Vector3f(-1, -1, 1))); }
public static Collection<GroupObject> getModelAll(String modid, String modelPath) { TechneModel tm = (TechneModel) modelLoader.loadInstance(new ResourceLocation(modid.toLowerCase(Locale.US), modelPath + ".tcn")); return TechneUtil.bakeModel(tm, 1f / 16, new Matrix4f().scale(new Vector3f(-1, -1, 1))).values(); }
public static void renderWithIcon(Collection<GroupObject> model, IIcon icon, IIcon override, Tessellator tes) { renderWithIcon(model, icon, override, tes, null); }
public static void renderWithIcon(Collection<GroupObject> model, IIcon icon, IIcon override, Tessellator tes, VertexTransform vt) { renderWithIcon(model, icon, override, tes, null, 0, 0, 0, vt); }
public static void renderWithIcon(Collection<GroupObject> model, IIcon icon, IIcon override, Tessellator tes, IBlockAccess world, int x, int y, int z) { renderWithIcon(model, icon, override, tes, world, x, y, z, null); }
public static void renderWithIcon(Collection<GroupObject> model, IIcon icon, IIcon override, Tessellator tes, IBlockAccess world, int x, int y, int z, VertexTransform vt) { renderWithIcon(model, icon, override, tes, world, x, y, z, vt, true); }
public static void renderWithIcon(Collection<GroupObject> model, IIcon icon, IIcon override, Tessellator tes, IBlockAccess world, int x, int y, int z, VertexTransform vt, boolean isbrh) { for (GroupObject go : model) { renderWithIcon(go, icon, override, tes, world, x, y, z, vt, isbrh); } }
public static void renderWithIcon(GroupObject go, IIcon icon, IIcon override, Tessellator tes, IBlockAccess world, int x, int y, int z, VertexTransform vt, boolean isbrh) { for (Face f : go.faces) { Vertex n = f.faceNormal; tes.setNormal(n.x, n.y, n.z); ForgeDirection normal = getNormalFor(n); ForgeDirection right = normal.getRotation(ForgeDirection.DOWN); if (normal == right) { right = ForgeDirection.EAST; } ForgeDirection down = normal.getRotation(right.getOpposite()); if (isbrh && world != null && world.getBlock(x, y, z).getLightOpacity() > 0) { int bx = x + normal.offsetX; int by = y + normal.offsetY; int bz = z + normal.offsetZ; tes.setBrightness(world.getBlock(bx, by, bz).getMixedBrightnessForBlock(world, bx, by, bz)); } for (int i = 0; i < f.vertices.length; i++) { Vertex vert = f.vertices[i]; Vector3d v = new Vector3d(vert); Vector3d tv = new Vector3d(v); tv.add(0.5, 0, 0.5); if (vt != null) { vt.apply(v); // TODO BLECH if (vt instanceof VertexRotationFacing) { normal = ((VertexRotationFacing) vt).rotate(normal); } if (vt instanceof VertexTransformComposite) { for (VertexTransform xform : ((VertexTransformComposite) vt).xforms) { if (xform instanceof VertexRotationFacing) { normal = ((VertexRotationFacing) xform).rotate(normal); } } } } if (isbrh) { int c = (int) (0xFF * RenderUtil.getColorMultiplierForFace(normal)); tes.setColorOpaque(c, c, c); } if (override != null) { double interpX = Math.abs(tv.x * right.offsetX + tv.y * right.offsetY + tv.z * right.offsetZ); double interpY = Math.abs(tv.x * down.offsetX + tv.y * down.offsetY + tv.z * down.offsetZ); // Handles verts outside block bounds. Modulo fails at 1.0. while (interpX > 1) { interpX--; } while (interpY > 1) { interpY--; } if (normal == ForgeDirection.SOUTH || normal == ForgeDirection.WEST) { interpX = 1 - interpX; } if (normal != ForgeDirection.UP && normal != ForgeDirection.DOWN) { interpY = 1 - interpY; } tes.addVertexWithUV(v.x, v.y, v.z, override.getInterpolatedU(interpX * 16), override.getInterpolatedV(interpY * 16)); } else { TextureCoordinate t = f.textureCoordinates[i]; tes.addVertexWithUV(v.x, v.y, v.z, getInterpolatedU(icon, t.u), getInterpolatedV(icon, t.v)); } } } }
public static void renderInventoryBlock(Collection<GroupObject> model, Block block, int metadata, RenderBlocks rb) { renderInventoryBlock(model, getIconFor(block, metadata), block, metadata, rb); }
public static boolean renderWorldBlock(Collection<GroupObject> model, IBlockAccess world, int x, int y, int z, Block block, RenderBlocks rb) { IIcon icon = getIconFor(block, world, x, y, z); return renderWorldBlock(model, icon, world, x, y, z, block, rb); }
public GroupObjectWithIcon(GroupObject go, @Nonnull ITextureProvider textureProvider) { this.name = go.name; this.glDrawingMode = go.glDrawingMode; this.faces = go.faces; this.textureProvider = textureProvider; }
@Nullable public GroupObject extractModelPart(@Nonnull String name) { return model.remove(name); }
@Nullable public GroupObject getControllerPart(int id) { return contr[id - 1]; }
public void registerController(@Nonnull String name, @Nonnull GroupObject active, @Nonnull GroupObject inactive) { controller.put(name, inactive); controller.put(name + "Active", active); }
@Override protected Collection<GroupObject> getModel(IBlockAccess world, int x, int y, int z) { List<GroupObject> result = new ArrayList<GroupObject>(super.getModel(world, x, y, z)); TileEntity te = world != null ? world.getTileEntity(x, y, z) : null; IFrameworkMachine frameworkMachine = te instanceof IFrameworkMachine ? (IFrameworkMachine) te : null; AbstractMachineEntity machineEntity = te instanceof AbstractMachineEntity ? (AbstractMachineEntity) te : null; if (frameworkMachine != null && machineEntity != null) { if (frameworkMachine.hasController()) { if (machineEntity.isActive()) { result.add(controller.get(frameworkMachine.getControllerModelName() + "Active")); } else { result.add(controller.get(frameworkMachine.getControllerModelName())); } } boolean stem1 = false, stem2 = false; for (TankSlot tankSlot : TankSlot.values()) { tankSlot = notnullJ(tankSlot, "enum.values()[i]"); if (frameworkMachine.hasTank(tankSlot)) { int i = tankSlot.ordinal(); result.add(tanks[i]); result.add(valves[i]); switch (tankSlot) { case FRONT_LEFT: case BACK_LEFT: stem1 = true; break; case FRONT_RIGHT: case BACK_RIGHT: stem2 = true; break; } } } if (stem1) { result.add(stems[0]); } if (stem2) { result.add(stems[1]); } } return result; }