Search in sources :

Example 6 with Rectangle3D

use of riskyken.armourersWorkshop.api.common.skin.Rectangle3D in project Armourers-Workshop by RiskyKen.

the class SkinPart method setupBlockBounds.

private void setupBlockBounds(int blockX, int blockY, int blockZ, int x, int y, int z) {
    BlockLocation loc = new BlockLocation(blockX + 1, -blockY, blockZ);
    if (blockGrid[loc.x][loc.y][loc.z] == null) {
        blockGrid[loc.x][loc.y][loc.z] = new Rectangle3D(127, 127, 127, -127, -127, -127);
    }
    Rectangle3D rec = blockGrid[loc.x][loc.y][loc.z];
    rec.setX(Math.min(rec.getX(), x));
    rec.setY(Math.min(rec.getY(), y));
    rec.setZ(Math.min(rec.getZ(), z));
    rec.setWidth(Math.max(rec.getWidth(), x));
    rec.setHeight(Math.max(rec.getHeight(), y));
    rec.setDepth(Math.max(rec.getDepth(), z));
// blockGrid[loc.x][loc.y][loc.z] = rec;
}
Also used : Rectangle3D(riskyken.armourersWorkshop.api.common.skin.Rectangle3D) BlockLocation(riskyken.armourersWorkshop.common.blocks.BlockLocation)

Example 7 with Rectangle3D

use of riskyken.armourersWorkshop.api.common.skin.Rectangle3D in project Armourers-Workshop by RiskyKen.

the class ItemStackRenderHelper method renderItemModelFromSkin.

@Deprecated
public static void renderItemModelFromSkin(Skin skin, ISkinPointer skinPointer, boolean showSkinPaint, boolean doLodLoading) {
    if (skin == null) {
        return;
    }
    // ModLogger.log("render skin");
    float blockScale = 16F;
    float mcScale = 1F / blockScale;
    float scale = 1;
    float offsetX = 0;
    float offsetY = 0;
    float offsetZ = 0;
    float scaleX = 1;
    float scaleY = 1;
    float scaleZ = 1;
    int width = 1;
    int height = 1;
    int depth = 1;
    Rectangle3D sb = skin.getSkinBounds();
    width = Math.max(width, sb.getWidth());
    height = Math.max(height, sb.getHeight());
    depth = Math.max(depth, sb.getDepth());
    scaleX = Math.min(scaleX, 1F / (float) width);
    scaleY = Math.min(scaleY, 1F / (float) height);
    scaleZ = Math.min(scaleZ, 1F / (float) depth);
    scale = Math.min(scale, scaleX);
    scale = Math.min(scale, scaleY);
    scale = Math.min(scale, scaleZ);
    offsetX = -sb.getX() - width / 2F;
    offsetY = -sb.getY() - height / 2F;
    offsetZ = -sb.getZ() - depth / 2F;
    GL11.glPushMatrix();
    GL11.glScalef(scale * blockScale, scale * blockScale, scale * blockScale);
    GL11.glTranslatef(offsetX * mcScale, 0, 0);
    GL11.glTranslatef(0, offsetY * mcScale, 0);
    GL11.glTranslatef(0, 0, offsetZ * mcScale);
    if (skin.getSkinType() == SkinTypeRegistry.skinWings) {
        GL11.glTranslated(-offsetX * mcScale, 0, 0);
    }
    renderSkinWithHelper(skin, skinPointer, showSkinPaint, doLodLoading);
    GL11.glPopMatrix();
}
Also used : Rectangle3D(riskyken.armourersWorkshop.api.common.skin.Rectangle3D)

Example 8 with Rectangle3D

use of riskyken.armourersWorkshop.api.common.skin.Rectangle3D in project Armourers-Workshop by RiskyKen.

the class SkinBaker method buildPartDisplayListArray.

public static void buildPartDisplayListArray(SkinPart partData, int[][] dyeColour, int[] dyeUseCount, int[][][] cubeArray) {
    boolean multipassSkinRendering = ClientProxy.useMultipassSkinRendering();
    ArrayList<ColouredFace>[] renderLists;
    int lodLevels = ConfigHandlerClient.maxLodLevels;
    /* LOD Indexs
         * 
         * with multipass;
         * 0 = normal
         * 1 = glowing
         * 2 = glass
         * 3 = glass glowing
         * 
         * without multipass
         * 0 = normal
         * 1 = glowing
         */
    renderLists = (ArrayList<ColouredFace>[]) new ArrayList[ClientProxy.getNumberOfRenderLayers() * (lodLevels + 1)];
    for (int i = 0; i < renderLists.length; i++) {
        renderLists[i] = new ArrayList<ColouredFace>();
    }
    float scale = 0.0625F;
    SkinCubeData cubeData = partData.getCubeData();
    Rectangle3D pb = partData.getPartBounds();
    for (int ix = 0; ix < pb.getWidth(); ix++) {
        for (int iy = 0; iy < pb.getHeight(); iy++) {
            for (int iz = 0; iz < pb.getDepth(); iz++) {
                int i = getIndexForLocation(ix, iy, iz, pb, cubeArray) - 1;
                if (i != -1) {
                    byte[] loc = cubeData.getCubeLocation(i);
                    byte[] paintType = cubeData.getCubePaintType(i);
                    ICube cube = partData.getCubeData().getCube(i);
                    byte a = (byte) 255;
                    if (cube.needsPostRender()) {
                        a = (byte) 127;
                    }
                    byte[] r = cubeData.getCubeColourR(i);
                    byte[] g = cubeData.getCubeColourG(i);
                    byte[] b = cubeData.getCubeColourB(i);
                    for (int j = 0; j < 6; j++) {
                        int paint = paintType[j] & 0xFF;
                        if (paint >= 1 && paint <= 8 && cubeData.getFaceFlags(i).get(j)) {
                            dyeUseCount[paint - 1]++;
                            dyeColour[0][paint - 1] += r[j] & 0xFF;
                            dyeColour[1][paint - 1] += g[j] & 0xFF;
                            dyeColour[2][paint - 1] += b[j] & 0xFF;
                        }
                        if (paint == 253) {
                            dyeUseCount[8]++;
                            dyeColour[0][8] += r[j] & 0xFF;
                            dyeColour[1][8] += g[j] & 0xFF;
                            dyeColour[2][8] += b[j] & 0xFF;
                        }
                        if (paint == 254) {
                            dyeUseCount[9]++;
                            dyeColour[0][9] += r[j] & 0xFF;
                            dyeColour[1][9] += g[j] & 0xFF;
                            dyeColour[2][9] += b[j] & 0xFF;
                        }
                    }
                    int listIndex = 0;
                    if (multipassSkinRendering) {
                        if (cube.isGlowing() && !cube.needsPostRender()) {
                            listIndex = 1;
                        }
                        if (cube.needsPostRender() && !cube.isGlowing()) {
                            listIndex = 2;
                        }
                        if (cube.isGlowing() && cube.needsPostRender()) {
                            listIndex = 3;
                        }
                    } else {
                        if (cube.isGlowing()) {
                            listIndex = 1;
                        }
                    }
                    for (int j = 0; j < 6; j++) {
                        if (cubeData.getFaceFlags(i).get(j)) {
                            ColouredFace ver = new ColouredFace(loc[0], loc[1], loc[2], r[j], g[j], b[j], a, paintType[j], (byte) j, (byte) (1));
                            renderLists[listIndex].add(ver);
                        }
                    }
                }
                // Create model LODs
                for (int lod = 1; lod < lodLevels + 1; lod++) {
                    byte lodLevel = (byte) Math.pow(2, lod);
                    if ((ix) % lodLevel == 0 & (iy) % lodLevel == 0 & (iz) % lodLevel == 0) {
                        for (int j = 0; j < 6; j++) {
                            boolean showFace = getAverageFaceFlags(ix, iy, iz, lodLevel, cubeArray, cubeData, pb, j);
                            if (showFace) {
                                byte[] avegC = getAverageRGBAT(ix, iy, iz, lodLevel, cubeArray, cubeData, pb, j);
                                ICube cube = CubeRegistry.INSTANCE.getCubeFormId(avegC[5]);
                                int listIndex = 0;
                                if (multipassSkinRendering) {
                                    if (cube.isGlowing() && !cube.needsPostRender()) {
                                        listIndex = 1;
                                    }
                                    if (cube.needsPostRender() && !cube.isGlowing()) {
                                        listIndex = 2;
                                    }
                                    if (cube.isGlowing() && cube.needsPostRender()) {
                                        listIndex = 3;
                                    }
                                } else {
                                    if (cube.isGlowing()) {
                                        listIndex = 1;
                                    }
                                }
                                int lodIndex = ((lod) * ClientProxy.getNumberOfRenderLayers()) + listIndex;
                                ColouredFace ver = new ColouredFace((byte) (ix + pb.getX()), (byte) (iy + pb.getY()), (byte) (iz + pb.getZ()), avegC[0], avegC[1], avegC[2], avegC[3], avegC[4], (byte) j, lodLevel);
                                renderLists[lodIndex].add(ver);
                            }
                        }
                    }
                }
            }
        }
    }
    partData.getClientSkinPartData().setVertexLists(renderLists);
}
Also used : SkinCubeData(riskyken.armourersWorkshop.common.skin.data.SkinCubeData) ArrayList(java.util.ArrayList) Rectangle3D(riskyken.armourersWorkshop.api.common.skin.Rectangle3D) ICube(riskyken.armourersWorkshop.common.skin.cubes.ICube)

Aggregations

Rectangle3D (riskyken.armourersWorkshop.api.common.skin.Rectangle3D)8 ArrayList (java.util.ArrayList)3 IRectangle3D (riskyken.armourersWorkshop.api.common.IRectangle3D)2 ISkinPartType (riskyken.armourersWorkshop.api.common.skin.type.ISkinPartType)2 SkinCubeData (riskyken.armourersWorkshop.common.skin.data.SkinCubeData)2 SkinPart (riskyken.armourersWorkshop.common.skin.data.SkinPart)2 SideOnly (cpw.mods.fml.relauncher.SideOnly)1 HashSet (java.util.HashSet)1 IPoint3D (riskyken.armourersWorkshop.api.common.IPoint3D)1 ISkinPart (riskyken.armourersWorkshop.api.common.skin.data.ISkinPart)1 ISkinPartTypeTextured (riskyken.armourersWorkshop.api.common.skin.type.ISkinPartTypeTextured)1 BlockLocation (riskyken.armourersWorkshop.common.blocks.BlockLocation)1 ICube (riskyken.armourersWorkshop.common.skin.cubes.ICube)1