Package com.rvandoosselaer.blocks
Interface Shape
- All Known Implementing Classes:
Cube,Cylinder,Pole,Pyramid,RoundedCube,Slab,Square,SquareCuboid,Stairs,StairsInnerCorner,StairsOuterCorner,Wedge
public interface Shape
The interface describing the shape of a
Block element. The add(Vec3i, Chunk, ChunkMesh) method is
called for each block in the chunk when the mesh is constructed using the ChunkMeshGenerator.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final Direction[]static final com.jme3.math.Quaternionstatic final com.jme3.math.Quaternionstatic final com.jme3.math.Quaternionstatic final com.jme3.math.Quaternionstatic final com.jme3.math.Quaternionstatic final com.jme3.math.Quaternionstatic final com.jme3.math.Quaternionstatic final com.jme3.math.Quaternionstatic final com.jme3.math.Quaternionstatic final com.jme3.math.Quaternion -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the shape at the location in the chunk to the chunk mesh.static com.jme3.math.Vector3fcreateVertex(com.jme3.math.Vector3f vertex, com.simsilica.mathd.Vec3i blockLocation, float blockScale) A helper method that offsets a vertex based on the location of the block in the chunk and the block scale.static DirectiongetFaceDirection(Direction faceDirection, Direction shapeDirection) Calculates the new direction of a face, based on the rotation of the shape.static com.jme3.math.QuaterniongetRotationFromDirection(Direction direction) A helper method to calculate the rotation of the shape from the given direction.static DirectiongetYawFaceDirection(Direction faceDirection, Direction shapeDirection) Calculates the new yaw direction (rotation around the y-axis) of a face, based on the yaw rotation of the shape.static com.jme3.math.QuaterniongetYawFromDirection(Direction direction) A helper method to calculate the yaw rotation (rotation around the y-axis) of the shape for the given direction.
-
Field Details
-
ROTATION_DOWN
static final com.jme3.math.Quaternion ROTATION_DOWN -
ROTATION_EAST
static final com.jme3.math.Quaternion ROTATION_EAST -
ROTATION_WEST
static final com.jme3.math.Quaternion ROTATION_WEST -
ROTATION_NORTH
static final com.jme3.math.Quaternion ROTATION_NORTH -
ROTATION_SOUTH
static final com.jme3.math.Quaternion ROTATION_SOUTH -
ROTATION_UP
static final com.jme3.math.Quaternion ROTATION_UP -
YAW_NORTH
static final com.jme3.math.Quaternion YAW_NORTH -
YAW_EAST
static final com.jme3.math.Quaternion YAW_EAST -
YAW_WEST
static final com.jme3.math.Quaternion YAW_WEST -
YAW_UP
static final com.jme3.math.Quaternion YAW_UP -
DIRECTIONS_SIZE
static final int DIRECTIONS_SIZE -
FACES_DIR
-
-
Method Details
-
add
Adds the shape at the location in the chunk to the chunk mesh.- Parameters:
location- of the shape in the chunkchunk- of the shapechunkMesh- to add the shape to
-
createVertex
static com.jme3.math.Vector3f createVertex(com.jme3.math.Vector3f vertex, com.simsilica.mathd.Vec3i blockLocation, float blockScale) A helper method that offsets a vertex based on the location of the block in the chunk and the block scale.- Parameters:
vertex-blockLocation-blockScale-- Returns:
- the same vertex with an offset
-
getRotationFromDirection
A helper method to calculate the rotation of the shape from the given direction. Depending on the direction, the rotation is done around a different axis. This has the effect of 'pushing' a shape over to the direction. This should be used for shapes that don't have a fixed upward position. The default direction is UP. All rotation calculations are relative to the UP direction.- Parameters:
direction- the shape is facing- Returns:
- the rotation to face the direction
-
getYawFromDirection
A helper method to calculate the yaw rotation (rotation around the y-axis) of the shape for the given direction. This should be used for shapes that have a fixed upwards position. The default direction is SOUTH. All rotation calculations are relative to the SOUTH direction.- Parameters:
direction- the shape is facing- Returns:
- the rotation to face the direction
-
getFaceDirection
Calculates the new direction of a face, based on the rotation of the shape. eg. The north face of a shape that is rotated, is not facing north anymore.- Parameters:
faceDirection- the original direction of the faceshapeDirection- the direction of the shape- Returns:
- the new direction of the face based on the direction of the shape
-
getYawFaceDirection
Calculates the new yaw direction (rotation around the y-axis) of a face, based on the yaw rotation of the shape. This should be used for shapes that have a fixed upwards position.- Parameters:
faceDirection- the original direction of the faceshapeDirection- the direction of the shape- Returns:
- the new direction of the face based on the direction of the shape
-