Created
July 8, 2016 19:51
-
-
Save Daomephsta/ad0e672cb70742a30a14aeaeaeb3d047 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float h = 5.0F; | |
float radius = 50.0F; | |
int segments = 4; | |
int subsegments = 8; | |
float subsegmentAngle; | |
Tessellator tess = Tessellator.getInstance(); | |
VertexBuffer vtxBuf = tess.getBuffer(); | |
GlStateManager.pushMatrix(); | |
GlStateManager.pushAttrib(); | |
GlStateManager.disableTexture2D(); | |
GlStateManager.enableBlend(); | |
GlStateManager.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.SRC_ALPHA); | |
GlStateManager.color(0, 128, 128); | |
GlStateManager.translate(x, y, 0.0F); | |
subsegmentAngle = (float) (2 * Math.toDegrees(Math.asin(h / radius))); | |
if(subsegments % 2 == 0) GlStateManager.rotate(0.5F * subsegmentAngle, 0.0F, 0.0F, 1.0F); | |
for(int segment = 0; segment < segments; segment++) | |
{ | |
GlStateManager.rotate(360 / segments, 0.0F, 0.0F, 1.0F); | |
GlStateManager.pushMatrix(); | |
GlStateManager.translate(SEGMENT_OFFSET, 0.0F, 0.0F); | |
GlStateManager.rotate(-(subsegments / 2) * subsegmentAngle, 0.0F, 0.0F, 1.0F); | |
for(int subsegment = 0; subsegment < subsegments; subsegment++) | |
{ | |
vtxBuf.begin(GL11.GL_TRIANGLE_FAN, DefaultVertexFormats.POSITION); | |
vtxBuf.pos(0, 0, 0).endVertex(); | |
vtxBuf.pos(radius, h, 0).endVertex(); | |
vtxBuf.pos(radius, -h, 0).endVertex(); | |
tess.draw(); | |
GlStateManager.rotate(subsegmentAngle, 0.0F, 0.0F, 1.0F); | |
} | |
GlStateManager.popMatrix(); | |
} | |
GlStateManager.popAttrib(); | |
GlStateManager.popMatrix(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment