public static Quaternion rotation(float pitch, float yaw, float roll) { final Quaternion qpitch = new Quaternion(pitch, Vector3.RIGHT); final Quaternion qyaw = new Quaternion(yaw, Vector3.UP); final Quaternion qroll = new Quaternion(roll, Vector3.FORWARD); return qyaw.multiply(qpitch).multiply(qroll); }
public void setBlockMaterial(int xx, int yy, int zz, BlockMaterial material, short data) { final Vector3 transformed = transform(xx, yy, zz); position .getWorld() .setBlockMaterial( transformed.getFloorX(), transformed.getFloorY(), transformed.getFloorZ(), material, data, null); if (material instanceof Directional) { final Directional directional = (Directional) material; final Block block = position.getWorld().getBlock(transformed); final BlockFace face = directional.getFacing(block); if (face != BlockFace.BOTTOM && face != BlockFace.TOP) { directional.setFacing( block, BlockFace.fromYaw(face.getDirection().getYaw() + rotation.getYaw())); } } else if (material instanceof Attachable) { final Attachable attachable = (Attachable) material; final Block block = position.getWorld().getBlock(transformed); final BlockFace face = attachable.getAttachedFace(block); if (face != BlockFace.BOTTOM && face != BlockFace.TOP) { attachable.setAttachedFace( block, BlockFace.fromYaw(face.getDirection().getYaw() + rotation.getYaw()), null); } } }
@Override protected void sendPosition(Point p, Quaternion rot) { PlayerPositionLookMessage PPLMsg = new PlayerPositionLookMessage( p.getX(), p.getY() + STANCE, p.getZ(), p.getY(), rot.getYaw(), rot.getPitch(), true, VanillaBlockDataChannelMessage.CHANNEL_ID, getRepositionManager()); session.send(false, PPLMsg); }
/** * Returns the angles about each axis of this quaternion stored in a Vector3 * * <p>vect.X = Rotation about the X axis (Roll) vect.Y = Rotation about the Y axis (Yaw) vect.Z = * Rotation about the Z axis (Pitch) * * @param a * @return */ public Vector3 getAxisAngles() { if (cachedAngle == null) { cachedAngle = Quaternion.getAxisAngles(this); } return cachedAngle; }
public void placeDoor(int xx, int yy, int zz, DoorBlock door, BlockFace facing) { final Block bottom = getBlock(xx, yy, zz); door.create( getBlock(xx, yy, zz), bottom.translate(BlockFace.TOP), BlockFace.fromYaw(facing.getDirection().getYaw() + rotation.getYaw()), false, false); }
@Override protected void sendPosition(Point p, Quaternion rot) { // TODO: Implement Spout Protocol Session session = owner.getSession(); if (p.distanceSquared(entity.getPosition()) >= 16) { EntityTeleportMessage ETMMsg = new EntityTeleportMessage( entity.getId(), (int) p.getX(), (int) p.getY(), (int) p.getZ(), (int) rot.getYaw(), (int) rot.getPitch()); PlayerLookMessage PLMsg = new PlayerLookMessage(rot.getYaw(), rot.getPitch(), true); session.sendAll(false, ETMMsg, PLMsg); } else { PlayerPositionLookMessage PPLMsg = new PlayerPositionLookMessage( p.getX(), p.getY() + STANCE, p.getZ(), STANCE, rot.getYaw(), rot.getPitch(), true); session.send(false, PPLMsg); } }
/** * Creates and returns a new Quaternion that represnets this quaternion rotated by the given Axis * and Angle * * @param angle * @param x axis * @param y axis * @param z axis * @return rotated Quaternion */ public Quaternion rotate(float angle, float x, float y, float z) { return Quaternion.rotate(this, angle, x, y, z); }
/** * Creates and returns a new Quaternion that represnets this quaternion rotated by the given Axis * and Angle * * @param angle * @param axis * @return rotated Quaternion */ public Quaternion rotate(float angle, Vector3 axis) { return Quaternion.rotate(this, angle, axis); }
/** * Multiplies this Quaternion by the other Quaternion * * @param o * @return */ public Quaternion multiply(Quaternion o) { return Quaternion.multiply(this, o); }
/** * Returns this quaternion but length() == 1 * * @return */ public Quaternion normalize() { return Quaternion.normalize(this); }
/** * Returns the length of the quaternion. Note: This uses square root, so is slowish * * @return */ public float length() { return Quaternion.length(this); }
/** * Returns the length squared of the quaternion * * @return */ public float lengthSquared() { return Quaternion.lengthSquared(this); }