use of riskyken.armourersWorkshop.common.skin.cubes.ICube in project Armourers-Workshop by RiskyKen.
the class SkinBaker method checkCubesAroundLocation.
private static ArrayList<CubeLocation> checkCubesAroundLocation(SkinCubeData cubeData, CubeLocation cubeLocation, Rectangle3D partBounds, int[][][] cubeArray) {
ArrayList<CubeLocation> openList = new ArrayList<SkinBaker.CubeLocation>();
ForgeDirection[] dirs = { ForgeDirection.DOWN, ForgeDirection.UP, ForgeDirection.SOUTH, ForgeDirection.NORTH, ForgeDirection.WEST, ForgeDirection.EAST };
int index = getIndexForLocation(cubeLocation, partBounds, cubeArray);
boolean isGlass = false;
if (index > 0) {
ICube cube = cubeData.getCube(index - 1);
isGlass = cube.needsPostRender();
}
for (int i = 0; i < dirs.length; i++) {
ForgeDirection dir = dirs[i];
int x = cubeLocation.x + dir.offsetX;
int y = cubeLocation.y + dir.offsetY;
int z = cubeLocation.z + dir.offsetZ;
int tarIndex = getIndexForLocation(x, y, z, partBounds, cubeArray);
// Add new cubes to the open list.
if (tarIndex < 1) {
openList.add(new CubeLocation(x, y, z));
} else {
if (cubeData.getCube(tarIndex - 1).needsPostRender()) {
openList.add(new CubeLocation(x, y, z));
}
}
// Update the face flags if there is a block at this location.
if (tarIndex > 0) {
flagCubeFace(x, y, z, i, partBounds, cubeArray, cubeData, isGlass);
}
}
return openList;
}
use of riskyken.armourersWorkshop.common.skin.cubes.ICube in project Armourers-Workshop by RiskyKen.
the class SkinBaker method flagCubeFace.
private static void flagCubeFace(int x, int y, int z, int face, Rectangle3D partBounds, int[][][] cubeArray, SkinCubeData cubeData, boolean isGlass) {
int checkIndex = getIndexForLocation(x, y, z, partBounds, cubeArray);
if (!isGlass) {
cubeData.getFaceFlags(checkIndex - 1).set(face, true);
} else {
ICube cube = cubeData.getCube(checkIndex - 1);
cubeData.getFaceFlags(checkIndex - 1).set(face, cube.needsPostRender() != isGlass);
}
}
use of riskyken.armourersWorkshop.common.skin.cubes.ICube in project Armourers-Workshop by RiskyKen.
the class ArmourerWorldHelper method loadSkinPartIntoWorld.
private static void loadSkinPartIntoWorld(World world, SkinPart partData, int xCoord, int yCoord, int zCoord, ForgeDirection direction, boolean mirror) {
ISkinPartType skinPart = partData.getPartType();
IRectangle3D buildSpace = skinPart.getBuildingSpace();
IPoint3D offset = skinPart.getOffset();
SkinCubeData cubeData = partData.getCubeData();
for (int i = 0; i < cubeData.getCubeCount(); i++) {
ICube blockData = cubeData.getCube(i);
int meta = 0;
for (int j = 0; j < partData.getMarkerBlocks().size(); j++) {
CubeMarkerData cmd = partData.getMarkerBlocks().get(j);
byte[] loc = cubeData.getCubeLocation(i);
if (cmd.x == loc[0] & cmd.y == loc[1] & cmd.z == loc[2]) {
meta = cmd.meta;
break;
}
}
int xOrigin = -offset.getX();
int yOrigin = -offset.getY() + -buildSpace.getY();
int zOrigin = offset.getZ();
loadSkinBlockIntoWorld(world, xCoord, yCoord, zCoord, xOrigin, yOrigin, zOrigin, blockData, direction, meta, cubeData, i, mirror);
}
}
use of riskyken.armourersWorkshop.common.skin.cubes.ICube in project Armourers-Workshop by RiskyKen.
the class Skin method getTotalCubes.
public int getTotalCubes() {
int totalCubes = 0;
for (int i = 0; i < CubeRegistry.INSTANCE.getTotalCubes(); i++) {
ICube cube = CubeRegistry.INSTANCE.getCubeFormId((byte) i);
totalCubes += getTotalOfCubeType(cube);
}
return totalCubes;
}
use of riskyken.armourersWorkshop.common.skin.cubes.ICube 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);
}
Aggregations