Search in sources :

Example 1 with RenderPatchFactory

use of org.dynmap.renderer.RenderPatchFactory in project dynmap by webbukkit.

the class RPSupportFrameRenderer method getRenderPatchList.

@Override
public RenderPatch[] getRenderPatchList(MapDataContext ctx) {
    int covermask = 0;
    Object v = ctx.getBlockTileEntityField("cvm");
    if (v instanceof Integer) {
        covermask = ((Integer) v).intValue();
    }
    RenderPatchFactory rpf = ctx.getPatchFactory();
    ArrayList<RenderPatch> list = new ArrayList<RenderPatch>();
    /* Use mask to add right sides first */
    /* Add top */
    list.add(rpf.getPatch(0, 1.001, 1, 1, 1.001, 1, 0, 1.001, 0, 0, 1, 0, 1, SideVisible.BOTH, ((covermask & 0x02) != 0) ? frame_txt_edge : frame_txt_side));
    /* Add bottom */
    list.add(rpf.getPatch(0, -0.001, 1, 1, -0.001, 1, 0, -0.001, 0, 0, 1, 0, 1, SideVisible.BOTH, ((covermask & 0x01) != 0) ? frame_txt_edge : frame_txt_side));
    /* Add minX side */
    list.add(rpf.getPatch(-0.001, 0, 0, -0.001, 0, 1, -0.001, 1, 0, 0, 1, 0, 1, SideVisible.BOTH, ((covermask & 0x10) != 0) ? frame_txt_edge : frame_txt_side));
    /* Add maxX side */
    list.add(rpf.getPatch(1.001, 0, 1, 1.001, 0, 0, 1.001, 1, 1, 0, 1, 0, 1, SideVisible.BOTH, ((covermask & 0x20) != 0) ? frame_txt_edge : frame_txt_side));
    /* Add minZ side */
    list.add(rpf.getPatch(1, 0, -0.001, 0, 0, -0.001, 1, 1, -0.001, 0, 1, 0, 1, SideVisible.BOTH, ((covermask & 0x04) != 0) ? frame_txt_edge : frame_txt_side));
    /* Add maxZ side */
    list.add(rpf.getPatch(0, 0, 1.001, 1, 0, 1.001, 0, 1, 1.001, 0, 1, 0, 1, SideVisible.BOTH, ((covermask & 0x08) != 0) ? frame_txt_edge : frame_txt_side));
    /* Get patches from any microblocks */
    if ((covermask & 0x3FFFFFFF) != 0) {
        RenderPatch[] rp = super.getRenderPatchList(ctx);
        for (int i = 0; i < rp.length; i++) {
            list.add(rp[i]);
        }
    }
    return list.toArray(new RenderPatch[list.size()]);
}
Also used : ArrayList(java.util.ArrayList) RenderPatch(org.dynmap.renderer.RenderPatch) RenderPatchFactory(org.dynmap.renderer.RenderPatchFactory)

Example 2 with RenderPatchFactory

use of org.dynmap.renderer.RenderPatchFactory in project dynmap by webbukkit.

the class FluidStateRenderer method getRenderPatchList.

@Override
public final RenderPatch[] getRenderPatchList(MapDataContext ctx) {
    // Get own state
    DynmapBlockState bs_0_0_0 = getFluidState(ctx, 0, 0, 0);
    // Check above block - if matching fluid, block will be full
    DynmapBlockState bs_0_1_0 = getFluidState(ctx, 0, 1, 0);
    if (bs_0_1_0.matchingBaseState(bs_0_0_0)) {
        return getFullCulledModel(ctx, bs_0_0_0, bs_0_1_0);
    }
    // Get other above blocks
    DynmapBlockState bs_0_1_1 = getFluidState(ctx, 0, 1, 1);
    DynmapBlockState bs_1_1_0 = getFluidState(ctx, 1, 1, 0);
    DynmapBlockState bs_1_1_1 = getFluidState(ctx, 1, 1, 1);
    DynmapBlockState bs_0_1_n1 = getFluidState(ctx, 0, 1, -1);
    DynmapBlockState bs_n1_1_0 = getFluidState(ctx, -1, 1, 0);
    DynmapBlockState bs_n1_1_n1 = getFluidState(ctx, -1, 1, -1);
    DynmapBlockState bs_1_1_n1 = getFluidState(ctx, 1, 1, -1);
    DynmapBlockState bs_n1_1_1 = getFluidState(ctx, -1, 1, 1);
    // See if full height corner due to upper blocks
    boolean isfull_1_1 = isUpperCornerHeightFull(bs_0_0_0, bs_0_1_0, bs_1_1_0, bs_0_1_1, bs_1_1_1);
    boolean isfull_1_n1 = isUpperCornerHeightFull(bs_0_0_0, bs_0_1_0, bs_1_1_0, bs_0_1_n1, bs_1_1_n1);
    boolean isfull_n1_1 = isUpperCornerHeightFull(bs_0_0_0, bs_0_1_0, bs_n1_1_0, bs_0_1_1, bs_n1_1_1);
    boolean isfull_n1_n1 = isUpperCornerHeightFull(bs_0_0_0, bs_0_1_0, bs_n1_1_0, bs_0_1_n1, bs_n1_1_n1);
    // If full height
    if (isfull_1_1 && isfull_1_n1 && isfull_n1_1 && isfull_n1_n1) {
        return getFullCulledModel(ctx, bs_0_0_0, bs_0_1_0);
    }
    // Get other neighbors to figure out corner heights
    DynmapBlockState bs_0_0_1 = getFluidState(ctx, 0, 0, 1);
    DynmapBlockState bs_1_0_0 = getFluidState(ctx, 1, 0, 0);
    DynmapBlockState bs_1_0_1 = getFluidState(ctx, 1, 0, 1);
    DynmapBlockState bs_0_0_n1 = getFluidState(ctx, 0, 0, -1);
    DynmapBlockState bs_n1_0_0 = getFluidState(ctx, -1, 0, 0);
    DynmapBlockState bs_n1_0_n1 = getFluidState(ctx, -1, 0, -1);
    DynmapBlockState bs_1_0_n1 = getFluidState(ctx, 1, 0, -1);
    DynmapBlockState bs_n1_0_1 = getFluidState(ctx, -1, 0, 1);
    // Get each corner height
    int bh_1_1 = isfull_1_1 ? 9 : getCornerHeight(bs_0_0_0, bs_0_0_1, bs_1_0_0, bs_1_0_1);
    int bh_1_n1 = isfull_1_n1 ? 9 : getCornerHeight(bs_0_0_0, bs_0_0_n1, bs_1_0_0, bs_1_0_n1);
    int bh_n1_1 = isfull_n1_1 ? 9 : getCornerHeight(bs_0_0_0, bs_0_0_1, bs_n1_0_0, bs_n1_0_1);
    int bh_n1_n1 = isfull_n1_n1 ? 9 : getCornerHeight(bs_0_0_0, bs_0_0_n1, bs_n1_0_0, bs_n1_0_n1);
    // If full height
    if ((bh_1_1 == 9) && (bh_1_n1 == 9) && (bh_n1_1 == 9) && (bh_n1_n1 == 9)) {
        return getFullCulledModel(ctx, bs_0_0_0, bs_0_1_0, bs_n1_0_0, bs_1_0_0, bs_0_0_n1, bs_0_0_1);
    }
    // Do cached lookup of model
    RenderPatch[] mod = getCachedModel(bh_1_1, bh_n1_1, bh_1_n1, bh_n1_n1);
    // If not found, create model
    if (mod == null) {
        RenderPatchFactory rpf = ctx.getPatchFactory();
        ArrayList<RenderPatch> list = new ArrayList<RenderPatch>();
        // All models have bottom patch
        list.add(bottom);
        // Add side for each face
        // Xminus
        addSide(list, rpf, 0, 0, 0, 1, bh_n1_n1, bh_n1_1);
        // Xplus
        addSide(list, rpf, 1, 1, 1, 0, bh_1_1, bh_1_n1);
        // Zminus
        addSide(list, rpf, 1, 0, 0, 0, bh_1_n1, bh_n1_n1);
        // Zplus
        addSide(list, rpf, 0, 1, 1, 1, bh_n1_1, bh_1_1);
        int edge_xm = bh_n1_n1 + bh_n1_1;
        int edge_xp = bh_1_n1 + bh_1_1;
        int edge_zm = bh_n1_n1 + bh_1_n1;
        int edge_zp = bh_1_1 + bh_n1_1;
        // See which edge is lowest
        if ((edge_xp <= edge_xm) && (edge_xp <= edge_zm) && (edge_xp <= edge_zp)) {
            // bh_1_1 and bh_1_n1 (Xplus)
            addTop(list, rpf, 1, 1, 1, 0, bh_1_1, bh_1_n1, bh_n1_1, bh_n1_n1);
        } else if ((edge_zp <= edge_zm) && (edge_zp <= edge_xm) && (edge_zp <= edge_xp)) {
            // bh_n1_1 and bh_1_1 (zPlus)
            addTop(list, rpf, 0, 1, 1, 1, bh_n1_1, bh_1_1, bh_n1_n1, bh_1_n1);
        } else if ((edge_xm <= edge_xp) && (edge_xm <= edge_zm) && (edge_xm <= edge_zp)) {
            // bh_n1_n1 and bh_n1_1 (xMinus)
            addTop(list, rpf, 0, 0, 0, 1, bh_n1_n1, bh_n1_1, bh_1_n1, bh_1_1);
        } else {
            // bh_1_n1 and bh_n1_n1 (zMinus)
            addTop(list, rpf, 1, 0, 0, 0, bh_1_n1, bh_n1_n1, bh_1_1, bh_n1_1);
        }
        mod = list.toArray(new RenderPatch[list.size()]);
        putCachedModel(bh_1_1, bh_n1_1, bh_1_n1, bh_n1_n1, mod);
    // Log.info(String.format("%d:%d:%d::bh_1_1=%d,bh_1_n1=%d,bh_n1_1=%d,bh_n1_n1=%d", ctx.getX(), ctx.getY(), ctx.getZ(), bh_1_1, bh_1_n1, bh_n1_1, bh_n1_n1));
    // for (RenderPatch rp : list) {
    // Log.info(rp.toString());
    // }
    }
    return mod;
}
Also used : DynmapBlockState(org.dynmap.renderer.DynmapBlockState) ArrayList(java.util.ArrayList) RenderPatch(org.dynmap.renderer.RenderPatch) RenderPatchFactory(org.dynmap.renderer.RenderPatchFactory)

Example 3 with RenderPatchFactory

use of org.dynmap.renderer.RenderPatchFactory in project dynmap by webbukkit.

the class HeadRenderer method getRenderPatchList.

@Override
public RenderPatch[] getRenderPatchList(MapDataContext ctx) {
    int idx = ctx.getBlockType().stateIndex;
    // Normalize (bad values from some mods)
    while (idx < 0) idx += NUM_DIRECTIONS;
    if (idx < meshes.length) {
        if (meshes[idx] == null) {
            RenderPatchFactory rpf = ctx.getPatchFactory();
            RenderPatch[] rp = new RenderPatch[basemesh.length];
            for (int i = 0; i < rp.length; i++) {
                rp[i] = rpf.getRotatedPatch(basemesh[i], 0, 45 * idx / 2, 0, faces[i]);
            }
            meshes[idx] = rp;
        }
        return meshes[idx];
    } else
        return meshes[0];
}
Also used : RenderPatch(org.dynmap.renderer.RenderPatch) RenderPatchFactory(org.dynmap.renderer.RenderPatchFactory)

Example 4 with RenderPatchFactory

use of org.dynmap.renderer.RenderPatchFactory in project dynmap by webbukkit.

the class WallHeadRenderer method getRenderPatchList.

@Override
public RenderPatch[] getRenderPatchList(MapDataContext ctx) {
    int idx = ctx.getBlockType().stateIndex;
    // Normalize (bad values from some mods)
    while (idx < 0) idx += NUM_DIRECTIONS;
    if (idx < meshes.length) {
        if (meshes[idx] == null) {
            RenderPatchFactory rpf = ctx.getPatchFactory();
            RenderPatch[] rp = new RenderPatch[basemesh.length];
            for (int i = 0; i < rp.length; i++) {
                rp[i] = rpf.getRotatedPatch(basemesh[i], 0, 45 * idx / 2, 0, faces[i]);
            }
            meshes[idx] = rp;
        }
        return meshes[idx];
    } else
        return meshes[0];
}
Also used : RenderPatch(org.dynmap.renderer.RenderPatch) RenderPatchFactory(org.dynmap.renderer.RenderPatchFactory)

Example 5 with RenderPatchFactory

use of org.dynmap.renderer.RenderPatchFactory in project dynmap by webbukkit.

the class SkullRenderer method getRenderPatchList.

@Override
public RenderPatch[] getRenderPatchList(MapDataContext ctx) {
    int rot = 0;
    int face = 0;
    Object val = ctx.getBlockTileEntityField("Rot");
    if (val instanceof Byte)
        rot = ((Byte) val).intValue();
    // Normalize (bad values from some mods)
    while (rot < 0) rot += NUM_DIRECTIONS;
    val = ctx.getBlockTileEntityField("SkullType");
    if (val instanceof Byte)
        face = ((Byte) val).intValue();
    // Normalize (bad values from some mods)
    while (face < 0) face += faces.length;
    int idx = (NUM_DIRECTIONS * face) + rot;
    if (idx < meshes.length) {
        if (meshes[idx] == null) {
            RenderPatchFactory rpf = ctx.getPatchFactory();
            RenderPatch[] rp = new RenderPatch[basemesh.length];
            for (int i = 0; i < rp.length; i++) {
                rp[i] = rpf.getRotatedPatch(basemesh[i], 0, 45 * rot / 2, 0, faces[i] + (6 * face));
            }
            meshes[idx] = rp;
        }
        return meshes[idx];
    } else
        return meshes[0];
}
Also used : RenderPatch(org.dynmap.renderer.RenderPatch) RenderPatchFactory(org.dynmap.renderer.RenderPatchFactory)

Aggregations

RenderPatch (org.dynmap.renderer.RenderPatch)5 RenderPatchFactory (org.dynmap.renderer.RenderPatchFactory)5 ArrayList (java.util.ArrayList)2 DynmapBlockState (org.dynmap.renderer.DynmapBlockState)1