當前位置: 首頁>>代碼示例>>Java>>正文


Java VertexFormat.getElementCount方法代碼示例

本文整理匯總了Java中net.minecraft.client.renderer.vertex.VertexFormat.getElementCount方法的典型用法代碼示例。如果您正苦於以下問題:Java VertexFormat.getElementCount方法的具體用法?Java VertexFormat.getElementCount怎麽用?Java VertexFormat.getElementCount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.client.renderer.vertex.VertexFormat的用法示例。


在下文中一共展示了VertexFormat.getElementCount方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: mapFormats

import net.minecraft.client.renderer.vertex.VertexFormat; //導入方法依賴的package包/類
public static int[] mapFormats(VertexFormat from, VertexFormat to)
{
    int fromCount = from.getElementCount();
    int toCount = to.getElementCount();
    int[] eMap = new int[fromCount];

    for(int e = 0; e < fromCount; e++)
    {
        VertexFormatElement expected = from.getElement(e);
        int e2;
        for(e2 = 0; e2 < toCount; e2++)
        {
            VertexFormatElement current = to.getElement(e2);
            if(expected.getUsage() == current.getUsage() && expected.getIndex() == current.getIndex())
            {
                break;
            }
        }
        eMap[e] = e2;
    }
    return eMap;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:23,代碼來源:LightUtil.java

示例2: put

import net.minecraft.client.renderer.vertex.VertexFormat; //導入方法依賴的package包/類
public void put(int e, float... data)
{
    VertexFormat format = getVertexFormat();
    if(renderer.isColorDisabled() && format.getElement(e).getUsage() == EnumUsage.COLOR)
    {
        data = dummyColor;
    }
    LightUtil.pack(data, quadData, format, v, e);
    if(e == format.getElementCount() - 1)
    {
        v++;
        if(v == 4)
        {
            renderer.addVertexData(quadData);
            renderer.putPosition(offset.getX(), offset.getY(), offset.getZ());
            //Arrays.fill(quadData, 0);
            v = 0;
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:21,代碼來源:VertexBufferConsumer.java

示例3: putBakedQuad

import net.minecraft.client.renderer.vertex.VertexFormat; //導入方法依賴的package包/類
public static void putBakedQuad(IVertexConsumer consumer, BakedQuad quad)
{
    try
    {
        consumer.setTexture(quad.getSprite());
    }
    catch(AbstractMethodError e)
    {
        // catch missing method errors caused by change to IVertexConsumer
    }
    consumer.setQuadOrientation(quad.getFace());
    if(quad.hasTintIndex())
    {
        consumer.setQuadTint(quad.getTintIndex());
    }
    consumer.setApplyDiffuseLighting(quad.shouldApplyDiffuseLighting());
    //int[] eMap = mapFormats(consumer.getVertexFormat(), DefaultVertexFormats.ITEM);
    float[] data = new float[4];
    VertexFormat formatFrom = consumer.getVertexFormat();
    VertexFormat formatTo = quad.getFormat();
    int countFrom = formatFrom.getElementCount();
    int countTo = formatTo.getElementCount();
    int[] eMap = formatMaps.getUnchecked(Pair.of(formatFrom, formatTo));
    for(int v = 0; v < 4; v++)
    {
        for(int e = 0; e < countFrom; e++)
        {
            if(eMap[e] != countTo)
            {
                unpack(quad.getVertexData(), data, quad.getFormat(), v, eMap[e]);
                consumer.put(e, data);
            }
            else
            {
                consumer.put(e);
            }
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:40,代碼來源:LightUtil.java

示例4: moreSpecific

import net.minecraft.client.renderer.vertex.VertexFormat; //導入方法依賴的package包/類
public static boolean moreSpecific(VertexFormat first, VertexFormat second)
{
    int size = first.getNextOffset();
    if(size != second.getNextOffset()) return false;

    int padding = 0;
    int j = 0;
    for(VertexFormatElement firstAttr : first.getElements())
    {
        while(j < second.getElementCount() && second.getElement(j).getUsage() == EnumUsage.PADDING)
        {
            padding += second.getElement(j++).getSize();
        }
        if(j >= second.getElementCount() && padding == 0)
        {
            // if no padding is left, but there are still elements in first (we're processing one) - it doesn't fit
            return false;
        }
        if(padding == 0)
        {
            // no padding - attributes have to match
            VertexFormatElement secondAttr = second.getElement(j++);
            if(
                firstAttr.getIndex() != secondAttr.getIndex() ||
                firstAttr.getElementCount() != secondAttr.getElementCount() ||
                firstAttr.getType() != secondAttr.getType() ||
                firstAttr.getUsage() != secondAttr.getUsage())
            {
                return false;
            }
        }
        else
        {
            // padding - attribute should fit in it
            padding -= firstAttr.getSize();
            if(padding < 0) return false;
        }
    }

    if(padding != 0 || j != second.getElementCount()) return false;
    return true;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:43,代碼來源:Attributes.java

示例5: Builder

import net.minecraft.client.renderer.vertex.VertexFormat; //導入方法依賴的package包/類
public Builder(VertexFormat format)
{
    this.format = format;
    unpackedData = new float[4][format.getElementCount()][4];
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:6,代碼來源:UnpackedBakedQuad.java

示例6: setVertexFormat

import net.minecraft.client.renderer.vertex.VertexFormat; //導入方法依賴的package包/類
public void setVertexFormat(VertexFormat format)
{
    this.format = format;
    dataLength = new byte[format.getElementCount()];
    quadData = new float[format.getElementCount()][4][4];
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:7,代碼來源:QuadGatheringTransformer.java

示例7: putVertex

import net.minecraft.client.renderer.vertex.VertexFormat; //導入方法依賴的package包/類
private static void putVertex(UnpackedBakedQuad.Builder builder, VertexFormat format, TRSRTransformation transform, EnumFacing side,
                              float x, float y, float z, float u, float v, int color)
{
    Vector4f vec = new Vector4f();
    for (int e = 0; e < format.getElementCount(); e++)
    {
        switch (format.getElement(e).getUsage())
        {
            case POSITION:
                if (transform == TRSRTransformation.identity())
                {
                    builder.put(e, x, y, z, 1);
                }
                // only apply the transform if it's not identity
                else
                {
                    vec.x = x;
                    vec.y = y;
                    vec.z = z;
                    vec.w = 1;
                    transform.getMatrix().transform(vec);
                    builder.put(e, vec.x, vec.y, vec.z, vec.w);
                }
                break;
            case COLOR:
                float r = ((color >> 16) & 0xFF) / 255f; // red
                float g = ((color >> 8) & 0xFF) / 255f; // green
                float b = ((color >> 0) & 0xFF) / 255f; // blue
                float a = ((color >> 24) & 0xFF) / 255f; // alpha
                builder.put(e, r, g, b, a);
                break;
            case UV:
                if (format.getElement(e).getIndex() == 0)
                {
                    builder.put(e, u, v, 0f, 1f);
                    break;
                }
            case NORMAL:
                builder.put(e, (float) side.getFrontOffsetX(), (float) side.getFrontOffsetY(), (float) side.getFrontOffsetZ(), 0f);
                break;
            default:
                builder.put(e);
                break;
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:47,代碼來源:ItemTextureQuadConverter.java

示例8: putVertex

import net.minecraft.client.renderer.vertex.VertexFormat; //導入方法依賴的package包/類
private static void putVertex(UnpackedBakedQuad.Builder builder, VertexFormat format, Optional<TRSRTransformation> transform, EnumFacing side, float x, float y, float z, float u, float v)
{
    Vector4f vec = new Vector4f();
    for(int e = 0; e < format.getElementCount(); e++)
    {
        switch(format.getElement(e).getUsage())
        {
        case POSITION:
            if(transform.isPresent())
            {
                vec.x = x;
                vec.y = y;
                vec.z = z;
                vec.w = 1;
                transform.get().getMatrix().transform(vec);
                builder.put(e, vec.x, vec.y, vec.z, vec.w);
            }
            else
            {
                builder.put(e, x, y, z, 1);
            }
            break;
        case COLOR:
            builder.put(e, 1f, 1f, 1f, 1f);
            break;
        case UV: if(format.getElement(e).getIndex() == 0)
        {
            builder.put(e, u, v, 0f, 1f);
            break;
        }
        case NORMAL:
            builder.put(e, (float)side.getFrontOffsetX(), (float)side.getFrontOffsetY(), (float)side.getFrontOffsetZ(), 0f);
            break;
        default:
            builder.put(e);
            break;
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:40,代碼來源:ItemLayerModel.java


注:本文中的net.minecraft.client.renderer.vertex.VertexFormat.getElementCount方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。