builder.line(planePoints[0], frustumColor, planePoints[1], frustumColor); builder.line(planePoints[1], frustumColor, planePoints[2], frustumColor); builder.line(planePoints[2], frustumColor, planePoints[3], frustumColor); builder.line(planePoints[3], frustumColor, planePoints[0], frustumColor); builder.line(planePoints[4], frustumColor, planePoints[5], frustumColor); builder.line(planePoints[5], frustumColor, planePoints[6], frustumColor); builder.line(planePoints[6], frustumColor, planePoints[7], frustumColor); builder.line(planePoints[7], frustumColor, planePoints[4], frustumColor); builder.line(planePoints[0], frustumColor, planePoints[4], frustumColor); builder.line(planePoints[1], frustumColor, planePoints[5], frustumColor); builder.line(planePoints[2], frustumColor, planePoints[6], frustumColor); builder.line(planePoints[3], frustumColor, planePoints[7], frustumColor); builder.line(middlePoint(planePoints[1], planePoints[0]), crossColor, middlePoint(planePoints[3], planePoints[2]), crossColor); builder.line(middlePoint(planePoints[2], planePoints[1]), crossColor, middlePoint(planePoints[3], planePoints[0]), crossColor); builder.line(middlePoint(planePoints[5], planePoints[4]), crossColor, middlePoint(planePoints[7], planePoints[6]), crossColor); builder.line(middlePoint(planePoints[6], planePoints[5]), crossColor, middlePoint(planePoints[7], planePoints[4]), crossColor);
builder.line(planePoints[0], frustumColor, planePoints[1], frustumColor); builder.line(planePoints[1], frustumColor, planePoints[2], frustumColor); builder.line(planePoints[2], frustumColor, planePoints[3], frustumColor); builder.line(planePoints[3], frustumColor, planePoints[0], frustumColor); builder.line(planePoints[4], frustumColor, planePoints[5], frustumColor); builder.line(planePoints[5], frustumColor, planePoints[6], frustumColor); builder.line(planePoints[6], frustumColor, planePoints[7], frustumColor); builder.line(planePoints[7], frustumColor, planePoints[4], frustumColor); builder.line(planePoints[0], frustumColor, planePoints[4], frustumColor); builder.line(planePoints[1], frustumColor, planePoints[5], frustumColor); builder.line(planePoints[2], frustumColor, planePoints[6], frustumColor); builder.line(planePoints[3], frustumColor, planePoints[7], frustumColor); builder.line(middlePoint(planePoints[1], planePoints[0]), crossColor, middlePoint(planePoints[3], planePoints[2]), crossColor); builder.line(middlePoint(planePoints[2], planePoints[1]), crossColor, middlePoint(planePoints[3], planePoints[0]), crossColor); builder.line(middlePoint(planePoints[5], planePoints[4]), crossColor, middlePoint(planePoints[7], planePoints[6]), crossColor); builder.line(middlePoint(planePoints[6], planePoints[5]), crossColor, middlePoint(planePoints[7], planePoints[4]), crossColor);
/** Build Camera with custom colors * @param builder * @param camera * @param frustumColor * @param coneColor * @param upColor * @param targetColor * @param crossColor */ public static void build (MeshPartBuilder builder, Camera camera, Color frustumColor, Color coneColor, Color upColor, Color targetColor, Color crossColor) { Vector3[] planePoints = camera.frustum.planePoints; // Frustum build(builder, camera.frustum, frustumColor, crossColor); // Cones (camera position to near plane) builder.line(planePoints[0], coneColor, camera.position, coneColor); builder.line(planePoints[1], coneColor, camera.position, coneColor); builder.line(planePoints[2], coneColor, camera.position, coneColor); builder.line(planePoints[3], coneColor, camera.position, coneColor); // Target line builder.line(camera.position, targetColor, centerPoint(planePoints[4], planePoints[5], planePoints[6]), targetColor); // Up triangle float halfNearSize = tmpV0.set(planePoints[1]).sub(planePoints[0]).scl(0.5f).len(); Vector3 centerNear = centerPoint(planePoints[0], planePoints[1], planePoints[2]); tmpV0.set(camera.up).scl(halfNearSize * 2); centerNear.add(tmpV0); builder.line(centerNear, upColor, planePoints[2], upColor); builder.line(planePoints[2], upColor, planePoints[3], upColor); builder.line(planePoints[3], upColor, centerNear, upColor); }
/** Build Camera with custom colors * @param builder * @param camera * @param frustumColor * @param coneColor * @param upColor * @param targetColor * @param crossColor */ public static void build (MeshPartBuilder builder, Camera camera, Color frustumColor, Color coneColor, Color upColor, Color targetColor, Color crossColor) { Vector3[] planePoints = camera.frustum.planePoints; // Frustum build(builder, camera.frustum, frustumColor, crossColor); // Cones (camera position to near plane) builder.line(planePoints[0], coneColor, camera.position, coneColor); builder.line(planePoints[1], coneColor, camera.position, coneColor); builder.line(planePoints[2], coneColor, camera.position, coneColor); builder.line(planePoints[3], coneColor, camera.position, coneColor); // Target line builder.line(camera.position, targetColor, centerPoint(planePoints[4], planePoints[5], planePoints[6]), targetColor); // Up triangle float halfNearSize = tmpV0.set(planePoints[1]).sub(planePoints[0]).scl(0.5f).len(); Vector3 centerNear = centerPoint(planePoints[0], planePoints[1], planePoints[2]); tmpV0.set(camera.up).scl(halfNearSize * 2); centerNear.add(tmpV0); builder.line(centerNear, upColor, planePoints[2], upColor); builder.line(planePoints[2], upColor, planePoints[3], upColor); builder.line(planePoints[3], upColor, centerNear, upColor); }
/** Convenience method to create a model which represents a grid of lines on the XZ plane. The resources the Material might * contain are not managed, use {@link Model#manageDisposable(Disposable)} to add those to the model. * @param xDivisions row count along x axis. * @param zDivisions row count along z axis. * @param xSize Length of a single row on x. * @param zSize Length of a single row on z. */ public Model createLineGrid (int xDivisions, int zDivisions, float xSize, float zSize, Material material, long attributes) { begin(); MeshPartBuilder partBuilder = part("lines", GL20.GL_LINES, attributes, material); float xlength = xDivisions * xSize, zlength = zDivisions * zSize, hxlength = xlength / 2, hzlength = zlength / 2; float x1 = -hxlength, y1 = 0, z1 = hzlength, x2 = -hxlength, y2 = 0, z2 = -hzlength; for (int i = 0; i <= xDivisions; ++i) { partBuilder.line(x1, y1, z1, x2, y2, z2); x1 += xSize; x2 += xSize; } x1 = -hxlength; y1 = 0; z1 = -hzlength; x2 = hxlength; y2 = 0; z2 = -hzlength; for (int j = 0; j <= zDivisions; ++j) { partBuilder.line(x1, y1, z1, x2, y2, z2); z1 += zSize; z2 += zSize; } return end(); }
/** Convenience method to create a model which represents a grid of lines on the XZ plane. The resources the Material might * contain are not managed, use {@link Model#manageDisposable(Disposable)} to add those to the model. * @param xDivisions row count along x axis. * @param zDivisions row count along z axis. * @param xSize Length of a single row on x. * @param zSize Length of a single row on z. */ public Model createLineGrid (int xDivisions, int zDivisions, float xSize, float zSize, Material material, long attributes) { begin(); MeshPartBuilder partBuilder = part("lines", GL20.GL_LINES, attributes, material); float xlength = xDivisions * xSize, zlength = zDivisions * zSize, hxlength = xlength / 2, hzlength = zlength / 2; float x1 = -hxlength, y1 = 0, z1 = hzlength, x2 = -hxlength, y2 = 0, z2 = -hzlength; for (int i = 0; i <= xDivisions; ++i) { partBuilder.line(x1, y1, z1, x2, y2, z2); x1 += xSize; x2 += xSize; } x1 = -hxlength; y1 = 0; z1 = -hzlength; x2 = hxlength; y2 = 0; z2 = -hzlength; for (int j = 0; j <= zDivisions; ++j) { partBuilder.line(x1, y1, z1, x2, y2, z2); z1 += zSize; z2 += zSize; } return end(); }
private void createAxes () { ModelBuilder modelBuilder = new ModelBuilder(); modelBuilder.begin(); MeshPartBuilder builder = modelBuilder.part("grid", GL20.GL_LINES, Usage.Position | Usage.ColorUnpacked, new Material()); builder.setColor(Color.LIGHT_GRAY); for (float t = GRID_MIN; t <= GRID_MAX; t += GRID_STEP) { builder.line(t, 0, GRID_MIN, t, 0, GRID_MAX); builder.line(GRID_MIN, 0, t, GRID_MAX, 0, t); } builder = modelBuilder.part("axes", GL20.GL_LINES, Usage.Position | Usage.ColorUnpacked, new Material()); builder.setColor(Color.RED); builder.line(0, 0, 0, 100, 0, 0); builder.setColor(Color.GREEN); builder.line(0, 0, 0, 0, 100, 0); builder.setColor(Color.BLUE); builder.line(0, 0, 0, 0, 0, 100); axesModel = modelBuilder.end(); axesInstance = new ModelInstance(axesModel); }
i2 = i1; } else if (innerWidth == width && innerHeight == height) { if (i != 0) builder.line(i1, i2); i2 = i1; } else {
i2 = i1; } else if (innerWidth == width && innerHeight == height) { if (i != 0) builder.line(i1, i2); i2 = i1; } else {
builder.line(planePoints[0], frustumColor, planePoints[1], frustumColor); builder.line(planePoints[1], frustumColor, planePoints[2], frustumColor); builder.line(planePoints[2], frustumColor, planePoints[3], frustumColor); builder.line(planePoints[3], frustumColor, planePoints[0], frustumColor); builder.line(planePoints[4], frustumColor, planePoints[5], frustumColor); builder.line(planePoints[5], frustumColor, planePoints[6], frustumColor); builder.line(planePoints[6], frustumColor, planePoints[7], frustumColor); builder.line(planePoints[7], frustumColor, planePoints[4], frustumColor); builder.line(planePoints[0], frustumColor, planePoints[4], frustumColor); builder.line(planePoints[1], frustumColor, planePoints[5], frustumColor); builder.line(planePoints[2], frustumColor, planePoints[6], frustumColor); builder.line(planePoints[3], frustumColor, planePoints[7], frustumColor); builder.line(middlePoint(planePoints[1], planePoints[0]), crossColor, middlePoint(planePoints[3], planePoints[2]), crossColor); builder.line(middlePoint(planePoints[2], planePoints[1]), crossColor, middlePoint(planePoints[3], planePoints[0]), crossColor); builder.line(middlePoint(planePoints[5], planePoints[4]), crossColor, middlePoint(planePoints[7], planePoints[6]), crossColor); builder.line(middlePoint(planePoints[6], planePoints[5]), crossColor, middlePoint(planePoints[7], planePoints[4]), crossColor);
/** Build Camera with custom colors * @param builder * @param camera * @param frustumColor * @param coneColor * @param upColor * @param targetColor * @param crossColor */ public static void build (MeshPartBuilder builder, Camera camera, Color frustumColor, Color coneColor, Color upColor, Color targetColor, Color crossColor) { Vector3[] planePoints = camera.frustum.planePoints; // Frustum build(builder, camera.frustum, frustumColor, crossColor); // Cones (camera position to near plane) builder.line(planePoints[0], coneColor, camera.position, coneColor); builder.line(planePoints[1], coneColor, camera.position, coneColor); builder.line(planePoints[2], coneColor, camera.position, coneColor); builder.line(planePoints[3], coneColor, camera.position, coneColor); // Target line builder.line(camera.position, targetColor, centerPoint(planePoints[4], planePoints[5], planePoints[6]), targetColor); // Up triangle float halfNearSize = tmpV0.set(planePoints[1]).sub(planePoints[0]).scl(0.5f).len(); Vector3 centerNear = centerPoint(planePoints[0], planePoints[1], planePoints[2]); tmpV0.set(camera.up).scl(halfNearSize * 2); centerNear.add(tmpV0); builder.line(centerNear, upColor, planePoints[2], upColor); builder.line(planePoints[2], upColor, planePoints[3], upColor); builder.line(planePoints[3], upColor, centerNear, upColor); }
/** Convenience method to create a model which represents a grid of lines on the XZ plane. The resources the Material might * contain are not managed, use {@link Model#manageDisposable(Disposable)} to add those to the model. * @param xDivisions row count along x axis. * @param zDivisions row count along z axis. * @param xSize Length of a single row on x. * @param zSize Length of a single row on z. */ public Model createLineGrid (int xDivisions, int zDivisions, float xSize, float zSize, Material material, long attributes) { begin(); MeshPartBuilder partBuilder = part("lines", GL20.GL_LINES, attributes, material); float xlength = xDivisions * xSize, zlength = zDivisions * zSize, hxlength = xlength / 2, hzlength = zlength / 2; float x1 = -hxlength, y1 = 0, z1 = hzlength, x2 = -hxlength, y2 = 0, z2 = -hzlength; for (int i = 0; i <= xDivisions; ++i) { partBuilder.line(x1, y1, z1, x2, y2, z2); x1 += xSize; x2 += xSize; } x1 = -hxlength; y1 = 0; z1 = -hzlength; x2 = hxlength; y2 = 0; z2 = -hzlength; for (int j = 0; j <= zDivisions; ++j) { partBuilder.line(x1, y1, z1, x2, y2, z2); z1 += zSize; z2 += zSize; } return end(); }
public static Model createAxes() { final float GRID_MIN = -10f; final float GRID_MAX = 10f; final float GRID_STEP = 1f; ModelBuilder modelBuilder = new ModelBuilder(); modelBuilder.begin(); MeshPartBuilder builder = modelBuilder.part("grid", GL20.GL_LINES, VertexAttributes.Usage.Position | VertexAttributes.Usage.ColorUnpacked, new Material()); builder.setColor(Color.LIGHT_GRAY); for (float t = GRID_MIN; t <= GRID_MAX; t += GRID_STEP) { builder.line(t, 0, GRID_MIN, t, 0, GRID_MAX); builder.line(GRID_MIN, 0, t, GRID_MAX, 0, t); } builder = modelBuilder.part("axes", GL20.GL_LINES, VertexAttributes.Usage.Position | VertexAttributes.Usage.ColorUnpacked, new Material()); builder.setColor(Color.RED); builder.line(0, 0, 0, 100, 0, 0); builder.setColor(Color.GREEN); builder.line(0, 0, 0, 0, 100, 0); builder.setColor(Color.BLUE); builder.line(0, 0, 0, 0, 0, 100); return modelBuilder.end(); }
private static void createAxes() { ModelBuilder modelBuilder = new ModelBuilder(); modelBuilder.begin(); MeshPartBuilder builder = modelBuilder.part("grid", GL20.GL_LINES, Usage.Position | Usage.ColorUnpacked, new Material()); builder.setColor(Color.LIGHT_GRAY); for (float t = GRID_MIN; t <= GRID_MAX; t+=GRID_STEP) { builder.line(t, 0, GRID_MIN, t, 0, GRID_MAX); builder.line(GRID_MIN, 0, t, GRID_MAX, 0, t); } builder = modelBuilder.part("axes", GL20.GL_LINES, Usage.Position | Usage.ColorUnpacked, new Material()); builder.setColor(Color.RED); builder.line(0, 0, 0, 10, 0, 0); builder.setColor(Color.GREEN); builder.line(0, 0, 0, 0, 10, 0); builder.setColor(Color.BLUE); builder.line(0, 0, 0, 0, 0, 10); axesModel = modelBuilder.end(); axesInstance = new ModelInstance(axesModel); }
ModelBuilder modelBuilder = new ModelBuilder(); modelBuilder.begin(); MeshPartBuilder builder = modelBuilder.part("line", 1, 3, new Material()); builder.setColor(Color.RED); builder.line(0.0f, 0.0f, -5.0f, 0.0f, 0.0f, 5.0f); lineModel = modelBuilder.end(); lineInstance = new ModelInstance(lineModel);
public static Model createArrowStub(Material mat, Vector3 from, Vector3 to) { ModelBuilder modelBuilder = new ModelBuilder(); modelBuilder.begin(); MeshPartBuilder meshBuilder; // line meshBuilder = modelBuilder.part("line", GL20.GL_LINES, VertexAttributes.Usage.Position | VertexAttributes.Usage.ColorUnpacked, mat); meshBuilder.line(from.x, from.y, from.z, to.x, to.y, to.z); // stub Node node = modelBuilder.node(); node.translation.set(to.x, to.y, to.z); meshBuilder = modelBuilder.part("stub", GL20.GL_TRIANGLES, Usage.Position | Usage.Normal, mat); BoxShapeBuilder.build(meshBuilder, 2, 2, 2); return modelBuilder.end(); }
i2 = i1; } else if (innerWidth == width && innerHeight == height) { if (i != 0) builder.line(i1, i2); i2 = i1; } else {