Search in sources :

Example 1 with IMixinTextureAtlasSprite

use of com.almuradev.content.mixin.iface.IMixinTextureAtlasSprite in project Almura by AlmuraDev.

the class OBJBakedModel method createParticleSpriteFor.

private TextureAtlasSprite createParticleSpriteFor(final Face face, final TextureAtlasSprite diffuseSprite) {
    /*
         * 0: (0, 0)       3: (0, 1)
         *
         *
         * 1: (1, 0)       2: (1, 1)
         */
    final TextureAtlasSprite particleSprite = new TextureAtlasSprite(diffuseSprite.getIconName());
    particleSprite.copyFrom(diffuseSprite);
    final VertexTextureCoordinate vt1 = face.getVertices().get(0).getTextureCoordinate().orElse(null);
    final VertexTextureCoordinate vt3 = face.getVertices().get(2).getTextureCoordinate().orElse(null);
    final float u1;
    final float u2;
    final float v1;
    final float v2;
    if (vt1 != null) {
        u1 = particleSprite.getInterpolatedU(vt1.getU() * 16f);
        v1 = particleSprite.getInterpolatedV((1 - vt1.getV()) * 16f);
    } else {
        u1 = 0f;
        v1 = 0f;
    }
    if (vt3 != null) {
        u2 = particleSprite.getInterpolatedU(vt3.getU() * 16f);
        v2 = particleSprite.getInterpolatedV((1 - vt3.getV()) * 16f);
    } else {
        u2 = 1f;
        v2 = 1f;
    }
    final IMixinTextureAtlasSprite mixinSprite = (IMixinTextureAtlasSprite) particleSprite;
    mixinSprite.setMinU(u1);
    mixinSprite.setMaxU(u2);
    mixinSprite.setMinV(v1);
    mixinSprite.setMaxV(v2);
    return particleSprite;
}
Also used : IMixinTextureAtlasSprite(com.almuradev.content.mixin.iface.IMixinTextureAtlasSprite) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) VertexTextureCoordinate(com.almuradev.content.model.obj.geometry.VertexTextureCoordinate) IMixinTextureAtlasSprite(com.almuradev.content.mixin.iface.IMixinTextureAtlasSprite)

Aggregations

IMixinTextureAtlasSprite (com.almuradev.content.mixin.iface.IMixinTextureAtlasSprite)1 VertexTextureCoordinate (com.almuradev.content.model.obj.geometry.VertexTextureCoordinate)1 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)1