List of usage examples for com.badlogic.gdx.graphics.glutils ShapeRenderer rectLine
public void rectLine(float x1, float y1, float x2, float y2, float width)
From source file:com.company.minery.utils.spine.SkeletonRendererDebug.java
License:Open Source License
public void draw(Skeleton skeleton) { float skeletonX = skeleton.getX(); float skeletonY = skeleton.getY(); Gdx.gl.glEnable(GL20.GL_BLEND);/*from w ww .ja va2 s.c o m*/ int srcFunc = premultipliedAlpha ? GL20.GL_ONE : GL20.GL_SRC_ALPHA; Gdx.gl.glBlendFunc(srcFunc, GL20.GL_ONE_MINUS_SRC_ALPHA); ShapeRenderer shapes = this.shapes; Array<Bone> bones = skeleton.getBones(); if (drawBones) { shapes.setColor(boneLineColor); shapes.begin(ShapeType.Filled); for (int i = 0, n = bones.size; i < n; i++) { Bone bone = bones.get(i); if (bone.parent == null) continue; float x = skeletonX + bone.data.length * bone.m00 + bone.worldX; float y = skeletonY + bone.data.length * bone.m10 + bone.worldY; shapes.rectLine(skeletonX + bone.worldX, skeletonY + bone.worldY, x, y, boneWidth * scale); } shapes.end(); shapes.begin(ShapeType.Line); shapes.x(skeletonX, skeletonY, 4 * scale); } else shapes.begin(ShapeType.Line); if (drawRegionAttachments) { shapes.setColor(attachmentLineColor); Array<Slot> slots = skeleton.getSlots(); for (int i = 0, n = slots.size; i < n; i++) { Slot slot = slots.get(i); Attachment attachment = slot.attachment; if (attachment instanceof RegionAttachment) { RegionAttachment regionAttachment = (RegionAttachment) attachment; regionAttachment.updateWorldVertices(slot, false); float[] vertices = regionAttachment.getWorldVertices(); shapes.line(vertices[X1], vertices[Y1], vertices[X2], vertices[Y2]); shapes.line(vertices[X2], vertices[Y2], vertices[X3], vertices[Y3]); shapes.line(vertices[X3], vertices[Y3], vertices[X4], vertices[Y4]); shapes.line(vertices[X4], vertices[Y4], vertices[X1], vertices[Y1]); } } } if (drawMeshHull || drawMeshTriangles) { Array<Slot> slots = skeleton.getSlots(); for (int i = 0, n = slots.size; i < n; i++) { Slot slot = slots.get(i); Attachment attachment = slot.attachment; float[] vertices = null; short[] triangles = null; int hullLength = 0; if (attachment instanceof MeshAttachment) { MeshAttachment mesh = (MeshAttachment) attachment; mesh.updateWorldVertices(slot, false); vertices = mesh.getWorldVertices(); triangles = mesh.getTriangles(); hullLength = mesh.getHullLength(); } else if (attachment instanceof SkinnedMeshAttachment) { SkinnedMeshAttachment mesh = (SkinnedMeshAttachment) attachment; mesh.updateWorldVertices(slot, false); vertices = mesh.getWorldVertices(); triangles = mesh.getTriangles(); hullLength = mesh.getHullLength(); } if (vertices == null || triangles == null) continue; if (drawMeshTriangles) { shapes.setColor(triangleLineColor); for (int ii = 0, nn = triangles.length; ii < nn; ii += 3) { int v1 = triangles[ii] * 5, v2 = triangles[ii + 1] * 5, v3 = triangles[ii + 2] * 5; shapes.triangle(vertices[v1], vertices[v1 + 1], // vertices[v2], vertices[v2 + 1], // vertices[v3], vertices[v3 + 1] // ); } } if (drawMeshHull && hullLength > 0) { shapes.setColor(attachmentLineColor); hullLength = hullLength / 2 * 5; float lastX = vertices[hullLength - 5], lastY = vertices[hullLength - 4]; for (int ii = 0, nn = hullLength; ii < nn; ii += 5) { float x = vertices[ii], y = vertices[ii + 1]; shapes.line(x, y, lastX, lastY); lastX = x; lastY = y; } } } } if (drawBoundingBoxes) { SkeletonBounds bounds = this.bounds; bounds.update(skeleton, true); shapes.setColor(aabbColor); shapes.rect(bounds.getMinX(), bounds.getMinY(), bounds.getWidth(), bounds.getHeight()); shapes.setColor(boundingBoxColor); Array<FloatArray> polygons = bounds.getPolygons(); for (int i = 0, n = polygons.size; i < n; i++) { FloatArray polygon = polygons.get(i); shapes.polygon(polygon.items, 0, polygon.size); } } shapes.end(); shapes.begin(ShapeType.Filled); if (drawBones) { shapes.setColor(boneOriginColor); for (int i = 0, n = bones.size; i < n; i++) { Bone bone = bones.get(i); shapes.setColor(Color.GREEN); shapes.circle(skeletonX + bone.worldX, skeletonY + bone.worldY, 3 * scale, 8); } } shapes.end(); }
From source file:io.piotrjastrzebski.dungen.HallwayPath.java
License:Apache License
public void draw(ShapeRenderer renderer) { if (recon) {//from w ww . ja v a 2s . c o m renderer.setColor(Color.ORANGE); } else { renderer.setColor(Color.LIME); } if (hasBend) { renderer.rectLine(start.x, start.y, bend.x, bend.y, gridSize * 0.33f); renderer.rectLine(bend.x, bend.y, end.x, end.y, gridSize * 0.33f); } else { renderer.rectLine(start.x, start.y, end.x, end.y, gridSize * 0.33f); } }
From source file:io.piotrjastrzebski.dungen.RoomGraph.java
License:Apache License
public void render(ShapeRenderer renderer, boolean drawEdges, boolean mst, float grid) { if (edges.size == 0) return;//from w w w. ja va 2s .c o m if (drawEdges) { for (RoomEdge e : edges) { renderer.setColor(0, 1, 0, 0.5f); renderer.rectLine(e.ax(), e.ay(), e.bx(), e.by(), grid * 0.2f); } } if (mst) { for (RoomEdge e : edges) { if (e.recon) { renderer.setColor(Color.ORANGE); renderer.rectLine(e.ax(), e.ay(), e.bx(), e.by(), grid * 0.4f); } else if (e.mst) { renderer.setColor(Color.LIME); renderer.rectLine(e.ax(), e.ay(), e.bx(), e.by(), grid * 0.4f); } } } }
From source file:org.catrobat.catroid.stage.PenActor.java
License:Open Source License
private void drawLinesAndStampsForSprite(Sprite sprite, Batch batch, float parentAlpha) { float x = sprite.look.getXInUserInterfaceDimensionUnit(); float y = sprite.look.getYInUserInterfaceDimensionUnit(); Sprite.PenConfiguration pen = sprite.penConfiguration; if (pen.previousPoint == null) { pen.previousPoint = new PointF(x, y); return;// w ww . j ava 2 s . co m } ShapeRenderer renderer = StageActivity.stageListener.shapeRenderer; renderer.setColor(pen.penColor); renderer.begin(ShapeRenderer.ShapeType.Filled); if (pen.penDown && (pen.previousPoint.x != sprite.look.getX() || pen.previousPoint.y != sprite.look.getY())) { renderer.circle(pen.previousPoint.x, pen.previousPoint.y, pen.penSize / 2); renderer.rectLine(pen.previousPoint.x, pen.previousPoint.y, x, y, pen.penSize); renderer.circle(x, y, pen.penSize / 2); } if (pen.stamp) { sprite.look.draw(batch, parentAlpha); pen.stamp = false; } renderer.end(); pen.previousPoint.x = x; pen.previousPoint.y = y; }
From source file:spine.SkeletonRendererDebug.java
License:Open Source License
public void draw(Skeleton skeleton) { float skeletonX = skeleton.getX(); float skeletonY = skeleton.getY(); Gdx.gl.glEnable(GL20.GL_BLEND);//from w w w .ja va 2 s. c om int srcFunc = premultipliedAlpha ? GL20.GL_ONE : GL20.GL_SRC_ALPHA; Gdx.gl.glBlendFunc(srcFunc, GL20.GL_ONE_MINUS_SRC_ALPHA); ShapeRenderer shapes = this.shapes; Array<Bone> bones = skeleton.getBones(); if (drawBones) { shapes.setColor(boneLineColor); shapes.begin(ShapeType.Filled); for (int i = 0, n = bones.size; i < n; i++) { Bone bone = bones.get(i); if (bone.parent == null) continue; float x = skeletonX + bone.data.length * bone.a + bone.worldX; float y = skeletonY + bone.data.length * bone.c + bone.worldY; shapes.rectLine(skeletonX + bone.worldX, skeletonY + bone.worldY, x, y, boneWidth * scale); } shapes.end(); shapes.begin(ShapeType.Line); shapes.x(skeletonX, skeletonY, 4 * scale); } else shapes.begin(ShapeType.Line); if (drawRegionAttachments) { shapes.setColor(attachmentLineColor); Array<Slot> slots = skeleton.getSlots(); for (int i = 0, n = slots.size; i < n; i++) { Slot slot = slots.get(i); Attachment attachment = slot.attachment; if (attachment instanceof RegionAttachment) { RegionAttachment regionAttachment = (RegionAttachment) attachment; float[] vertices = regionAttachment.updateWorldVertices(slot, false); shapes.line(vertices[X1], vertices[Y1], vertices[X2], vertices[Y2]); shapes.line(vertices[X2], vertices[Y2], vertices[X3], vertices[Y3]); shapes.line(vertices[X3], vertices[Y3], vertices[X4], vertices[Y4]); shapes.line(vertices[X4], vertices[Y4], vertices[X1], vertices[Y1]); } } } if (drawMeshHull || drawMeshTriangles) { Array<Slot> slots = skeleton.getSlots(); for (int i = 0, n = slots.size; i < n; i++) { Slot slot = slots.get(i); Attachment attachment = slot.attachment; float[] vertices = null; short[] triangles = null; int hullLength = 0; if (attachment instanceof MeshAttachment) { MeshAttachment mesh = (MeshAttachment) attachment; mesh.updateWorldVertices(slot, false); vertices = mesh.getWorldVertices(); triangles = mesh.getTriangles(); hullLength = mesh.getHullLength(); } else if (attachment instanceof SkinnedMeshAttachment) { SkinnedMeshAttachment mesh = (SkinnedMeshAttachment) attachment; mesh.updateWorldVertices(slot, false); vertices = mesh.getWorldVertices(); triangles = mesh.getTriangles(); hullLength = mesh.getHullLength(); } if (vertices == null || triangles == null) continue; if (drawMeshTriangles) { shapes.setColor(triangleLineColor); for (int ii = 0, nn = triangles.length; ii < nn; ii += 3) { int v1 = triangles[ii] * 5, v2 = triangles[ii + 1] * 5, v3 = triangles[ii + 2] * 5; shapes.triangle(vertices[v1], vertices[v1 + 1], // vertices[v2], vertices[v2 + 1], // vertices[v3], vertices[v3 + 1] // ); } } if (drawMeshHull && hullLength > 0) { shapes.setColor(attachmentLineColor); hullLength = hullLength / 2 * 5; float lastX = vertices[hullLength - 5], lastY = vertices[hullLength - 4]; for (int ii = 0, nn = hullLength; ii < nn; ii += 5) { float x = vertices[ii], y = vertices[ii + 1]; shapes.line(x, y, lastX, lastY); lastX = x; lastY = y; } } } } if (drawBoundingBoxes) { SkeletonBounds bounds = this.bounds; bounds.update(skeleton, true); shapes.setColor(aabbColor); shapes.rect(bounds.getMinX(), bounds.getMinY(), bounds.getWidth(), bounds.getHeight()); shapes.setColor(boundingBoxColor); Array<FloatArray> polygons = bounds.getPolygons(); for (int i = 0, n = polygons.size; i < n; i++) { FloatArray polygon = polygons.get(i); shapes.polygon(polygon.items, 0, polygon.size); } } shapes.end(); shapes.begin(ShapeType.Filled); if (drawBones) { shapes.setColor(boneOriginColor); for (int i = 0, n = bones.size; i < n; i++) { Bone bone = bones.get(i); shapes.setColor(Color.GREEN); shapes.circle(skeletonX + bone.worldX, skeletonY + bone.worldY, 3 * scale, 8); } } shapes.end(); }
From source file:us.thirdmillenium.strategicassaultsimulator.agents.ConeAgent.java
License:Apache License
@Override public void drawPath(ShapeRenderer sr) { if (this.ALIVE) { // Draws the CurrentPath. if (this.preferredPath != null) { for (int i = this.preferredPathIndex; i < this.preferredPath.getCount() - 1; i++) { sr.rectLine(this.preferredPath.get(i + 1).getPixelX(), this.preferredPath.get(i + 1).getPixelY(), this.preferredPath.get(i).getPixelX(), this.preferredPath.get(i).getPixelY(), 5); }/* w w w. j a va2 s. c o m*/ } } }
From source file:us.thirdmillenium.strategicassaultsimulator.agents.PuppetAgent.java
License:Apache License
@Override public void drawPath(ShapeRenderer sr) { // Draws the CurrentPath. if (this.CurrentPath != null) { for (int i = 1; i < this.CurrentPath.getCount(); i++) { sr.rectLine(this.CurrentPath.get(i - 1).getPixelX(), this.CurrentPath.get(i - 1).getPixelY(), this.CurrentPath.get(i).getPixelX(), this.CurrentPath.get(i).getPixelY(), 5); }/*from w w w.j a v a 2s . c om*/ } }
From source file:us.thirdmillenium.strategicassaultsimulator.agents.TrainingAgent.java
License:Apache License
@Override public void drawPath(ShapeRenderer sr) { // Draws the CurrentPath. if (this.preferredPath != null) { for (int i = this.preferredPathIndex + 1; i < this.preferredPath.getCount(); i++) { sr.rectLine(this.preferredPath.get(i - 1).getPixelX(), this.preferredPath.get(i - 1).getPixelY(), this.preferredPath.get(i).getPixelX(), this.preferredPath.get(i).getPixelY(), 5); }/*from www . j a v a2 s.c o m*/ } }