mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-27 15:33:18 +00:00
Add renderable API to allow easier rendering of OBJ and other custom models, from Entity and BlockEntity renderers. (#8259)
This is a redesign of a discarded section of my initial model system rewrite, back in 1.14. In order to use it with the OBJ loader, you can use OBJLoader.INSTANCE.loadModel to get the OBJModel, and then call OBJModel#bakeRenderable() to get a SimpleRenderable object to render with. The SimpleRenderable support animation, by providing different transformation matrices for each part in the MultipartTransforms. Additionally, a BakedRenderable helper exists to turn an arbitrary BakedModel into a renderable. After trying to get the B3D loader to work, I decided it wasn't worth the trouble and marked it for removal instead.
This commit is contained in:
1 parent
6c6a4817e7
commit
f704d65d5a
14 files changed
+793
-70
No files matched your search
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2021.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.textures;
|
||||
|
||||
import com.mojang.blaze3d.platform.NativeImage;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.resources.metadata.animation.AnimationMetadataSection;
|
||||
import net.minecraft.client.resources.model.Material;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* A helper that lets you bake quads that won't be used with an atlas.
|
||||
*/
|
||||
public class UnitSprite extends TextureAtlasSprite
|
||||
{
|
||||
public static final UnitSprite INSTANCE = new UnitSprite();
|
||||
public static final ResourceLocation LOCATION = new ResourceLocation("forge", "unit");
|
||||
public static final Function<Material, TextureAtlasSprite> GETTER = (x) -> INSTANCE;
|
||||
|
||||
private UnitSprite()
|
||||
{
|
||||
super(new TextureAtlas(LOCATION),
|
||||
new Info(LOCATION, 1, 1, AnimationMetadataSection.EMPTY),
|
||||
0, 1, 1,
|
||||
0, 0, new NativeImage(1, 1, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getU(double u)
|
||||
{
|
||||
return (float) u / 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getV(double v)
|
||||
{
|
||||
return (float) v / 16;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user