net.minecraft.client.renderer.vertex.VertexFormatElement.getType()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(72)

本文整理了Java中net.minecraft.client.renderer.vertex.VertexFormatElement.getType()方法的一些代码示例,展示了VertexFormatElement.getType()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。VertexFormatElement.getType()方法的具体详情如下:
包路径:net.minecraft.client.renderer.vertex.VertexFormatElement
类名称:VertexFormatElement
方法名:getType

VertexFormatElement.getType介绍

暂无

代码示例

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

private int findPositionOffset( VertexFormat format )
  {
    List<VertexFormatElement> elements = format.getElements();
    for( int i = 0; i < elements.size(); i++ )
    {
      VertexFormatElement e = elements.get( i );
      if( e.isPositionElement() )
      {
        if( e.getType() != VertexFormatElement.EnumType.FLOAT )
        {
          throw new IllegalArgumentException( "Only floating point positions are supported" );
        }
        return i;
      }
    }

    throw new IllegalArgumentException( "Vertex format " + format + " has no position attribute!" );
  }
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

if( element.getUsage() == VertexFormatElement.EnumUsage.NORMAL )
  normalType = element.getType();

代码示例来源:origin: Direwolf20-MC/BuildingGadgets

@Override
public BufferBuilder pos(double x, double y, double z) {
  int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex);
  switch (this.vertexFormatElement.getType()) {
    case FLOAT:
      this.byteBuffer.putFloat(i, (float) (x + this.xOffset));
      this.byteBuffer.putFloat(i + 4, (float) (y + this.yOffset));
      this.byteBuffer.putFloat(i + 8, (float) (z + this.zOffset));
      break;
    case UINT:
    case INT:
      this.byteBuffer.putInt(i, Float.floatToRawIntBits((float) (x + this.xOffset)));
      this.byteBuffer.putInt(i + 4, Float.floatToRawIntBits((float) (y + this.yOffset)));
      this.byteBuffer.putInt(i + 8, Float.floatToRawIntBits((float) (z + this.zOffset)));
      break;
    case USHORT:
    case SHORT:
      this.byteBuffer.putShort(i, (short) ((int) (x + this.xOffset)));
      this.byteBuffer.putShort(i + 2, (short) ((int) (y + this.yOffset)));
      this.byteBuffer.putShort(i + 4, (short) ((int) (z + this.zOffset)));
      break;
    case UBYTE:
    case BYTE:
      this.byteBuffer.put(i, (byte) ((int) (x + this.xOffset)));
      this.byteBuffer.put(i + 1, (byte) ((int) (y + this.yOffset)));
      this.byteBuffer.put(i + 2, (byte) ((int) (z + this.zOffset)));
  }
  this.nextVertexFormatIndex();
  return this;
}

代码示例来源:origin: Direwolf20-MC/BuildingGadgets

@Override
public BufferBuilder lightmap(int p_187314_1_, int p_187314_2_) {
  int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex);
  switch (this.vertexFormatElement.getType()) {
    case FLOAT:
      this.byteBuffer.putFloat(i, p_187314_1_);
      this.byteBuffer.putFloat(i + 4, p_187314_2_);
      break;
    case UINT:
    case INT:
      this.byteBuffer.putInt(i, p_187314_1_);
      this.byteBuffer.putInt(i + 4, p_187314_2_);
      break;
    case USHORT:
    case SHORT:
      this.byteBuffer.putShort(i, (short) p_187314_2_);
      this.byteBuffer.putShort(i + 2, (short) p_187314_1_);
      break;
    case UBYTE:
    case BYTE:
      this.byteBuffer.put(i, (byte) p_187314_2_);
      this.byteBuffer.put(i + 1, (byte) p_187314_1_);
  }
  this.nextVertexFormatIndex();
  return this;
}

代码示例来源:origin: Direwolf20-MC/BuildingGadgets

@Override
public BufferBuilder normal(float x, float y, float z) {
  int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex);
  switch (this.vertexFormatElement.getType()) {
    case FLOAT:
      this.byteBuffer.putFloat(i, x);
      this.byteBuffer.putFloat(i + 4, y);
      this.byteBuffer.putFloat(i + 8, z);
      break;
    case UINT:
    case INT:
      this.byteBuffer.putInt(i, (int) x);
      this.byteBuffer.putInt(i + 4, (int) y);
      this.byteBuffer.putInt(i + 8, (int) z);
      break;
    case USHORT:
    case SHORT:
      this.byteBuffer.putShort(i, (short) ((int) (x * 32767) & 65535));
      this.byteBuffer.putShort(i + 2, (short) ((int) (y * 32767) & 65535));
      this.byteBuffer.putShort(i + 4, (short) ((int) (z * 32767) & 65535));
      break;
    case UBYTE:
    case BYTE:
      this.byteBuffer.put(i, (byte) ((int) (x * 127) & 255));
      this.byteBuffer.put(i + 1, (byte) ((int) (y * 127) & 255));
      this.byteBuffer.put(i + 2, (byte) ((int) (z * 127) & 255));
  }
  this.nextVertexFormatIndex();
  return this;
}

代码示例来源:origin: Direwolf20-MC/BuildingGadgets

@Override
public BufferBuilder tex(double u, double v) {
  int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex);
  switch (this.vertexFormatElement.getType()) {
    case FLOAT:
      this.byteBuffer.putFloat(i, (float) u);
      this.byteBuffer.putFloat(i + 4, (float) v);
      break;
    case UINT:
    case INT:
      this.byteBuffer.putInt(i, (int) u);
      this.byteBuffer.putInt(i + 4, (int) v);
      break;
    case USHORT:
    case SHORT:
      this.byteBuffer.putShort(i, (short) ((int) v));
      this.byteBuffer.putShort(i + 2, (short) ((int) u));
      break;
    case UBYTE:
    case BYTE:
      this.byteBuffer.put(i, (byte) ((int) v));
      this.byteBuffer.put(i + 1, (byte) ((int) u));
  }
  this.nextVertexFormatIndex();
  return this;
}

代码示例来源:origin: Direwolf20-MC/BuildingGadgets

switch (this.vertexFormatElement.getType()) {
  case FLOAT:
    this.byteBuffer.putFloat(i, red / 255.0F);

代码示例来源:origin: AlgorithmX2/Chisels-and-Bits

@Override
public void put(
    final int element,
    final float... data )
{
  final VertexFormatElement e = getVertexFormat().getElement( element );
  if ( e.getUsage() == EnumUsage.UV && e.getIndex() == 1 && e.getType() == EnumType.SHORT && data.length >= 2 && hasLightMap )
  {
    final int lvFromData_sky = (int) ( data[0] / maxLightmap ) & 0xf;
    final int lvFromData_block = (int) ( data[1] / maxLightmap ) & 0xf;
    lv = Math.max( lvFromData_sky, lv );
    lv = Math.max( lvFromData_block, lv );
  }
}

代码示例来源:origin: AlgorithmX2/Chisels-and-Bits

public void setVertexFormat(
    VertexFormat format )
{
  hasLightMap = false;
  int eCount = format.getElementCount();
  for ( int x = 0; x < eCount; x++ )
  {
    VertexFormatElement e = format.getElement( x );
    if ( e.getUsage() == EnumUsage.UV && e.getIndex() == 1 && e.getType() == EnumType.SHORT )
    {
      hasLightMap = true;
    }
  }
  this.format = format;
}

代码示例来源:origin: SleepyTrousers/EnderCore

switch (el.getUsage()) {
case COLOR:
 if (el.getType() == EnumType.FLOAT) {
  tes.color(v.r(), v.g(), v.b(), v.a());
 break;
case UV:
 if (el.getType() == EnumType.FLOAT && v.uv != null) {
  tes.tex(v.u(), v.v());

代码示例来源:origin: OpenMods/OpenModsLib

final int offset = vf.getOffset(i);
final int count = attr.getElementCount();
final int constant = attr.getType().getGlConstant();
final int index = attr.getIndex();
final EnumUsage usage = attr.getUsage();

代码示例来源:origin: RS485/LogisticsPipes

switch (el.getUsage()) {
  case COLOR:
    if (el.getType() == VertexFormatElement.EnumType.FLOAT) {
      tes.color(v.r(), v.g(), v.b(), v.a());
    break;
  case UV:
    if (el.getType() == VertexFormatElement.EnumType.FLOAT && v.uv != null) {
      tes.tex(v.u(), v.v());

相关文章