/** * Constructor instantiates a new <code>StripBox</code> object. The minimum and maximum point are provided. These * two points define the shape and size of the box, but not it's orientation or position. You should use the * <code>setTranslation</code> and <code>setLocalRotation</code> for those attributes. * * @param name * the name of the scene element. This is required for identification and comparison purposes. * @param min * the minimum point that defines the box. * @param max * the maximum point that defines the box. */ public StripBox(final String name, final Vector3 min, final Vector3 max) { super(name); setData(min, max); }
/** * Changes the data of the box so that its center is <code>center</code> and it extends in the x, y, and z * directions by the given extent. Note that the actual sides will be 2x the given extent values because the box * extends in + & - from the center for each extent. * * @param center * The center of the box. * @param xExtent * x extent of the box, in both directions. * @param yExtent * y extent of the box, in both directions. * @param zExtent * z extent of the box, in both directions. */ public void setData(final Vector3 center, final double xExtent, final double yExtent, final double zExtent) { if (center != null) { _center.set(center); } _xExtent = xExtent; _yExtent = yExtent; _zExtent = zExtent; setVertexData(); setNormalData(); setTextureData(); setIndexData(); }
/** * * <code>setVertexData</code> sets the vertex positions that define the box. These eight points are determined from * the minimum and maximum point. * */ private void setVertexData() { _meshData.setVertexBuffer(BufferUtils.createVector3Buffer(_meshData.getVertexBuffer(), 8)); final Vector3[] vert = computeVertices(); // returns 8 _meshData.getVertexBuffer().clear(); _meshData.getVertexBuffer().put(vert[0].getXf()).put(vert[0].getYf()).put(vert[0].getZf()); _meshData.getVertexBuffer().put(vert[1].getXf()).put(vert[1].getYf()).put(vert[1].getZf()); _meshData.getVertexBuffer().put(vert[2].getXf()).put(vert[2].getYf()).put(vert[2].getZf()); _meshData.getVertexBuffer().put(vert[3].getXf()).put(vert[3].getYf()).put(vert[3].getZf()); _meshData.getVertexBuffer().put(vert[4].getXf()).put(vert[4].getYf()).put(vert[4].getZf()); _meshData.getVertexBuffer().put(vert[5].getXf()).put(vert[5].getYf()).put(vert[5].getZf()); _meshData.getVertexBuffer().put(vert[6].getXf()).put(vert[6].getYf()).put(vert[6].getZf()); _meshData.getVertexBuffer().put(vert[7].getXf()).put(vert[7].getYf()).put(vert[7].getZf()); }
/** * * <code>setVertexData</code> sets the vertex positions that define the box. These eight points are determined from * the minimum and maximum point. * */ private void setVertexData() { _meshData.setVertexBuffer(BufferUtils.createVector3Buffer(_meshData.getVertexBuffer(), 8)); final Vector3[] vert = computeVertices(); // returns 8 _meshData.getVertexBuffer().clear(); _meshData.getVertexBuffer().put(vert[0].getXf()).put(vert[0].getYf()).put(vert[0].getZf()); _meshData.getVertexBuffer().put(vert[1].getXf()).put(vert[1].getYf()).put(vert[1].getZf()); _meshData.getVertexBuffer().put(vert[2].getXf()).put(vert[2].getYf()).put(vert[2].getZf()); _meshData.getVertexBuffer().put(vert[3].getXf()).put(vert[3].getYf()).put(vert[3].getZf()); _meshData.getVertexBuffer().put(vert[4].getXf()).put(vert[4].getYf()).put(vert[4].getZf()); _meshData.getVertexBuffer().put(vert[5].getXf()).put(vert[5].getYf()).put(vert[5].getZf()); _meshData.getVertexBuffer().put(vert[6].getXf()).put(vert[6].getYf()).put(vert[6].getZf()); _meshData.getVertexBuffer().put(vert[7].getXf()).put(vert[7].getYf()).put(vert[7].getZf()); }
/** * Changes the data of the box so that its center is <code>center</code> and it extends in the x, y, and z * directions by the given extent. Note that the actual sides will be 2x the given extent values because the box * extends in + & - from the center for each extent. * * @param center * The center of the box. * @param xExtent * x extent of the box, in both directions. * @param yExtent * y extent of the box, in both directions. * @param zExtent * z extent of the box, in both directions. */ public void setData(final Vector3 center, final double xExtent, final double yExtent, final double zExtent) { if (center != null) { _center.set(center); } _xExtent = xExtent; _yExtent = yExtent; _zExtent = zExtent; setVertexData(); setNormalData(); setTextureData(); setIndexData(); }
/** * Constructor instantiates a new <code>StripBox</code> object. The minimum and maximum point are provided. These * two points define the shape and size of the box, but not it's orientation or position. You should use the * <code>setTranslation</code> and <code>setLocalRotation</code> for those attributes. * * @param name * the name of the scene element. This is required for identification and comparison purposes. * @param min * the minimum point that defines the box. * @param max * the maximum point that defines the box. */ public StripBox(final String name, final Vector3 min, final Vector3 max) { super(name); setData(min, max); }
/** * * <code>setNormalData</code> sets the normals of each of the box's planes. * * */ private void setNormalData() { final Vector3[] vert = computeVertices(); // returns 8 _meshData.setNormalBuffer(BufferUtils.createVector3Buffer(_meshData.getNormalBuffer(), 8)); final Vector3 norm = new Vector3(); _meshData.getNormalBuffer().clear(); for (int i = 0; i < 8; i++) { norm.set(vert[i]).normalizeLocal(); _meshData.getNormalBuffer().put(norm.getXf()).put(norm.getYf()).put(norm.getZf()); } }
/** * Constructs a new box. The box has the given center and extends in the x, y, and z out from the center (+ and -) * by the given amounts. So, for example, a box with extent of .5 would be the unit cube. * * @param name * Name of the box. * @param center * Center of the box. * @param xExtent * x extent of the box, in both directions. * @param yExtent * y extent of the box, in both directions. * @param zExtent * z extent of the box, in both directions. */ public StripBox(final String name, final Vector3 center, final double xExtent, final double yExtent, final double zExtent) { super(name); setData(center, xExtent, yExtent, zExtent); }
/** * * <code>setNormalData</code> sets the normals of each of the box's planes. * * */ private void setNormalData() { final Vector3[] vert = computeVertices(); // returns 8 _meshData.setNormalBuffer(BufferUtils.createVector3Buffer(_meshData.getNormalBuffer(), 8)); final Vector3 norm = new Vector3(); _meshData.getNormalBuffer().clear(); for (int i = 0; i < 8; i++) { norm.set(vert[i]).normalizeLocal(); _meshData.getNormalBuffer().put(norm.getXf()).put(norm.getYf()).put(norm.getZf()); } }
/** * Constructs a new box. The box has the given center and extends in the x, y, and z out from the center (+ and -) * by the given amounts. So, for example, a box with extent of .5 would be the unit cube. * * @param name * Name of the box. * @param center * Center of the box. * @param xExtent * x extent of the box, in both directions. * @param yExtent * y extent of the box, in both directions. * @param zExtent * z extent of the box, in both directions. */ public StripBox(final String name, final Vector3 center, final double xExtent, final double yExtent, final double zExtent) { super(name); setData(center, xExtent, yExtent, zExtent); }
/** * Changes the data of the box so that the two opposite corners are minPoint and maxPoint. The other corners are * created from those two poitns. If update buffers is flagged as true, the vertex/normal/texture/color/index * buffers are updated when the data is changed. * * @param minPoint * The new minPoint of the box. * @param maxPoint * The new maxPoint of the box. */ public void setData(final Vector3 minPoint, final Vector3 maxPoint) { _center.set(maxPoint).addLocal(minPoint).multiplyLocal(0.5f); final double x = maxPoint.getX() - _center.getX(); final double y = maxPoint.getY() - _center.getY(); final double z = maxPoint.getZ() - _center.getZ(); setData(_center, x, y, z); }
/** * Changes the data of the box so that the two opposite corners are minPoint and maxPoint. The other corners are * created from those two poitns. If update buffers is flagged as true, the vertex/normal/texture/color/index * buffers are updated when the data is changed. * * @param minPoint * The new minPoint of the box. * @param maxPoint * The new maxPoint of the box. */ public void setData(final Vector3 minPoint, final Vector3 maxPoint) { _center.set(maxPoint).addLocal(minPoint).multiplyLocal(0.5f); final double x = maxPoint.getX() - _center.getX(); final double y = maxPoint.getY() - _center.getY(); final double z = maxPoint.getZ() - _center.getZ(); setData(_center, x, y, z); }