public class Skybox extends Object3D implements java.io.Serializable { Skybox() { name = "Skybox"; minima = LA.newVector(-5, -5, -5); maxima = LA.newVector(5, 5, 5); bRep = new BoundaryRep(); bRep.redimension(24, 12); for (int i=0; i < 12; i++) bRep.setFace(i, faces[i]); recalculate(); CreateMaterial(); } Object3D deepCopy() { Box rec = new Box(); deepCopySelf(rec); return rec; } protected void deepCopySelf(Object3D other) { super.deepCopySelf(other); Skybox rec = (Skybox)other; rec.minima = new cVector(); LA.vecCopy(minima, rec.minima); rec.maxima = new cVector(); LA.vecCopy(maxima, rec.maxima); } void createEditWindow(GroupEditor callee, boolean newWindow) { //editWindow = new BoxEditor(this, deepCopy(), callee); /**/ if (newWindow) objectUI = new ObjEditor(this, deepCopy(), callee); else objectUI = new ObjEditor(this, callee); editWindow = objectUI.GetEditor(); if (!newWindow) ((ObjEditor)objectUI).SetupUI2(callee); /**/ } void generatePOV(StringBuffer buffer) { generateNameComment(buffer); generateIndent(buffer); buffer.append("box { "); LA.toPOVRay(minima, buffer); buffer.append(", "); LA.toPOVRay(maxima, buffer); buffer.append("\n"); generateTransform(buffer); generateIndent(buffer); buffer.append("}\n"); } void recalculate() { for (int i=0; i < 8; i++) { double x = i >= 4 ? maxima.x : minima.x; double y = (i / 2) % 2 != 0 ? maxima.y : minima.y; double z = i % 2 != 0 ? maxima.z : minima.z; bRep.setVertex(i, x, y, z, umap[i], vmap[i]); } // bRep.Trim(false, false); super.recalculate(); } void getBounds(cVector min, cVector max, boolean xform) { LA.vecCopy(minima, min); LA.vecCopy(maxima, max); if (xform) transformBounds(min, max); } boolean inside(double x, double y, double z, boolean xform) { if (xform) untransform(x, y, z, inPnt); else LA.setVector(inPnt, x, y, z); for (int i=0; i < 3; i++) { if (inPnt.get(i) < minima.get(i)) return false; if (inPnt.get(i) > maxima.get(i)) return false; } return true; } cVector minima; cVector maxima; static float umap[] = { 0, 1, 0, 1, 1, 0, 1, 0 }; static float vmap[] = { 0, 0, 1, 1, 1, 1, 0, 0 }; static int faces[][] = { { 0, 1, 3 }, { 0, 3, 2 }, { 2, 3, 7 }, { 2, 7, 6 }, { 1, 5, 7 }, { 1, 7, 3 }, { 4, 6, 7 }, { 4, 7, 5 }, { 0, 4, 5 }, { 0, 5, 1 }, { 0, 2, 6 }, { 0, 6, 4 } }; static cVector inPnt = new cVector(); }