本文整理汇总了Java中net.minecraft.client.renderer.vertex.VertexFormat.getElement方法的典型用法代码示例。如果您正苦于以下问题:Java VertexFormat.getElement方法的具体用法?Java VertexFormat.getElement怎么用?Java VertexFormat.getElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.client.renderer.vertex.VertexFormat
的用法示例。
在下文中一共展示了VertexFormat.getElement方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: begin
import net.minecraft.client.renderer.vertex.VertexFormat; //导入方法依赖的package包/类
public void begin(int p_181668_1_, VertexFormat p_181668_2_)
{
if (this.isDrawing)
{
throw new IllegalStateException("Already building!");
}
else
{
this.isDrawing = true;
this.reset();
this.drawMode = p_181668_1_;
this.vertexFormat = p_181668_2_;
this.field_181677_f = p_181668_2_.getElement(this.field_181678_g);
this.needsUpdate = false;
this.byteBuffer.limit(this.byteBuffer.capacity());
}
}
示例2: 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;
}
示例3: begin
import net.minecraft.client.renderer.vertex.VertexFormat; //导入方法依赖的package包/类
public void begin(int glMode, VertexFormat format)
{
if (this.isDrawing)
{
throw new IllegalStateException("Already building!");
}
else
{
this.isDrawing = true;
this.reset();
this.drawMode = glMode;
this.vertexFormat = format;
this.vertexFormatElement = format.getElement(this.vertexFormatIndex);
this.noColor = false;
this.byteBuffer.limit(this.byteBuffer.capacity());
}
}
示例4: begin
import net.minecraft.client.renderer.vertex.VertexFormat; //导入方法依赖的package包/类
public void begin(int p_181668_1_, VertexFormat p_181668_2_)
{
if (this.isDrawing)
{
throw new IllegalStateException("Already building!");
}
else
{
this.isDrawing = true;
this.reset();
this.drawMode = p_181668_1_;
this.vertexFormat = p_181668_2_;
this.field_181677_f = p_181668_2_.getElement(this.field_181678_g);
this.needsUpdate = false;
this.byteBuffer.limit(this.byteBuffer.capacity());
if (Config.isMultiTexture())
{
if (this.blockLayer != null && this.quadSprites == null)
{
this.quadSprites = new TextureAtlasSprite[this.getBufferQuadSize()];
}
}
else
{
this.quadSprites = null;
}
}
}
示例5: preDraw
import net.minecraft.client.renderer.vertex.VertexFormat; //导入方法依赖的package包/类
public static void preDraw(EnumUsage attrType, VertexFormat format, int element, int stride, ByteBuffer buffer)
{
VertexFormatElement attr = format.getElement(element);
int count = attr.getElementCount();
int constant = attr.getType().getGlConstant();
buffer.position(format.getOffset(element));
switch(attrType)
{
case POSITION:
glVertexPointer(count, constant, stride, buffer);
glEnableClientState(GL_VERTEX_ARRAY);
break;
case NORMAL:
if(count != 3)
{
throw new IllegalArgumentException("Normal attribute should have the size 3: " + attr);
}
glNormalPointer(constant, stride, buffer);
glEnableClientState(GL_NORMAL_ARRAY);
break;
case COLOR:
glColorPointer(count, constant, stride, buffer);
glEnableClientState(GL_COLOR_ARRAY);
break;
case UV:
OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit + attr.getIndex());
glTexCoordPointer(count, constant, stride, buffer);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit);
break;
case PADDING:
break;
case GENERIC:
glEnableVertexAttribArray(attr.getIndex());
glVertexAttribPointer(attr.getIndex(), count, constant, false, stride, buffer);
default:
FMLLog.severe("Unimplemented vanilla attribute upload: %s", attrType.getDisplayName());
}
}
示例6: postDraw
import net.minecraft.client.renderer.vertex.VertexFormat; //导入方法依赖的package包/类
public static void postDraw(EnumUsage attrType, VertexFormat format, int element, int stride, ByteBuffer buffer)
{
VertexFormatElement attr = format.getElement(element);
switch(attrType)
{
case POSITION:
glDisableClientState(GL_VERTEX_ARRAY);
break;
case NORMAL:
glDisableClientState(GL_NORMAL_ARRAY);
break;
case COLOR:
glDisableClientState(GL_COLOR_ARRAY);
// is this really needed?
GlStateManager.resetColor();
break;
case UV:
OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit + attr.getIndex());
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit);
break;
case PADDING:
break;
case GENERIC:
glDisableVertexAttribArray(attr.getIndex());
default:
FMLLog.severe("Unimplemented vanilla attribute upload: %s", attrType.getDisplayName());
}
}
示例7: pack
import net.minecraft.client.renderer.vertex.VertexFormat; //导入方法依赖的package包/类
public static void pack(float[] from, int[] to, VertexFormat formatTo, int v, int e)
{
VertexFormatElement element = formatTo.getElement(e);
int vertexStart = v * formatTo.getNextOffset() + formatTo.getOffset(e);
int count = element.getElementCount();
VertexFormatElement.EnumType type = element.getType();
int size = type.getSize();
int mask = (256 << (8 * (size - 1))) - 1;
for(int i = 0; i < 4; i++)
{
if(i < count)
{
int pos = vertexStart + size * i;
int index = pos >> 2;
int offset = pos & 3;
int bits = 0;
float f = i < from.length ? from[i] : 0;
if(type == VertexFormatElement.EnumType.FLOAT)
{
bits = Float.floatToRawIntBits(f);
}
else if(
type == VertexFormatElement.EnumType.UBYTE ||
type == VertexFormatElement.EnumType.USHORT ||
type == VertexFormatElement.EnumType.UINT
)
{
bits = (int)(f * mask);
}
else
{
bits = (int)(f * mask / 2);
}
to[index] &= ~(mask << (offset * 8));
to[index] |= (((bits & mask) << (offset * 8)));
// TODO handle overflow into to[index + 1]
}
}
}
示例8: begin
import net.minecraft.client.renderer.vertex.VertexFormat; //导入方法依赖的package包/类
public void begin(int p_181668_1_, VertexFormat p_181668_2_)
{
if (this.isDrawing)
{
throw new IllegalStateException("Already building!");
}
else
{
this.isDrawing = true;
this.reset();
this.drawMode = p_181668_1_;
this.vertexFormat = p_181668_2_;
this.field_181677_f = p_181668_2_.getElement(this.field_181678_g);
this.needsUpdate = false;
this.byteBuffer.limit(this.byteBuffer.capacity());
if (Config.isShaders())
{
SVertexBuilder.endSetVertexFormat(this);
}
if (Config.isMultiTexture())
{
if (this.blockLayer != null)
{
if (this.quadSprites == null)
{
this.quadSprites = this.quadSpritesPrev;
}
if (this.quadSprites == null || this.quadSprites.length < this.getBufferQuadSize())
{
this.quadSprites = new TextureAtlasSprite[this.getBufferQuadSize()];
}
}
}
else
{
if (this.quadSprites != null)
{
this.quadSpritesPrev = this.quadSprites;
}
this.quadSprites = null;
}
}
}
示例9: begin
import net.minecraft.client.renderer.vertex.VertexFormat; //导入方法依赖的package包/类
public void begin(int glMode, VertexFormat format)
{
if (this.isDrawing)
{
throw new IllegalStateException("Already building!");
}
else
{
this.isDrawing = true;
this.reset();
this.drawMode = glMode;
this.vertexFormat = format;
this.vertexFormatElement = format.getElement(this.vertexFormatIndex);
this.noColor = false;
this.byteBuffer.limit(this.byteBuffer.capacity());
if (Config.isShaders())
{
SVertexBuilder.endSetVertexFormat(this);
}
if (Config.isMultiTexture())
{
if (this.blockLayer != null)
{
if (this.quadSprites == null)
{
this.quadSprites = this.quadSpritesPrev;
}
if (this.quadSprites == null || this.quadSprites.length < this.getBufferQuadSize())
{
this.quadSprites = new TextureAtlasSprite[this.getBufferQuadSize()];
}
}
}
else
{
if (this.quadSprites != null)
{
this.quadSpritesPrev = this.quadSprites;
}
this.quadSprites = null;
}
}
}
示例10: 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;
}
示例11: unpack
import net.minecraft.client.renderer.vertex.VertexFormat; //导入方法依赖的package包/类
public static void unpack(int[] from, float[] to, VertexFormat formatFrom, int v, int e)
{
int length = 4 < to.length ? 4 : to.length;
VertexFormatElement element = formatFrom.getElement(e);
int vertexStart = v * formatFrom.getNextOffset() + formatFrom.getOffset(e);
int count = element.getElementCount();
VertexFormatElement.EnumType type = element.getType();
int size = type.getSize();
int mask = (256 << (8 * (size - 1))) - 1;
for(int i = 0; i < length; i++)
{
if(i < count)
{
int pos = vertexStart + size * i;
int index = pos >> 2;
int offset = pos & 3;
int bits = from[index];
bits = bits >>> (offset * 8);
if((pos + size - 1) / 4 != index)
{
bits |= from[index + 1] << ((4 - offset) * 8);
}
bits &= mask;
if(type == VertexFormatElement.EnumType.FLOAT)
{
to[i] = Float.intBitsToFloat(bits);
}
else if(type == VertexFormatElement.EnumType.UBYTE || type == VertexFormatElement.EnumType.USHORT)
{
to[i] = (float)bits / mask;
}
else if(type == VertexFormatElement.EnumType.UINT)
{
to[i] = (float)((double)(bits & 0xFFFFFFFFL) / 0xFFFFFFFFL);
}
else if(type == VertexFormatElement.EnumType.BYTE)
{
to[i] = ((float)(byte)bits) / mask * 2;
}
else if(type == VertexFormatElement.EnumType.SHORT)
{
to[i] = ((float)(short)bits) / mask * 2;
}
else if(type == VertexFormatElement.EnumType.INT)
{
to[i] = ((float)(bits & 0xFFFFFFFFL)) / 0xFFFFFFFFL * 2;
}
}
else
{
to[i] = 0;
}
}
}