Java 类net.minecraftforge.client.model.pipeline.UnpackedBakedQuad 实例源码

项目:pnc-repressurized    文件:PressureGlassBakedModel.java   
private void putVertex(UnpackedBakedQuad.Builder builder, Vec3d normal, double x, double y, double z, TextureAtlasSprite sprite, float u, float v) {
    for (int e = 0; e < format.getElementCount(); e++) {
        switch (format.getElement(e).getUsage()) {
            case POSITION:
                builder.put(e, (float)x, (float)y, (float)z, 1.0f);
                break;
            case COLOR:
                builder.put(e, 1.0f, 1.0f, 1.0f, 1.0f);
                break;
            case UV:
                if (format.getElement(e).getIndex() == 0) {
                    u = sprite.getInterpolatedU(u);
                    v = sprite.getInterpolatedV(v);
                    builder.put(e, u, v, 0f, 1f);
                    break;
                }
            case NORMAL:
                builder.put(e, (float) normal.x, (float) normal.y, (float) normal.z, 0f);
                break;
            default:
                builder.put(e);
                break;
        }
    }
}
项目:Solar    文件:QuadBuilder.java   
private BakedQuad createQuad(QuadHolder holder, EnumFacing facing) {
    Vector4f uv = holder.uv;
    Vector3 a = holder.a;
    Vector3 b = holder.b;
    Vector3 c = holder.c;
    Vector3 d = holder.d;

    Vector3 normal = c.copy().subtract(b).cross(a.copy().subtract(b)).normalize();
    UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(format);
    putVertex(builder, normal, a.x, a.y, a.z, holder.sprite, uv.y, uv.w, hasBrightness);
    putVertex(builder, normal, b.x, b.y, b.z, holder.sprite, uv.y, uv.z, hasBrightness);
    putVertex(builder, normal, c.x, c.y, c.z, holder.sprite, uv.x, uv.z, hasBrightness);
    putVertex(builder, normal, d.x, d.y, d.z, holder.sprite, uv.x, uv.w, hasBrightness);
    builder.setQuadOrientation(facing);
    builder.setTexture(holder.sprite);
    return builder.build();
}
项目:CustomWorldGen    文件:ItemTextureQuadConverter.java   
/**
 * Generates a Front/Back quad for an itemmodel. Therefore only supports facing NORTH and SOUTH.
 * Coordinates are [0,16] to match the usual coordinates used in TextureAtlasSprites
 */
public static UnpackedBakedQuad genQuad(VertexFormat format, TRSRTransformation transform, float x1, float y1, float x2, float y2, float z, TextureAtlasSprite sprite, EnumFacing facing, int color)
{
    float u1 = sprite.getInterpolatedU(x1);
    float v1 = sprite.getInterpolatedV(y1);
    float u2 = sprite.getInterpolatedU(x2);
    float v2 = sprite.getInterpolatedV(y2);

    x1 /= 16f;
    y1 /= 16f;
    x2 /= 16f;
    y2 /= 16f;

    float tmp = y1;
    y1 = 1f - y2;
    y2 = 1f - tmp;

    return putQuad(format, transform, facing, sprite, color, x1, y1, x2, y2, z, u1, v1, u2, v2);
}
项目:CustomWorldGen    文件:ItemTextureQuadConverter.java   
private static UnpackedBakedQuad putQuad(VertexFormat format, TRSRTransformation transform, EnumFacing side, TextureAtlasSprite sprite, int color,
                                         float x1, float y1, float x2, float y2, float z,
                                         float u1, float v1, float u2, float v2)
{
    side = side.getOpposite();
    UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(format);
    builder.setQuadTint(-1);
    builder.setQuadOrientation(side);
    builder.setTexture(sprite);

    if (side == EnumFacing.NORTH)
    {
        putVertex(builder, format, transform, side, x1, y1, z, u1, v2, color);
        putVertex(builder, format, transform, side, x2, y1, z, u2, v2, color);
        putVertex(builder, format, transform, side, x2, y2, z, u2, v1, color);
        putVertex(builder, format, transform, side, x1, y2, z, u1, v1, color);
    } else
    {
        putVertex(builder, format, transform, side, x1, y1, z, u1, v2, color);
        putVertex(builder, format, transform, side, x1, y2, z, u1, v1, color);
        putVertex(builder, format, transform, side, x2, y2, z, u2, v1, color);
        putVertex(builder, format, transform, side, x2, y1, z, u2, v2, color);
    }
    return builder.build();
}
项目:CustomWorldGen    文件:ItemLayerModel.java   
private static final BakedQuad buildQuad(
    VertexFormat format, Optional<TRSRTransformation> transform, EnumFacing side, TextureAtlasSprite sprite, int tint,
    float x0, float y0, float z0, float u0, float v0,
    float x1, float y1, float z1, float u1, float v1,
    float x2, float y2, float z2, float u2, float v2,
    float x3, float y3, float z3, float u3, float v3)
{
    UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(format);
    builder.setQuadTint(tint);
    builder.setQuadOrientation(side);
    builder.setTexture(sprite);
    putVertex(builder, format, transform, side, x0, y0, z0, u0, v0);
    putVertex(builder, format, transform, side, x1, y1, z1, u1, v1);
    putVertex(builder, format, transform, side, x2, y2, z2, u2, v2);
    putVertex(builder, format, transform, side, x3, y3, z3, u3, v3);
    return builder.build();
}
项目:ExPetrum    文件:ModelIngotBaked.java   
@Override
  public List<BakedQuad> getQuads(IBlockState blockState, EnumFacing side, long rand)
  {
      if (this.hackedQuads == null)
      {
          List<BakedQuad> wrappedQuads = this.model.getQuads(blockState, side, rand);
          if (!wrappedQuads.isEmpty())
          {
              List<BakedQuad> ret = new ArrayList<>(wrappedQuads.size());
              wrappedQuads.forEach(q -> ret.add(q instanceof UnpackedBakedQuad ? new WrappedQuad((UnpackedBakedQuad) q) : q));
              hackedQuads = ImmutableList.copyOf(ret);
          }
          else
          {
              return wrappedQuads;
          }
      }

return this.hackedQuads;
  }
项目:BetterWithAddons    文件:ModelToolShardInner.java   
private static final BakedQuad buildQuad(
        VertexFormat format, Optional<TRSRTransformation> transform, EnumFacing side, TextureAtlasSprite sprite, int tint, int color,
        float x0, float y0, float z0, float u0, float v0,
        float x1, float y1, float z1, float u1, float v1,
        float x2, float y2, float z2, float u2, float v2,
        float x3, float y3, float z3, float u3, float v3)
{
    UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(format);
    builder.setQuadTint(tint);
    builder.setQuadOrientation(side);
    builder.setTexture(sprite);
    putVertex(builder, format, transform, side, color, x0, y0, z0, u0, v0);
    putVertex(builder, format, transform, side, color, x1, y1, z1, u1, v1);
    putVertex(builder, format, transform, side, color, x2, y2, z2, u2, v2);
    putVertex(builder, format, transform, side, color, x3, y3, z3, u3, v3);
    return builder.build();
}
项目:CrystalMod    文件:ModelCustomLayers.java   
private static final BakedQuad buildQuad(
    VertexFormat format, Optional<TRSRTransformation> transform, EnumFacing side, TextureAtlasSprite sprite, int color,
    float x0, float y0, float z0, float u0, float v0,
    float x1, float y1, float z1, float u1, float v1,
    float x2, float y2, float z2, float u2, float v2,
    float x3, float y3, float z3, float u3, float v3)
{
    UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(format);
    builder.setQuadTint(-1);
    builder.setQuadOrientation(side);
    builder.setTexture(sprite);
    putVertex(builder, format, transform, side, color, x0, y0, z0, u0, v0);
    putVertex(builder, format, transform, side, color, x1, y1, z1, u1, v1);
    putVertex(builder, format, transform, side, color, x2, y2, z2, u2, v2);
    putVertex(builder, format, transform, side, color, x3, y3, z3, u3, v3);
    return builder.build();
}
项目:CodeChickenLib    文件:VertexDataUtils.java   
public static BakedQuad buildQuad(VertexFormat format, TextureAtlasSprite sprite, EnumFacing face, Colour colour, UVTransformation t, Vertex5 v1, Vertex5 v2, Vertex5 v3, Vertex5 v4) {
    UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(format);
    builder.setQuadTint(-1);
    builder.setQuadOrientation(face);
    builder.setTexture(sprite);

    t.apply(v1.uv);
    t.apply(v2.uv);
    t.apply(v3.uv);
    t.apply(v4.uv);
    putVertex(builder, format, face, v1, colour);
    putVertex(builder, format, face, v2, colour);
    putVertex(builder, format, face, v3, colour);
    putVertex(builder, format, face, v4, colour);

    return copyQuad(builder.build());
}
项目:CodeChickenLib    文件:VertexDataUtils.java   
private static void putVertex(UnpackedBakedQuad.Builder builder, VertexFormat format, EnumFacing face, Vertex5 vert, Colour colour) {
    for (int e = 0; e < format.getElementCount(); e++) {
        VertexFormatElement element = format.getElement(e);
        switch (element.getUsage()) {

            case POSITION:
                Vector3 vec = vert.vec;
                builder.put(e, (float) vec.x, (float) vec.y, (float) vec.z, 1);
                break;
            case NORMAL:
                builder.put(e, face.getFrontOffsetX(), face.getFrontOffsetY(), face.getFrontOffsetZ(), 0);
                break;
            case COLOR:
                builder.put(e, (colour.r & 0xFF) / 255F, (colour.g & 0xFF) / 255F, (colour.b & 0xFF) / 255F, (colour.a & 0xFF) / 255F);
                break;
            case UV:
                UV uv = vert.uv;
                builder.put(e, (float) uv.u, (float) uv.v, 0, 1);
                break;
            default:
                builder.put(e);
                break;
        }
    }
}
项目:InfinityLib    文件:ItemQuadGenerator.java   
public static UnpackedBakedQuad genQuad(VertexFormat format, TRSRTransformation transform, float x1, float y1, float x2, float y2, float u1, float v1, float u2, float v2, float z, TextureAtlasSprite sprite, EnumFacing facing, int color) {
    u1 = sprite.getInterpolatedU(u1);
    v1 = sprite.getInterpolatedV(v1);
    u2 = sprite.getInterpolatedU(u2);
    v2 = sprite.getInterpolatedV(v2);

    x1 /= 16f;
    y1 /= 16f;
    x2 /= 16f;
    y2 /= 16f;

    float tmp = y1;
    y1 = 1f - y2;
    y2 = 1f - tmp;

    return putQuad(format, transform, facing, color, x1, y1, x2, y2, z, u1, v1, u2, v2);
}
项目:InfinityLib    文件:ItemQuadGenerator.java   
private static UnpackedBakedQuad putQuad(VertexFormat format, TRSRTransformation transform, EnumFacing side, int color,
        float x1, float y1, float x2, float y2, float z,
        float u1, float v1, float u2, float v2) {
    side = side.getOpposite();
    UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(format);
    builder.setQuadTint(-1);
    builder.setQuadOrientation(side);

    if (side == EnumFacing.NORTH) {
        putVertex(builder, format, transform, side, x1, y1, z, u1, v2, color);
        putVertex(builder, format, transform, side, x2, y1, z, u2, v2, color);
        putVertex(builder, format, transform, side, x2, y2, z, u2, v1, color);
        putVertex(builder, format, transform, side, x1, y2, z, u1, v1, color);
    } else {
        putVertex(builder, format, transform, side, x1, y1, z, u1, v2, color);
        putVertex(builder, format, transform, side, x1, y2, z, u1, v1, color);
        putVertex(builder, format, transform, side, x2, y2, z, u2, v1, color);
        putVertex(builder, format, transform, side, x2, y1, z, u2, v2, color);
    }
    return builder.build();
}
项目:InfinityLib    文件:VertexData.java   
private void applyVertexDataForType(int index, VertexFormatElement.EnumUsage type, UnpackedBakedQuad.Builder builder) {
    switch (type) {
        case POSITION:
            builder.put(index, x, y, z, 1);
            break;
        case UV:
            builder.put(index, u, v, 0, 1);
            break;
        case COLOR:
            builder.put(index, r, g, b, a);
            break;
        case NORMAL:
            builder.put(index, nX, nY, nZ, 0);
            break;
        case PADDING:
            //TODO: figure this one out
            builder.put(index);
            break;
        case GENERIC:
            //TODO: figure this one out
            builder.put(index);

    }
}
项目:InfinityLib    文件:TessellatorAbstractBase.java   
public final UnpackedBakedQuad transformQuad(BakedQuad quad) {
    // Fetch required information
    final VertexFormat format = quad.getFormat();
    final float[][][] vertexData = new float[4][format.getElementCount()][4];

    // Objects to be reused in the loop
    final Vector4f temp = new Vector4f();

    //unpack and transform vertex data
    for (int v = 0; v < 4; v++) {
        for (int e = 0; e < format.getElementCount(); e++) {
            LightUtil.unpack(quad.getVertexData(), vertexData[v][e], format, v, e);
            transformUnpackedVertexDataElement(format.getElement(e).getUsage(), vertexData[v][e], temp);
        }
    }
    //create new quad with the transformed vertex data
    return new UnpackedBakedQuad(vertexData, quad.getTintIndex(), quad.getFace(), quad.getSprite(), quad.shouldApplyDiffuseLighting(), format);
}
项目:AquaMunda    文件:TankBakedModel.java   
private void putVertex(UnpackedBakedQuad.Builder builder, Vec3d normal, double x, double y, double z, float u, float v) {
    for (int e = 0; e < format.getElementCount(); e++) {
        switch (format.getElement(e).getUsage()) {
            case POSITION:
                builder.put(e, (float)x, (float)y, (float)z, 1.0f);
                break;
            case COLOR:
                builder.put(e, 1.0f, 1.0f, 1.0f, 1.0f);
                break;
            case UV:
                if (format.getElement(e).getIndex() == 0) {
                    u = sprite.getInterpolatedU(u);
                    v = sprite.getInterpolatedV(v);
                    builder.put(e, u, v, 0f, 1f);
                    break;
                }
            case NORMAL:
                builder.put(e, (float) normal.xCoord, (float) normal.yCoord, (float) normal.zCoord, 0f);
                break;
            default:
                builder.put(e);
                break;
        }
    }
}
项目:MrCrayfishSkateboardingMod    文件:QuadHelper.java   
public BakedQuad createQuad(Vertex v1, Vertex v2, Vertex v3, Vertex v4, EnumFacing face)
{
    v1 = rotate(v1, facing);
    v2 = rotate(v2, facing);
    v3 = rotate(v3, facing);
    v4 = rotate(v4, facing);
    face = rotateFacing(face);

    Vec3d normal = v1.getVec3d().subtract(v2.getVec3d()).crossProduct(v3.getVec3d().subtract(v2.getVec3d()));

       UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(format);
       builder.setTexture(sprite);
       builder.setQuadOrientation(face);

       putVertex(builder, face, normal, v1.x, v1.y, v1.z, v1.u, v1.v);
       putVertex(builder, face, normal, v2.x, v2.y, v2.z, v2.u, v2.v);
       putVertex(builder, face, normal, v3.x, v3.y, v3.z, v3.u, v3.v);
       putVertex(builder, face, normal, v4.x, v4.y, v4.z, v4.u, v4.v);

       return builder.build();
}
项目:MrCrayfishSkateboardingMod    文件:QuadHelper.java   
public BakedQuad createQuad(Vertex v1, Vertex v2, Vertex v3, Vertex v4, EnumFacing face)
{
    v1 = rotate(v1, facing);
    v2 = rotate(v2, facing);
    v3 = rotate(v3, facing);
    v4 = rotate(v4, facing);
    face = rotateFacing(face);

    Vec3d normal = v1.getVec3d().subtract(v2.getVec3d()).crossProduct(v3.getVec3d().subtract(v2.getVec3d()));

       UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(format);
       builder.setTexture(sprite);
       builder.setQuadOrientation(face);

       putVertex(builder, face, normal, v1.x, v1.y, v1.z, v1.u, v1.v);
       putVertex(builder, face, normal, v2.x, v2.y, v2.z, v2.u, v2.v);
       putVertex(builder, face, normal, v3.x, v3.y, v3.z, v3.u, v3.v);
       putVertex(builder, face, normal, v4.x, v4.y, v4.z, v4.u, v4.v);

       return builder.build();
}
项目:MCAnm    文件:PartDirect.java   
@Override
public void getAsBakedQuads(Map<String, TextureAtlasSprite> slotToTex, VertexFormat format, List<BakedQuad> out) {
    TextureAtlasSprite tex = retrieveSprite(slotToTex);
    for (int i = 0; i < indices.length; i += 3) {
        Point point1 = pointsList[indices[i]];
        Point point2 = pointsList[indices[i + 1]];
        Point point3 = pointsList[indices[i + 2]];
        UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(format);
        point1.putIntoBakedQuadBuilder(builder, tex);
        point2.putIntoBakedQuadBuilder(builder, tex);
        point3.putIntoBakedQuadBuilder(builder, tex);
        point1.putIntoBakedQuadBuilder(builder, tex);
        builder.setTexture(tex);
        out.add(builder.build());
    }
}
项目:OpenBlocks    文件:StencilCoverQuadBuilder.java   
private void addQuad(final UnpackedBakedQuad.Builder builder, EnumFacing face, TextureAtlasSprite sprite, Vertex position, Vertex texture) {
    for (int e = 0; e < format.getElementCount(); e++) {
        final VertexFormatElement el = format.getElement(e);
        switch (el.getUsage()) {
            case POSITION:
                builder.put(e, position.x, position.y, position.z);
                break;
            case NORMAL:
                builder.put(e, face.getFrontOffsetX(), face.getFrontOffsetY(), face.getFrontOffsetZ());
                break;
            case COLOR:
                builder.put(e, 1, 1, 1, 1);
                break;
            case UV:
                if (el.getIndex() == 0) {
                    builder.put(e, sprite.getInterpolatedU(16 * texture.u), sprite.getInterpolatedV(16 * texture.v));
                } else {
                    builder.put(e, 0, 0);
                }
                break;
            default:
                builder.put(e);
        }
    }
}
项目:EnderIO    文件:HalfBakedQuad.java   
public void bake(@Nonnull List<BakedQuad> quads) {
  float w01 = 1;
  float w23 = 1;

  if (hasMojangFixedUVXWTextureCoords && face != EnumFacing.DOWN && face != EnumFacing.UP) {
    // assuming the first vertex is upper-left or lower-right
    w01 = (float) corners.get(0).xyz.distance(corners.get(1).xyz);
    w23 = (float) corners.get(2).xyz.distance(corners.get(3).xyz);
  }

  UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(DefaultVertexFormats.ITEM); // this one has normals
  builder.setQuadOrientation(face);
  builder.setTexture(tex);
  putVertexData(builder, corners.get(0), w01);
  putVertexData(builder, corners.get(1), w01);
  putVertexData(builder, corners.get(2), w23);
  putVertexData(builder, corners.get(3), w23);
  quads.add(builder.build());
}
项目:pnc-repressurized    文件:PressureGlassBakedModel.java   
private BakedQuad createQuad(Vec3d v1, Vec3d v2, Vec3d v3, Vec3d v4, TextureAtlasSprite sprite) {
    Vec3d normal = v3.subtract(v2).crossProduct(v1.subtract(v2)).normalize();

    UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(format);
    builder.setTexture(sprite);
    putVertex(builder, normal, v1.x, v1.y, v1.z, sprite, 0, 0);
    putVertex(builder, normal, v2.x, v2.y, v2.z, sprite, 0, 16);
    putVertex(builder, normal, v3.x, v3.y, v3.z, sprite, 16, 16);
    putVertex(builder, normal, v4.x, v4.y, v4.z, sprite, 16, 0);
    return builder.build();
}
项目:Solar    文件:QuadBuilder.java   
private void putVertex(UnpackedBakedQuad.Builder builder, Vector3 normal, double x, double y, double z, TextureAtlasSprite sprite, float u, float v, boolean hasBrightness) {
    for(int e = 0; e < format.getElementCount(); e++) {
        switch(format.getElement(e).getUsage()) {
            case POSITION:
                builder.put(e, (float) x, (float) y, (float) z, 1F);
                break;
            case COLOR:
                builder.put(e, 1F, 1F, 1F, 1F);
                break;
            case UV:
                if(!ClientProxy.isOptifineInstalled() && format.getElement(e).getIndex() == 1) {
                    if(hasBrightness) {
                        builder.put(e, 1F, 1F);
                    } else {
                        builder.put(e, 0F, 0F);
                    }
                    break;
                } else if(format.getElement(e).getIndex() == 0) {
                    u = sprite.getInterpolatedU(u);
                    v = sprite.getInterpolatedV(v);
                    builder.put(e, u, v, 0F, 1F);
                    break;
                }
            case NORMAL:
                if(!ClientProxy.isOptifineInstalled() && hasBrightness) {
                    builder.put(e, 0F, 1F, 0F);
                } else {
                    builder.put(e, (float) normal.x, (float) normal.y, (float) normal.z);
                }
                break;
            default:
                builder.put(e);
                break;
        }
    }
}
项目:SimpleTubes    文件:ModelFactory.java   
protected static void putVertexData(UnpackedBakedQuad.Builder builder, Vector3f pos, EnumFacing facing, float u, float v, TextureAtlasSprite sprite, Color col, TRSRTransformation transform) {
    for (int e = 0; e < builder.getVertexFormat().getElementCount(); e++)
        switch (builder.getVertexFormat().getElement(e).getUsage()) {
            case POSITION:
                if (transform == TRSRTransformation.identity()) {
                    builder.put(e, pos.getX(), pos.getY(), pos.getZ(), 1F);
                } else {
                    Vector4f vec = new Vector4f();
                    vec.x = pos.x;
                    vec.y = pos.y;
                    vec.z = pos.z;
                    vec.w = 1;

                    transform.getMatrix().transform(vec);
                    builder.put(e, vec.x, vec.y, vec.z, vec.w);
                }
                break;
            case COLOR:
                float r = ((col.getRGB() >> 16) & 0xFF) / 255f; // red
                float g = ((col.getRGB()>> 8) & 0xFF) / 255f; // green
                float b = ((col.getRGB() >> 0) & 0xFF) / 255f; // blue
                float a = ((col.getRGB() >> 24) & 0xFF) / 255f; // alpha
                builder.put(e, r, g, b, a);
                break;
            case UV:

                if (builder.getVertexFormat().getElement(e).getIndex() == 0) {
                    builder.put(e, u, v, 0F, 1F);
                    break;
                }
                break;
            case NORMAL:
                Normal normal = new Normal(facing.getDirectionVec().getX(), facing.getDirectionVec().getY(), facing.getDirectionVec().getZ());
                builder.put(e, normal.x, normal.y, normal.z, 0);
                break;
            default:
                builder.put(e);
        }
}
项目:CustomWorldGen    文件:ModelFluid.java   
private void putVertex(UnpackedBakedQuad.Builder builder, EnumFacing side, float x, float y, float z, float u, float v)
{
    for(int e = 0; e < format.getElementCount(); e++)
    {
        switch(format.getElement(e).getUsage())
        {
        case POSITION:
            float[] data = new float[]{ x - side.getDirectionVec().getX() * eps, y, z - side.getDirectionVec().getZ() * eps, 1 };
            if(transformation.isPresent() && transformation.get() != TRSRTransformation.identity())
            {
                Vector4f vec = new Vector4f(data);
                transformation.get().getMatrix().transform(vec);
                vec.get(data);
            }
            builder.put(e, data);
            break;
        case COLOR:
            builder.put(e,
                ((color >> 16) & 0xFF) / 255f,
                ((color >> 8) & 0xFF) / 255f,
                (color & 0xFF) / 255f,
                ((color >> 24) & 0xFF) / 255f);
            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;
        }
    }
}
项目:Qbar    文件:ModelTransformer.java   
private static BakedQuad transform(final BakedQuad quad, final IVertexTransformer transformer)
{
    final VertexFormat format = quad.getFormat();
    final UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(format);
    LightUtil.putBakedQuad(new VertexTransformerWrapper(builder, quad, transformer), quad);
    return builder.build();
}
项目:Qbar    文件:QBarBakedOBJModel.java   
private final void putVertexData(UnpackedBakedQuad.Builder builder, OBJModel.Vertex v, OBJModel.Normal faceNormal,
                                 OBJModel.TextureCoordinate defUV, TextureAtlasSprite sprite)
{
    for (int e = 0; e < format.getElementCount(); e++)
    {
        switch (format.getElement(e).getUsage())
        {
            case POSITION:
                builder.put(e, v.getPos().x, v.getPos().y, v.getPos().z, v.getPos().w);
                break;
            case COLOR:
                if (v.getMaterial() != null)
                    builder.put(e, v.getMaterial().getColor().x, v.getMaterial().getColor().y,
                            v.getMaterial().getColor().z, v.getMaterial().getColor().w);
                else
                    builder.put(e, 1, 1, 1, 1);
                break;
            case UV:
                if (!v.hasTextureCoordinate())
                    builder.put(e, sprite.getInterpolatedU(defUV.u * 16),
                            sprite.getInterpolatedV((1 - defUV.v) * 16), 0, 1);
                else
                    builder.put(e, sprite.getInterpolatedU(v.getTextureCoordinate().u * 16),
                            sprite.getInterpolatedV((1 - v.getTextureCoordinate().v) * 16), 0, 1);
                break;
            case NORMAL:
                if (!v.hasNormal())
                    builder.put(e, faceNormal.x, faceNormal.y, faceNormal.z, 0);
                else
                    builder.put(e, v.getNormal().x, v.getNormal().y, v.getNormal().z, 0);
                break;
            default:
                builder.put(e);
        }
    }
}
项目:CodeChickenLib    文件:CCQuad.java   
public BakedQuad bake(VertexFormat format) {
    quadulate();
    computeNormals();
    UnpackedBakedQuad.Builder quadBuilder = new UnpackedBakedQuad.Builder(format);
    pipe(quadBuilder);
    return quadBuilder.build();
}
项目:InfinityLib    文件:ItemQuadGenerator.java   
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;
        }
    }
}
项目:InfinityLib    文件:ModelTechne.java   
private BakedQuad createBakedQuad(VertexFormat format, ModelRenderer renderer, TexturedQuad quad, Matrix4f matrix, float scale, TextureAtlasSprite icon) {
    //Transformation
    loadRenderMatrix(renderer, matrix, scale);

    //normal for the quad
    Vec3d vec3d = quad.vertexPositions[1].vector3D.subtractReverse(quad.vertexPositions[0].vector3D);
    Vec3d vec3d1 = quad.vertexPositions[1].vector3D.subtractReverse(quad.vertexPositions[2].vector3D);
    Vec3d vec3d2 = vec3d1.crossProduct(vec3d).normalize();
    final Vector4f normal = new Vector4f((float) vec3d2.x, (float) vec3d2.y, (float) vec3d2.z, 1);
    matrix.transform(normal);
    final Vector4f pos = new Vector4f();

    //define vertex data for the quad
    VertexData[] vertexData = new VertexData[quad.vertexPositions.length];
    for (int i = 0; i < vertexData.length; i++) {
        PositionTextureVertex vertex = quad.vertexPositions[i];
        vertexData[i] = new VertexData(format);
        pos.set((float) vertex.vector3D.x * scale, (float) vertex.vector3D.y * scale, (float) vertex.vector3D.z * scale, 1);
        matrix.transform(pos);
        vertexData[i].setXYZ(pos.x, pos.y, pos.z);
        vertexData[i].setRGBA(1, 1, 1, 1);
        vertexData[i].setNormal(normal.x, normal.y, normal.z);
        if (icon != null) {
            vertexData[i].setUV(icon.getInterpolatedU(vertex.texturePositionX * 16), icon.getInterpolatedV(vertex.texturePositionY * 16));
        } else {
            vertexData[i].setUV(vertex.texturePositionX, vertex.texturePositionY);
        }
    }

    //build and return the quad
    UnpackedBakedQuad.Builder quadBuilder = new UnpackedBakedQuad.Builder(format);
    quadBuilder.setTexture(icon);
    quadBuilder.setApplyDiffuseLighting(this.getDiffuseLighting());
    for (VertexData data : vertexData) {
        data.applyVertexData(quadBuilder);
    }
    return quadBuilder.build();
}
项目:InfinityLib    文件:TessellatorBakedQuad.java   
/**
 * Adds a vertex
 *
 * @param x the x-coordinate for the vertex
 * @param y the y-coordinate for the vertex
 * @param z the z-coordinate for the vertex
 * @param u u value for the vertex
 * @param v v value for the vertex
 */
@Override
public void addVertexWithUV(float x, float y, float z, float u, float v) {
    if (drawMode == DRAW_MODE_NOT_DRAWING) {
        throw new RuntimeException("NOT CONSTRUCTING VERTICES");
    }

    // Create and transform the point.
    final Vector4f pos = new Vector4f(x, y, z, 1);
    this.transform(pos);

    // Create the new vertex data element.
    final VertexData vert = new VertexData(getVertexFormat());
    vert.setXYZ(pos.x, pos.y, pos.z);
    vert.setUV(u, v);
    vert.setRGBA(r, g, b, a);
    vert.setNormal(normal.x, normal.y, normal.z);
    vertexData.add(vert);

    if (vertexData.size() == drawMode) {
        final EnumFacing dir = EnumFacing.getFacingFromVector(normal.x, normal.y, normal.z);
        if (dir == this.face) {
            UnpackedBakedQuad.Builder quadBuilder = new UnpackedBakedQuad.Builder(getVertexFormat());
            quadBuilder.setQuadTint(getTintIndex());
            quadBuilder.setApplyDiffuseLighting(getApplyDiffuseLighting());
            quadBuilder.setQuadOrientation(dir);
            quadBuilder.setTexture(this.icon);
            for (VertexData vertex : vertexData) {
                vertex.applyVertexData(quadBuilder);
            }
            quads.add(quadBuilder.build());
        }
        vertexData.clear();
    }
}
项目:Factorization    文件:ShaftModel.java   
protected void reset() {
    tint  = -1;
    orientation = null;
    colored = false;
    bakery = new UnpackedBakedQuad.Builder(format);
    dropQuad = false;
    resetPass();
}
项目:Factorization    文件:SocketModel.java   
private Impl(TRSRTransformation transform, VertexFormat format) {
    super(new UnpackedBakedQuad.Builder(format));
    this.transform = transform.getMatrix();
    Vector3f vtr = transform.getTranslation();
    this.invTranslate = new Matrix3f();
    this.invTranslate.transform(vtr);
    this.invTranslate.setIdentity();
    this.builder = (UnpackedBakedQuad.Builder) super.parent;
    this.format = format;
}
项目:Factorization    文件:SocketModel.java   
private Impl(Impl orig) {
    super(new UnpackedBakedQuad.Builder(orig.format));
    this.format = orig.format;
    this.builder = (UnpackedBakedQuad.Builder) super.parent;
    this.transform = orig.transform;
    this.invTranslate = orig.invTranslate;
}
项目:AquaMunda    文件:TankBakedModel.java   
private BakedQuad createQuad(Vec3d v1, Vec3d v2, Vec3d v3, Vec3d v4) {
    Vec3d normal = v2.subtract(v1).crossProduct(v3.subtract(v1)).normalize();

    UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(format);
    builder.setTexture(sprite);
    putVertex(builder, normal, v1.xCoord, v1.yCoord, v1.zCoord, 0, 0);
    putVertex(builder, normal, v2.xCoord, v2.yCoord, v2.zCoord, 0, 16);
    putVertex(builder, normal, v3.xCoord, v3.yCoord, v3.zCoord, 16, 16);
    putVertex(builder, normal, v4.xCoord, v4.yCoord, v4.zCoord, 16, 0);
    return builder.build();
}
项目:MrCrayfishSkateboardingMod    文件:QuadHelper.java   
private void putVertex(UnpackedBakedQuad.Builder builder, EnumFacing side, Vec3d normal, double x, double y, double z, float u, float v) 
{
       for (int i = 0; i < format.getElementCount(); i++) 
       {
           switch (format.getElement(i).getUsage()) 
           {
               case POSITION:
                   builder.put(i, (float) x, (float) y, (float) z, 1.0F);
                   break;
               case COLOR:
                   builder.put(i, 1.0F, 1.0F, 1.0F, 1.0F);
                   break;
               case UV: if (format.getElement(i).getIndex() == 0) 
               {
                   u = sprite.getInterpolatedU(u);
                   v = sprite.getInterpolatedV(v);
                   builder.put(i, u, v, 0.0F, 1.0F);
                   break;
               }
               case NORMAL:
                   builder.put(i, (float) side.getFrontOffsetX(), (float) side.getFrontOffsetY(), (float) side.getFrontOffsetZ(), 0.0F);
                   break;
               default:
                   builder.put(i);
                   break;
           }
       }
   }
项目:TFC2    文件:TRSRBakedModel.java   
public Transformer(TRSRTransformation transformation, VertexFormat format) {
    super(new UnpackedBakedQuad.Builder(format));
    // position transform
    this.transformation = transformation.getMatrix();
    // normal transform
    this.normalTransformation = new Matrix3f();
    this.transformation.getRotationScale(this.normalTransformation);
    this.normalTransformation.invert();
    this.normalTransformation.transpose();
}
项目:MrCrayfishSkateboardingMod    文件:QuadHelper.java   
private void putVertex(UnpackedBakedQuad.Builder builder, EnumFacing side, Vec3d normal, double x, double y, double z, float u, float v) 
{
       for (int i = 0; i < format.getElementCount(); i++) 
       {
           switch (format.getElement(i).getUsage()) 
           {
               case POSITION:
                   builder.put(i, (float) x, (float) y, (float) z, 1.0F);
                   break;
               case COLOR:
                   builder.put(i, 1.0F, 1.0F, 1.0F, 1.0F);
                   break;
               case UV: if (format.getElement(i).getIndex() == 0) 
               {
                   u = sprite.getInterpolatedU(u);
                   v = sprite.getInterpolatedV(v);
                   builder.put(i, u, v, 0.0F, 1.0F);
                   break;
               }
               case NORMAL:
                   builder.put(i, (float) side.getFrontOffsetX(), (float) side.getFrontOffsetY(), (float) side.getFrontOffsetZ(), 0.0F);
                   break;
               default:
                   builder.put(i);
                   break;
           }
       }
   }
项目:taam    文件:OBJModel.java   
private final void putVertexData(UnpackedBakedQuad.Builder builder, Vertex v, Vector3f defUV, TextureAtlasSprite sprite)
{
    for (int e = 0; e < format.getElementCount(); e++)
    {
        switch (format.getElement(e).getUsage())
        {
            case POSITION:
                builder.put(e, v.getPos().x, v.getPos().y, v.getPos().z, v.getPos().w);
                break;
            case COLOR:
                builder.put(e,
                        v.getMaterial().getColor().x,
                        v.getMaterial().getColor().y,
                        v.getMaterial().getColor().z,
                        v.getMaterial().getColor().w);
                break;
            case UV:
                if (this.model.customData.useFullAtlas)
                    builder.put(e, defUV.x, defUV.y, 0, 1);
                else if (sprite.equals(ModelLoader.White.INSTANCE))
                    builder.put(e,
                            sprite.getInterpolatedU(defUV.x * 16),
                            sprite.getInterpolatedV(defUV.y * 16),
                            0, 1);
                else
                    builder.put(e,
                            sprite.getInterpolatedU(v.getTextureCoordinate().x * 16),
                            sprite.getInterpolatedV(v.getTextureCoordinate().y * 16),
                            0, 1);
                break;
            case NORMAL:
                builder.put(e, v.getNormal().x, v.getNormal().y, v.getNormal().z, 0);
                break;
            default:
                builder.put(e);
        }
    }
}
项目:TFC2    文件:TRSRBakedModel.java   
public Transformer(TRSRTransformation transformation, VertexFormat format) {
    super(new UnpackedBakedQuad.Builder(format));
    // position transform
    this.transformation = transformation.getMatrix();
    // normal transform
    this.normalTransformation = new Matrix3f();
    this.transformation.getRotationScale(this.normalTransformation);
    this.normalTransformation.invert();
    this.normalTransformation.transpose();
}
项目:MCAnm    文件:Point.java   
public void putIntoBakedQuadBuilder(UnpackedBakedQuad.Builder builder, TextureAtlasSprite sprite) {
    Vertex transformed = getTransformedVertex();
    Tuple4f positionBuffer = new Vector4f();
    transformed.getPosition(positionBuffer);
    Tuple3f normalBuffer = new Vector3f();
    transformed.getNormal(normalBuffer);
    Tuple2f uvBuffer = new Vector2f();
    transformed.getUV(uvBuffer);

    VertexFormat vertexFormat = builder.getVertexFormat();
    int elementCount = vertexFormat.getElementCount();
    for (int e = 0; e < elementCount; e++) {
        VertexFormatElement element = vertexFormat.getElement(e);
        switch (element.getUsage()) {
        case POSITION:
            builder.put(e, positionBuffer.x, positionBuffer.z, -positionBuffer.y, positionBuffer.w);
            break;
        case NORMAL:
            builder.put(e, normalBuffer.x, normalBuffer.z, -normalBuffer.y, 0);
            break;
        case UV:
            if (element.getIndex() != 0)
                break;
            builder.put(
                    e,
                    sprite.getInterpolatedU(uvBuffer.x * 16),
                    sprite.getInterpolatedV(uvBuffer.y * 16),
                    0,
                    1);
            break;
        case COLOR:
            builder.put(e, 1, 1, 1, 1);
            break;
        default:
            builder.put(e);
        }
    }
}