Posted December 21, 20195 yr I am trying to draw a circle (flat, in 3D) currently. I am using GlStateManager to handle all the translation, rotation, and scaling. My question is: does Tesselator expect arguments passed to `pos` to be transformed already, or will they be transformed by the matrix I set up with GlStateManager? I'd assume the second, but I'm not sure; my circle isn't exactly a circle... in that, it's not being drawn at all... Here's the relevant code: private void drawCircle(final double x, final double y, final double z, final double r, final int segments, final int color) { final Tessellator tess = Tessellator.getInstance(); final BufferBuilder buf = tess.getBuffer(); buf.begin(GL11.GL_TRIANGLE_FAN, DefaultVertexFormats.POSITION_COLOR); final int red = (color >> 24) & 0xFF; final int green = (color >> 16) & 0xFF; final int blue = (color >> 8) & 0xFF; final int alpha = color & 0xFF; buf.pos(x, y, z); buf.color(red, green, blue, alpha); buf.endVertex(); for(int i = 0; i < segments; i++) { final double s = Math.sin(i * Math.PI * 2 / segments); final double c = Math.cos(i * Math.PI * 2 / segments); buf.pos(x, y + (r * s), z + (r * c)); buf.color(red, green, blue, alpha); buf.endVertex(); } tess.draw(); } Another question (I guess) would be if I'm allowed to use GL_TRIANGLE_FAN and the POSITION_COLOR vertex format... EDIT: Even if I set x, y, and z to known values (0, 70, 0 fir example) and then go to that location in the world, I do not see anything (excluding the GlStateManager stuff)... Edited December 21, 20195 yr by sci4me
December 22, 20195 yr Where are you calling the drawCircle method? There are some places where transformation matrices are already in the stack (i.e. RenderWorldLastEvent), and reversing transformation is needed in such case if you want to use world coordinates. Some tips: Spoiler Modder Support: Spoiler 1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code. 2. Always post your code. 3. Never copy and paste code. You won't learn anything from doing that. 4. Quote Programming via Eclipse's hotfixes will get you nowhere 5. Learn to use your IDE, especially the debugger. 6. Quote The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it. Support & Bug Reports: Spoiler 1. Read the EAQ before asking for help. Remember to provide the appropriate log(s). 2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.
December 22, 20195 yr Author 30 minutes ago, DavidM said: Where are you calling the drawCircle method? There are some places where transformation matrices are already in the stack (i.e. RenderWorldLastEvent), and reversing transformation is needed in such case if you want to use world coordinates. From within the `render` method in a class of mine that extends `ModelBiped`, used for armor. I have an IBakedModel that I'm rendering using RenderItem, which works fine, but I want to add dynamic rendering on top of my model, hence trying to draw colored circles...
December 22, 20195 yr 41 minutes ago, sci4me said: From within the `render` method in a class of mine that extends `ModelBiped`, used for armor. I have an IBakedModel that I'm rendering using RenderItem, which works fine, but I want to add dynamic rendering on top of my model, hence trying to draw colored circles... In that case the rendering will be relative to the position of your player. Therefore: 9 hours ago, sci4me said: EDIT: Even if I set x, y, and z to known values (0, 70, 0 fir example) and then go to that location in the world, I do not see anything (excluding the GlStateManager stuff)... would render the model 70 blocks above the player, and will move as the player moves, thus you cannot see it. Some tips: Spoiler Modder Support: Spoiler 1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code. 2. Always post your code. 3. Never copy and paste code. You won't learn anything from doing that. 4. Quote Programming via Eclipse's hotfixes will get you nowhere 5. Learn to use your IDE, especially the debugger. 6. Quote The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it. Support & Bug Reports: Spoiler 1. Read the EAQ before asking for help. Remember to provide the appropriate log(s). 2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.
December 22, 20195 yr Author 14 hours ago, DavidM said: In that case the rendering will be relative to the position of your player. Therefore: would render the model 70 blocks above the player, and will move as the player moves, thus you cannot see it. So, with the code I posted (although I changed the less than to a less than or equal in the for loop, but besides that..) even if I do something like (0, 2, 0), I don't see anything. EDIT: Okay so I just tried it again and I _did_ see something but it disappeared and never reappeared... once I rotated my player... EDIT 2: Restarted the game; this time it stuck around a bit longer before disappearing after rotating my player... WTF? EDIT 3: I think going underwater also makes it disappear? #ThisIsWeird #YayRendering EDIT 4: Opening chat also makes it disappear and not reappear after closing chat. EDIT 5: It blinks opposite to the cursor flash of chat LOL EDIT 6: Also chat appears to mess with my colors? Either that or the lack of chat I guess... (Actually I think it's the lack of chat) (Yes I'm disabling lighting during rendering of these circles (supposed to be LED lights (eventually..)) EDIT 7: Okay now the issue just magically went away? Or something? I don't know... wtf is going on lol. That being said, I think it's safe to call this question answered by now. Thanks! EDIT 8: Nevermind it's not actually fixed all the issues are still here WTF IS GRAPHICS PROGRAMMING ANYWAY; also there's an issue where my colors aren't as bright as they need to be... for some reason.. EDIT 9: Turns out all I had to do to fix these problems was disable TEXTURE_2D. Makes sense. NOW this thread can officially rest in peace. Edited December 22, 20195 yr by sci4me
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.