com.jme3.scene.debug.WireBox Java Examples

The following examples show how to use com.jme3.scene.debug.WireBox. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SceneToolController.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
protected void attachBoxSelection(Spatial geom) {
    BoundingVolume bound = geom.getWorldBound();
    if (bound instanceof BoundingBox) {
        BoundingBox bbox = (BoundingBox) bound;
        Vector3f extent = new Vector3f();
        bbox.getExtent(extent);
        WireBox wireBox = new WireBox();
        wireBox.fromBoundingBox(bbox);
        selctionShapeOffset.set(bbox.getCenter()).subtractLocal(geom.getWorldTranslation());
        Geometry selectionGeometry = new Geometry("selection_geometry_sceneviewer", wireBox);
        selectionGeometry.setMaterial(blueMat);
        selectionGeometry.setLocalTransform(geom.getWorldTransform());
        selectionGeometry.setLocalTranslation(bbox.getCenter());
        toolsNode.attachChild(selectionGeometry);
        selectionShape = selectionGeometry;

    }
}
 
Example #2
Source File: DragAndDropDemoState.java    From Lemur with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public ContainerNode( String name, ColorRGBA color ) {
    super(name);
    material = GuiGlobals.getInstance().createMaterial(containerColor, false);
           
    wire = new WireBox(1, 1, 1);
    wireGeom = new Geometry(name + ".wire", wire);
    wireGeom.setMaterial(material.getMaterial());
    attachChild(wireGeom);
    
    box = new Box(1, 1, 1);
    boxGeom = new Geometry(name + ".box", box);
    boxGeom.setMaterial(material.getMaterial()); // might as well reuse it
    boxGeom.setCullHint(CullHint.Always); // invisible
    attachChild(boxGeom);
}
 
Example #3
Source File: TerrainQuad.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * 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);
}
 
Example #4
Source File: TerrainQuad.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * 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);
}
 
Example #5
Source File: Octnode.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void renderBounds(RenderQueue rq, Matrix4f transform, WireBox box, Material mat){
        int numChilds = 0;
        for (int i = 0; i < 8; i++){
            if (children[i] != null){
                numChilds ++;
                break;
            }
        }
        if (geoms != null && numChilds == 0){
            BoundingBox bbox2 = new BoundingBox(bbox);
            bbox.transform(transform, bbox2);
//            WireBox box = new WireBox(bbox2.getXExtent(), bbox2.getYExtent(),
//                                      bbox2.getZExtent());
//            WireBox box = new WireBox(1,1,1);

            Geometry geom = new Geometry("bound", box);
            geom.setLocalTranslation(bbox2.getCenter());
            geom.setLocalScale(bbox2.getXExtent(), bbox2.getYExtent(),
                               bbox2.getZExtent());
            geom.updateGeometricState();
            geom.setMaterial(mat);
            rq.addToQueue(geom, Bucket.Opaque);
            box = null;
            geom = null;
        }
        for (int i = 0; i < 8; i++){
            if (children[i] != null){
                children[i].renderBounds(rq, transform, box, mat);
            }
        }
    }
 
Example #6
Source File: AbstractSceneEditor3DPart.java    From jmonkeybuilder with Apache License 2.0 4 votes vote down vote up
@Override
protected void postCameraUpdate(final float tpf) {
    super.postCameraUpdate(tpf);

    final Array<EditorLightNode> lightNodes = getLightNodes();
    lightNodes.forEach(EditorLightNode::updateModel);

    final Array<EditorAudioNode> audioNodes = getAudioNodes();
    audioNodes.forEach(EditorAudioNode::updateModel);

    final Array<EditorPresentableNode> presentableNodes = getPresentableNodes();
    presentableNodes.forEach(EditorPresentableNode::updateModel);

    final Array<Spatial> selected = getSelected();
    selected.forEach(this, (spatial, state) -> {

        if (spatial instanceof EditorLightNode) {
            spatial = ((EditorLightNode) spatial).getModel();
        } else if (spatial instanceof EditorAudioNode) {
            spatial = ((EditorAudioNode) spatial).getModel();
        } else if (spatial instanceof EditorPresentableNode) {
            spatial = ((EditorPresentableNode) spatial).getModel();
        }

        if (spatial == null) {
            return;
        }

        state.updateTransformNode(spatial.getWorldTransform());

        final ObjectDictionary<Spatial, Geometry> selectionShape = state.getSelectionShape();
        final Geometry shape = selectionShape.get(spatial);
        if (shape == null) {
            return;
        }

        final Vector3f position = shape.getLocalTranslation();
        position.set(spatial.getWorldTranslation());

        final Vector3f center = shape.getUserData(KEY_SHAPE_CENTER);
        final Vector3f initScale = shape.getUserData(KEY_SHAPE_INIT_SCALE);

        if (center != null) {

            if (!initScale.equals(spatial.getLocalScale())) {

                initScale.set(spatial.getLocalScale());

                NodeUtils.updateWorldBound(spatial);

                final BoundingBox bound = (BoundingBox) spatial.getWorldBound();
                bound.getCenter().subtract(spatial.getWorldTranslation(), center);

                final WireBox mesh = (WireBox) shape.getMesh();
                mesh.updatePositions(bound.getXExtent(), bound.getYExtent(), bound.getZExtent());
            }

            position.addLocal(center);

        } else {
            shape.setLocalRotation(spatial.getWorldRotation());
            shape.setLocalScale(spatial.getWorldScale());
        }

        shape.setLocalTranslation(position);
    });

    transformToolNode.detachAllChildren();

    if (transformType == TransformType.MOVE_TOOL) {
        transformToolNode.attachChild(getMoveTool());
    } else if (transformType == TransformType.ROTATE_TOOL) {
        transformToolNode.attachChild(getRotateTool());
    } else if (transformType == TransformType.SCALE_TOOL) {
        transformToolNode.attachChild(getScaleTool());
    }

    final Node toolNode = getToolNode();

    // FIXME change when will support transform multi-nodes
    if (selected.size() != 1) {
        toolNode.detachChild(transformToolNode);
    } else if (!isPaintingMode()) {
        toolNode.attachChild(transformToolNode);
    }

    if (isPaintingMode()) {
        updatePaintingNodes();
        updatePainting(tpf);
    }
}
 
Example #7
Source File: TestDebugShapes.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void putBox(Vector3f pos, float size, ColorRGBA color){
    putShape(new WireBox(size, size, size), color, 1).setLocalTranslation(pos);
}
 
Example #8
Source File: Octree.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void renderBounds(RenderQueue rq, Matrix4f transform, WireBox box, Material mat){
    root.renderBounds(rq, transform, box, mat);
}
 
Example #9
Source File: TestDebugShapes.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void putBox(Vector3f pos, float size, ColorRGBA color){
    putShape(new WireBox(size, size, size), color).setLocalTranslation(pos);
}