Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.7.10] SOLVED OBJ As 3D rendered item


StarGlas
 Share

Recommended Posts

Hello all.

 

I am trying to use a .obj in my mod as 3d rendered item. The reason for it is because Techne isn't really great for high detailed models.

 

I tried to follow this http://www.minecraftforge.net/wiki/Using_wavefront_model tutorial but that is for blocks and not for items. The things I tried don't works because it always crashed on de model.renderAll() function

 

Here is my test code

TESRnowball

 

 

package starglas.dsremake.renderer;

 

import net.minecraft.client.Minecraft;

import net.minecraft.item.ItemStack;

import net.minecraft.util.ResourceLocation;

import net.minecraftforge.client.IItemRenderer;

import net.minecraftforge.client.IItemRenderer.ItemRenderType;

import net.minecraftforge.client.model.AdvancedModelLoader;

import net.minecraftforge.client.model.IModelCustom;

 

import org.lwjgl.opengl.GL11;

 

import starglas.dsremake.common.block.TESnowball;

import starglas.dsremake.common.helpers.Reference;

import starglas.dsremake.common.models.paladinglaive;

 

public class TESRSnowball implements IItemRenderer {

IModelCustom model;

ResourceLocation texture = new ResourceLocation(Reference.MODID,

"textures/items/testtexture.png");

 

public TESRSnowball(){

IModelCustom model = AdvancedModelLoader.loadModel(new ResourceLocation(

Reference.MODID, "obj/lance.obj"));

}

 

@Override

public boolean handleRenderType(ItemStack item, ItemRenderType type) {

switch(type){

case EQUIPPED:

case EQUIPPED_FIRST_PERSON:

return true;

default:

return false;

}

}

 

@Override

public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item,

ItemRendererHelper helper) {

// TODO Auto-generated method stub

return false;

}

@Override

public void renderItem(ItemRenderType type, ItemStack item, Object... data) {

 

GL11.glPushMatrix();

//Minecraft.getMinecraft().renderEngine.bindTexture(texture);

GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

GL11.glTranslatef(0F, 0F, 0F);

 

model.renderAll();

GL11.glPopMatrix();

}

}

 

 

 

ClientProxy

 

 

package starglas.dsremake.client;

 

import net.minecraft.item.Item;

import net.minecraftforge.client.IItemRenderer;

import net.minecraftforge.client.MinecraftForgeClient;

import starglas.dsremake.common.CommonProxy;

import starglas.dsremake.common.block.ModBlocks;

import starglas.dsremake.common.block.TileEntityBonfire;

import starglas.dsremake.common.helpers.RegisterHelper;

import starglas.dsremake.common.items.ModItems;

import starglas.dsremake.renderer.ItemRendererBlockBonfire;

import starglas.dsremake.renderer.ItemRendererLongSword;

import starglas.dsremake.renderer.ItemRendererPaladinGlaive;

import starglas.dsremake.renderer.RendererBonfire;

import starglas.dsremake.renderer.TESRSnowball;

import cpw.mods.fml.client.registry.ClientRegistry;

import cpw.mods.fml.common.registry.GameRegistry;

 

public class ClientProxy extends CommonProxy {

public void registerRenderers(){

MinecraftForgeClient.registerItemRenderer(ModItems.longSword, (IItemRenderer)new ItemRendererLongSword());

MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.blockBonfire), (IItemRenderer)new ItemRendererBlockBonfire());

GameRegistry.registerTileEntity(TileEntityBonfire.class, "blockBonfire");

ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBonfire.class, new RendererBonfire());

RegisterHelper.registerRender(ModItems.PaladinGlaive, new ItemRendererPaladinGlaive());

MinecraftForgeClient.registerItemRenderer(ModItems.MK1BloodStone, new TESRSnowball());

 

}

}

 

 

I hope someone can help me because it will be really nice to have 3D textures

 

EDIT. Welp, I removed some coded and now it works strangly enough, so mods this threat can be deleted

Link to comment
Share on other sites

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
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



×
×
  • Create New...

Important Information

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