当前位置: 首页>>代码示例>>Java>>正文


Java TextureUtils.getMissingSprite方法代码示例

本文整理汇总了Java中codechicken.lib.texture.TextureUtils.getMissingSprite方法的典型用法代码示例。如果您正苦于以下问题:Java TextureUtils.getMissingSprite方法的具体用法?Java TextureUtils.getMissingSprite怎么用?Java TextureUtils.getMissingSprite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在codechicken.lib.texture.TextureUtils的用法示例。


在下文中一共展示了TextureUtils.getMissingSprite方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: bake

import codechicken.lib.texture.TextureUtils; //导入方法依赖的package包/类
@Override
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {

    Map<BlockRenderLayer, IBakedModel> layerModelMap = new HashMap<>();
    TextureAtlasSprite particle = TextureUtils.getMissingSprite();
    for (Entry<BlockRenderLayer, Map<EnumFacing, String>> layerEntry : layerFaceSpriteMap.entrySet()) {
        Map<String, String> kvTextures = new HashMap<>();
        for (Entry<EnumFacing, String> faceEntry : layerEntry.getValue().entrySet()) {
            if (faceEntry.getKey() == null) {
                kvTextures.put("particle", faceEntry.getValue());
            } else {
                kvTextures.put(faceEntry.getKey().getName(), faceEntry.getValue());
            }
        }
        IModel vanillaModel = ModelLoaderRegistry.getModelOrLogError(new ResourceLocation("minecraft:block/cube"), "Unable to get vanilla model wrapper..");
        vanillaModel = vanillaModel.retexture(ImmutableMap.copyOf(addMissing(kvTextures)));
        IBakedModel model = vanillaModel.bake(state, format, bakedTextureGetter);

        if (layerEntry.getKey() == BlockRenderLayer.SOLID) {
            particle = model.getParticleTexture();
        }

        layerModelMap.put(layerEntry.getKey(), model);
    }

    ModelProperties.Builder builder = ModelProperties.builder();
    builder.withAO(isAO).withGui3D(gui3d);
    builder.withParticle(particle);

    return new PerspectiveAwareLayeredModelWrapper(layerModelMap, builder.withState(state).build());
}
 
开发者ID:TheCBProject,项目名称:CodeChickenLib,代码行数:32,代码来源:CCModelCube.java

示例2: getParticleTexture

import codechicken.lib.texture.TextureUtils; //导入方法依赖的package包/类
@Override
default TextureAtlasSprite getParticleTexture() {
    return TextureUtils.getMissingSprite();
}
 
开发者ID:TheCBProject,项目名称:CodeChickenLib,代码行数:5,代码来源:IModelParticleProvider.java

示例3: bake

import codechicken.lib.texture.TextureUtils; //导入方法依赖的package包/类
/**
 * Bakes the data inside the VertexBuffer to a baked quad.
 *
 * @return The list of quads baked.
 */
public List<BakedQuad> bake() {
    if (isDrawing) {
        CCLLog.log(Level.WARN, new IllegalStateException("Bake called before finishDrawing!"), "Someone is calling bake before finishDrawing!");
        finishDrawing();
    }
    State state = getVertexState();
    VertexFormat format = state.getVertexFormat();
    if (!format.hasUvOffset(0)) {
        throw new IllegalStateException("Unable to bake format that does not have UV mappings!");
    }
    int[] rawBuffer = Arrays.copyOf(state.getRawBuffer(), state.getRawBuffer().length);

    List<BakedQuad> quads = new LinkedList<>();
    TextureAtlasSprite sprite = TextureUtils.getMissingSprite();

    int curr = 0;
    int next = format.getNextOffset();
    int i = 0;
    while (rawBuffer.length >= next) {
        int[] quadData = Arrays.copyOfRange(rawBuffer, curr, next);
        Vector3 normal = new Vector3();
        if (format.hasNormal()) {
            //Grab first normal.
            float[] normalData = new float[4];
            LightUtil.unpack(quadData, normalData, format, 0, VertexDataUtils.getNormalElement(format));
            normal = Vector3.fromArray(normalData);
        } else {
            //No normal provided in format, so we calculate.
            float[][] posData = new float[4][4];
            for (int v = 0; v < 4; v++) {
                LightUtil.unpack(quadData, posData[v], format, v, VertexDataUtils.getPositionElement(format));
            }
            normal.set(VectorUtils.calculateNormal(Vector3.fromArray(posData[0]), Vector3.fromArray(posData[1]), Vector3.fromArray(posData[3])));
        }
        if (useSprites) {
            //Attempt to get sprite for vertex.
            if (spriteMap.containsKey(i)) {
                //Use provided sprite for vertex.
                sprite = spriteMap.get(i);
            } else {
                //Sprite not found for vertex, so we attempt to calculate the sprite.
                float[] uvData = new float[4];
                LightUtil.unpack(quadData, uvData, format, 0, VertexDataUtils.getUVElement(format));
                UV uv = new UV(uvData[0], uvData[1]);
                sprite = VertexDataUtils.getSpriteForUV(TextureUtils.getTextureMap(), uv);
            }
        }
        //Use normal to calculate facing.
        EnumFacing facing = VectorUtils.calcNormalSide(normal);
        if (facing == null) {
            facing = EnumFacing.UP;
        }
        BakedQuad quad = new BakedQuad(quadData, -1, facing, sprite, useDiffuseLighting, format);
        quads.add(quad);
        curr = next;
        next += format.getNextOffset();
        i++;
    }
    return ImmutableList.copyOf(quads);
}
 
开发者ID:TheCBProject,项目名称:CodeChickenLib,代码行数:66,代码来源:BakingVertexBuffer.java

示例4: getParticleTexture

import codechicken.lib.texture.TextureUtils; //导入方法依赖的package包/类
@Override
public TextureAtlasSprite getParticleTexture() {
    return TextureUtils.getMissingSprite();
}
 
开发者ID:TheCBProject,项目名称:CodeChickenLib,代码行数:5,代码来源:CCBakeryModel.java


注:本文中的codechicken.lib.texture.TextureUtils.getMissingSprite方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。