/* * This file is part of Applied Energistics 2. * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. * * Applied Energistics 2 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, either version 3 of the License, or * (at your option) any later version. * * Applied Energistics 2 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 Applied Energistics 2. If not, see . */ package appeng.client.render.model; import java.util.EnumMap; import java.util.List; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.Vec3d; // TODO: Investigate use of CubeBuilder instead final class RenderHelper { private static EnumMap> cornersForFacing = generateCornersForFacings(); private RenderHelper() { } static List getFaceCorners( EnumFacing side ) { return cornersForFacing.get( side ); } private static EnumMap> generateCornersForFacings() { EnumMap> result = new EnumMap<>( EnumFacing.class ); for( EnumFacing facing : EnumFacing.values() ) { List corners; float offset = ( facing.getAxisDirection() == EnumFacing.AxisDirection.NEGATIVE ) ? 0 : 1; switch( facing.getAxis() ) { default: case X: corners = Lists.newArrayList( new Vec3d( offset, 1, 1 ), new Vec3d( offset, 0, 1 ), new Vec3d( offset, 0, 0 ), new Vec3d( offset, 1, 0 ) ); break; case Y: corners = Lists.newArrayList( new Vec3d( 1, offset, 1 ), new Vec3d( 1, offset, 0 ), new Vec3d( 0, offset, 0 ), new Vec3d( 0, offset, 1 ) ); break; case Z: corners = Lists.newArrayList( new Vec3d( 0, 1, offset ), new Vec3d( 0, 0, offset ), new Vec3d( 1, 0, offset ), new Vec3d( 1, 1, offset ) ); break; } if( facing.getAxisDirection() == EnumFacing.AxisDirection.NEGATIVE ) { corners = Lists.reverse( corners ); } result.put( facing, ImmutableList.copyOf( corners ) ); } return result; } private static Vec3d adjust( Vec3d vec, EnumFacing.Axis axis, double delta ) { switch( axis ) { default: case X: return new Vec3d( vec.xCoord + delta, vec.yCoord, vec.zCoord ); case Y: return new Vec3d( vec.xCoord, vec.yCoord + delta, vec.zCoord ); case Z: return new Vec3d( vec.xCoord, vec.yCoord, vec.zCoord + delta ); } } }