mirror of
https://github.com/GTNewHorizons/StorageDrawers.git
synced 2026-11-12 16:37:28 +00:00
Copy in renderer updates from Garden Stuff
This commit is contained in:
1 parent
24bcad1fbe
commit
37db38bc99
3 files changed
+144
-158
No files matched your search
@@ -21,15 +21,6 @@ public class RenderHelper
|
||||
|
||||
public static final int FULL_BRIGHTNESS = 15728880;
|
||||
|
||||
private static final float rgbMap[][] = {
|
||||
{ 0.5f, 0.5f, 0.5f },
|
||||
{ 1.0f, 1.0f, 1.0f },
|
||||
{ 0.8f, 0.8f, 0.8f },
|
||||
{ 0.8f, 0.8f, 0.8f },
|
||||
{ 0.6f, 0.6f, 0.6f },
|
||||
{ 0.6f, 0.6f, 0.6f },
|
||||
};
|
||||
|
||||
private static final float normMap[][] = {
|
||||
{ 0, -1, 0 },
|
||||
{ 0, 1, 0 },
|
||||
@@ -91,6 +82,14 @@ public class RenderHelper
|
||||
setRenderBounds(block.getBlockBoundsMinX(), block.getBlockBoundsMinY(), block.getBlockBoundsMinZ(), block.getBlockBoundsMaxX(), block.getBlockBoundsMaxY(), block.getBlockBoundsMaxZ());
|
||||
}
|
||||
|
||||
public void setColorAndBrightness (IBlockAccess blockAccess, Block block, int x, int y, int z) {
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.setBrightness(block.getMixedBrightnessForBlock(blockAccess, x, y, z));
|
||||
|
||||
calculateBaseColor(colorScratch, block.colorMultiplier(blockAccess, x, y, z));
|
||||
setTessellatorColor(tessellator, colorScratch);
|
||||
}
|
||||
|
||||
public void renderBlock (IBlockAccess blockAccess, Block block, int meta) {
|
||||
calculateBaseColor(colorScratch, block.getRenderColor(meta));
|
||||
float r = colorScratch[0];
|
||||
@@ -141,19 +140,19 @@ public class RenderHelper
|
||||
}
|
||||
|
||||
public void renderFaceColorMult (int face, IBlockAccess blockAccess, Block block, int x, int y, int z, IIcon icon, float r, float g, float b) {
|
||||
face = state.getTransformedFace(face);
|
||||
setupColorMult(face, blockAccess, block, x, y, z, r, g, b);
|
||||
|
||||
face = RenderHelperState.FACE_BY_FACE_ROTATION[face][state.rotateTransform];
|
||||
llHelper.drawFace(face, x, y, z, icon);
|
||||
|
||||
if (blockAccess == null)
|
||||
Tessellator.instance.draw();
|
||||
}
|
||||
|
||||
|
||||
public void renderFaceAOPartial (int face, IBlockAccess blockAccess, Block block, int x, int y, int z, IIcon icon, float r, float g, float b) {
|
||||
state.enableAO = true;
|
||||
|
||||
face = state.getTransformedFace(face);
|
||||
face = RenderHelperState.FACE_BY_FACE_ROTATION[face][state.rotateTransform];
|
||||
|
||||
switch (face) {
|
||||
case YNEG:
|
||||
@@ -211,7 +210,7 @@ public class RenderHelper
|
||||
public void renderPartialFaceAOPartial (int face, IBlockAccess blockAccess, Block block, int x, int y, int z, IIcon icon, double uMin, double vMin, double uMax, double vMax, float r, float g, float b) {
|
||||
state.enableAO = true;
|
||||
|
||||
switch (state.getTransformedFace(face)) {
|
||||
switch (RenderHelperState.FACE_BY_FACE_ROTATION[face][state.rotateTransform]) {
|
||||
case YNEG:
|
||||
aoHelper.setupYNegAOPartial(blockAccess, block, x, y, z, r, g, b);
|
||||
break;
|
||||
@@ -238,12 +237,12 @@ public class RenderHelper
|
||||
|
||||
public void renderPartialFace (int face, IIcon icon, double uMin, double vMin, double uMax, double vMax) {
|
||||
state.enableAO = false;
|
||||
face = state.getTransformedFace(face);
|
||||
face = RenderHelperState.FACE_BY_FACE_ROTATION[face][state.rotateTransform];
|
||||
llHelper.drawPartialFace(face, 0, 0, 0, icon, uMin, vMin, uMax, vMax);
|
||||
}
|
||||
|
||||
public void renderPartialFace (int face, double x, double y, double z, IIcon icon, double uMin, double vMin, double uMax, double vMax) {
|
||||
face = state.getTransformedFace(face);
|
||||
face = RenderHelperState.FACE_BY_FACE_ROTATION[face][state.rotateTransform];
|
||||
llHelper.drawPartialFace(face, x, y, z, icon, uMin, vMin, uMax, vMax);
|
||||
}
|
||||
|
||||
@@ -289,6 +288,10 @@ public class RenderHelper
|
||||
{
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
x += state.renderOffsetX;
|
||||
y += state.renderOffsetY;
|
||||
z += state.renderOffsetZ;
|
||||
|
||||
double uMin = icon.getInterpolatedU(state.renderMinX * 16.0D);
|
||||
double uMax = icon.getInterpolatedU(state.renderMaxX * 16.0D);
|
||||
double vMin = icon.getInterpolatedV(16 - state.renderMaxY * 16.0D);
|
||||
@@ -325,6 +328,10 @@ public class RenderHelper
|
||||
{
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
x += state.renderOffsetX;
|
||||
y += state.renderOffsetY;
|
||||
z += state.renderOffsetZ;
|
||||
|
||||
double vMin = icon.getInterpolatedV(16 - state.renderMaxY * 16.0D);
|
||||
double vMax = icon.getInterpolatedV(16 - state.renderMinY * 16.0D);
|
||||
|
||||
@@ -378,10 +385,10 @@ public class RenderHelper
|
||||
|
||||
private void setupColorMult (int face, float r, float g, float b) {
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
float[] rgb = rgbMap[face];
|
||||
float[] norm = normMap[face];
|
||||
float scale = state.getColorMult(face);
|
||||
|
||||
tessellator.setColorOpaque_F(rgb[0] * r, rgb[1] * g, rgb[2] * b);
|
||||
tessellator.setColorOpaque_F(scale * r, scale * g, scale * b);
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(norm[0], norm[1], norm[2]);
|
||||
|
||||
@@ -390,8 +397,8 @@ public class RenderHelper
|
||||
|
||||
private void setupColorMult (int face, IBlockAccess blockAccess, Block block, int x, int y, int z, float r, float g, float b) {
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
float[] rgb = rgbMap[face];
|
||||
float[] norm = normMap[face];
|
||||
float scale = state.getColorMult(face);
|
||||
|
||||
if (blockAccess == null) {
|
||||
tessellator.startDrawingQuads();
|
||||
@@ -412,7 +419,7 @@ public class RenderHelper
|
||||
case XPOS: brightX = (state.renderMaxX < 1) ? x : x + 1; break;
|
||||
}
|
||||
|
||||
tessellator.setColorOpaque_F(rgb[0] * r, rgb[1] * g, rgb[2] * b);
|
||||
tessellator.setColorOpaque_F(scale * r, scale * g, scale * b);
|
||||
tessellator.setBrightness(block.getMixedBrightnessForBlock(blockAccess, brightX, brightY, brightZ));
|
||||
}
|
||||
|
||||
|
||||
@@ -71,6 +71,8 @@ public class RenderHelperLL
|
||||
}
|
||||
|
||||
public void drawFace (int face, double x, double y, double z, IIcon icon) {
|
||||
boolean flip = state.flipTexture;
|
||||
|
||||
switch (face) {
|
||||
case RenderHelper.YNEG:
|
||||
case RenderHelper.YPOS:
|
||||
@@ -78,13 +80,19 @@ public class RenderHelperLL
|
||||
break;
|
||||
case RenderHelper.ZNEG:
|
||||
case RenderHelper.ZPOS:
|
||||
if (state.rotateTransform == RenderHelperState.ROTATE180 || state.rotateTransform == RenderHelperState.ROTATE90)
|
||||
state.flipTexture = !state.flipTexture;
|
||||
drawFaceZ(face, x, y, z, icon);
|
||||
break;
|
||||
case RenderHelper.XNEG:
|
||||
case RenderHelper.XPOS:
|
||||
if (state.rotateTransform == RenderHelperState.ROTATE180 || state.rotateTransform == RenderHelperState.ROTATE270)
|
||||
state.flipTexture = !state.flipTexture;
|
||||
drawFaceX(face, x, y, z, icon);
|
||||
break;
|
||||
}
|
||||
|
||||
state.flipTexture = flip;
|
||||
}
|
||||
|
||||
private void drawFaceY (int face, double x, double y, double z, IIcon icon) {
|
||||
@@ -195,7 +203,11 @@ public class RenderHelperLL
|
||||
state.brightnessBottomLeft = brightnessLerp[ix][iy + 1];
|
||||
state.brightnessBottomRight = brightnessLerp[ix + 1][iy + 1];
|
||||
|
||||
setUV(icon, minUDiv[ix], minVDiv[iy], maxUDiv[ix], maxVDiv[iy]);
|
||||
if (state.flipTexture)
|
||||
setUV(icon, 1 - minUDiv[ix], 1 - maxVDiv[iy], 1 - maxUDiv[ix], 1 - minVDiv[iy]);
|
||||
else
|
||||
setUV(icon, minUDiv[ix], 1 - maxVDiv[iy], maxUDiv[ix], 1 - minVDiv[iy]);
|
||||
|
||||
renderXYZUVAO(xyzuvMap[face]);
|
||||
|
||||
xyz[MINY] = xyz[MAXY];
|
||||
@@ -214,8 +226,7 @@ public class RenderHelperLL
|
||||
xyz[MAXZ] = z + state.renderMinZ;
|
||||
}
|
||||
|
||||
if (rangeZ <= 1 && rangeZ <= 1) {
|
||||
|
||||
if (rangeZ <= 1 && rangeY <= 1) {
|
||||
if (state.flipTexture)
|
||||
setUV(icon, state.renderMaxZ + state.shiftU, 1 - state.renderMaxY + state.shiftV, state.renderMinZ + state.shiftU, 1 - state.renderMinY + state.shiftV);
|
||||
else
|
||||
@@ -249,9 +260,9 @@ public class RenderHelperLL
|
||||
state.brightnessBottomRight = brightnessLerp[iz + 1][iy + 1];
|
||||
|
||||
if (state.flipTexture)
|
||||
setUV(1 - minUDiv[iz], minVDiv[iy], 1 - maxUDiv[iz], maxVDiv[iy]);
|
||||
setUV(icon, 1 - minUDiv[iz], 1 - maxVDiv[iy], 1 - maxUDiv[iz], 1 - minVDiv[iy]);
|
||||
else
|
||||
setUV(minUDiv[iz], minVDiv[iy], maxUDiv[iz], maxVDiv[iy]);
|
||||
setUV(icon, minUDiv[iz], 1 - maxVDiv[iy], maxUDiv[iz], 1 - minVDiv[iy]);
|
||||
|
||||
renderXYZUVAO(xyzuvMap[face]);
|
||||
|
||||
@@ -307,7 +318,7 @@ public class RenderHelperLL
|
||||
double diffLR = right - left;
|
||||
double diffTB = bottom - top;
|
||||
|
||||
double posLR = left;
|
||||
double posLR = 0;
|
||||
|
||||
for (int lr = 0; lr <= rangeLR; lr++) {
|
||||
float lerpLR = (float)(posLR / diffLR);
|
||||
@@ -315,7 +326,7 @@ public class RenderHelperLL
|
||||
int brightTop = RenderHelperAO.mixAOBrightness(state.brightnessTopLeft, state.brightnessTopRight, 1 - lerpLR, lerpLR);
|
||||
int brightBottom = RenderHelperAO.mixAOBrightness(state.brightnessBottomLeft, state.brightnessBottomRight, 1 - lerpLR, lerpLR);
|
||||
|
||||
double posTB = top;
|
||||
double posTB = 0;
|
||||
for (int tb = 0; tb <= rangeTB; tb++) {
|
||||
float lerpTB = (float)(posTB / diffTB);
|
||||
|
||||
@@ -345,12 +356,12 @@ public class RenderHelperLL
|
||||
}
|
||||
|
||||
private void setXYZ (double x, double y, double z) {
|
||||
xyz[0] = x + state.renderMinX;
|
||||
xyz[1] = x + state.renderMaxX;
|
||||
xyz[2] = y + state.renderMinY;
|
||||
xyz[3] = y + state.renderMaxY;
|
||||
xyz[4] = z + state.renderMinZ;
|
||||
xyz[5] = z + state.renderMaxZ;
|
||||
xyz[0] = x + state.renderOffsetX + state.renderMinX;
|
||||
xyz[1] = x + state.renderOffsetX + state.renderMaxX;
|
||||
xyz[2] = y + state.renderOffsetY + state.renderMinY;
|
||||
xyz[3] = y + state.renderOffsetY + state.renderMaxY;
|
||||
xyz[4] = z + state.renderOffsetZ + state.renderMinZ;
|
||||
xyz[5] = z + state.renderOffsetZ + state.renderMaxZ;
|
||||
}
|
||||
|
||||
private void renderXYZUV (int[][] index) {
|
||||
|
||||
@@ -2,11 +2,12 @@ package com.jaquadro.minecraft.storagedrawers.util;
|
||||
|
||||
public class RenderHelperState
|
||||
{
|
||||
public static final int ROTATE0 = 0;
|
||||
public static final int ROTATE90 = 1;
|
||||
public static final int ROTATE180 = 2;
|
||||
public static final int ROTATE270 = 3;
|
||||
|
||||
public static final int[][] ROTATION_BY_FACE_FACE_Y = {
|
||||
public static final int[][] ROTATION_BY_FACE_FACE = {
|
||||
{ 0, 0, 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, 2, 3, 1 },
|
||||
@@ -15,25 +16,7 @@ public class RenderHelperState
|
||||
{ 0, 0, 3, 1, 2, 0 },
|
||||
};
|
||||
|
||||
public static final int[][] ROTATION_BY_FACE_FACE_Z = {
|
||||
{ 0, 2, 0, 0, 1, 3 },
|
||||
{ 2, 0, 0, 0, 3, 1 },
|
||||
{ 0, 0, 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0, 0, 0 },
|
||||
{ 3, 1, 0, 0, 0, 2 },
|
||||
{ 1, 3, 0, 0, 2, 0 },
|
||||
};
|
||||
|
||||
public static final int[][] ROTATION_BY_FACE_FACE_X = {
|
||||
{ 0, 2, 1, 3, 0, 0 },
|
||||
{ 2, 0, 3, 1, 0, 0 },
|
||||
{ 3, 1, 0, 2, 0, 0 },
|
||||
{ 1, 3, 2, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0, 0, 0 },
|
||||
};
|
||||
|
||||
public static final int[][] FACE_BY_FACE_ROTATION_Y = {
|
||||
public static final int[][] FACE_BY_FACE_ROTATION = {
|
||||
{ 0, 0, 0, 0 },
|
||||
{ 1, 1, 1, 1 },
|
||||
{ 2, 5, 3, 4 },
|
||||
@@ -42,24 +25,6 @@ public class RenderHelperState
|
||||
{ 5, 3, 4, 2 },
|
||||
};
|
||||
|
||||
public static final int[][] FACE_BY_FACE_ROTATION_Z = {
|
||||
{ 0, 4, 1, 5 },
|
||||
{ 1, 5, 0, 4 },
|
||||
{ 2, 2, 2, 2 },
|
||||
{ 3, 3, 3, 3 },
|
||||
{ 4, 1, 5, 0 },
|
||||
{ 5, 0, 4, 1 },
|
||||
};
|
||||
|
||||
public static final int[][] FACE_BY_FACE_ROTATION_X = {
|
||||
{ 0, 2, 1, 3 },
|
||||
{ 1, 3, 0, 2 },
|
||||
{ 2, 1, 3, 0 },
|
||||
{ 3, 0, 2, 1 },
|
||||
{ 4, 4, 4, 4 },
|
||||
{ 5, 5, 5, 5 },
|
||||
};
|
||||
|
||||
public double renderMinX;
|
||||
public double renderMinY;
|
||||
public double renderMinZ;
|
||||
@@ -67,13 +32,15 @@ public class RenderHelperState
|
||||
public double renderMaxY;
|
||||
public double renderMaxZ;
|
||||
|
||||
public double renderOffsetX;
|
||||
public double renderOffsetY;
|
||||
public double renderOffsetZ;
|
||||
|
||||
public boolean flipTexture;
|
||||
public boolean renderFromInside;
|
||||
public boolean enableAO;
|
||||
|
||||
public int rotateTransformX;
|
||||
public int rotateTransformY;
|
||||
public int rotateTransformZ;
|
||||
public int rotateTransform;
|
||||
|
||||
public float shiftU;
|
||||
public float shiftV;
|
||||
@@ -111,6 +78,33 @@ public class RenderHelperState
|
||||
renderMaxX = xMax;
|
||||
renderMaxY = yMax;
|
||||
renderMaxZ = zMax;
|
||||
|
||||
if (rotateTransform != 0)
|
||||
transformRenderBound(rotateTransform);
|
||||
}
|
||||
|
||||
public void setRenderOffset (double xOffset, double yOffset, double zOffset) {
|
||||
renderOffsetX = xOffset;
|
||||
renderOffsetY = yOffset;
|
||||
renderOffsetZ = zOffset;
|
||||
|
||||
if (rotateTransform != 0)
|
||||
transformRenderOffset(rotateTransform);
|
||||
}
|
||||
|
||||
public void clearRenderOffset () {
|
||||
renderOffsetX = 0;
|
||||
renderOffsetY = 0;
|
||||
renderOffsetZ = 0;
|
||||
}
|
||||
|
||||
public void setColorMult (float yPos, float z, float x, float yNeg) {
|
||||
colorMultYNeg = yNeg;
|
||||
colorMultYPos = yPos;
|
||||
colorMultZNeg = z;
|
||||
colorMultZPos = z;
|
||||
colorMultXNeg = x;
|
||||
colorMultXPos = x;
|
||||
}
|
||||
|
||||
public void resetColorMult () {
|
||||
@@ -122,6 +116,18 @@ public class RenderHelperState
|
||||
colorMultXPos = 0.6f;
|
||||
}
|
||||
|
||||
public float getColorMult (int side) {
|
||||
switch (side) {
|
||||
case 0: return colorMultYNeg;
|
||||
case 1: return colorMultYPos;
|
||||
case 2: return colorMultZNeg;
|
||||
case 3: return colorMultZPos;
|
||||
case 4: return colorMultXNeg;
|
||||
case 5: return colorMultXPos;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void setTextureOffset (float u, float v) {
|
||||
shiftU = u;
|
||||
shiftV = v;
|
||||
@@ -163,40 +169,51 @@ public class RenderHelperState
|
||||
color[i] *= scale;
|
||||
}
|
||||
|
||||
public int getTransformedFace (int face) {
|
||||
face = FACE_BY_FACE_ROTATION_X[face][rotateTransformX];
|
||||
face = FACE_BY_FACE_ROTATION_Y[face][rotateTransformY];
|
||||
face = FACE_BY_FACE_ROTATION_Z[face][rotateTransformZ];
|
||||
|
||||
return face;
|
||||
public void setRotateTransform (int faceFrom, int faceTo) {
|
||||
rotateTransform = ROTATION_BY_FACE_FACE[faceFrom][faceTo];
|
||||
if (rotateTransform != 0) {
|
||||
transformRenderBound(rotateTransform);
|
||||
transformRenderOffset(rotateTransform);
|
||||
}
|
||||
}
|
||||
|
||||
public void setRotateTransform (int faceFrom, int faceTo) {
|
||||
rotateTransformX = ROTATION_BY_FACE_FACE_X[faceFrom][faceTo];
|
||||
faceFrom = FACE_BY_FACE_ROTATION_X[faceFrom][rotateTransformX];
|
||||
rotateTransformY = ROTATION_BY_FACE_FACE_Y[faceFrom][faceTo];
|
||||
faceFrom = FACE_BY_FACE_ROTATION_Y[faceFrom][rotateTransformY];
|
||||
rotateTransformZ = ROTATION_BY_FACE_FACE_Z[faceFrom][faceTo];
|
||||
|
||||
transformRenderBound();
|
||||
public void undoRotateTransform () {
|
||||
if (rotateTransform != 0) {
|
||||
transformRenderBound(4 - rotateTransform);
|
||||
transformRenderOffset(4 - rotateTransform);
|
||||
}
|
||||
clearRotateTransform();
|
||||
}
|
||||
|
||||
public void clearRotateTransform () {
|
||||
rotateTransformX = 0;
|
||||
rotateTransformY = 0;
|
||||
rotateTransformZ = 0;
|
||||
rotateTransform = 0;
|
||||
}
|
||||
|
||||
private void transformRenderBound () {
|
||||
if (rotateTransformX == 0 && rotateTransformY == 0 && rotateTransformZ == 0)
|
||||
return;
|
||||
private void transformRenderOffset (int rotation) {
|
||||
double scratch;
|
||||
switch (rotation) {
|
||||
case ROTATE90:
|
||||
scratch = renderOffsetX;
|
||||
renderOffsetX = -renderOffsetZ;
|
||||
renderOffsetZ = scratch;
|
||||
break;
|
||||
case ROTATE180:
|
||||
renderOffsetX = -renderOffsetX;
|
||||
renderOffsetZ = -renderOffsetZ;
|
||||
break;
|
||||
case ROTATE270:
|
||||
scratch = renderOffsetX;
|
||||
renderOffsetX = renderOffsetZ;
|
||||
renderOffsetZ = -scratch;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void transformRenderBound (int rotation) {
|
||||
scratchIn[0] = renderMinX;
|
||||
scratchIn[1] = renderMinY;
|
||||
scratchIn[2] = renderMinZ;
|
||||
transformCoordX(scratchIn, scratchOut, rotateTransformX);
|
||||
transformCoordY(scratchOut, scratchIn, rotateTransformY);
|
||||
transformCoordZ(scratchIn, scratchOut, rotateTransformZ);
|
||||
transformCoord(scratchIn, scratchOut, rotation);
|
||||
renderMinX = scratchOut[0];
|
||||
renderMinY = scratchOut[1];
|
||||
renderMinZ = scratchOut[2];
|
||||
@@ -204,9 +221,7 @@ public class RenderHelperState
|
||||
scratchIn[0] = renderMaxX;
|
||||
scratchIn[1] = renderMaxY;
|
||||
scratchIn[2] = renderMaxZ;
|
||||
transformCoordX(scratchIn, scratchOut, rotateTransformX);
|
||||
transformCoordY(scratchOut, scratchIn, rotateTransformY);
|
||||
transformCoordZ(scratchIn, scratchOut, rotateTransformZ);
|
||||
transformCoord(scratchIn, scratchOut, rotation);
|
||||
renderMaxX = scratchOut[0];
|
||||
renderMaxY = scratchOut[1];
|
||||
renderMaxZ = scratchOut[2];
|
||||
@@ -217,12 +232,6 @@ public class RenderHelperState
|
||||
renderMaxX = temp;
|
||||
}
|
||||
|
||||
if (renderMinY > renderMaxY) {
|
||||
double temp = renderMinY;
|
||||
renderMinY = renderMaxY;
|
||||
renderMaxY = temp;
|
||||
}
|
||||
|
||||
if (renderMinZ > renderMaxZ) {
|
||||
double temp = renderMinZ;
|
||||
renderMinZ = renderMaxZ;
|
||||
@@ -230,75 +239,34 @@ public class RenderHelperState
|
||||
}
|
||||
}
|
||||
|
||||
public void transformCoordY (double[] coordIn, double[] coordOut, int rotation) {
|
||||
public void transformCoord (double x, double y, double z, double[] coordCout, int rotation) {
|
||||
scratchIn[0] = x;
|
||||
scratchIn[1] = y;
|
||||
scratchIn[2] = z;
|
||||
transformCoord(scratchIn, coordCout, rotation);
|
||||
}
|
||||
|
||||
public void transformCoord (double[] coordIn, double[] coordOut, int rotation) {
|
||||
coordOut[1] = coordIn[1];
|
||||
|
||||
switch (rotation) {
|
||||
case 1: // 90
|
||||
case 1:
|
||||
coordOut[0] = 1 - coordIn[2];
|
||||
coordOut[2] = coordIn[0];
|
||||
break;
|
||||
case 2: // 180
|
||||
case 2:
|
||||
coordOut[0] = 1 - coordIn[0];
|
||||
coordOut[2] = 1 - coordIn[2];
|
||||
break;
|
||||
case 3: // 270
|
||||
case 3:
|
||||
coordOut[0] = coordIn[2];
|
||||
coordOut[2] = 1 - coordIn[0];
|
||||
break;
|
||||
case 0: // 0
|
||||
case 0:
|
||||
default:
|
||||
coordOut[0] = coordIn[0];
|
||||
coordOut[2] = coordIn[2];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void transformCoordZ (double[] coordIn, double[] coordOut, int rotation) {
|
||||
coordOut[2] = coordIn[2];
|
||||
|
||||
switch (rotation) {
|
||||
case 1: // 90
|
||||
coordOut[0] = coordIn[1];
|
||||
coordOut[1] = 1 - coordIn[0];
|
||||
break;
|
||||
case 2: // 180
|
||||
coordOut[0] = 1 - coordIn[0];
|
||||
coordOut[1] = 1 - coordIn[1];
|
||||
break;
|
||||
case 3: // 270
|
||||
coordOut[0] = 1 - coordIn[1];
|
||||
coordOut[1] = coordIn[0];
|
||||
break;
|
||||
case 0: // 0
|
||||
default:
|
||||
coordOut[0] = coordIn[0];
|
||||
coordOut[1] = coordIn[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void transformCoordX (double[] coordIn, double[] coordOut, int rotation) {
|
||||
coordOut[0] = coordIn[0];
|
||||
|
||||
switch (rotation) {
|
||||
case 1: // 90
|
||||
coordOut[2] = coordIn[1];
|
||||
coordOut[1] = 1 - coordIn[2];
|
||||
break;
|
||||
case 2: // 180
|
||||
coordOut[2] = 1 - coordIn[2];
|
||||
coordOut[1] = 1 - coordIn[1];
|
||||
break;
|
||||
case 3: // 270
|
||||
coordOut[2] = 1 - coordIn[1];
|
||||
coordOut[1] = coordIn[2];
|
||||
break;
|
||||
case 0: // 0
|
||||
default:
|
||||
coordOut[2] = coordIn[2];
|
||||
coordOut[1] = coordIn[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user