/** * Flat projection for 2D textures. * * @param mesh * mesh that is to be projected * @param bb * the bounding box for projecting * @return UV coordinates after the projection */ public static float[] flatProjection(float[] positions, BoundingBox bb) { Vector3f min = bb.getMin(null); float[] ext = new float[] { bb.getXExtent() * 2.0f, bb.getZExtent() * 2.0f }; float[] uvCoordinates = new float[positions.length / 3 * 2]; for (int i = 0, j = 0; i < positions.length; i += 3, j += 2) { uvCoordinates[j] = (positions[i] - min.x) / ext[0]; // skip the Y-coordinate uvCoordinates[j + 1] = (positions[i + 2] - min.z) / ext[1]; } return uvCoordinates; }
private float getMinMax(BoundingBox bbox, boolean doMin, int axis) { if (doMin) { return bbox.getMin(null).get(axis); } else { return bbox.getMax(null).get(axis); } }
private void setMinMax(BoundingBox bbox, boolean doMin, int axis, float value) { Vector3f min = bbox.getMin(null); Vector3f max = bbox.getMax(null); if (doMin) { min.set(axis, value); } else { max.set(axis, value); } bbox.setMinMax(min, max); }
/** * This method returns the bounding tube of the given geometries. * * @param geometries * the list of geometries * @return bounding tube of the given geometries */ /* package */static BoundingTube getBoundingTube(Geometry... geometries) { BoundingTube result = null; for (Geometry geometry : geometries) { BoundingBox bb = UVCoordinatesGenerator.getBoundingBox(geometry); Vector3f max = bb.getMax(null); Vector3f min = bb.getMin(null); float radius = Math.max(max.x - min.x, max.y - min.y) * 0.5f; BoundingTube bt = new BoundingTube(radius, max.z - min.z, bb.getCenter()); if (result == null) { result = bt; } else { result.merge(bt); } } return result; }
Vector3f min = bb.getMin(null); float[] uvCoordsResults = new float[4];// used for coordinates swapping float[] ext = new float[] { bb.getXExtent() * 2, bb.getYExtent() * 2, bb.getZExtent() * 2 };
Vector3f casterMin = casterBB.getMin(vars.vect1); Vector3f casterMax = casterBB.getMax(vars.vect2); Vector3f receiverMin = receiverBB.getMin(vars.vect3); Vector3f receiverMax = receiverBB.getMax(vars.vect4); Vector3f splitMin = splitBB.getMin(vars.vect5); Vector3f splitMax = splitBB.getMax(vars.vect6);
/** * Instantly emits available particles, up to num. */ public void emitParticles(int num) { // Force world transform to update this.getWorldTransform(); TempVars vars = TempVars.get(); BoundingBox bbox = (BoundingBox) this.getMesh().getBound(); Vector3f min = vars.vect1; Vector3f max = vars.vect2; bbox.getMin(min); bbox.getMax(max); if (!Vector3f.isValidVector(min)) { min.set(Vector3f.POSITIVE_INFINITY); } if (!Vector3f.isValidVector(max)) { max.set(Vector3f.NEGATIVE_INFINITY); } for(int i=0;i<num;i++) { if( emitParticle(min, max) == null ) break; } bbox.setMinMax(min, max); this.setBoundRefresh(); vars.release(); }
Vector3f y = new Vector3f(0, 1, 0); Vector3f z = new Vector3f(0, 0, 1); Vector3f min = bb.getMin(null); float[] ext = new float[] { bb.getXExtent() * 2.0f, bb.getYExtent() * 2.0f, bb.getZExtent() * 2.0f };
Vector3f splitMin = splitBB.getMin(vars.vect1); Vector3f splitMax = splitBB.getMax(vars.vect2);
Vector3f min = bb.getMin(null); float[] ext = new float[]{bb.getXExtent() * 2, bb.getYExtent() * 2, bb.getZExtent() * 2};
float depth = boundingBox.getZExtent() * 2; Vector3f min = boundingBox.getMin(null); Vector3f v1 = min.add(uv[uvIndices[0]].x * width, uv[uvIndices[0]].y * height, uv[uvIndices[0]].z * depth); Vector3f v2 = min.add(uv[uvIndices[1]].x * width, uv[uvIndices[1]].y * height, uv[uvIndices[1]].z * depth);
private float getMinMax(BoundingBox bbox, boolean doMin, int axis) { if (doMin) { return bbox.getMin(null).get(axis); } else { return bbox.getMax(null).get(axis); } }
private float getMinMax(BoundingBox bbox, boolean doMin, int axis) { if (doMin) { return bbox.getMin(null).get(axis); } else { return bbox.getMax(null).get(axis); } }
private void setMinMax(BoundingBox bbox, boolean doMin, int axis, float value) { Vector3f min = bbox.getMin(null); Vector3f max = bbox.getMax(null); if (doMin) { min.set(axis, value); } else { max.set(axis, value); } bbox.setMinMax(min, max); }
private void setMinMax(BoundingBox bbox, boolean doMin, int axis, float value) { Vector3f min = bbox.getMin(null); Vector3f max = bbox.getMax(null); if (doMin) { min.set(axis, value); } else { max.set(axis, value); } bbox.setMinMax(min, max); }
public static Vector3f getMinBounding(Spatial spatial) { spatial.updateModelBound(); BoundingVolume wb = spatial.getWorldBound(); if (wb instanceof BoundingBox) { BoundingBox bb = (BoundingBox) wb; Vector3f min = new Vector3f(); return bb.getMin(min); } else if (wb instanceof BoundingSphere) { BoundingSphere bs = (BoundingSphere) wb; float radius = bs.getRadius(); return new Vector3f(-radius, -radius, -radius); } return spatial.getWorldTranslation(); }
private void expandBoxToContainTri(BoundingBox bbox, OCTTriangle t){ Vector3f min = bbox.getMin(null); Vector3f max = bbox.getMax(null); BoundingBox.checkMinMax(min, max, t.get1()); BoundingBox.checkMinMax(min, max, t.get2()); BoundingBox.checkMinMax(min, max, t.get3()); bbox.setMinMax(min, max); }
/** * Instantly emits available particles, up to num. */ public void emitParticles(int num) { // Force world transform to update this.getWorldTransform(); TempVars vars = TempVars.get(); BoundingBox bbox = (BoundingBox) this.getMesh().getBound(); Vector3f min = vars.vect1; Vector3f max = vars.vect2; bbox.getMin(min); bbox.getMax(max); if (!Vector3f.isValidVector(min)) { min.set(Vector3f.POSITIVE_INFINITY); } if (!Vector3f.isValidVector(max)) { max.set(Vector3f.NEGATIVE_INFINITY); } for(int i=0;i<num;i++) { if( emitParticle(min, max) == null ) break; } bbox.setMinMax(min, max); this.setBoundRefresh(); vars.release(); }
/** * Instantly emits all the particles possible to be emitted. Any particles * which are currently inactive will be spawned immediately. */ public void emitAllParticles() { // Force world transform to update this.getWorldTransform(); TempVars vars = TempVars.get(); BoundingBox bbox = (BoundingBox) this.getMesh().getBound(); Vector3f min = vars.vect1; Vector3f max = vars.vect2; bbox.getMin(min); bbox.getMax(max); if (!Vector3f.isValidVector(min)) { min.set(Vector3f.POSITIVE_INFINITY); } if (!Vector3f.isValidVector(max)) { max.set(Vector3f.NEGATIVE_INFINITY); } while (emitParticle(min, max) != null); bbox.setMinMax(min, max); this.setBoundRefresh(); vars.release(); }
Vector3f splitMin = splitBB.getMin(vars.vect1); Vector3f splitMax = splitBB.getMax(vars.vect2);