rheel.ac.client.renderer.model.ModelSAPC.java Source code

Java tutorial

Introduction

Here is the source code for rheel.ac.client.renderer.model.ModelSAPC.java

Source

/*
 * This class belongs to the source code of Advanced Chemistry.
 * It might depend on other Advanced Chemistry classes to work
 * properly.
 * 
 * For the full license, please see the licence.txt in the source
 * directory.
 */
package rheel.ac.client.renderer.model;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;

import org.lwjgl.opengl.GL11;

/**
 * @author Rheel
 */
@Deprecated
//Unused
public class ModelSAPC {
    private final ModelBase model = new ModelBase() {

    };

    private final ModelRenderer bottom;
    private final ModelRenderer bottomRight1;
    private final ModelRenderer bottomRight2;
    private final ModelRenderer bottomRight3;
    private final ModelRenderer right;
    private final ModelRenderer topRight1;
    private final ModelRenderer topRight2;
    private final ModelRenderer topRight3;
    private final ModelRenderer top;
    private final ModelRenderer topLeft1;
    private final ModelRenderer topleft2;
    private final ModelRenderer topLeft3;
    private final ModelRenderer left;
    private final ModelRenderer bottomLeft1;
    private final ModelRenderer bottomLeft2;
    private final ModelRenderer bottomLeft3;

    private final int renderID;

    public ModelSAPC(int texType) {
        this.model.textureWidth = 256;
        this.model.textureHeight = 256;

        this.bottom = new ModelRenderer(this.model, 64 * texType + 0, 0);
        this.bottom.addBox(-0.5F, 0F, -8F, 1, 8, 16);
        this.bottom.setRotationPoint(0F, 16F, 0F);
        this.bottom.setTextureSize(256, 256);
        this.bottom.mirror = true;
        this.setRotation(this.bottom, 0F, 0F, 0F);
        this.bottomRight1 = new ModelRenderer(this.model, 64 * texType + 34, 0);
        this.bottomRight1.addBox(-0.5F, 0F, -2F, 1, 8, 4);
        this.bottomRight1.setRotationPoint(0F, 12F, -10F);
        this.bottomRight1.setTextureSize(256, 256);
        this.bottomRight1.mirror = true;
        this.setRotation(this.bottomRight1, 0F, 0F, 0F);
        this.bottomRight2 = new ModelRenderer(this.model, 64 * texType + 44, 0);
        this.bottomRight2.addBox(-0.5F, 0F, -2F, 1, 12, 4);
        this.bottomRight2.setRotationPoint(0F, 8F, -14F);
        this.bottomRight2.setTextureSize(256, 256);
        this.bottomRight2.mirror = true;
        this.setRotation(this.bottomRight2, 0F, 0F, 0F);
        this.bottomRight3 = new ModelRenderer(this.model, 64 * texType + 54, 0);
        this.bottomRight3.addBox(-0.5F, 0F, -2F, 1, 8, 4);
        this.bottomRight3.setRotationPoint(0F, 8F, -18F);
        this.bottomRight3.setTextureSize(256, 256);
        this.bottomRight3.mirror = true;
        this.setRotation(this.bottomRight3, 0F, 0F, 0F);
        this.right = new ModelRenderer(this.model, 64 * texType + 0, 24);
        this.right.addBox(-0.5F, 0F, -4F, 1, 16, 8);
        this.right.setRotationPoint(0F, -8F, -20F);
        this.right.setTextureSize(256, 256);
        this.right.mirror = true;
        this.setRotation(this.right, 0F, 0F, 0F);
        this.topRight1 = new ModelRenderer(this.model, 64 * texType + 18, 24);
        this.topRight1.addBox(-0.5F, 0F, -2F, 1, 8, 4);
        this.topRight1.setRotationPoint(0F, -16F, -18F);
        this.topRight1.setTextureSize(256, 256);
        this.topRight1.mirror = true;
        this.setRotation(this.topRight1, 0F, 0F, 0F);
        this.topRight2 = new ModelRenderer(this.model, 64 * texType + 28, 24);
        this.topRight2.addBox(-0.5F, 0F, -2F, 1, 12, 4);
        this.topRight2.setRotationPoint(0F, -20F, -14F);
        this.topRight2.setTextureSize(256, 256);
        this.topRight2.mirror = true;
        this.setRotation(this.topRight2, 0F, 0F, 0F);
        this.topRight3 = new ModelRenderer(this.model, 64 * texType + 38, 24);
        this.topRight3.addBox(-0.5F, 0F, -2F, 1, 8, 4);
        this.topRight3.setRotationPoint(0F, -20F, -10F);
        this.topRight3.setTextureSize(256, 256);
        this.topRight3.mirror = true;
        this.setRotation(this.topRight3, 0F, 0F, 0F);
        this.top = new ModelRenderer(this.model, 64 * texType + 0, 48);
        this.top.addBox(-0.5F, 0F, -8F, 1, 8, 16);
        this.top.setRotationPoint(0F, -24F, 0F);
        this.top.setTextureSize(256, 256);
        this.top.mirror = true;
        this.setRotation(this.top, 0F, 0F, 0F);
        this.topLeft1 = new ModelRenderer(this.model, 64 * texType + 34, 48);
        this.topLeft1.addBox(-0.5F, 0F, -2F, 1, 8, 4);
        this.topLeft1.setRotationPoint(0F, -20F, 10F);
        this.topLeft1.setTextureSize(256, 256);
        this.topLeft1.mirror = true;
        this.setRotation(this.topLeft1, 0F, 0F, 0F);
        this.topleft2 = new ModelRenderer(this.model, 64 * texType + 44, 48);
        this.topleft2.addBox(-0.5F, 0F, -2F, 1, 12, 4);
        this.topleft2.setRotationPoint(0F, -20F, 14F);
        this.topleft2.setTextureSize(256, 256);
        this.topleft2.mirror = true;
        this.setRotation(this.topleft2, 0F, 0F, 0F);
        this.topLeft3 = new ModelRenderer(this.model, 64 * texType + 54, 48);
        this.topLeft3.addBox(-0.5F, -16F, -2F, 1, 8, 4);
        this.topLeft3.setRotationPoint(0F, 0F, 18F);
        this.topLeft3.setTextureSize(256, 256);
        this.topLeft3.mirror = true;
        this.setRotation(this.topLeft3, 0F, 0F, 0F);
        this.left = new ModelRenderer(this.model, 64 * texType + 0, 72);
        this.left.addBox(-0.5F, 0F, -4F, 1, 16, 8);
        this.left.setRotationPoint(0F, -8F, 20F);
        this.left.setTextureSize(256, 256);
        this.left.mirror = true;
        this.setRotation(this.left, 0F, 0F, 0F);
        this.bottomLeft1 = new ModelRenderer(this.model, 64 * texType + 18, 72);
        this.bottomLeft1.addBox(-0.5F, 0F, -2F, 1, 8, 4);
        this.bottomLeft1.setRotationPoint(0F, 8F, 18F);
        this.bottomLeft1.setTextureSize(256, 256);
        this.bottomLeft1.mirror = true;
        this.setRotation(this.bottomLeft1, 0F, 0F, 0F);
        this.bottomLeft2 = new ModelRenderer(this.model, 64 * texType + 28, 72);
        this.bottomLeft2.addBox(-0.5F, 0F, -2F, 1, 12, 4);
        this.bottomLeft2.setRotationPoint(0F, 8F, 14F);
        this.bottomLeft2.setTextureSize(256, 256);
        this.bottomLeft2.mirror = true;
        this.setRotation(this.bottomLeft2, 0F, 0F, 0F);
        this.bottomLeft3 = new ModelRenderer(this.model, 64 * texType + 38, 72);
        this.bottomLeft3.addBox(-0.5F, 0F, -2F, 1, 8, 4);
        this.bottomLeft3.setRotationPoint(0F, 12F, 10F);
        this.bottomLeft3.setTextureSize(256, 256);
        this.bottomLeft3.mirror = true;
        this.setRotation(this.bottomLeft3, 0F, 0F, 0F);

        this.renderID = this.setupRenderer();
    }

    public void render(float f) {
        GL11.glScalef(f, f, f);
        GL11.glCallList(this.renderID);
        GL11.glScalef(1 / f, 1 / f, 1 / f);
    }

    private int setupRenderer() {
        final int id = GL11.glGenLists(1);
        GL11.glNewList(id, GL11.GL_COMPILE);
        this.bottom.render(1);
        this.bottomRight1.render(1);
        this.bottomRight2.render(1);
        this.bottomRight3.render(1);
        this.right.render(1);
        this.topRight1.render(1);
        this.topRight2.render(1);
        this.topRight3.render(1);
        this.top.render(1);
        this.topLeft1.render(1);
        this.topleft2.render(1);
        this.topLeft3.render(1);
        this.left.render(1);
        this.bottomLeft1.render(1);
        this.bottomLeft2.render(1);
        this.bottomLeft3.render(1);
        GL11.glEndList();
        return id;
    }

    private void setRotation(ModelRenderer model, float x, float y, float z) {
        model.rotateAngleX = x;
        model.rotateAngleY = y;
        model.rotateAngleZ = z;
    }
}