Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[1.12.2] Render .obj and .mtl file

Featured Replies

Posted

Hello I hope, you can help me with the problem of rendering the model. The model itself is rendered, but here maps of textures/glare/normals/smooth/shading are not superimposed, and the .mtl file itself seems to be skipping. All paths and file names are named correctly. I do everything via json file in blockstates. What is the problem?

Attached screenshots, including the console.

I will be very grateful for help. 

Item

Spoiler

public class LongSword extends ItemSword {
    public LongSword(String name, ToolMaterial material) {
        super(material);
        setRegistryName(name);
        setUnlocalizedName(name);
        setCreativeTab(Main.LevWeapon);
    }
}

 


Register

Spoiler

public class ItemsRegister {
  
    public static ToolMaterial LongSwordMaterial = EnumHelper.addToolMaterial("LongSwordMaterial", 2, 256, 50.0F, 2.0F, 12);
  
    public static ItemSword long_sword = new LongSword("long_sword", LongSwordMaterial);
  
    public static void register() {
        setRegister(long_sword);
    }
  
    @SideOnly(Side.CLIENT)
    public static void registerRender() {
        setRender(long_sword);
    }
  
    private static void setRegister(Item item) {
        ForgeRegistries.ITEMS.register(item);
    }
  
    @SideOnly(Side.CLIENT)
    private static void setRender(Item item) {
        Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));

    }
}

 


Proxy

Spoiler

public class ClientProxy extends CommonProxy {

    public void registerModel(Item item) {
        ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));
    }

    @Override
    public void preInit(FMLPreInitializationEvent event) {
        OBJLoader.INSTANCE.addDomain(Main.MODID);
        registerModel(ItemsRegister.long_sword);
        super.preInit(event);
    }

    @Override
    public void init(FMLInitializationEvent event) {
        ItemsRegister.registerRender();
        super.init(event);
    }

    @Override
    public void postInit(FMLPostInitializationEvent event) {
        super.postInit(event);
    }
}

 


blockstates .json file

Spoiler

{
  "forge_marker": 1,
  "defaults": {
    "model": "leviathan:long_sword.obj"
  },
  "variants": {
    "inventory": [
      {
        "transform": {
          "thirdperson_lefthand": {
            "rotation": [ { "x": -90 }, { "y": 0 }, { "z": 0 } ],
            "translation": [ 0, -0.1, 0.1 ],
            "scale": 1.00
          },
          "thirdperson_righthand": {
            "rotation": [ { "x": -90 }, { "y": 0 }, { "z": 0 } ],
            "translation": [ 0, -0.1, 0.1 ],
            "scale": 1.00
          },
          "gui": {
            "rotation": [ { "x": -90 }, { "y": 0 }, { "z": -0 } ],
            "translation": [ -0.2, -0.2, 0 ],
            "scale": 1.00
          },
          "firstperson_righthand": {
            "rotation": [ { "x": -90 }, { "y": 0 }, { "z": 0 } ],
            "translation": [ 0, -0.1, 0 ],
            "scale": 1.00
          },
          "firstperson_lefthand": {
            "rotation": [ { "x": -90 }, { "y": 0 }, { "z": 0 } ],
            "translation": [ 0, -0.1, 0 ],
            "scale": 1.00
          },
          "ground": {
            "rotation": [ { "x": -90 }, { "y": 0 }, { "z": 0 } ],
            "scale": 1.00
          }
        }
      }
    ]
  }
}

 


.mtl file

Spoiler

newmtl Garda
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.000000 0.000000 0.000000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 1
map_Bump leviathan:textures/items/models/nmap_long_sword
map_Ka leviathan:textures/items/models/aomap_long_sword
map_Kd leviathan:textures/items/models/cycmap_long_sword

newmtl Leswie
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.000000 0.000000 0.000000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 1
map_Bump leviathan:textures/items/models/nmap_long_sword
map_Ka leviathan:textures/items/models/aomap_long_sword
map_Kd leviathan:textures/items/models/cycmap_long_sword

newmtl Ruka
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

 

 

2018-06-10_23.29.49.jpg

Screenshot_314.png

Edited by _mudblood

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.