com.jme3.scene.debug.Grid Java Examples

The following examples show how to use com.jme3.scene.debug.Grid. 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: AbstractSceneEditor3DPart.java    From jmonkeybuilder with Apache License 2.0 4 votes vote down vote up
@FromAnyThread
private @NotNull Node createGrid() {

    final Node gridNode = new Node("GridNode");

    final ColorRGBA gridColor = new ColorRGBA(0.4f, 0.4f, 0.4f, 0.5f);
    final ColorRGBA xColor = new ColorRGBA(1.0f, 0.1f, 0.1f, 0.5f);
    final ColorRGBA zColor = new ColorRGBA(0.1f, 1.0f, 0.1f, 0.5f);

    final Material gridMaterial = createColorMaterial(gridColor);
    gridMaterial.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);

    final Material xMaterial = createColorMaterial(xColor);
    xMaterial.getAdditionalRenderState().setLineWidth(5);

    final Material zMaterial = createColorMaterial(zColor);
    zMaterial.getAdditionalRenderState().setLineWidth(5);

    final int gridSize = getGridSize();

    final Geometry grid = new Geometry("grid", new Grid(gridSize, gridSize, 1.0f));
    grid.setMaterial(gridMaterial);
    grid.setQueueBucket(RenderQueue.Bucket.Transparent);
    grid.setShadowMode(RenderQueue.ShadowMode.Off);
    grid.setCullHint(Spatial.CullHint.Never);
    grid.setLocalTranslation(gridSize / 2 * -1, 0, gridSize / 2 * -1);

    final Quad quad = new Quad(gridSize, gridSize);
    final Geometry gridCollision = new Geometry("collision", quad);
    gridCollision.setMaterial(createColorMaterial(gridColor));
    gridCollision.setQueueBucket(RenderQueue.Bucket.Transparent);
    gridCollision.setShadowMode(RenderQueue.ShadowMode.Off);
    gridCollision.setCullHint(Spatial.CullHint.Always);
    gridCollision.setLocalTranslation(gridSize / 2 * -1, 0, gridSize / 2 * -1);
    gridCollision.setLocalRotation(new Quaternion().fromAngles(AngleUtils.degreeToRadians(90), 0, 0));

    gridNode.attachChild(grid);
    gridNode.attachChild(gridCollision);

    // Red line for X axis
    final Line xAxis = new Line(new Vector3f(-gridSize / 2, 0f, 0f), new Vector3f(gridSize / 2 - 1, 0f, 0f));

    final Geometry gxAxis = new Geometry("XAxis", xAxis);
    gxAxis.setModelBound(new BoundingBox());
    gxAxis.setShadowMode(RenderQueue.ShadowMode.Off);
    gxAxis.setCullHint(Spatial.CullHint.Never);
    gxAxis.setMaterial(xMaterial);

    gridNode.attachChild(gxAxis);

    // Blue line for Z axis
    final Line zAxis = new Line(new Vector3f(0f, 0f, -gridSize / 2), new Vector3f(0f, 0f, gridSize / 2 - 1));

    final Geometry gzAxis = new Geometry("ZAxis", zAxis);
    gzAxis.setModelBound(new BoundingBox());
    gzAxis.setShadowMode(RenderQueue.ShadowMode.Off);
    gzAxis.setCullHint(Spatial.CullHint.Never);
    gzAxis.setMaterial(zMaterial);

    gridNode.attachChild(gzAxis);

    return gridNode;
}
 
Example #2
Source File: TestDebugShapes.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void putGrid(Vector3f pos, ColorRGBA color){
    putShape(new Grid(6, 6, 0.2f), color, 1).center().move(pos);
}
 
Example #3
Source File: TestDebugShapes.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void putGrid(Vector3f pos, ColorRGBA color){
    putShape(new Grid(6, 6, 0.2f), color).center().move(pos);
}