Posted January 27, 20196 yr Hello I am currently in the works of making a model loader that loads in boned/jointed models from maya/blender. I have the models loading and rendering sorted I am just wondering i am using Minecraft.getMinecraft().getItemRenderer().renderItem(entityIn, new ItemStack(Items.IRON_AXE), ItemCameraTransforms.TransformType.NONE); to render the item model but i want to rotate it following its bone which has its data stored in a matrix4f. What can i do to apply these translations and rotations onto the item. Thank you for reading.
January 27, 20196 yr If you already know your way around openGL and matrix transformations, the two main ways of interacting with it when MC modding are... 1. Through the GlStateManager, which is a layer between MC and LWJGL, and caches some openGL state data, then only updates LWJGL (and therefore openGL) when the data has changed (eg. if you set the color to the same color it has cached, it won't send the LWJGL command) 2. Through LWJGL, which sits between GlStateManager and openGL, and has commands very similar to the normal openGL command set If you don't know exactly what to do with the matrix itself...well then I'm not much help because neither do I. I did some direct matrix stuff a long time ago but don't remember any of it. In any case, if you haven't already done so, I suggest looking through the GlStateManager class and the openGL documentation. That's probably about as much as I can say to help, so gl! Edited January 27, 20196 yr by Laike_Endaril Fixed typo
January 27, 20196 yr Author 9 minutes ago, Laike_Endaril said: If you already know your way around openGL and matrix transformations, the two main ways of interacting with it when MC modding are... 1. Through the GlStateManager, which is a layer between MC and LWJGL, and caches some openGL state data, then only updates LWJGL (and therefore openGL) when the data has changed (eg. if you set the color to the same color it has cached, it won't send the LWJGL command) 2. Through LWJGL, which sits between GlStateManager and openGL, and has commands very similar to the normal openGL command set If you don't know exactly what to do with the matrix itself...well then I'm not much help because neither do I. I did some direct matrix stuff a long time ago but don't remember any of it. In any case, if you haven't already done so, I suggest looking through the GlStateManager class and the openGL documentation. That's probably about as much as I can say to help, so gl! thanks i have been i am just trying to find a way to get the translations and stuffi already have in a matrix4F and eaither return them to their float values or just use the matrix instead
January 27, 20196 yr You can almost certainly use the matrix itself...but beyond that I'm not sure exactly which method(s) you'll need to do so correctly. It might be the multMatrix call, but I can't remember for sure. Whatever you do, make sure you pushMatrix exactly once before you do any matrix alterations, and popMatrix exactly once after you render. In GlStateManager: public static void multMatrix(FloatBuffer matrix) { GL11.glMultMatrix(matrix); } And on the openGL docs page: https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glMultMatrix.xml I don't remember what order the matrix data needs to be in when changing from a matrix4f to a float buffer, but I would hope the provided method for doing so would do so correctly, so if you're really lucky... GlStateManager.pushMatrix(); FloatBuffer buf = FloatBuffer.allocate(16); Matrix4f yourMatrix = ???; yourMatrix.store(buf); GlStateManager.multMatrix(buf); //Render stuff here GlStateManager.popMatrix(); Also keep in mind that there are several Matrix4f classes to choose from when importing. LWJGL has one, minecraft has one...I'm not sure what the differences between them are, but the minecraft one may do something special with the data ordering...I have no idea. I don't even have confidence that this will work, but it's something you can try if you feel like.
January 27, 20196 yr Author 2 minutes ago, Laike_Endaril said: You can almost certainly use the matrix itself...but beyond that I'm not sure exactly which method(s) you'll need to do so correctly. It might be the multMatrix call, but I can't remember for sure. Whatever you do, make sure you pushMatrix exactly once before you do any matrix alterations, and popMatrix exactly once after you render. In GlStateManager: public static void multMatrix(FloatBuffer matrix) { GL11.glMultMatrix(matrix); } And on the openGL docs page: https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glMultMatrix.xml I don't remember what order the matrix data needs to be in when changing from a matrix4f to a float buffer, but I would hope the provided method for doing so would do so correctly, so if you're really lucky... GlStateManager.pushMatrix(); FloatBuffer buf = FloatBuffer.allocate(16); Matrix4f yourMatrix = ???; yourMatrix.store(buf); GlStateManager.multMatrix(buf); //Render stuff here GlStateManager.popMatrix(); Also keep in mind that there are several Matrix4f classes to choose from when importing. LWJGL has one, minecraft has one...I'm not sure what the differences between them are, but the minecraft one may do something special with the data ordering...I have no idea. I don't even have confidence that this will work, but it's something you can try if you feel like. Thank you i will look into it
January 28, 20196 yr GL11.glMultMatrix(getRenderMatrix().asDoubleBuffer()); as Laike_Endaril already noticed. Is your source available somewhere? I did something a while back for Wavefront Object Models, but never finished it. And would be interested in some working solution for rigged Meshs, as my Rig was just based on an hand written XML File for now. Also im curious about how you solve Collision Detection ? (you might want to switch over to some other Matrix4f class like https://github.com/TheCBProject/CodeChickenLib/blob/master/src/main/java/codechicken/lib/vec/Matrix4.java, as LWJGL code isnt available on serverside)
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.