Search in sources :

Example 6 with CCModel

use of codechicken.lib.render.CCModel in project GregTech by GregTechCE.

the class StonePileModelGenerator method generatePebblePileModel.

public static CCModel generatePebblePileModel(Random random) {
    List<IndexedCuboid6> cuboid6s = generateCuboidList(random);
    CCModel ccModel = CCModel.quadModel(cuboid6s.size() * 24);
    for (int i = 0; i < cuboid6s.size(); i++) {
        IndexedCuboid6 cuboid6 = cuboid6s.get(i);
        ccModel.generateBlock(i * 24, cuboid6);
        int b = (int) cuboid6.data;
        int[] colours = ccModel.getOrAllocate(ColourAttribute.attributeKey);
        int color = (b & 0xFF) << 24 | (b & 0xFF) << 16 | (b & 0xFF) << 8 | (0xFF);
        Arrays.fill(colours, i * 24, i * 24 + 24, color);
    }
    return ccModel.computeNormals();
}
Also used : IndexedCuboid6(codechicken.lib.raytracer.IndexedCuboid6) CCModel(codechicken.lib.render.CCModel)

Example 7 with CCModel

use of codechicken.lib.render.CCModel in project GregTech by GregTechCE.

the class ShapeModelGenerator method generateModel.

public static CCModel generateModel(int angles, double height, double radius, double segmentHeight) {
    int amountOfSegments = (int) Math.ceil(height / segmentHeight);
    CCModel initialModel = CCModel.quadModel(angles * 4 * amountOfSegments);
    double radiansPerAngle = (Math.PI * 2) / (angles * 1.0);
    for (int i = 0; i < angles; i++) {
        Vector3 first = generatePoint(radiansPerAngle, i, radius);
        Vector3 second = generatePoint(radiansPerAngle, i + 1, radius);
        Vector3 firstTop = first.copy().add(0.0, segmentHeight, 0.0);
        Vector3 secondTop = second.copy().add(0.0, segmentHeight, 0.0);
        double width = first.copy().subtract(second).mag();
        double heightLeft = height;
        for (int j = 0; j < amountOfSegments; j++) {
            double actualHeight = firstTop.y - first.y;
            double textureHeight = 1.0 * (actualHeight / segmentHeight);
            double textureWidth = (textureHeight / actualHeight) * width;
            int offset = i * amountOfSegments * 4 + j * 4;
            initialModel.verts[offset] = new Vertex5(first.copy(), 0.0, 0.0);
            initialModel.verts[offset + 1] = new Vertex5(firstTop.copy(), 0.0, textureHeight);
            initialModel.verts[offset + 2] = new Vertex5(secondTop.copy(), textureWidth, textureHeight);
            initialModel.verts[offset + 3] = new Vertex5(second.copy(), textureWidth, 0.0);
            heightLeft -= actualHeight;
            double nextSegmentHeight = Math.min(segmentHeight, heightLeft);
            first.add(0.0, actualHeight, 0.0);
            second.add(0.0, actualHeight, 0.0);
            firstTop.y = first.y + nextSegmentHeight;
            secondTop.y = second.y + nextSegmentHeight;
        }
    }
    return initialModel.computeNormals();
}
Also used : CCModel(codechicken.lib.render.CCModel)

Example 8 with CCModel

use of codechicken.lib.render.CCModel in project GregTech by GregTechCE.

the class ShapeModelGenerator method generateFullBlockVariants.

public static CCModel[] generateFullBlockVariants(CCModel originalModel) {
    CCModel[] result = new CCModel[3];
    for (int i = 0; i < 3; i++) {
        Transformation rotation = Rotation.sideRotations[i * 2].at(Vector3.center);
        CCModel rotatedModel = originalModel.copy().apply(rotation);
        result[i] = rotatedModel;
    }
    return result;
}
Also used : CCModel(codechicken.lib.render.CCModel)

Example 9 with CCModel

use of codechicken.lib.render.CCModel in project GregTech by GregTechCE.

the class StoneRenderer method getActualModel.

private static CCModel getActualModel(IBlockAccess world, BlockPos pos) {
    TileEntitySurfaceRock tileEntity = BlockSurfaceRockNew.getTileEntity(world, pos);
    if (tileEntity != null) {
        if (tileEntity.cachedModel == null) {
            Random random = new Random(MathHelper.getPositionRandom(pos));
            tileEntity.cachedModel = generateModel(random);
        }
        return (CCModel) tileEntity.cachedModel;
    }
    return placeholderModels[0];
}
Also used : Random(java.util.Random) TileEntitySurfaceRock(gregtech.common.blocks.surfacerock.TileEntitySurfaceRock) CCModel(codechicken.lib.render.CCModel)

Aggregations

CCModel (codechicken.lib.render.CCModel)9 ColourMultiplier (codechicken.lib.render.pipeline.ColourMultiplier)2 IVertexOperation (codechicken.lib.render.pipeline.IVertexOperation)2 IconTransformation (codechicken.lib.vec.uv.IconTransformation)2 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)2 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)2 EnumFacing (net.minecraft.util.EnumFacing)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 IndexedCuboid6 (codechicken.lib.raytracer.IndexedCuboid6)1 CCRenderState (codechicken.lib.render.CCRenderState)1 Cuboid6 (codechicken.lib.vec.Cuboid6)1 Matrix4 (codechicken.lib.vec.Matrix4)1 TransformationList (codechicken.lib.vec.TransformationList)1 Material (gregtech.api.unification.material.type.Material)1 BlockSurfaceRock (gregtech.common.blocks.surfacerock.BlockSurfaceRock)1 TileEntitySurfaceRock (gregtech.common.blocks.surfacerock.TileEntitySurfaceRock)1 FluidPipeType (gregtech.common.pipelike.fluidpipe.FluidPipeType)1 InventoryPipeType (gregtech.common.pipelike.inventory.InventoryPipeType)1 Random (java.util.Random)1