Posted March 1, 20178 yr I use Blender to create my OBJ models, and most are then rendered through a TESR(for animation purposes like spinning and stuff) However, Forge doesn't "scale" or "proportion-ize" the UV coordinates up to the size of the texture file, and treats them as coordinates in the texture. Blender(as far as I know) exports "proportional" or "percentage" UV coordinates in relation to the size of the texture between 0 and 1. Is there a way to force or trick forge into treating these as percentages of the texture size, or having blender export as such, or do I have to go in and manually scale them up in the obj file(please no) [shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]
March 1, 20178 yr Well normaly this is how UVs work, UV are float/double from 0 to 1. Are you sure Forge is doing this wrong ? Edited March 1, 20178 yr by MCenderdragon catch(Exception e) { } Yay, Pokémon exception handling, gotta catch 'em all (and then do nothing with 'em).
March 2, 20178 yr Author Well my models are textured using only the top left pixel stretched across the model, so either I was not told you need to tell forge "Hey, UV is a thing" or forge just doesn't do that [shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]
March 2, 20178 yr Author Okay it's not the top left pixel. It is rendering (12,10) across the whole model. It is a 16x16 texture [shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]
March 2, 20178 yr Author If my rendering code is of any use here it is package keegan.labstuff.render; import org.lwjgl.opengl.GL11; import keegan.labstuff.tileentity.*; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.*; import net.minecraft.client.renderer.block.model.*; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.client.model.*; import net.minecraftforge.client.model.obj.OBJLoader; import net.minecraftforge.common.model.TRSRTransformation; import net.minecraftforge.fml.relauncher.*; @SideOnly(Side.CLIENT) public class RenderRocket extends TileEntitySpecialRenderer<TileEntityRocket> { private IModel model; private IBakedModel bakedModel; private IBakedModel getBakedModel(TileEntityRocket te) { // Since we cannot bake in preInit() we do lazy baking of the model as soon as we need it // for rendering if (bakedModel == null) { try { model = OBJLoader.INSTANCE.loadModel(new ResourceLocation("labstuff", "models/" + te.getModel() + ".obj")); } catch (Exception e) { throw new RuntimeException(e); } bakedModel = model.bake(TRSRTransformation.identity(), DefaultVertexFormats.BLOCK, location -> Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location.toString())); } return bakedModel; } @Override public void renderTileEntityAt(TileEntityRocket te, double x, double y, double z, float partialTicks, int destroyStage) { GlStateManager.pushAttrib(); GlStateManager.pushMatrix(); // Translate to the location of our tile entity GlStateManager.translate(x, y, z); GlStateManager.disableRescaleNormal(); // Render the rotating handles if(te.formed) renderHandles(te); GlStateManager.popMatrix(); GlStateManager.popAttrib(); } private void renderHandles(TileEntityRocket te) { GlStateManager.enableLighting(); GlStateManager.pushMatrix(); GlStateManager.translate(.5, 0, .5); GlStateManager.translate(0, -te.rocket.length, 0); long height = (long)te.height; GlStateManager.translate(0, height, 0); //RenderHelper.disableStandardItemLighting(); int bright = 0xF0; int brightX = bright % 65536; int brightY = bright / 65536; OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, brightX, brightY); if (Minecraft.isAmbientOcclusionEnabled()) { GlStateManager.shadeModel(GL11.GL_SMOOTH); } else { GlStateManager.shadeModel(GL11.GL_FLAT); } World world = te.getWorld(); // Translate back to local view coordinates so that we can do the acual rendering here // GlStateManager.translate(-te.getPos().getX(), -te.getPos().getY(), -te.getPos().getZ()); this.bindTexture(new ResourceLocation("labstuff:textures/models/" + te.getModel() + ".png")); Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer().renderModelBrightness(getBakedModel(te), world.getBlockState(te.getPos()), bright, true); //RenderHelper.enableStandardItemLighting(); GlStateManager.popMatrix(); } } [shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]
March 3, 20178 yr Author Split them up? As in each face needs a texture? I've actually made some obj models in blender now that I look, and they are texture properly in Minecraft. They use one texture file(assuming you're saying each face needs one texture file.) How did those export I wonder. Hmmm [shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]
March 3, 20178 yr Author NOTICE: DO NOT USE BIND TEXTURE IT OVERRIDES OBJ MATERIALS AND THUS OBJ on a side not this one particular model like cycles through the textures in that folder, even some not connected to an obj, based on position I guess EDIT: all models loaded through TESR do it, and I tried moving the model I was working with's texture into it's own subfolder but it still flashes between a different texture and missing. Edited March 3, 20178 yr by KeeganDeathman [shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]
March 4, 20178 yr Author I don't want it to repeat lol I want it to stretch the texture over the model based off UV lol [shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]
March 4, 20178 yr Author In blender I baked a UV map into the model, each face is represented fully(if scaled) in the map. This map was used in the creation of the texture. However, instead of each face using the portion of the texture, the UV assigns to that face, they all use one little pixel at UV (.75,.625) stretched across the entire face [shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]
March 5, 20178 yr Author I just thought y'all should know it's something to do with the fact I'm rendering through a TESR, JSON OBJs UV correctly [shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]
March 5, 20178 yr Author Okay all here's how I fixed it. When baking, use this bakedModel = model.bake(TRSRTransformation.identity(), Attributes.DEFAULT_BAKED_FORMAT, textureGetterFlipV); /* Credit to Eternal Energy */ public static Function<ResourceLocation, TextureAtlasSprite> textureGetterFlipV = new Function<ResourceLocation, TextureAtlasSprite>() { @Override public TextureAtlasSprite apply(ResourceLocation location) { return DummyAtlasTextureFlipV.instance; } }; private static class DummyAtlasTextureFlipV extends TextureAtlasSprite { public static DummyAtlasTextureFlipV instance = new DummyAtlasTextureFlipV(); protected DummyAtlasTextureFlipV() { super("dummyFlipV"); } @Override public float getInterpolatedU(double u) { return (float)u / 16; } @Override public float getInterpolatedV(double v) { return (float)v / -16; } } and then DO use bindTexture on your texture file. thanks all. [shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]
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.