1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
| public static final QuadArray makePlaneForCuboid(int side, float x, float y, float z, Point2f texCoordPoint) { QuadArray plane = new QuadArray(24, GeometryArray.COORDINATES | QuadArray.TEXTURE_COORDINATE_2);
Point3f pa = new Point3f(-1.0f * x, 1.0f * y, 1.0f * z); Point3f pb = new Point3f(-1.0f * x, -1.0f * y, 1.0f * z); Point3f pc = new Point3f(1.0f * x, -1.0f * y, 1.0f * z); Point3f pd = new Point3f(1.0f * x, 1.0f * y, 1.0f * z); Point3f pe = new Point3f(-1.0f * x, 1.0f * y, -1.0f * z); Point3f pf = new Point3f(-1.0f * x, -1.0f * y, -1.0f * z); Point3f pg = new Point3f(1.0f * x, -1.0f * y, -1.0f * z); Point3f ph = new Point3f(1.0f * x, 1.0f * y, -1.0f * z);
switch (side) { case 1: plane.setCoordinate(0, pa); plane.setCoordinate(1, pb); plane.setCoordinate(2, pc); plane.setCoordinate(3, pd); break;
case 2: plane.setCoordinate(0, pe); plane.setCoordinate(1, pf); plane.setCoordinate(2, pg); plane.setCoordinate(3, ph); break;
case 3: plane.setCoordinate(0, pe); plane.setCoordinate(1, pf); plane.setCoordinate(2, pb); plane.setCoordinate(3, pa); break;
case 4: plane.setCoordinate(0, pd); plane.setCoordinate(1, pc); plane.setCoordinate(2, pg); plane.setCoordinate(3, ph); break;
case 5: plane.setCoordinate(0, pe); plane.setCoordinate(1, pa); plane.setCoordinate(2, pd); plane.setCoordinate(3, ph); break;
case 6: plane.setCoordinate(0, pf); plane.setCoordinate(1, pb); plane.setCoordinate(2, pc); plane.setCoordinate(3, pg); break;
default: plane.setCoordinate(0, pa); plane.setCoordinate(1, pb); plane.setCoordinate(2, pc); plane.setCoordinate(3, pd); break; }
if (texCoordPoint == null) { plane.setTextureCoordinate(0, 0, new TexCoord2f(0f, 1f)); plane.setTextureCoordinate(0, 1, new TexCoord2f(0f, 0f)); plane.setTextureCoordinate(0, 2, new TexCoord2f(1f, 0f)); plane.setTextureCoordinate(0, 3, new TexCoord2f(1f, 1f)); } else { plane.setTextureCoordinate(0, 0, new TexCoord2f(0f, texCoordPoint.y)); plane.setTextureCoordinate(0, 1, new TexCoord2f(0f, 0f)); plane.setTextureCoordinate(0, 2, new TexCoord2f(texCoordPoint.x, 0f)); plane.setTextureCoordinate(0, 3, new TexCoord2f(texCoordPoint.x, texCoordPoint.y)); }
return plane; } |