Search in sources :

Example 1 with BakedPerspectiveModel

use of net.silentchaos512.gear.client.model.BakedPerspectiveModel in project Silent-Gear by SilentChaos512.

the class FragmentModel method bake.

@SuppressWarnings("MethodWithTooManyParameters")
public BakedModel bake(List<MaterialLayer> layers, IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelTransform, FragmentModelOverrideList fragmentModelOverrideList, ResourceLocation modelLocation) {
    ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
    Transformation rotation = modelTransform.getRotation();
    ImmutableMap<ItemTransforms.TransformType, Transformation> transforms = PerspectiveMapWrapper.getTransforms(modelTransform);
    for (int i = 0; i < layers.size(); i++) {
        MaterialLayer layer = layers.get(i);
        TextureAtlasSprite texture = spriteGetter.apply(new Material(InventoryMenu.BLOCK_ATLAS, layer.getTexture(GearType.FRAGMENT, 0)));
        builder.addAll(getQuadsForSprite(i, texture, rotation, layer.getColor()));
    }
    // No layers?
    if (layers.isEmpty()) {
        if (Const.Materials.EXAMPLE.isPresent()) {
            buildFakeModel(spriteGetter, builder, rotation, Const.Materials.EXAMPLE.get());
        } else {
            // Shouldn't happen, but...
            SilentGear.LOGGER.error("Example material is missing?");
            TextureAtlasSprite texture = spriteGetter.apply(new Material(InventoryMenu.BLOCK_ATLAS, SilentGear.getId("item/error")));
            builder.addAll(getQuadsForSprite(0, texture, rotation, 0xFFFFFF));
        }
    }
    TextureAtlasSprite particle = spriteGetter.apply(owner.resolveTexture("particle"));
    return new BakedPerspectiveModel(builder.build(), particle, transforms, overrideList, rotation.isIdentity(), owner.isSideLit(), cameraTransforms);
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) BakedPerspectiveModel(net.silentchaos512.gear.client.model.BakedPerspectiveModel) Transformation(com.mojang.math.Transformation) ImmutableList(com.google.common.collect.ImmutableList) MaterialLayer(net.silentchaos512.gear.api.material.MaterialLayer) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) IMaterial(net.silentchaos512.gear.api.material.IMaterial)

Example 2 with BakedPerspectiveModel

use of net.silentchaos512.gear.client.model.BakedPerspectiveModel in project Silent-Gear by SilentChaos512.

the class CompoundPartModel method bake.

@SuppressWarnings("MethodWithTooManyParameters")
public BakedModel bake(List<MaterialLayer> layers, String transformVariant, IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelTransform, ItemOverrides overrideList, ResourceLocation modelLocation) {
    ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
    Transformation rotation = modelTransform.getRotation();
    ImmutableMap<ItemTransforms.TransformType, Transformation> transforms = PerspectiveMapWrapper.getTransforms(modelTransform);
    for (int i = 0; i < layers.size(); i++) {
        MaterialLayer layer = layers.get(i);
        TextureAtlasSprite texture = spriteGetter.apply(new Material(InventoryMenu.BLOCK_ATLAS, layer.getTexture(this.texturePath, 0)));
        builder.addAll(getQuadsForSprite(i, texture, rotation, layer.getColor()));
    }
    // No layers?
    if (layers.isEmpty()) {
        if (Const.Materials.EXAMPLE.isPresent()) {
            buildFakeModel(spriteGetter, builder, rotation, Const.Materials.EXAMPLE.get());
        } else {
            // Shouldn't happen, but...
            SilentGear.LOGGER.error("Example material is missing?");
            TextureAtlasSprite texture = spriteGetter.apply(new Material(InventoryMenu.BLOCK_ATLAS, SilentGear.getId("item/error")));
            builder.addAll(getQuadsForSprite(0, texture, rotation, Color.VALUE_WHITE));
        }
    }
    // Extras
    for (int i = 0; i < this.extraLayers.size(); i++) {
        ResourceLocation texture = this.extraLayers.get(i);
        builder.addAll(getQuadsForSprite(layers.size() + i, spriteGetter.apply(new Material(InventoryMenu.BLOCK_ATLAS, new StaticLayer(texture).getTexture())), rotation, Color.VALUE_WHITE));
    }
    builder.addAll(getQuadsForSprite(layers.size(), spriteGetter.apply(new Material(InventoryMenu.BLOCK_ATLAS, new StaticLayer(PART_MARKER_TEXTURE).getTexture())), rotation, Color.LIGHTSKYBLUE.getColor()));
    TextureAtlasSprite particle = spriteGetter.apply(owner.resolveTexture("particle"));
    return new BakedPerspectiveModel(builder.build(), particle, transforms, overrideList, rotation.isIdentity(), owner.isSideLit(), getCameraTransforms(transformVariant));
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) Transformation(com.mojang.math.Transformation) ImmutableList(com.google.common.collect.ImmutableList) MaterialLayer(net.silentchaos512.gear.api.material.MaterialLayer) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) IMaterial(net.silentchaos512.gear.api.material.IMaterial) BakedPerspectiveModel(net.silentchaos512.gear.client.model.BakedPerspectiveModel) ResourceLocation(net.minecraft.resources.ResourceLocation) ModResourceLocation(net.silentchaos512.gear.util.ModResourceLocation) StaticLayer(net.silentchaos512.gear.api.material.StaticLayer)

Example 3 with BakedPerspectiveModel

use of net.silentchaos512.gear.client.model.BakedPerspectiveModel in project Silent-Gear by SilentChaos512.

the class GearModel method bake.

@SuppressWarnings("MethodWithTooManyParameters")
public BakedModel bake(ItemStack stack, List<MaterialLayer> layers, int animationFrame, String transformVariant, IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelTransform, ItemOverrides overrideList, ResourceLocation modelLocation) {
    ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
    Transformation rotation = modelTransform.getRotation();
    ImmutableMap<ItemTransforms.TransformType, Transformation> transforms = PerspectiveMapWrapper.getTransforms(modelTransform);
    boolean broken = GearHelper.isBroken(stack);
    for (int i = 0; i < layers.size(); i++) {
        MaterialLayer layer = layers.get(i);
        Material renderMaterial = getTexture(layer, animationFrame, broken);
        TextureAtlasSprite texture = spriteGetter.apply(renderMaterial);
        builder.addAll(getQuadsForSprite(i, texture, rotation, layer.getColor()));
        if (GearModelOverrideList.isDebugLoggingEnabled()) {
            SilentGear.LOGGER.info("  - {} -> {}", layer.getTextureId(), renderMaterial.texture());
        }
    }
    // No layers?
    if (layers.isEmpty()) {
        if (Const.Materials.EXAMPLE.isPresent()) {
            buildFakeModel(spriteGetter, builder, rotation, Const.Materials.EXAMPLE.get());
        } else {
            // Shouldn't happen, but...
            SilentGear.LOGGER.error("Example material is missing?");
            TextureAtlasSprite texture = spriteGetter.apply(new Material(InventoryMenu.BLOCK_ATLAS, SilentGear.getId("item/error")));
            builder.addAll(getQuadsForSprite(0, texture, rotation, 0xFFFFFF));
        }
    }
    TextureAtlasSprite particle = spriteGetter.apply(owner.resolveTexture("particle"));
    return new BakedPerspectiveModel(builder.build(), particle, transforms, overrideList, rotation.isIdentity(), owner.isSideLit(), getCameraTransforms(transformVariant));
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) BakedPerspectiveModel(net.silentchaos512.gear.client.model.BakedPerspectiveModel) Transformation(com.mojang.math.Transformation) ImmutableList(com.google.common.collect.ImmutableList) MaterialLayer(net.silentchaos512.gear.api.material.MaterialLayer) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) IMaterial(net.silentchaos512.gear.api.material.IMaterial)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)3 Transformation (com.mojang.math.Transformation)3 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)3 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)3 IMaterial (net.silentchaos512.gear.api.material.IMaterial)3 MaterialLayer (net.silentchaos512.gear.api.material.MaterialLayer)3 BakedPerspectiveModel (net.silentchaos512.gear.client.model.BakedPerspectiveModel)3 ResourceLocation (net.minecraft.resources.ResourceLocation)1 StaticLayer (net.silentchaos512.gear.api.material.StaticLayer)1 ModResourceLocation (net.silentchaos512.gear.util.ModResourceLocation)1