net.minecraft.client.renderer.vertex.VertexFormat Java Examples
The following examples show how to use
net.minecraft.client.renderer.vertex.VertexFormat.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VariantModel.java From OpenModsLib with MIT License | 6 votes |
@Override public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { final Map<ResourceLocation, IBakedModel> bakedSubModels = Maps.newHashMap(); for (ResourceLocation subModel : modelData.getAllModels()) { IModel model = ModelLoaderRegistry.getModelOrLogError(subModel, "Couldn't load sub-model dependency: " + subModel); bakedSubModels.put(subModel, model.bake(new ModelStateComposition(state, model.getDefaultState()), format, bakedTextureGetter)); } final IModel baseModel; if (base.isPresent()) { ResourceLocation baseLocation = base.get(); baseModel = ModelLoaderRegistry.getModelOrLogError(baseLocation, "Couldn't load base-model dependency: " + baseLocation); } else { baseModel = ModelLoaderRegistry.getMissingModel(); } final IBakedModel bakedBaseModel = baseModel.bake(new ModelStateComposition(state, baseModel.getDefaultState()), format, bakedTextureGetter); return new BakedModel(bakedBaseModel, modelData, bakedSubModels, PerspectiveMapWrapper.getTransforms(state)); }
Example #2
Source File: BakedModelCamouflageBlock.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
@Nullable public static IBakedModel getRotatedBakedModel(@Nullable IModel model, @Nullable IBakedModel bakedModelDefault, IBlockState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { if (model != null) { if (state.getPropertyKeys().contains(BlockEnderUtilities.FACING)) { return model.bake(TRSRTransformation.from(state.getValue(BlockEnderUtilities.FACING)), format, bakedTextureGetter); } else if (state.getPropertyKeys().contains(BlockEnderUtilities.FACING_H)) { return model.bake(TRSRTransformation.from(state.getValue(BlockEnderUtilities.FACING_H)), format, bakedTextureGetter); } } return bakedModelDefault; }
Example #3
Source File: ModelNullifierBaked.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
@Override public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { IModel baseModel = null; IModel lockedModel = null; try { baseModel = ModelLoaderRegistry.getModel(BASE_MODEL); lockedModel = ModelLoaderRegistry.getModel(LOCKED_MODEL); lockedModel = lockedModel.retexture(ImmutableMap.of("layer0", TEX_LOCKED)); } catch (Exception e) { EnderUtilities.logger.warn("Failed to load a model for the Nullifier!"); } return new ModelNullifierBaked(baseModel, lockedModel, state, format, bakedTextureGetter); }
Example #4
Source File: BakedModelInserter.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
@Override public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { IModel baseModel = null; IModel sideModel = null; try { baseModel = ModelLoaderRegistry.getModel(BASE_MODEL); sideModel = ModelLoaderRegistry.getModel(SIDE_MODEL); } catch (Exception e) { EnderUtilities.logger.warn("Failed to load a model for the Inserter!"); } return new BakedModelInserter(this, baseModel, sideModel, state, format, bakedTextureGetter); }
Example #5
Source File: PerspectiveAwareModel.java From OpenModsLib with MIT License | 6 votes |
@Override public IBakedModel bake(final IModelState state, final VertexFormat format, final Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { final Map<TransformType, IBakedModel> bakedModels = Maps.transformValues(models, location -> bakeModel(location, state, format, bakedTextureGetter)); IModel missing = ModelLoaderRegistry.getMissingModel(); IBakedModel bakedMissing = missing.bake(missing.getDefaultState(), format, bakedTextureGetter); final IBakedModel bakedBase; if (base.isPresent()) { bakedBase = bakeModel(base.get(), state, format, bakedTextureGetter); } else { bakedBase = bakedMissing; } return new PerspectiveAwareBakedModel( bakedModels, bakedBase, PerspectiveMapWrapper.getTransforms(state)); }
Example #6
Source File: VertexDataUtils.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 6 votes |
public static BakedQuad buildQuad(VertexFormat format, TextureAtlasSprite sprite, Direction face, Colour colour, UVTransformation t, Vertex5 v1, Vertex5 v2, Vertex5 v3, Vertex5 v4) { // BakedQuadBuilder builder = new BakedQuadBuilder(format); // builder.setQuadTint(-1); // builder.setQuadOrientation(face); // builder.setTexture(sprite); // // t.apply(v1.uv); // t.apply(v2.uv); // t.apply(v3.uv); // t.apply(v4.uv); // putVertex(builder, format, face, v1, colour); // putVertex(builder, format, face, v2, colour); // putVertex(builder, format, face, v3, colour); // putVertex(builder, format, face, v4, colour); // // return copyQuad(builder.build()); return null; }
Example #7
Source File: VertexDataUtils.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 6 votes |
private static void putVertex(BakedQuadBuilder builder, VertexFormat format, Direction face, Vertex5 vert, Colour colour) { // for (int e = 0; e < format.getElementCount(); e++) { // VertexFormatElement element = format.getElement(e); // switch (element.getUsage()) { // // case POSITION: // Vector3 vec = vert.vec; // builder.put(e, (float) vec.x, (float) vec.y, (float) vec.z, 1); // break; // case NORMAL: // builder.put(e, face.getXOffset(), face.getYOffset(), face.getZOffset(), 0); // break; // case COLOR: // builder.put(e, (colour.r & 0xFF) / 255F, (colour.g & 0xFF) / 255F, (colour.b & 0xFF) / 255F, (colour.a & 0xFF) / 255F); // break; // case UV: // UV uv = vert.uv; // builder.put(e, (float) uv.u, (float) uv.v, 0, 1); // break; // default: // builder.put(e); // break; // } // } }
Example #8
Source File: RenderSeedStorage.java From AgriCraft with MIT License | 6 votes |
/** * Render the seed as TESR */ private void drawSeed(ITessellator tess, ItemStack seed) { if (seed.isEmpty() || seed.getItem() == null) { return; } float dx = 8 * Constants.UNIT; float dy = 5 * Constants.UNIT; float dz = 0.99F * Constants.UNIT; float f = 0.75F; final VertexFormat format = tess.getVertexFormat(); tess.draw(); renderItemStack(seed, dx, dy, dz, f, false); tess.startDrawingQuads(format); tess.pushMatrix(); }
Example #9
Source File: BWBakedModel.java From NOVA-Core with GNU Lesser General Public License v3.0 | 6 votes |
public BWBakedModel(IBakedModel wrapped, VertexFormat format, Optional<IBlockState> state, long rand) { this.wrapped = wrapped; this.format = format; this.matrix.translate(-0.5, -0.5, -0.5); this.blockState = state; this.rand = rand; if (!format.getElements().stream().anyMatch(VertexFormatElement::isPositionElement)) return; // VertexFormat doesn't have a position Arrays.stream(Direction.values()) .map(this::getQuads) .flatMap(Collection::stream) .map(this::quadToFace) .forEachOrdered(faces::add); }
Example #10
Source File: BWBakedModel.java From NOVA-Core with GNU Lesser General Public License v3.0 | 6 votes |
@SuppressWarnings("unchecked") public BWBakedModel(@SuppressWarnings("deprecation") net.minecraft.client.resources.model.IBakedModel wrapped, VertexFormat format) { this.wrapped = wrapped; this.format = format; this.matrix.translate(-0.5, -0.5, -0.5); if (!((List<VertexFormatElement>) format.getElements()).stream().anyMatch(VertexFormatElement::isPositionElement)) return; // VertexFormat doesn't have a position getGeneralQuads().stream() .map(this::quadToFace) .forEachOrdered(faces::add); Arrays.stream(Direction.VALID_DIRECTIONS) .map(this::getFaceQuads) .flatMap(Collection::stream) .map(this::quadToFace) .forEachOrdered(faces::add); }
Example #11
Source File: ItemStateModel.java From OpenModsLib with MIT License | 6 votes |
@Override public IBakedModel bake(IModelState state, final VertexFormat format, final Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { final IModel defaultModel; if (this.defaultModel.isPresent()) { defaultModel = getModel(this.defaultModel.get()); } else if (!this.stateModels.isEmpty()) { final ResourceLocation first = this.stateModels.values().iterator().next(); defaultModel = getModel(first); } else { defaultModel = ModelLoaderRegistry.getMissingModel(); } final IBakedModel bakedDefaultModel = defaultModel.bake(defaultModel.getDefaultState(), format, bakedTextureGetter); final Map<State, IBakedModel> bakedStateModels = Maps.transformValues(stateModels, input -> { final IModel model = getModel(input); return model.bake(model.getDefaultState(), format, bakedTextureGetter); }); return new ItemStateOverrideList(bakedStateModels).wrapModel(bakedDefaultModel); }
Example #12
Source File: GTModelTestTube.java From GT-Classic with GNU Lesser General Public License v3.0 | 6 votes |
@Override public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> getter) { if (BAKED_BASE == null) BAKED_BASE = GTModelUtils.load(GTMod.MODID, "test_tube_model").bake(state, format, getter); if (BAKED_OVERLAY == null) BAKED_OVERLAY = GTModelUtils.load(GTMod.MODID, "test_tube_overlay_model").bake(state, format, getter); ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder(); if (fluid != null) { TextureAtlasSprite sprite = getter.apply(fluid.getStill()); if (sprite != null) { List<BakedQuad> quads = BAKED_OVERLAY.getQuads(null, null, 0); quads = GTModelUtils.texAndTint(quads, fluid.getColor(), sprite); builder.addAll(quads); } } builder.addAll(BAKED_BASE.getQuads(null, null, 0)); return new GTBakedTestTube(builder.build(), this, getter.apply(BASE), format); }
Example #13
Source File: MultiLayerModel.java From OpenModsLib with MIT License | 6 votes |
@Override public IBakedModel bake(final IModelState state, final VertexFormat format, final Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { final Map<BlockRenderLayer, IBakedModel> bakedModels = Maps.transformValues(models, location -> bakeModel(location, state, format, bakedTextureGetter)); IModel missing = ModelLoaderRegistry.getMissingModel(); IBakedModel bakedMissing = missing.bake(missing.getDefaultState(), format, bakedTextureGetter); final IBakedModel bakedBase; if (base.isPresent()) { bakedBase = bakeModel(base.get(), state, format, bakedTextureGetter); } else { bakedBase = bakedMissing; } return new MultiLayerBakedModel( bakedModels, bakedBase, bakedMissing, PerspectiveMapWrapper.getTransforms(state)); }
Example #14
Source File: ModelWithDependencies.java From OpenModsLib with MIT License | 5 votes |
@Override public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { final IModel model; if (base.isPresent()) { model = ModelLoaderRegistry.getModelOrLogError(base.get(), "Couldn't load MultiLayerModel dependency: " + base.get()); } else { model = ModelLoaderRegistry.getMissingModel(); } return model.bake(state, format, bakedTextureGetter); }
Example #15
Source File: VertexDataUtils.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
public static void fullyUnPackQuads(int[] packedData, float[][][] unpackedData, VertexFormat format) { List<VertexFormatElement> elements = format.getElements(); for (int e = 0; e < elements.size(); e++) { for (int v = 0; v < 4; v++) { LightUtil.unpack(packedData, unpackedData[v][e], format, v, e); } } }
Example #16
Source File: EvalModel.java From OpenModsLib with MIT License | 5 votes |
@Override public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { final IModel model = loadBaseModel(state, format, bakedTextureGetter); final ITransformEvaluator evaluator = evaluatorFactory.createEvaluator(c -> model.getClip(c)); return new BakedEvalModel(model, state, format, bakedTextureGetter, evaluator); }
Example #17
Source File: BakedModelInserter.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
private BakedModelInserter(ModelInserter inserterModel, IModel baseModel, IModel sideModel, IModelState modelState, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { ImmutableMap<String, String> textures = inserterModel.getTextureMapping(); this.baseModel = baseModel.retexture(textures); this.sideModelValid = sideModel.retexture(ImmutableMap.of("side", textures.get("side_valid"))); this.sideModelInvalid = sideModel.retexture(ImmutableMap.of("side", textures.get("side_invalid"))); this.format = format; this.bakedTextureGetter = bakedTextureGetter; this.bakedBaseModel = this.baseModel.bake(modelState, format, bakedTextureGetter); this.particle = bakedTextureGetter.apply(new ResourceLocation(textures.get("particle"))); }
Example #18
Source File: TessellatorPool.java From OpenModsLib with MIT License | 5 votes |
public void startDrawing(int primitive, VertexFormat vertexFormat, WorldRendererUser user) { final Tessellator tes = reserveTessellator(); final BufferBuilder wr = tes.getBuffer(); wr.begin(primitive, vertexFormat); user.execute(wr); tes.draw(); pool.add(tes); }
Example #19
Source File: ModelEnderBucket.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
public BakedEnderBucket(ModelEnderBucket parent, ImmutableList<BakedQuad> quads, TextureAtlasSprite particle, VertexFormat format, ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> transforms, Map<String, IBakedModel> cache) { this.quads = quads; this.particle = particle; this.format = format; this.parent = parent; this.transforms = transforms; this.cache = cache; }
Example #20
Source File: VertexDataUtils.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
/** * Gets the position for the element 'position' in the elements list for use in LightUtil.pack/unpack for a given format. * * @param format The format. * @return The element position, -1 if it does not exist. */ public static int getPositionElement(VertexFormat format) { List<VertexFormatElement> elements = format.getElements(); for (int e = 0; e < elements.size(); e++) { if (elements.get(e).isPositionElement()) { return e; } } return -1; }
Example #21
Source File: VanillaModelWrapper.java From VanillaFix with MIT License | 5 votes |
@Override public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { if (!Attributes.moreSpecific(format, Attributes.DEFAULT_BAKED_FORMAT)) { throw new IllegalArgumentException("can't bake vanilla models to the format that doesn't fit into the default one: " + format); } ModelBlock model = this.model; if (model == null) { return BuiltinLoader.WRAPPED_MODEL_MISSING.bake(BuiltinLoader.WRAPPED_MODEL_MISSING.getDefaultState(), format, bakedTextureGetter); } List<TRSRTransformation> newTransforms = Lists.newArrayList(); for (int i = 0; i < model.getElements().size(); i++) { BlockPart part = model.getElements().get(i); newTransforms.add(animation.getPartTransform(state, part, i)); } ItemCameraTransforms transforms = model.getAllTransforms(); Map<ItemCameraTransforms.TransformType, TRSRTransformation> tMap = Maps.newEnumMap(ItemCameraTransforms.TransformType.class); tMap.putAll(PerspectiveMapWrapper.getTransforms(transforms)); tMap.putAll(PerspectiveMapWrapper.getTransforms(state)); IModelState perState = new SimpleModelState(ImmutableMap.copyOf(tMap)); if (hasItemModel(model)) { return new ItemLayerModel(model).bake(perState, format, bakedTextureGetter); } if (isCustomRenderer(model)) { return new BuiltInModel(transforms, model.createOverrides()); } return bakeNormal(model, perState, state, newTransforms, format, bakedTextureGetter, uvlock); }
Example #22
Source File: VertexDataUtils.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
/** * Gets the position for the element 'normal' in the elements list for use in LightUtil.pack/unpack for a given format. * * @param format The format. * @return The element position, -1 if it does not exist. */ public static int getNormalElement(VertexFormat format) { List<VertexFormatElement> elements = format.getElements(); for (int e = 0; e < elements.size(); e++) { if (elements.get(e).getUsage() == Usage.NORMAL) { return e; } } return -1; }
Example #23
Source File: VertexDataUtils.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
/** * Gets the position for the element 'uv' in the elements list for use in LightUtil.pack/unpack for a given format. * * @param format The format. * @return The element position, -1 if it does not exist. */ public static int getUVElement(VertexFormat format) { List<VertexFormatElement> elements = format.getElements(); for (int e = 0; e < elements.size(); e++) { if (elements.get(e).getUsage() == Usage.UV && elements.get(e).getIndex() == 0) { return e; } } return -1; }
Example #24
Source File: VertexDataUtils.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
/** * Gets the position for the element provided in the elements list for use in LightUtil.pack/unpack for a given format. * * @param format The format. * @param element THe element to get. * @return The element position, -1 if it does not exist. */ public static int getElement(VertexFormat format, VertexFormatElement element) { List<VertexFormatElement> elements = format.getElements(); for (int e = 0; e < elements.size(); e++) { if (elements.get(e).equals(element)) { return e; } } return -1; }
Example #25
Source File: VertexDataUtils.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
public static void fullyPackQuads(int[] packedData, float[][][] unpackedData, VertexFormat format) { List<VertexFormatElement> elements = format.getElements(); for (int e = 0; e < elements.size(); e++) { for (int v = 0; v < 4; v++) { LightUtil.pack(unpackedData[v][e], packedData, format, v, e); } } }
Example #26
Source File: TexturedItemModel.java From OpenModsLib with MIT License | 5 votes |
@Override public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { final IModel untexturedModel = getModel(this.untexturedModel); final IBakedModel untexturedBakedModel = untexturedModel.bake(new ModelStateComposition(state, untexturedModel.getDefaultState()), format, bakedTextureGetter); final IModel texturedModel = getModel(this.texturedModel); final IBakedModel texturedBakedModel = texturedModel.bake(new ModelStateComposition(state, texturedModel.getDefaultState()), format, bakedTextureGetter); final ItemOverrideList overrides = new TexturedItemOverrides(untexturedBakedModel, texturedModel, texturedBakedModel.getOverrides().getOverrides(), textures, state, format, bakedTextureGetter); return new BakedModel(untexturedBakedModel, PerspectiveMapWrapper.getTransforms(state), overrides); }
Example #27
Source File: UICharComponent.java From TFC2 with GNU General Public License v3.0 | 5 votes |
public UICharComponent(VertexFormat f, double x, double y, double z, int zLevel, float scale) { super(f, zLevel); this.scale = scale; xPos = x; yPos = y; zPos = z; }
Example #28
Source File: ModelRocket.java From AdvancedRocketry with MIT License | 5 votes |
@Override public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { IModel subComponent; try { subComponent = ModelLoaderRegistry.getModel(resource); IBakedModel bakedModelCore = subComponent.bake(state, format, bakedTextureGetter); return bakedModelCore; } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
Example #29
Source File: BakedEvalModel.java From OpenModsLib with MIT License | 5 votes |
public BakedEvalModel(IModel model, IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, ITransformEvaluator evaluator) { super(model.bake(state, format, bakedTextureGetter), PerspectiveMapWrapper.getTransforms(state)); this.model = model; this.originalState = state; this.format = format; this.bakedTextureGetter = bakedTextureGetter; this.evaluator = evaluator; }
Example #30
Source File: TRSRBakedModel.java From TFC2 with GNU General Public License v3.0 | 5 votes |
public Transformer(TRSRTransformation transformation, VertexFormat format) { super(new UnpackedBakedQuad.Builder(format)); // position transform this.transformation = transformation.getMatrix(); // normal transform this.normalTransformation = new Matrix3f(); this.transformation.getRotationScale(this.normalTransformation); this.normalTransformation.invert(); this.normalTransformation.transpose(); }