codechicken.lib.render.CCModelLibrary Java Examples

The following examples show how to use codechicken.lib.render.CCModelLibrary. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RenderTracker.java    From WirelessRedstone with MIT License 6 votes vote down vote up
public void renderTracker(int freq)
{
    GL11.glDisable(GL11.GL_LIGHTING);

    TextureUtils.bindAtlas(0);
    CCRenderState.reset();
    CCRenderState.startDrawing(7);
    CCRenderState.setColour(0xFFFFFFFF);
    model.render(new IconTransformation(Blocks.obsidian.getIcon(0, 0)));
    CCRenderState.draw();
    
    Matrix4 pearlMat = CCModelLibrary.getRenderMatrix(
        new Vector3(0, 0.44+RedstoneEther.getSineWave(ClientUtils.getRenderTime(), 7)*0.02, 0),
        new Rotation(RedstoneEther.getRotation(ClientUtils.getRenderTime(), freq), new Vector3(0, 1, 0)),
        0.04);

    CCRenderState.changeTexture("wrcbe_core:textures/hedronmap.png");
    CCRenderState.startDrawing(4);
    CCRenderState.setColour(freq == 0 ? 0xC0C0C0FF : 0xFFFFFFFF);
    CCModelLibrary.icosahedron4.render(pearlMat);
    CCRenderState.draw();
    
    GL11.glEnable(GL11.GL_LIGHTING);
}
 
Example #2
Source File: RenderTileEnderChest.java    From EnderStorage with MIT License 5 votes vote down vote up
public static void renderChest(CCRenderState ccrs, MatrixStack mStack, IRenderTypeBuffer getter, int rotation, double yToCamera, Frequency freq, float lidAngle, int pearlOffset) {
    Matrix4 mat = new Matrix4(mStack);
    if (lidAngle != 0) {//Micro optimization, lid closed, dont render starfield.
        renderEndPortal.render(mat, getter, yToCamera);
    }
    ccrs.reset();
    mStack.push();
    mStack.translate(0, 1.0, 1.0);
    mStack.scale(1.0F, -1.0F, -1.0F);
    mStack.translate(0.5, 0.5, 0.5);
    mStack.rotate(new Quaternion(0, rotation * 90, 0, true));
    mStack.translate(-0.5, -0.5, -0.5);
    model.chestLid.rotateAngleX = lidAngle;
    model.render(mStack, getter.getBuffer(chestType), ccrs.brightness, ccrs.overlay, freq.hasOwner());
    mStack.pop();

    //Buttons
    ccrs.bind(buttonType, getter);
    EnumColour[] colours = freq.toArray();
    for (int i = 0; i < 3; i++) {
        CCModel button = ButtonModelLibrary.button.copy();
        button.apply(BlockEnderChest.buttonT[i]);
        button.apply(new Translation(0.5, 0, 0.5));
        button.apply(new Rotation(lidAngle, 1, 0, 0).at(new Vector3(0, 9D / 16D, 1 / 16D)));
        button.apply(new Rotation((-90 * (rotation)) * MathHelper.torad, Vector3.Y_POS).at(new Vector3(0.5, 0, 0.5)));
        button.render(ccrs, mat, new UVTranslation(0.25 * (colours[i].getWoolMeta() % 4), 0.25 * (colours[i].getWoolMeta() / 4)));
    }
    mat.translate(0.5, 0, 0.5);

    //Pearl
    if (lidAngle != 0) {//Micro optimization, lid closed, dont render pearl.
        double time = ClientUtils.getRenderTime() + pearlOffset;
        Matrix4 pearlMat = RenderUtils.getMatrix(mat.copy(), new Vector3(0, 0.2 + lidAngle * -0.5 + RenderUtils.getPearlBob(time), 0), new Rotation(time / 3, new Vector3(0, 1, 0)), 0.04);
        ccrs.brightness = 15728880;
        ccrs.bind(pearlType, getter);
        CCModelLibrary.icosahedron4.render(ccrs, pearlMat);
    }
    ccrs.reset();
}
 
Example #3
Source File: EnderChestRenderer.java    From EnderStorage with MIT License 5 votes vote down vote up
public static void renderChest(int rotation, int freq, boolean owned, double x, double y, double z, int offset, float lidAngle) {
    TileEntityRendererDispatcher info = TileEntityRendererDispatcher.instance;
    renderEndPortal.render(x, y, z, 0, info.field_147560_j, info.field_147560_j, info.field_147561_k, info.field_147553_e);
    GL11.glColor4f(1, 1, 1, 1);

    CCRenderState.changeTexture("enderstorage:textures/enderchest.png");
    GL11.glPushMatrix();
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    GL11.glColor4f(1, 1, 1, 1);
    GL11.glTranslated(x, y + 1.0, z + 1.0F);
    GL11.glScalef(1.0F, -1F, -1F);
    GL11.glTranslatef(0.5F, 0.5F, 0.5F);
    GL11.glRotatef(rotation * 90, 0.0F, 1.0F, 0.0F);
    GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
    model.chestLid.rotateAngleX = lidAngle;
    model.render(owned);
    GL11.glPopMatrix();

    GL11.glPushMatrix();
    GL11.glTranslated(x, y, z);
    renderButtons(freq, rotation, lidAngle);
    GL11.glPopMatrix();

    double time = ClientUtils.getRenderTime() + offset;
    Matrix4 pearlMat = CCModelLibrary.getRenderMatrix(
            new Vector3(x + 0.5, y + 0.2 + lidAngle * -0.5 + EnderStorageClientProxy.getPearlBob(time), z + 0.5),
            new Rotation(time / 3, new Vector3(0, 1, 0)),
            0.04);

    GL11.glDisable(GL11.GL_LIGHTING);
    CCRenderState.changeTexture("enderstorage:textures/hedronmap.png");
    CCRenderState.startDrawing(4);
    CCModelLibrary.icosahedron4.render(pearlMat);
    CCRenderState.draw();
    GL11.glEnable(GL11.GL_LIGHTING);
}
 
Example #4
Source File: EnderTankRenderer.java    From EnderStorage with MIT License 4 votes vote down vote up
public static void renderTank(int rotation, float valve, int freq, boolean owned, double x, double y, double z, int offset)
{
    TileEntityRendererDispatcher info = TileEntityRendererDispatcher.instance;
    renderEndPortal.render(x, y, z, 0, info.field_147560_j, info.field_147560_j, info.field_147561_k, info.field_147553_e);
    GL11.glColor4f(1, 1, 1, 1);
    
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    GL11.glPushMatrix();
        GL11.glTranslated(x+0.5, y, z+0.5);
        GL11.glRotatef(-90*(rotation+2), 0, 1, 0);
        
        CCRenderState.changeTexture("enderstorage:textures/endertank.png");
        CCRenderState.startDrawing(4);
        tankModel.render();
        CCRenderState.draw();

        CCRenderState.changeTexture("enderstorage:textures/buttons.png");
        CCRenderState.startDrawing(7);
        for(int i = 0; i < 3; i++)
        {
            int colour = EnderStorageManager.getColourFromFreq(freq, i);
            buttons[i].render(new UVTranslation(0.25 * (colour % 4), 0.25 * (colour / 4)));
        }
        CCRenderState.draw();
        
        new Rotation(valve, new Vector3(0, 0, 1)).at(new Vector3(0, 0.4165, 0)).glApply();

        CCRenderState.changeTexture("enderstorage:textures/endertank.png");
        CCRenderState.startDrawing(4);
        valveModel.render(new UVTranslation(0, owned ? 13/64D : 0));
        CCRenderState.draw();
    GL11.glPopMatrix();
        
    double time = ClientUtils.getRenderTime()+offset;
    Matrix4 pearlMat = CCModelLibrary.getRenderMatrix(
        new Vector3(x+0.5, y+0.45+EnderStorageClientProxy.getPearlBob(time)*2, z+0.5),
        new Rotation(time/3, new Vector3(0, 1, 0)),
        0.04);
    
    GL11.glDisable(GL11.GL_LIGHTING);
    CCRenderState.changeTexture("enderstorage:textures/hedronmap.png");
    CCRenderState.startDrawing(4);
    CCModelLibrary.icosahedron4.render(pearlMat);
    CCRenderState.draw();
    GL11.glEnable(GL11.GL_LIGHTING);
}
 
Example #5
Source File: TileChunkLoaderRenderer.java    From ChickenChunks with MIT License 4 votes vote down vote up
@Override
public void renderTileEntityAt(TileEntity tile, double d, double d1, double d2, float f)
{
    CCRenderState.reset();
    CCRenderState.setBrightness(tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord);
    
    double rot = ClientUtils.getRenderTime()*2;
    double height;
    double size;
    double updown = (ClientUtils.getRenderTime()%50) / 25F;
    
    updown = (float) Math.sin(updown*3.141593);
    updown *= 0.2;
    
    TileChunkLoaderBase chunkLoader = (TileChunkLoaderBase)tile;
    if(chunkLoader instanceof TileChunkLoader)
    {
        TileChunkLoader ctile = (TileChunkLoader)chunkLoader;
        rot /= Math.pow(ctile.radius, 0.2);
        height = 0.9;
        size = 0.08;
    }
    else if(chunkLoader instanceof TileSpotLoader)
    {
        height = 0.5;
        size = 0.05;
    }
    else
        return;
    
    RenderInfo renderInfo = chunkLoader.renderInfo;
    double active = (renderInfo.activationCounter)/20D;
    if(chunkLoader.active && renderInfo.activationCounter < 20)
        active += f/20D;
    else if(!chunkLoader.active && renderInfo.activationCounter > 0)
        active -= f/20D;
    
    if(renderInfo.showLasers)
    {            
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glDisable(GL11.GL_FOG);
        drawRays(d, d1, d2, rot, updown, tile.xCoord, tile.yCoord, tile.zCoord, chunkLoader.getChunks());
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_FOG);
    }
    rot = ClientUtils.getRenderTime()*active / 3F;

    Matrix4 pearlMat = CCModelLibrary.getRenderMatrix(
        new Vector3(d+0.5, d1+height+(updown + 0.3)*active, d2+0.5),
        new Rotation(rot, new Vector3(0, 1, 0)),
        size);
    
    GL11.glDisable(GL11.GL_LIGHTING);
    CCRenderState.changeTexture("chickenchunks:textures/hedronmap.png");
    CCRenderState.startDrawing(4);
    CCModelLibrary.icosahedron4.render(pearlMat);
    CCRenderState.draw();
    GL11.glEnable(GL11.GL_LIGHTING);
}