Posted September 17, 20178 yr I previously asked this question and I was told to translate, rotate, then translate back. After many hours of debugging trying to understand what was going wrong, I have come to the conclusion that it doesn't work like that. When one rotates using GlStateManager.rotate, all the axes of the OBJ rotate as well. In other words, the final translation will translate in reference to the rotated axis, making it impossible to translate to it's previous position. For example: // Move in the x axis 0.5 (works fine) GlStateManager.translate(0.5, 0, 0) // Rotate around the z axis, 45 degrees (code breaks. the object rotates as intended, but all the axes get rotated as well) GlStateManager.rotate(45f, 0f, 0f, 1f) // Return the object to its previous position (Doesn't work, translates the object diagonally because the axes changed) GlStateManager.translate(-0.5, 0, 0) How would one rotate the OBJ without the OBJ axes being rotated? Edited September 17, 20178 yr by ctbe typo
September 17, 20178 yr https://academo.org/demos/rotation-about-point/ Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
September 17, 20178 yr Author Thanks for the answer, but I give up. I think no one has ever managed to do a custom chest in minecraft. If they did, they had a thorough understanding of what opengl is doing. I don't. I'll make my chest a simple static block. No animation or anything.
September 17, 20178 yr What part are you trying to rotate the direction the chest is facing or the chest opening animation also could you post a link to you git repo.
September 17, 20178 yr 8 minutes ago, ctbe said: I think no one has ever managed to do a custom chest in minecraft. Cough: http://mod-minecraft.net/iron-chests-mod/ In order to rotate around a point you need to translate to the origin by that point's offset from the origin, then rotate, then translate back. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
September 17, 20178 yr 1 hour ago, Draco18s said: http://mod-minecraft.net/iron-chests-mod/ Uhm... Draco..? Check out my mods: BTAM Armor sets Avoid Exploding Creepers Tools compressor Anti Id Conflict Key bindings overhaul Colourfull blocks Invisi Zones
September 17, 20178 yr Author It's okay guys. I appreciate the intention on helping , but I'm really leaving it since this has been eating me for too long. If anyone asks me to add animation to my chests for when the lid opens and close I'll just tell them I don't know how to do it as I don't understand the GL. Don't worry . Here is an illustration in 2D of what I meant in my first post that is happening with the gl calls. Spoiler In step 3, all the axes of reference get rotated. Meaning that any translation in the x axis afterwards, will be diagonal. This is 2D, but in minecraft, all 3 axes of reference get rotated together with the object (x, y, z).
September 17, 20178 yr 2 minutes ago, Elix_x said: Uhm... Draco..? So I grabbed the first link on google for what I knew existed. 9.9 Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
September 17, 20178 yr 2 minutes ago, ctbe said: In step 3, all the axes of reference get rotated. Meaning that any translation in the x axis afterwards, will be diagonal. This is 2D, but in minecraft, all 3 axes of reference get rotated together with the object (x, y, z). This is the definition of matrices. Understanding matrices will definitely help you solve this. I recommend watching this: Linear transformations and matrices | Essence of linear algebra, chapter 3* Spoiler As for how to rotate around an axis, in 3D, you can look at how utility method is implemented in JOML: https://github.com/JOML-CI/JOML/blob/c312304fefbe757e3d37cba866f5742b3448a85c/src/org/joml/Matrix4f.java#L11379 This is generic use case, but now i have to correct you. What you put in the "What is happening" is not correct. Because in both translation, rotation and scaling, coordinates do "the same" what the model does (it is actually the opposite - model does whatever you do to the coordinate system). That said, the transformations you apply further down in the stack, actually apply to the already transformed coordinates as a whole, so Check out my mods: BTAM Armor sets Avoid Exploding Creepers Tools compressor Anti Id Conflict Key bindings overhaul Colourfull blocks Invisi Zones
September 19, 20178 yr Author Why thanks for the references and explanation. I know I said I'm leaving it, but just to show my whole problem, here is the rendering result of my code and the code itself that makes the linked video. Lid Rotation: https://vgy.me/EvxpWl Chest Body Rotation (how I wanted the lid to rotate): https://vgy.me/NOOLZg Code... (This code is quite a bit so don't worry if you don't look at it. I'm opting for going static.) TileEntity (TileEntitySimpleChest.kt) http://www.codesend.com/view/67ca9f38cda506bb1cbd0485d549aa8b/ Block properties http://www.codesend.com/view/b502d4257d3be71c3f7801d3dc34b0e1/ Block (BlockSimpleChest.kt) http://www.codesend.com/view/d1f28420c3518684918d930941e8e830/ TileEntitySpecialRenderer (TileEntitySimpleChestRenderer.kt) http://www.codesend.com/view/5248c50e70d83ba6b891a00e53100f45/ Blockstate JSON (blocksimplechest.json) http://www.codesend.com/view/2d66a1853026a2d6e1ce4a19aa08a7ea/ Chest Model (simple_chest.obj) http://www.codesend.com/view/4d62970462e21a83fd292d9f8c3d46ba/ Chest MTL (simple_chest.mtl) http://www.codesend.com/view/fbc3f45beb2651edde86582f9b83da82/ Lid Model (simple_chest_lid.obj) http://www.codesend.com/view/9715006f7c39b7dae56c42b795d0aa76/ Lid MTL (simple_chest_lid.mtl) http://www.codesend.com/view/dbf55dcb142c5aba6e9dee6ae2087c0e/ This was an extension of the tutorial: https://wiki.mcjty.eu/modding/index.php/Render_Block_TESR_/_OBJ-1.12 but I changed a lot of it to fit my purposes. Though the rendering code is pretty much a copy paste. No amount of transformation fixes the problem for me. The problem must be me and I could never identify what I was doing wrong. The code I provided here renders the first video only. The chest body rotation happens if one uses false for the IS_CHEST_LID property in the TileEntitySpecialRenderer... in case you wonder how I shifted from rotating the lid to rotate the chest body in the second video. Edited September 19, 20178 yr by ctbe Better formatting
September 19, 20178 yr Just as Draco said, you have to translate the lid such that it's origin is world origin, rotate, then translate it back. Notice GlStateManager.translate(x, y, z) in the beginning of the method. This method translates tile entity in the world view space. Now the origin (0,0,0) is "actually" the XYZ of the tile entity, AKA you're working in local coordinates - coordinates relative to the origin of tile/model. So you have to translate the lid by it's local model coordinates to local origin and back. Ex: GL.trans(-lidModelCoords).rot(rot).trans(lidModelCoords). Check out my mods: BTAM Armor sets Avoid Exploding Creepers Tools compressor Anti Id Conflict Key bindings overhaul Colourfull blocks Invisi Zones
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.