List of usage examples for com.badlogic.gdx.graphics.glutils ShapeRenderer circle
public void circle(float x, float y, float radius, int segments)
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);/*w ww. j av a2s . co 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:com.github.mkjensen.breakall.actor.Ball.java
License:Apache License
@Override protected void draw(ShapeRenderer renderer) { renderer.begin(ShapeType.Filled);//from www .j a v a2s . c o m renderer.setColor(Color.BLUE); renderer.circle(getX(), getY(), getRadius(), CIRCLE_SEGMENTS); renderer.end(); }
From source file:com.hindelid.ld.thirtyfour.Fish.java
License:Apache License
public void render(ShapeRenderer aShapeRenderer) { aShapeRenderer.circle(mPos.x, mPos.y, mRadus, 30); // Body aShapeRenderer.circle(mPos.x - 0.25f, mPos.y + 0.15f, 0.06f, 30); // Eye aShapeRenderer.line(mPos.x + mTailOffset.x, mPos.y + mTailOffset.y, mPos.x + 1f, mPos.y - 0.4f); // \ aShapeRenderer.line(mPos.x + mTailOffset.x, mPos.y - mTailOffset.y, mPos.x + 1f, mPos.y + 0.4f); // / aShapeRenderer.line(mPos.x + 1f, mPos.y - 0.4f, mPos.x + 1f, mPos.y + 0.4f); // | aShapeRenderer.line(mPos.x - mLampOffset.x, mPos.y + mLampOffset.y, mPos.x - mLampOffset.x * 2f, mPos.y + mLampOffset.y * 2f); aShapeRenderer.line(mPos.x - mLampOffset.x * 3.3f, mPos.y + mLampOffset.y, mPos.x - mLampOffset.x * 2f, mPos.y + mLampOffset.y * 2f); aShapeRenderer.circle(mPos.x - mLampOffset.x * 3.3f, mPos.y + mLampOffset.y - 0.08f, 0.08f, 30); aShapeRenderer.curve(mPos.x - mTailOffset.x, mPos.y - mTailOffset.y, mPos.x - mTailOffset.x, mPos.y - mTailOffset.y * 1.6f, mPos.x, mPos.y - mTailOffset.y * 1.5f, mPos.x - mTailOffset.x / 2f, mPos.y - mTailOffset.y / 2f, 30); // aShapeRenderer.rect(mBoundingBox.x, mBoundingBox.y, mBoundingBox.width, mBoundingBox.height); }
From source file:com.kotcrab.vis.editor.module.scene.entitymanipulator.tool.RotateTool.java
License:Apache License
@Override public void render(ShapeRenderer shapeRenderer) { super.render(shapeRenderer); if (totalSelectionBounds != null) { innerRadius = camera.getZoom() * 0.6f * 100f / scene.pixelsPerUnit; outerRadius = camera.getZoom() * 0.7f * 100f / scene.pixelsPerUnit; circleCenterX = totalSelectionBounds.x + totalSelectionBounds.width / 2; circleCenterY = totalSelectionBounds.y + totalSelectionBounds.height / 2; shapeRenderer.setColor(Color.WHITE); shapeRenderer.begin(ShapeType.Line); shapeRenderer.circle(circleCenterX, circleCenterY, innerRadius, 36); shapeRenderer.circle(circleCenterX, circleCenterY, outerRadius, 36); float rotation = entityManipulator.getSelectedEntities().peek().getRotation(); float startX = circleCenterX; float startY = circleCenterY - innerRadius; float endX = circleCenterX; float endY = circleCenterY + innerRadius; shapeRenderer.setColor(Color.RED); ShapeRendererUtils.lineRotatedAroundPoint(shapeRenderer, startX, startY, endX, endY, rotation, circleCenterX, circleCenterY); shapeRenderer.setColor(Color.GREEN); ShapeRendererUtils.lineRotatedAroundPoint(shapeRenderer, startX, startY, endX, endY, rotation + 90, circleCenterX, circleCenterY); shapeRenderer.end();/* w ww .j a v a2 s .c o m*/ } }
From source file:releasethekraken.entity.seacreature.EntityPlayer.java
@Override public void renderShapes(ShapeRenderer shapeRenderer, float delta, float runTime) { super.renderShapes(shapeRenderer, delta, runTime); //Render power up preview if (this.powerUpPreview != null) { shapeRenderer.end();//from ww w . ja va2 s.c o m //Enable OpenGL alpha blending Gdx.gl.glEnable(Gdx.gl.GL_BLEND); Gdx.gl.glBlendFunc(Gdx.gl.GL_SRC_ALPHA, Gdx.gl.GL_ONE_MINUS_SRC_ALPHA); shapeRenderer.begin(ShapeRenderer.ShapeType.Filled); EntityPowerUp.PowerUpStats powerUpStats = EntityPowerUp.getStats(this.powerUpPreview); shapeRenderer.setColor(powerUpStats.previewColor); shapeRenderer.circle(this.physBody.getPosition().x, this.physBody.getPosition().y, powerUpStats.radius, 32); shapeRenderer.end(); //Disable OpenGL blending so everything else doesn't get messed up Gdx.gl.glDisable(Gdx.gl.GL_BLEND); shapeRenderer.begin(ShapeRenderer.ShapeType.Filled); } /* shapeRenderer.setColor(Color.BLACK); shapeRenderer.rect(this.getPos().x - (this.maxHealth * .25f), this.getPos().y + 1.1f, this.maxHealth * .5f, 0.5f); shapeRenderer.setColor(Color.RED); shapeRenderer.rect(this.getPos().x - (this.maxHealth * .25f), this.getPos().y + 1.1f, this.health * .5f, 0.5f); */ //Draw crosshair //shapeRenderer.setColor(Color.RED); //shapeRenderer.x(this.aimPos, 1); }
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 va2s .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.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(); }