public void putBox(Vector3f pos, float size, ColorRGBA color){ putShape(new WireBox(size, size, size), color, 1).setLocalTranslation(pos); }
public WireBox(float xExt, float yExt, float zExt){ updatePositions(xExt,yExt,zExt); setBuffer(Type.Index, 2, new short[]{ 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7, } ); setMode(Mode.Lines); updateCounts(); }
public void updatePositions(float xExt, float yExt, float zExt){ VertexBuffer pvb = getBuffer(Type.Position); FloatBuffer pb; if (pvb == null){ pvb = new VertexBuffer(Type.Position); pb = BufferUtils.createVector3Buffer(8); pvb.setupData(Usage.Dynamic, 3, Format.Float, pb); setBuffer(pvb); }else{ pb = (FloatBuffer) pvb.getData(); pvb.updateData(pb); } pb.rewind(); pb.put( new float[]{ -xExt, -yExt, zExt, xExt, -yExt, zExt, xExt, yExt, zExt, -xExt, yExt, zExt, -xExt, -yExt, -zExt, xExt, -yExt, -zExt, xExt, yExt, -zExt, -xExt, yExt, -zExt, } ); updateBound(); }
private void setupVisualsForSelection() { matWireBox = new Material(this.app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); matWireBox.getAdditionalRenderState().setFaceCullMode(FaceCullMode.Off); matWireBox.setColor("Color", selectionColor.getColor()); matWireBox.getAdditionalRenderState().setLineWidth(6); this.wireBox = new WireBox(MapLoader.TILE_WIDTH, MapLoader.TILE_WIDTH, MapLoader.TILE_WIDTH); this.wireBox.setDynamic(); this.wireBoxGeo = new Geometry("wireBox", wireBox); this.wireBoxGeo.setMaterial(matWireBox); this.wireBoxGeo.setCullHint(CullHint.Never); this.wireBoxGeo.setShadowMode(RenderQueue.ShadowMode.Off); this.app.getRootNode().attachChild(this.wireBoxGeo); }
public void fromBoundingBox(BoundingBox bbox){ updatePositions(bbox.getXExtent(), bbox.getYExtent(), bbox.getZExtent()); }
public void updateSelectionBox() { if (isVisible()) { float dx = selectionArea.getDeltaX(); float dy = selectionArea.getDeltaY(); float delta = 0.01f; Vector2f position = selectionArea.getCenter(); wireBoxGeo.setLocalTranslation(position.x, MapLoader.FLOOR_HEIGHT, position.y); wireBox.updatePositions(MapLoader.TILE_WIDTH / 2 * dx + delta, MapLoader.FLOOR_HEIGHT + delta, MapLoader.TILE_WIDTH / 2 * dy + delta); // Selection color indicator ColorIndicator newSelectionColor = getColorIndicator(); if (!newSelectionColor.equals(selectionColor)) { selectionColor = newSelectionColor; matWireBox.setColor("Color", selectionColor.getColor()); } this.wireBoxGeo.setCullHint(CullHint.Never); } else { this.wireBoxGeo.setCullHint(CullHint.Always); } }
public WireBox(float xExt, float yExt, float zExt){ updatePositions(xExt,yExt,zExt); setBuffer(Type.Index, 2, new short[]{ 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7, } ); setMode(Mode.Lines); updateCounts(); }
public void updatePositions(float xExt, float yExt, float zExt){ VertexBuffer pvb = getBuffer(Type.Position); FloatBuffer pb; if (pvb == null){ pvb = new VertexBuffer(Type.Position); pb = BufferUtils.createVector3Buffer(8); pvb.setupData(Usage.Dynamic, 3, Format.Float, pb); setBuffer(pvb); }else{ pb = (FloatBuffer) pvb.getData(); pvb.updateData(pb); } pb.rewind(); pb.put( new float[]{ -xExt, -yExt, zExt, xExt, -yExt, zExt, xExt, yExt, zExt, -xExt, yExt, zExt, -xExt, -yExt, -zExt, xExt, -yExt, -zExt, xExt, yExt, -zExt, -xExt, yExt, -zExt, } ); updateBound(); }
/** * Create a geometry suitable for visualizing the specified bounding box. * * @param bbox the bounding box (not null) * @return a new Geometry instance in world space */ public static Geometry makeGeometry(BoundingBox bbox) { float xExtent = bbox.getXExtent(); float yExtent = bbox.getYExtent(); float zExtent = bbox.getZExtent(); WireBox mesh = new WireBox(xExtent, yExtent, zExtent); Geometry result = new Geometry("bounding box", mesh); Vector3f center = bbox.getCenter(); result.setLocalTranslation(center); return result; } }
public WireBox(float xExt, float yExt, float zExt){ updatePositions(xExt,yExt,zExt); setBuffer(Type.Index, 2, new short[]{ 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7, } ); setMode(Mode.Lines); updateCounts(); }
public void updatePositions(float xExt, float yExt, float zExt){ VertexBuffer pvb = getBuffer(Type.Position); FloatBuffer pb; if (pvb == null){ pvb = new VertexBuffer(Type.Position); pb = BufferUtils.createVector3Buffer(8); pvb.setupData(Usage.Dynamic, 3, Format.Float, pb); setBuffer(pvb); }else{ pb = (FloatBuffer) pvb.getData(); pvb.updateData(pb); } pb.rewind(); pb.put( new float[]{ -xExt, -yExt, zExt, xExt, -yExt, zExt, xExt, yExt, zExt, -xExt, yExt, zExt, -xExt, -yExt, -zExt, xExt, -yExt, -zExt, xExt, yExt, -zExt, -xExt, yExt, -zExt, } ); updateBound(); }
/** * used by attachBoundChildren() */ private void attachBoundingBox(BoundingBox bb, Node parent) { WireBox wb = new WireBox(bb.getXExtent(), bb.getYExtent(), bb.getZExtent()); Geometry g = new Geometry(); g.setMesh(wb); g.setLocalTranslation(bb.getCenter()); parent.attachChild(g); }
WireBox box = new WireBox(bb.getXExtent(), bb.getYExtent(), bb.getZExtent()); Geometry geom = new Geometry(test.name + " bounds", box); geom.setMaterial(new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md")); box = new WireBox(size, size, 0); geom = new Geometry(test.name + " metric", box); geom.setMaterial(new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"));
/** * Create a geometry suitable for visualizing the specified bounding box. * * @param bbox the bounding box (not null) * @return a new Geometry instance in world space */ public static Geometry makeGeometry(BoundingBox bbox) { float xExtent = bbox.getXExtent(); float yExtent = bbox.getYExtent(); float zExtent = bbox.getZExtent(); WireBox mesh = new WireBox(xExtent, yExtent, zExtent); Geometry result = new Geometry("bounding box", mesh); Vector3f center = bbox.getCenter(); result.setLocalTranslation(center); return result; } }
/** * used by attachBoundChildren() */ private void attachBoundingBox(BoundingBox bb, Node parent) { WireBox wb = new WireBox(bb.getXExtent(), bb.getYExtent(), bb.getZExtent()); Geometry g = new Geometry(); g.setMesh(wb); g.setLocalTranslation(bb.getCenter()); parent.attachChild(g); }