Posted October 11, 201410 yr Heyho Guys! I searched for a method to draw NURBS Curves with GL. The problem is: I googled a bit and it told me that I can use the method GLU.newNurbsRenderer(). The problem is that this method doesnt exist. How can I draw one of these curves? Or is there another way of drawing Curves which are formed with controlpoints like the nurbs curve? http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
October 11, 201410 yr Author But this is no NURBS Curve with multiple control vertices. Its just a generated curve between two points which looks lile its affected by gravity. http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
October 12, 201410 yr Author This looks quite useful, but I still cannot find out where the needed method gluNewNurbsRenderer is implemented. Either I'm totally blind or it doesn't exist in GLU.class or anywhere else. Edit: Looks like NURBS are not supported by this version of lwjgl. Take a look over here. Damn.. seems like I have to implement my own methods for this. I have no Idea how this works but I'll try. http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
October 12, 201410 yr This looks quite useful, but I still cannot find out where the needed method gluNewNurbsRenderer is implemented. Either I'm totally blind or it doesn't exist in GLU.class or anywhere else. Being a NURBS noob I'm for sure no expert but it looks to me like you can either use the glu methods, or the OpenGL 1.1 glMap2f methods. i.e. you don't need the glu methods. (Or - do the matrix maths yourself to generate the patches manually, if you don't go crazy on the number of patches it should be plenty fast enough) -TGG
October 12, 201410 yr Author Ok, I now used the GLMap methods and it works. Only one problem: It seems like the colour green is disabled. Can this have sonething to do with the drawing of a "missing-texture" before? And how can I re-enable the colour? http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
October 12, 201410 yr > Ok, I now used the GLMap methods and it works. keen. > Only one problem: show code? -TGG
October 12, 201410 yr Author @SideOnly(Side.CLIENT) public void renderToCodex(GuiCodexMagicum gui, Minecraft mc, int x, int y) { if (Codex.getStatusFor(mc.thePlayer, this) > 0) { mc.getTextureManager().bindTexture(this.icons); GLUtil.resetColour(); GL11.glDisable(GL11.GL_LIGHTING); gui.drawTexturedModalRect(x, y, (Codex.getStatusFor(mc.thePlayer, this) - 1) * 26, this.hasSpecialLayout ? 26 : 0, 26, 26); if (this.isIconItem) { gui.drawItemStack(this.iconItem, x + 5, y + 5, ""); } else { mc.getTextureManager().bindTexture(this.labels); gui.drawTexturedModalRect(x + 5, y + 5, this.iconX * 16, this.iconY * 16, 16, 16); } GL11.glDisable(GL11.GL_LIGHTING); if (Codex.getStatusFor(mc.thePlayer, this) == 1) { GLUtil.setColour(0, 0, 0); } else { GLUtil.setColour((this.lineColour >> 16) % 256, (this.lineColour >> % 256, this.lineColour % 256); } GL11.glColor3f(0, 1, 0); for (Vertex2D[] line : this.lines) { if (line.length > 2) { this.renderBezier(gui, line, x - this.getX(), y - this.getY()); } else { GL11.glBegin(GL11.GL_LINE); GL11.glVertex3d(line[0].x + x - this.getX(), line[0].y + y - this.getY(), gui.getZLevel() - 2); GL11.glVertex3d(line[1].x + x - this.getX(), line[1].y + y - this.getY(), gui.getZLevel() - 2); GL11.glEnd(); } } } } private void renderBezier(GuiCodexMagicum gui, Vertex2D[] controlpoints, int x, int y) { FloatBuffer buf = BufferUtils.createFloatBuffer(controlpoints.length * 6); for (int i = 0; i < controlpoints.length; i ++) { buf.put(i*3, (float) controlpoints[i].x + x); buf.put(i*3+1, (float) controlpoints[i].y + y); buf.put(i*3+2, gui.getZLevel() - 2); buf.put(i*3+3, (float) controlpoints[i].x + x); buf.put(i*3+4, (float) controlpoints[i].y + y); buf.put(i*3+5, gui.getZLevel() - 2); } GL11.glMap1f(GL11.GL_MAP1_VERTEX_3, 0.0f, 1.0f, 3, 4, buf); GL11.glEnable(GL11.GL_MAP1_VERTEX_3); GL11.glBegin(GL11.GL_LINE_STRIP); for (int i = 0; i < 24; i ++) { GL11.glEvalCoord1f(i / 24.0f); } GL11.glEnd(); } http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
October 12, 201410 yr I am no expert, but maybe, try using GL11.glColor4f(1, 1, 1, 1); this will enable red, green, blue, and alpha (transparency) I saw you had GL11.glColor3f(0, 1, 0); I have never used this one, but I'm logically assuming that is red, green and blue. so this is only enabling green. But weirdly, you said green is the only one not working. Maybe it is somehow inverted? try setting that 1 to a 0, or all of them to 1. I ask complicated questions, and apparently like to write really long detailed posts. But I also help others when I can.
October 12, 201410 yr Author The line where I set the color to green was a test; I wanted to check if green is really disabled. With this code the curve is rendered black instead of bright green http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
October 12, 201410 yr When you say "with this code" do you mean when I suggested GL11.glColor4f(1, 1, 1, 1); or when I said to set the 1 to a 0, or when I said to set the zeros to a 1? I ask complicated questions, and apparently like to write really long detailed posts. But I also help others when I can.
October 12, 201410 yr Author I meant the code I posted. Edit:I also tried glColorMask(true, true, true, true) but with no Effect. And I encountered that the line is green for one tick and then switches to black. http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
October 12, 201410 yr Off topic: Can you post a screenshot of the curve? I'm just curious about how it looks. Check out my mod, Realms of Chaos, here. If I helped you, be sure to press the "Thank You" button!
October 12, 201410 yr Author But (for tests) The line should be green http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
October 12, 201410 yr That looks really cool! In my opinion, I think it would look better if you left it black, instead of making it bright green. But, your mod, so your decision. I ask complicated questions, and apparently like to write really long detailed posts. But I also help others when I can.
October 12, 201410 yr Author I dont want to make it green. It should be white. But if I set it to white it turns out purple because green doesnt work. The set to green is just a test. http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
October 12, 201410 yr Author If I write this piece of code at the beginning of the method, the line is in a very dark green. Maybe this helps you.. GL11.glDisable(GL11.GL_LIGHTING); if (Codex.getStatusFor(mc.thePlayer, this) == 1) { GLUtil.setColour(0, 0, 0); } else { GLUtil.setColour((this.lineColour >> 16) % 256, (this.lineColour >> % 256, this.lineColour % 256); } GL11.glColor3f(0, 1, 0); for (Vertex2D[] line : this.lines) { if (line.length > 2) { this.renderBezier(gui, line, x - this.getX(), y - this.getY()); } else { GL11.glBegin(GL11.GL_LINE); GL11.glVertex3d(line[0].x + x - this.getX(), line[0].y + y - this.getY(), gui.getZLevel() - 2); GL11.glVertex3d(line[1].x + x - this.getX(), line[1].y + y - this.getY(), gui.getZLevel() - 2); GL11.glEnd(); } } } } If I use only this piece of code, without the rest, nothing is rendered. Is it possible that the Lines are rendered with the actual texture? Its the Purple/Black Missing Texture, this would explain the green colour problem. How can I disable the texture, if this is the problem? http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
October 12, 201410 yr Author It really was the texture which caused the problem! I now added glBindTexture(GL_TEXTURE_2D, 0) to clear it and it works fine!(except from some zLevel problems) http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
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.