use of org.terasology.engine.math.Rotation in project Terasology by MovingBlocks.
the class MultiConnectFamily method registerBlock.
/**
* @param root The root block URI of the family
* @param definition The definition of the block family as passed down from the engine
* @param blockBuilder The block builder to make the blocks in the family
* @param sides A byte representing the sides which should be connected for this block
* @param rotations All of the ways the block should be rotated
* @return All of the rotations possible for the block with the given sides
*/
public Set<Block> registerBlock(BlockUri root, BlockFamilyDefinition definition, final BlockBuilderHelper blockBuilder, byte sides, Iterable<Rotation> rotations) {
Set<Block> result = Sets.newLinkedHashSet();
for (Rotation rotation : rotations) {
byte sideBits = 0;
for (Side side : SideBitFlag.getSides(sides)) {
sideBits |= SideBitFlag.getSide(rotation.rotate(side));
}
BlockUri uri = new BlockUri(root, new Name(String.valueOf(sideBits)));
Block block = blockBuilder.constructTransformedBlock(definition, rotation, uri, this);
block.setUri(uri);
blocks.put(sideBits, block);
result.add(block);
}
return result;
}
use of org.terasology.engine.math.Rotation in project Terasology by MovingBlocks.
the class RotationTest method testRotateSideYaw.
@Test
public void testRotateSideYaw() {
Rotation rotation = Rotation.rotate(Yaw.CLOCKWISE_90);
Quaternionfc rot = rotation.orientation();
Vector3f dir = rot.transform(Side.FRONT.toDirection().asVector3f(), new Vector3f());
assertEquals(Direction.inDirection(dir).toSide(), rotation.rotate(Side.FRONT));
assertEquals(Side.LEFT, Rotation.rotate(Yaw.CLOCKWISE_90).rotate(Side.FRONT));
assertEquals(Side.TOP, Rotation.rotate(Yaw.CLOCKWISE_90).rotate(Side.TOP));
}
use of org.terasology.engine.math.Rotation in project Terasology by MovingBlocks.
the class RotationTest method testRotateMixed.
@Test
public void testRotateMixed() {
Rotation rotation = Rotation.rotate(Yaw.CLOCKWISE_180, Pitch.CLOCKWISE_90, Roll.CLOCKWISE_90);
Quaternionfc rot = rotation.orientation();
Vector3f dir = rot.transform(Side.FRONT.toDirection().asVector3f(), new Vector3f());
assertEquals(Direction.inDirection(dir).toSide(), rotation.rotate(Side.FRONT));
}
use of org.terasology.engine.math.Rotation in project Terasology by MovingBlocks.
the class RotationTest method testRotateSideRoll.
@Test
public void testRotateSideRoll() {
Rotation rotation = Rotation.rotate(Roll.CLOCKWISE_90);
Quaternionfc rot = rotation.orientation();
Vector3f dir = rot.transform(Side.TOP.toDirection().asVector3f(), new Vector3f());
assertEquals(Direction.inDirection(dir).toSide(), rotation.rotate(Side.TOP));
assertEquals(Side.LEFT, Rotation.rotate(Roll.CLOCKWISE_90).rotate(Side.TOP));
assertEquals(Side.FRONT, Rotation.rotate(Roll.CLOCKWISE_90).rotate(Side.FRONT));
}
use of org.terasology.engine.math.Rotation in project Terasology by MovingBlocks.
the class RotationTest method testRotateSidePitch.
@Test
public void testRotateSidePitch() {
Rotation rotation = Rotation.rotate(Pitch.CLOCKWISE_90);
Quaternionfc rot = rotation.orientation();
Vector3f dir = rot.transform(Side.FRONT.toDirection().asVector3f(), new Vector3f());
assertEquals(Direction.inDirection(dir).toSide(), rotation.rotate(Side.FRONT));
assertEquals(Side.TOP, Rotation.rotate(Pitch.CLOCKWISE_90).rotate(Side.FRONT));
assertEquals(Side.RIGHT, Rotation.rotate(Pitch.CLOCKWISE_90).rotate(Side.RIGHT));
}
Aggregations