Search in sources :

Example 1 with Yaw

use of org.terasology.engine.math.Yaw in project Terasology by MovingBlocks.

the class CeilingSupportingHorizontalFamily method populateBlockMaps.

/**
 * Populates the map with all 8 rotations of the block that are possible.
 * <p>
 * These are all four 90 degree rotations about the Y-axis (YAW) for each case where the TOP side is
 * - facing upwards
 * - facing downwards
 *
 * @param blockBuilder The block builder to use to produce blocks
 * @param shape        The shape the block should be made in
 * @param definition   The definition for the family
 * @param uri          The base URI for the block
 */
private void populateBlockMaps(BlockBuilderHelper blockBuilder, BlockShape shape, BlockFamilyDefinition definition, BlockUri uri) {
    for (Rotation rotation : Rotation.horizontalRotations()) {
        Side horizontalSide = rotation.rotate(Side.FRONT);
        ExtendedSide extendedSideTop = ExtendedSide.getExtendedSideFor(Side.TOP, horizontalSide);
        blocks.put(extendedSideTop, transformBlock(blockBuilder, shape, definition, new BlockUri(uri, new Name(extendedSideTop.name())), rotation, extendedSideTop));
        ExtendedSide extendedSideBottom = ExtendedSide.getExtendedSideFor(Side.BOTTOM, horizontalSide);
        Yaw yaw = Rotation.horizontalRotations().get((rotation.getYaw().getIndex() + 2) % 4).getYaw();
        blocks.put(extendedSideBottom, transformBlock(blockBuilder, shape, definition, new BlockUri(uri, new Name(extendedSideBottom.name())), Rotation.rotate(yaw, Pitch.CLOCKWISE_180, Roll.NONE), extendedSideBottom));
    }
}
Also used : Side(org.terasology.engine.math.Side) BlockUri(org.terasology.engine.world.block.BlockUri) Rotation(org.terasology.engine.math.Rotation) Yaw(org.terasology.engine.math.Yaw) Name(org.terasology.gestalt.naming.Name)

Aggregations

Rotation (org.terasology.engine.math.Rotation)1 Side (org.terasology.engine.math.Side)1 Yaw (org.terasology.engine.math.Yaw)1 BlockUri (org.terasology.engine.world.block.BlockUri)1 Name (org.terasology.gestalt.naming.Name)1