Xumuk Posted August 20, 2018 Posted August 20, 2018 (edited) Hello eweryone! The loading of the mtl library. More precisely, it works, but the texture of it is not loaded. The model is loaded, but the texture is not. Forge does not throw an error. Only the notification that the texture I use for my model is not supported and is skipping. My MC version - 1.12.2 Loading the model like this: public static void registerRenderObj(Block block) { ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block),0, new ModelResourceLocation(new ResourceLocation(block.getRegistryName().getResourceDomain(), block.getRegistryName().getResourcePath().concat(".obj")),"inventory")); } Spoiler #this is mtl-lib. appletop.png - basic 16px texture # 3ds Max Wavefront OBJ Exporter v0.97b - (c)2007 guruware # File Created: 12.08.2018 19:45:17 newmtl 01___Default Ns 10.0000 Ni 1.5000 d 1.0000 Tr 0.0000 Tf 1.0000 1.0000 1.0000 illum 2 Ka 0.5882 0.5882 0.5882 Kd 0.5882 0.5882 0.5882 Ks 0.0000 0.0000 0.0000 Ke 0.0000 0.0000 0.0000 map_Ka realism:textures\blocks\appletop.png map_Kd realism:textures\blocks\appletop.png I export the model like this: Edited August 20, 2018 by Xumuk Quote
Draco18s Posted August 20, 2018 Posted August 20, 2018 1) Your block isn't at the correct origin. Minecraft block origins are the bottom, north, west corner. 2) Its scale is likely wrong. It needs to fit within a 1x1x1 unit volume within your modeling program. Quote 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.
Xumuk Posted August 20, 2018 Author Posted August 20, 2018 (edited) 19 minutes ago, Draco18s said: 1) Your block isn't at the correct origin. Minecraft block origins are the bottom, north, west corner. 2) Its scale is likely wrong. It needs to fit within a 1x1x1 unit volume within your modeling program. Your advice didn't help. The model is now less than one block size, located inside the coordinates 1x1x1, but still has no texture. Edited August 20, 2018 by Xumuk Quote
Draco18s Posted August 20, 2018 Posted August 20, 2018 There's also a problem with the texture, but yes, those two things are also problems. Quote 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.
Xumuk Posted August 20, 2018 Author Posted August 20, 2018 # 3ds Max Wavefront OBJ Exporter v0.97b - (c)2007 guruware # File Created: 20.08.2018 18:34:47 newmtl 01___Default Ns 10.0000 Ni 1.5000 d 1.0000 Tr 0.0000 Tf 1.0000 1.0000 1.0000 illum 2 Ka 0.5882 0.5882 0.5882 Kd 0.5882 0.5882 0.5882 Ks 0.0000 0.0000 0.0000 Ke 0.0000 0.0000 0.0000 map_Ka realism:textures\blocks\appletop.png map_Kd realism:textures\blocks\appletop.png Maybe the wrong way to textures? Quote
Draco18s Posted August 20, 2018 Posted August 20, 2018 I don't know how the textures work for OBJ models. Quote 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.
☀☀☀ Posted August 21, 2018 Posted August 21, 2018 21 hours ago, Xumuk said: Maybe the wrong way to textures? Quote
Xumuk Posted August 21, 2018 Author Posted August 21, 2018 I'm use custom name. But still does not work Quote
☀☀☀ Posted August 21, 2018 Posted August 21, 2018 7 minutes ago, Xumuk said: I'm use custom name. But still does not work map_Kd realism:textures\blocks\appletop should be without ".png" Quote
Xumuk Posted August 21, 2018 Author Posted August 21, 2018 1 hour ago, ☀☀☀ said: map_Kd realism:textures\blocks\appletop should be without ".png" It didn't help me Quote
DouYanC Posted August 22, 2018 Posted August 22, 2018 (edited) You try it out setBlockBounds(0.0F, 0.0F, 0.0F, 5.0F, 5.0F, 5.0F); Edited August 22, 2018 by DouYanC Quote
Draco18s Posted August 22, 2018 Posted August 22, 2018 8 hours ago, DouYanC said: You try it out setBlockBounds(0.0F, 0.0F, 0.0F, 5.0F, 5.0F, 5.0F); No. This won't work. This will never work, I don't even know how you think this would even solve the problem at hand. Block bounds are not allowed to exceed 1 block wide and 1.5 blocks tall. Quote 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.
Pheenixm Posted August 27, 2018 Posted August 27, 2018 (edited) Your texture is in the wrong place. Here's an example of one of my mtl files # Blender MTL File: 'engine.blend' # Material Count: 14 newmtl Material Ns 96.078431 Ka 1.000000 1.000000 1.000000 Kd 0.640000 0.640000 0.640000 Ks 0.500000 0.500000 0.500000 Ke 0.000000 0.000000 0.000000 Ni 1.000000 d 1.000000 illum 2 map_Kd explosivesplus:items/engine_tank newmtl Material.001 Ns 96.078431 Ka 1.000000 1.000000 1.000000 Kd 0.640000 0.640000 0.640000 Ks 0.500000 0.500000 0.500000 Ke 0.000000 0.000000 0.000000 Ni 1.000000 d 1.000000 illum 2 map_Kd explosivesplus:items/engine_nozzle You'll note I don't specify the "textures" folder at all; that's automatic. My textures are in assets/explosivesplus/textures/items. But the "texture" line is just implied Also, you can just load the model in your blockstates file. "model": "explosivesplus:silo.obj", You'll also want to put @SubscribeEvent public static void registerModels(ModelRegistryEvent event) { OBJLoader.INSTANCE.addDomain(ExplosivesPlus.MOD_ID); } somewhere in your ClientProxy file. Edited August 27, 2018 by Pheenixm Quote
Pheenixm Posted August 27, 2018 Posted August 27, 2018 On 8/20/2018 at 11:18 AM, Draco18s said: 1) Your block isn't at the correct origin. Minecraft block origins are the bottom, north, west corner. 2) Its scale is likely wrong. It needs to fit within a 1x1x1 unit volume within your modeling program. Think you're wrong on 2. Obj files can be as large as you want them to be; you'll run into some errors with frustrum though. Quote
Draco18s Posted August 27, 2018 Posted August 27, 2018 13 minutes ago, Pheenixm said: Think you're wrong on 2. Obj files can be as large as you want them to be; you'll run into some errors with frustrum though. Oh, it can be larger, but you'll run into all kinds of issues...like frustum culling, being able to place blocks inside it, being unable to collide with it, unable to prevent mobs moving through it, and so on. Quote 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.
Pheenixm Posted August 27, 2018 Posted August 27, 2018 Just now, Draco18s said: Oh, it can be larger, but you'll run into all kinds of issues...like frustum culling, being able to place blocks inside it, being unable to collide with it, unable to prevent mobs moving through it, and so on. Oh, definitely. I've been using invisible blocks with large .obj models in my multiblock setup, and it has been a pain to get the frustrum culling to stop. I'm having to use @Override public boolean isGlobalRenderer(TileEntitySilo tile) { return true; } in my TESR just to ward off the frustrum culling issues. Fortunately, I don't expect a lot of my multiblocks to ever be built (350 block composition), so it shouldn't be too much of a problem. Quote
Xumuk Posted August 27, 2018 Author Posted August 27, 2018 (edited) @Pheenixm I did everything you said, but the white color just got a little darker. And texture my still there is no? My mtl file now: # 3ds Max Wavefront OBJ Exporter v0.97b - (c)2007 guruware # File Created: 20.08.2018 18:34:47 newmtl mymtl Ns 96.078431 Ni 1.000000 d 1.000000 Tr 0.0000 Tf 1.0000 1.0000 1.0000 illum 2 Ka 1.000000 1.000000 1.000000 Kd 0.640000 0.640000 0.640000 Ks 0.500000 0.500000 0.500000 Ke 0.000000 0.000000 0.000000 map_Ka realism:blocks\appletop map_Kd realism:blocks\appletop What's that ? There are no such values in your mtl file. Tr 0.0000 Tf 1.0000 1.0000 1.0000 Edited August 27, 2018 by Xumuk Quote
Pheenixm Posted August 27, 2018 Posted August 27, 2018 3 minutes ago, Xumuk said: @Pheenixm I did everything you said, but the white color just got a little darker. And texture my still there is no)) My mtl file now: # 3ds Max Wavefront OBJ Exporter v0.97b - (c)2007 guruware # File Created: 20.08.2018 18:34:47 newmtl mymtl Ns 96.078431 Ni 1.000000 d 1.000000 Tr 0.0000 Tf 1.0000 1.0000 1.0000 illum 2 Ka 1.000000 1.000000 1.000000 Kd 0.640000 0.640000 0.640000 Ks 0.500000 0.500000 0.500000 Ke 0.000000 0.000000 0.000000 map_Ka realism:blocks\appletop map_Kd realism:blocks\appletop What's that ? There are no such values in your mtl file. Tr 0.0000 Tf 1.0000 1.0000 1.0000 Show me your blockstate.json for the block. I don't know what those values are, most of the values in mtl's are essentially unnecessary, beyond the most basic map_Kd or map_Ka calls. For instance, look at Immersive Engineering. Also, a picture of your folder structure would be ideal. What rendering software are you using? Quote
Xumuk Posted August 27, 2018 Author Posted August 27, 2018 3ds Max ~~~ I haven't created blockstate for this model since I don't know what it should look like for .obj Quote
Pheenixm Posted August 27, 2018 Posted August 27, 2018 (edited) You don't need this ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block),0, new ModelResourceLocation(new ResourceLocation(block.getRegistryName().getResourceDomain(), block.getRegistryName().getResourcePath().concat(".obj")),"inventory")) Use a blockstate.json file, like I do here https://bitbucket.org/Pheenixm/explosivesplus/src/master/Explosives%2B/src/main/resources/assets/explosivesplus/blockstates/concrete.json Edited August 27, 2018 by Pheenixm Quote
Xumuk Posted August 28, 2018 Author Posted August 28, 2018 If you do as you said, in the end it will simply be loaded default model specified in the blockstate. OBJ model is not loaded at all... { "forge_marker": 1, "defaults": { "model": "realism:beton" }, "variants": { "normal": [ { } ], "inventory": [ { } ], "multi": { "invalid": { "model": "realism:beton" }, "center":{}, "render": { "custom": { "flip-v": true }, "model": "realism:testobj.obj", "transform": { "scale": [ 1, 1, 1 ], "translation": [ 0.5, 0, 0.5 ] } }, "structure": { } } } } Quote
Pheenixm Posted August 28, 2018 Posted August 28, 2018 10 hours ago, Xumuk said: If you do as you said, in the end it will simply be loaded default model specified in the blockstate. OBJ model is not loaded at all... { "forge_marker": 1, "defaults": { "model": "realism:beton" }, "variants": { "normal": [ { } ], "inventory": [ { } ], "multi": { "invalid": { "model": "realism:beton" }, "center":{}, "render": { "custom": { "flip-v": true }, "model": "realism:testobj.obj", "transform": { "scale": [ 1, 1, 1 ], "translation": [ 0.5, 0, 0.5 ] } }, "structure": { } } } } I didn't mean copy my code exactly. That code is specific to my block, not yours. If you don't understand the fields in blockstate.json files, I suggest you go learn them independently. What you need to know is that you have to have the custom tag, because flip-v has to be specified as true, and ALL of your model references need to end in .obj when you're referring to .obj files. Quote
Xumuk Posted August 31, 2018 Author Posted August 31, 2018 (edited) I understood. If I do this: { "forge_marker": 1, "variants": { "normal": { "model": "realism:testobj.obj","flip-v": true} } } But the texture is still missing, only gray. Gray, but not white default, because to the loader writed , that it takes the color from the material. But the texture is still present. If mtl insert row "map_Ke realism:blocks\appletop", nothing will change Console writed: [13:36:16] [main/INFO] [FML]: OBJLoader.MaterialLibrary: key '' (model: 'realism:models/block/testobj.mtl') is not currently supported, skipping [13:36:16] [main/INFO] [FML]: OBJLoader.MaterialLibrary: key 'Ni' (model: 'realism:models/block/testobj.mtl') is not currently supported, skipping [13:36:16] [main/INFO] [FML]: OBJModel: A color has already been defined for material 'mylib' in 'realism:models/block/testobj.mtl'. The color defined by key 'Ks' will not be applied! [13:36:16] [main/INFO] [FML]: OBJLoader.MaterialLibrary: key 'Ke' (model: 'realism:models/block/testobj.mtl') is not currently supported, skipping [13:36:16] [main/INFO] [FML]: OBJLoader.Parser: command 's' (model: 'realism:models/block/testobj.obj') is not currently supported, skipping. Line: 37 's 2' File testobj with "s 2" line mtllib testobj.mtl # # object Box001 # v 0.1500 -0.0000 0.8500 v 0.1500 -0.0000 0.1500 v 0.8500 -0.0000 0.1500 v 0.8500 -0.0000 0.8500 v 0.1500 0.7000 0.8500 v 0.8500 0.7000 0.8500 v 0.8500 0.7000 0.1500 v 0.1500 0.7000 0.1500 # 8 vertices vn 0.0000 -1.0000 -0.0000 vn 0.0000 1.0000 -0.0000 vn 0.0000 0.0000 1.0000 vn 1.0000 0.0000 -0.0000 vn 0.0000 0.0000 -1.0000 vn -1.0000 0.0000 -0.0000 # 6 vertex normals vt 1.0000 0.0000 0.0000 vt 1.0000 1.0000 0.0000 vt 0.0000 1.0000 0.0000 vt 0.0000 0.0000 0.0000 # 4 texture coords o Box001 g Box001 usemtl mylib s 2 f 1/1/1 2/2/1 3/3/1 f 3/3/1 4/4/1 1/1/1 s 4 f 5/4/2 6/1/2 7/2/2 f 7/2/2 8/3/2 5/4/2 s 8 f 1/4/3 4/1/3 6/2/3 f 6/2/3 5/3/3 1/4/3 s 16 f 4/4/4 3/1/4 7/2/4 f 7/2/4 6/3/4 4/4/4 s 32 f 3/4/5 2/1/5 8/2/5 f 8/2/5 7/3/5 3/4/5 s 64 f 2/4/6 1/1/6 5/2/6 f 5/2/6 8/3/6 2/4/6 # 12 faces Edited August 31, 2018 by Xumuk Quote
Pheenixm Posted August 31, 2018 Posted August 31, 2018 (edited) Looks like you're the not the first person to have trouble with 3DSMax. I'd switch to blender while I was still early on, it actually works. That said, try removing all 's' references you can find; it probably won't do anything, but it's worth a shot. Finally, I'd try reimporting your model, because I've thought about it further; your texture is DEFINITELY loading, otherwise, you'd have the purple and black checkers that Forge applies by default to missing texture objects. Try changing your texture files (appletop) to neon yellow, then see if the render of the block in-game changes at all. If it does, you're likely dealing with UV errors, and again, I'd recommend you just go learn blender. Edited August 31, 2018 by Pheenixm Quote
Recommended Posts
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.