Posted April 2, 201510 yr Hello all, I wanted to render a line going from a point to another. The problem of GL_LINES is that the texture is rendered 1 pixel wide. The solution that i found is render a quad going from a point to another, but i'm having issues when rendering the quad that needs to face the player I took this code from "renderParticle", and it works perfectly if you want to draw a textured square. private double prevFromX, prevFromY, prevFromZ; private double prevToX, prevToY, prevToZ; public void render(float partialTicks, double fromX, double fromY, double fromZ, double toX, double toY, double toZ) { float rX = ActiveRenderInfo.rotationX; float rZ = ActiveRenderInfo.rotationZ; float rYZ = ActiveRenderInfo.rotationYZ; float rXY = ActiveRenderInfo.rotationXY; float rXZ = ActiveRenderInfo.rotationXZ; float startX = (float)(prevFromX + (fromX - prevFromX) * partialTicks); float startY = (float)(prevFromY + (fromY - prevFromY) * partialTicks); float startZ = (float)(prevFromZ + (fromZ - prevFromZ) * partialTicks); float endX = (float)(prevToX + (fromX - prevToX) * partialTicks); float endY = (float)(prevToY + (fromY - prevToY) * partialTicks); float endZ = (float)(prevToZ + (fromZ - prevToZ) * partialTicks); t.startDrawingQuads(); t.addVertexWithUV(startX - rX - rYZ, startY - rXZ, startZ - rZ - rXY, 0, 1); t.addVertexWithUV(startX - rX + rYZ, startY + rXZ, startZ - rZ + rXY, 1, 1); t.addVertexWithUV(startX + rX + rYZ, startY + rXZ, startZ + rZ + rXY, 1, 0); t.addVertexWithUV(startX + rX - rYZ, startY - rXZ, startZ + rZ - rXY, 0, 0); t.draw(); this.prevFromX = fromX; this.prevFromY = fromY; this.prevFromZ = fromZ; this.prevToX = toX; this.prevToY = toY; this.prevToZ = toZ; } I'm using this method in RenderWorldLastEvent What should I change in the vertexes to work with endX, endY and endZ? Thanks for any help and sorry for my bad english
April 2, 201510 yr Hi This page talks a bit about the Tessellator and quads http://greyminecraftcoder.blogspot.com.au/2013/08/the-tessellator.html A couple of comments 1) If you're drawing a quad instead of a line, you don't need addVertexWithUV, use addVertex instead 2) If you want your line to be roughly the same thickness regardless of where the player is looking from, I think you'll need to choose one of two tricks either a) use some vector maths to draw the quad in a plane perpendicular to the viewer's eyes and figure out the width based on the distance to the player (this is not easy to do from scratch but ActiveRenderInfo.updateRenderInfo() has the necessary calculations and method calls to do the first one for you, you just need to figure out how to use it..), or b) draw a tube (rectangular prism) with four sides (figure out deltaX = endX - startX, deltaY = endY - startY, deltaZ = endZ - startZ, choose the biggest one (eg deltaY if the line is most vertical), then the four quads: south side [startX - half_line_width, startY, startZ+half_line_width] to [endX + half_line_width, endY, endZ + half_line_width] north side [startX - half_line_width, startY, startZ-half_line_width] to [endX + half_line_width, endY, endZ - half_line_width] west side [startX - half_line_width, startY, startZ - half_line_width] to [endX - half_line_width, endY, endZ + half_line_width] east side [startX + half_line_width, startY, startZ - half_line_width] to [endX + half_line_width, endY, endZ + half_line_width] This is a lot easier, but the line will change thickness a bit as you move around, and might look more like a square tube than a line, depending on how big it is. The width of the line will also vary depending how close the player is; you would need to change the line width proportional to the player's distance from the line. Depends what effect you're looking for really. -TGG
April 3, 201510 yr Author I gave up and solved the problem by taking a look at the source of Wireless Redstone, by ChickenBones. Also, Botania and Thaumcraft are using the same code for lightning. https://github.com/Chicken-Bones/WirelessRedstone Thanks @TheGreyGhost for trying to help, I appreciate.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.