Posted December 19, 20177 yr Hi, I'm trying to render a .obj model with TESR but nothing render.. if anyone have an idea. @SideOnly(Side.CLIENT) public class ElementItemRender implements LayerRenderer<AbstractClientPlayer> { static private IModel model; static private IBakedModel bakedModel; static ResourceLocation texture; public ElementItemRender(){ this.texture = new ResourceLocation(References.MOD_ID, "models/item/tutorial_item.obj"); try { this.model = OBJLoader.INSTANCE.loadModel(this.texture); } catch (Exception e) { e.printStackTrace(); } if (this.model != null) { this.bakedModel = this.model.bake(TRSRTransformation.identity(), DefaultVertexFormats.ITEM, ModelLoader.defaultTextureGetter()); } } private static void renderModel(IBakedModel model, VertexFormat fmt) { Tessellator tessellator = Tessellator.getInstance(); BufferBuilder worldrenderer = tessellator.getBuffer(); worldrenderer.begin(GL11.GL_QUADS, fmt); for (BakedQuad bakedquad : model.getQuads(null, null, 0)) { worldrenderer.addVertexData(bakedquad.getVertexData()); // net.minecraftforge.client.model.pipeline.LightUtil.renderQuadColor(worldrenderer, bakedquad, -1); } tessellator.draw(); } @Override public void doRenderLayer(AbstractClientPlayer entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { GlStateManager.pushMatrix(); GlStateManager.translate(entitylivingbaseIn.posX, entitylivingbaseIn.posY, entitylivingbaseIn.posZ); // GlStateManager.enableRescaleNormal(); GlStateManager.scale(scale * 1.0f, scale * 1.0f, scale * 1.0f); // this.renderModel(this.bakedModel, DefaultVertexFormats.ITEM); GlStateManager.popMatrix(); } @Override public boolean shouldCombineTextures() { return true; } } @Override public void init() { Map<String, RenderPlayer> skinMap = Minecraft.getMinecraft().getRenderManager().getSkinMap(); RenderPlayer render = skinMap.get("default"); render.addLayer(new ElementItemRender()); render = skinMap.get("slim"); render.addLayer(new ElementItemRender()); } Thank's for help
December 21, 20177 yr First and foremost: You should rename this thread. A TESR (TileEntitySpecialRenderer) is used by TileEntities to render things dynamically. The code given, has no references at all to TESR's, but rather Entity Renderers. Now, are you sure that your OBJ model is actually being rendered? Try placing a few println's around your code. Specifically in your model null-check etc. Also try printing out wether or not your objects are empty (like your skinmap). Then there could be an issue within your actual OBJ model. What program do you use to create your OBJ models? For blender (the most common program it would seem for OBJ models in MInecraft), a default vanilla minecraft block is represented by a cube at x0.5 y-0.5 z0.5 at 0.5 scale. This should give you a sense of scale and translation between Minecraft <-> OBJ rendering program. Be sure to have your Normals correct. If they're inside out, the OBJ will render inside out AKA be invisible unless the camera is inside of the model. Also be sure that your OBJ model has correct UV-mappings. Whilst I believe you can texture the materials directly, I strongly encourage proper UV-mappings. Check how your model looks like in your OBJ rendering program. For Blender, select the "Texture Viewport" at the bottom of the screen next to Object/Edit Mode. Also previously known as eAndPi. "Pi, is there a station coming up where we can board your train of thought?" -Kronnn Published Mods: Underworld Handy links: Vic_'s Forge events Own WIP Tutorials.
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.