Jump to content

Recommended Posts

Posted

Hey, I have a custom model for an item that id like to render. All the tutorials i've found so far use techne. Seeing as i'm a linux user and wine isn't running techne I opted to use blender. I have exported the blender model as an obj file but i have no idea how to create the model class to import the model. I have the Item renderer class built and ready but i need to have the model class obviously to make it work.

 

Any suggestions or links to tutorials that show how to make the java file for an obj would be welcome.

 

Thanks

WORKING CODE

 

  Reveal hidden contents

 

Posted

Think i got the model stuff in the right places but the model is not rendering. Here is what i have so far.

 

Item Renderer

 

  Reveal hidden contents

 

 

Item WoodenShield

 

  Reveal hidden contents

 

 

Model Class

 

  Reveal hidden contents

 

 

Client Proxy

 

  Reveal hidden contents

 

Posted

To load an obj model you need an IModelCustom, and a ResourceLocation. You don't need a model class, that just over complicates things. You just put these in the ItemRenderer. You only need a model class if you are using techne, and also, not needed, but if you are using tessellators too.

 

public final ResourceLocation modelResource = new ResourceLocation("modid:yourModelLocation/yourModel.obj");
public final ResourceLocation texture = new ResourceLocation("modid:yourTextureLocation/yourTexture.png");

public IModelCustom model = AdvancedModelLoader.loadModel(modelResource);

public void renderItem(ItemRenderType type, ItemStack stack, Object... data) {
        GL11.glPushMatrix();
        Minecraft.getMinecraft().renderEngine.bindTexture(this.texture); //Not 100% sure if I got this right, but you bing the texture here.
        //Do all your GL11 rotations, scales, and translaters here...
        this.model.renderAll(); //Finally render the model
        GL11.glPopMatrix();
}

 

Hope this helped!

 

Also please note that your model HAS to be triangulated. If your model isn't triangulated, you will get a crash saying ModelFormatException.

I ask complicated questions, and apparently like to write really long detailed posts. But I also help others when I can.

Posted

Okay, for that crash, there is a NullPointerException on line 19 of your model class. always make sure something is not null if there is the possibility for it to be. Unfortunately, I can't look at the code you put on bitbucket, I am on a school pc, and that website is blocked due to a security error. May you put the code in "code" and "/code" (with square brackets [ ]) annotations? that way I can see what you have changed.

 

As I said though, you don't need a model class, put it in the ItemRenderer.

I ask complicated questions, and apparently like to write really long detailed posts. But I also help others when I can.

Posted

ok i tried what u suggested im getting a ModelFormatException error now

I did triangulate it.

Error parsing entry ('o Cylinder.002_Cylinder.003', line 4)

 

ItemRenderer Class

 

  Reveal hidden contents

 

 

Error

http://pastebin.com/0i0BgURQ

 

 

Posted

Well, if it isn't rendering, you either haven't bound the texture properly, or it is out of the players FOV, if you go into third person mode, can you see it? if not, the texture is not done properly, if so, you just need to use GL11 to translate it into the players view, and from there, you need to figure out the rotations and translations as no two models have the same translations/rotations.

I ask complicated questions, and apparently like to write really long detailed posts. But I also help others when I can.

Posted
  On 10/10/2014 at 12:37 PM, TheEpicTekkit said:

Well, if it isn't rendering, you either haven't bound the texture properly, or it is out of the players FOV, if you go into third person mode, can you see it? if not, the texture is not done properly, if so, you just need to use GL11 to translate it into the players view, and from there, you need to figure out the rotations and translations as no two models have the same translations/rotations.

 

 

Got It all working, thnx a lot for ur help

 

spoiler is broken again so

package com.kitsu.medievalcraft.renderer;

 

import org.lwjgl.opengl.GL11;

 

//import com.kitsu.medievalcraft.models.Model;

 

 

import com.kitsu.medievalcraft.item.weapon.ItemWoodenShield;

 

import net.minecraft.client.Minecraft;

import net.minecraft.entity.Entity;

import net.minecraft.item.ItemStack;

import net.minecraft.util.ResourceLocation;

import net.minecraftforge.client.IItemRenderer;

import net.minecraftforge.client.model.AdvancedModelLoader;

import net.minecraftforge.client.model.IModelCustom;

 

 

 

public class ItemRenderWoodenShield implements IItemRenderer {

 

public static final ResourceLocation WOODEN_SHIELD = new ResourceLocation("kitsumedievalcraft:models/woodenShieldObjectTriangle.obj");

public static final ResourceLocation woodenshield = new ResourceLocation("kitsumedievalcraft:models/woodenshield.png");

 

public IModelCustom model = AdvancedModelLoader.loadModel(WOODEN_SHIELD);

 

@Override

public boolean handleRenderType(ItemStack item, ItemRenderType type) {

 

switch(type) {

case EQUIPPED: {

return true;

}

case EQUIPPED_FIRST_PERSON: {

return true;

}

 

default: return false;

}

}

 

@Override

public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item,

ItemRendererHelper helper) {

 

return false;

}

 

@Override

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

 

switch(type) {

 

case EQUIPPED: {

 

GL11.glPushMatrix();

GL11.glScalef(0.875F, 0.875F, 0.875F);

 

//ANGLE, X ROTATE, Y ROTATE, Z ROTATE

GL11.glRotatef(270F, 0.0F, 1.0F, 0.0F);

GL11.glRotatef(10F, 0.0F, 0.0F, -1.0F);

//GL11.glRotatef(30F, 0.0F, 0.0F, 1.0F);

GL11.glRotated(90, 1.0, 0.0, 0.0);

 

GL11.glTranslatef(-0.35F, -1.5F, -0.55F);

 

Minecraft.getMinecraft().renderEngine.bindTexture(woodenshield);

model.renderAll();

 

GL11.glPopMatrix();

} break;

 

case EQUIPPED_FIRST_PERSON: {

if (ItemWoodenShield.woodenShieldInUse == true) {

GL11.glPushMatrix();

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

 

//ANGLE, X ROTATE, Y ROTATE, Z ROTATE

//GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F);

GL11.glRotatef(0F, 0.0F, 0.0F, 0.0F);

//GL11.glRotatef(30F, 0.0F, 0.0F, 1.0F);

 

 

GL11.glRotated(-85, 1.0, 0.0, 0.0);

GL11.glRotated(50, 0.0F, 0.0F, 1.0F);

GL11.glRotated(3, 0.0F, 1.0F, 0.0F);

 

GL11.glTranslatef(0.9F, -0.9F, 0.9F);

//GL11.glTranslatef(-0.35F, -1.5F, -0.55F);

 

Minecraft.getMinecraft().renderEngine.bindTexture(woodenshield);

model.renderAll();

 

GL11.glPopMatrix();

}

} break;

 

default:

break;

}

}

 

 

}

Posted
  On 10/10/2014 at 3:38 PM, MultiMote said:

> GL11.glScalef(1.0F, 1.0F, 1.0F);

 

This does nothing.

 

> GL11.glRotatef(0F, 0.0F, 0.0F, 0.0F);

 

And this too.

 

i changed those after i posted my code, woops =p

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...

×   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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • wait, i just did that. why didn't it work? also it's the same. help me!!!!
    • Culprit has been located! It was Tough As Nails + (plus) which was among one of the mods *added* before re-entering, in an attempt to improve compatibility. It, for some reason or another, did not want to work!
    • "You can either try to load it with only the vanilla data pack ("safe mode"), or go back to the title screen and fix it manually." Hello! I encountered this error just now while attempting to re-enter my world for the first time. Notably, no mods were removed before encountering this error and, while being able to find this error elsewhere on the internet, in my scenario it is seemingly caused by a specific mod, of which I cannot isolate. Things I have tried: - Enter "Safe Mode" (fails) - Remove datapacks (no change) - Reverted to old save data (no change) Here is the server log: https://mclo.gs/9vJQEfN I use Modrinth mod loader so please let me know how to share my mod list, and if it is needed.
    • So, i'm hosting (or attempting to host) a port-forwarded modded server for 1.12.2. There's quite a few mods in this pack, but they all run and have no compatibility issues (besides something causing the game to crash if you go fullscreen, a problem ive given up trying to identify or fix). It can run on 6gb of ram or less, and works fine in singleplayer. All of my friends that want to join have the exact same mod/config/game setup as I do (I personally helped them set everything up). Just to be safe, we've all allocated 12 gigabytes of RAM to the installation, and I've also allocated 12GB to the server itself. I am able to join with no issue and it runs fine. However, when they try to join, it gets stuck in the 'logging in' screen before their game becomes unresponsive. When they close it, it gives them the exit code 805306369, which usually means not enough RAM, but this cant be the case. On my screen, in the server, it shows them joining, and then disconnecting, so I dont think its a port-forwarding issue. They can all run it just fine in singleplayer as well. The annoying bit about this particular issue is that it generates no crash log. Does anyone have any suggestions? Thanks! Here is my debug log, and his, starting from the same place. MINE: [132647] [Netty Client IO #5INFO] [FML] Attempting connection with missing mods [ctm, fusion] at SERVER 132653.817 [132653] [Client threadINFO] [minecraftGuiConnecting] Connecting to 0, 25565 132654.682 [132654] [Netty Client IO #9INFO] [STDOUT] [xaero.common.core.transformer.ClassNodeTransformertransform29] Transforming class brz net.minecraft.client.network.NetHandlerPlayClient 132654.684 [132654] [Netty Client IO #9INFO] [STDOUT] [xaero.map.core.transformer.ClassNodeTransformertransform29] Transforming class net.minecraft.client.network.NetHandlerPlayClient 132654.764 [132654] [Netty Client IO #9INFO] [FML] Server protocol version 2 132654.777 [132654] [Netty Client IO #9INFO] [FML] Attempting connection with missing mods [ctm, fusion] at SERVER 132656.193 [132656] [Client threadINFO] [FML] Injecting existing registry data into this client instance 132659.081 [132659] [Client threadINFO] [FML] Applying holder lookups 132659.082 [132659] [Client threadINFO] [FML] Holder lookups applied 132659.092 [132659] [Netty Client IO #9INFO] [FML] [Netty Client IO #9] Client side modded connection established HIS: [13:12:16] [Netty Client IO #0/INFO] [FML]: Attempting connection with missing mods [ctm, fusion] at SERVER 13:12:25.597 [13:12:25] [Client thread/INFO] [minecraft/GuiConnecting]: Connecting to (my IP address and the server port 25565) 13:12:26.805 [13:12:26] [Netty Client IO #1/INFO] [STDOUT]: [xaero.common.core.transformer.ClassNodeTransformer:transform:29]: Transforming class brz net.minecraft.client.network.NetHandlerPlayClient 13:12:26.808 [13:12:26] [Netty Client IO #1/INFO] [STDOUT]: [xaero.map.core.transformer.ClassNodeTransformer:transform:29]: Transforming class net.minecraft.client.network.NetHandlerPlayClient 13:12:26.936 [13:12:26] [Netty Client IO #1/INFO] [FML]: Server protocol version 2 13:12:27.114 [13:12:27] [Netty Client IO #1/INFO] [FML]: Attempting connection with missing mods [ctm, fusion] at SERVER 13:12:27.480 [13:12:27] [Client thread/INFO] [FML]: Injecting existing registry data into this client instance 13:12:30.669 [13:12:30] [Client thread/INFO] [FML]: Applying holder lookups 13:12:30.671 [13:12:30] [Client thread/INFO] [FML]: Holder lookups applied 13:13:04.700 Process crashed with exit code -805306369 P.S - Both mods "CTM" and "FUSION" are present in both our folders so idk what that's about.
    • Please read the FAQ (link is orange banner at top of page), and post logs as described there, to an external site such as https://mclo.gs  
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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