VoxelEngine
Below is a list of each module in VoxelEngine, along with a brief description of its purpose and usage.
EngineCore
Main engine controller. Handles game loop, window management, inputs and resource cleanup.
- Package:
-
com.bitwave.VoxelGameEngine.core
-
- Usage:
- Construct with a
Gameimplementation. - Call
run()to start the engine.
- Construct with a
- Methods:
run()- Initializes engine, enters main loop.stop()- Signals the engine to exit main loop.- Private helpers:
init(),loop(),cleanup()
Game (Interface)
Defines the contract for plugging custom game logic.
- Package:
-
com.bitwave.VoxelGameEngine.core
-
- Methods:
init()- Initialize game state.update(float deltaTime)- Update game logic.render()- Render the game scene.cleanup()- Cleanup resources.resize(int width, int height)- Handle window resize events.
CameraController
Manages user input for moving and rotating the camera.
- Package:
-
com.bitwave.VoxelGameEngine.core
-
- Usage:
- Construct with a
Cameraobject. - Call
update(dt, window)every frame to process input and update the camera.
- Construct with a
- Methods:
update(float dt, long window)- Handles keyboard and mouse input to update camera position, rotation and mode.- Private Methods:
key,switchModeandresetCamera.
Input
Static utility for keyboard and mouse input, using GLFW.
- Package:
-
com.bitwave.VoxelGameEngine.input
-
- Methods:
init()- Initializes input settings.poll()- Polls GLFW events (should be used in every frame)isKeyPressed(int key)- Returnstrueif specified key is pressed.isMouseButtonPressed(int button)- Returnstrueif specified mouse button is pressed.
Camera
Represents a 3D camera with multiple operation modes.
- Package:
-
com.bitwave.VoxelGameEngine.render
-
- Properties:
CameraMode- Enum (FREE_FLY, ORBIT, ISOMETRIC, TOP_DOWN)position,target,yaw,pitch,distance,fov,orthoZoom
- Methods:
setMode(CameraMode mode),getMode()move(Vector3f delta)- Moves camera and target together.setPosition(Vector3f pos),setTarget(Vector3f target)updateProjection(),updateView()setYaw(float),setPitch(float),setDistance(float),setOrthoZoom(float)- Getters:
getProjectionMatrix(),getViewMatrix(),getPosition(),getTarget()
Mesh
Manages OpenGL mesh resources (VAO, VBO, EBO). Encapsulates mesh creation, uploading, rendering and cleanup.
- Package:
-
com.bitwave.VoxelGameEngine.render
-
- Methods:
Mesh(float[] vertices, int[] indices)- Constructor, creates and uploads mesh.upload(float[] verticies, int[] indices)- Uploads vertex/index data to GPU.render()- Renders mesh.cleanup()- Releases OpenGL resources.
Renderer
Manages OpenGL rendering state and per-frame clearing.
- Package:
-
com.bitwave.VoxelGameEngine.render
-
- Methods:
init()- Sets up OpenGL and enables depth test.clear()- Clears color and depth buffers.
ShaderProgram
Manages OpenGL shader programs. Handles loading, compiling, linknig and setting uniforms.
- Package:
-
com.bitwave.VoxelGameEngine.render
-
- Methods:
shaderProgram(String vertexPath, String fragmentPath)- Loads and builds shaders.bind(),unbind()- Activates/deactivates shader program.setUniform(String name, ...)- Sets uniform values.cleanup()- Deletes shader program.getId()- Returns OpenGL program ID.
Window
Static class for managing game window via GLFW.
- Package:
-
com.bitwave.VoxelGameEngine.window
-
- Methods:
create(int width, int height, String title)- Creates the window.update()- Swaps buffers and polls events.clear()- Cleans the screen.shouldClose()- Returnstrueif the window should close.destroy()- Cleans up the window and terminates GLFW.getID()- Returns the window handle.
BlockType (Enum)
Enumerates block types and properties.
- Package:
-
com.bitwave.VoxelGameEngine.world
-
- Values:
AIRID = 0, isSolid = false, isOpaque = falseSOLIDID = 1, isSolid = true, isOpaque = true
- Methods:
fromId(int id)- Returns theBlockTypefor a given ID.
Chunk
Represents a 16x16x16 section of blocks in the world.
- Package:
-
com.bitwave.VoxelGameEngine.world
-
- Fields:
BlockType[][][] blocks- Block data storage.ChunkMesh chunkMesh- Mesh for rendering this chunk.int chunkX, chunkZ- World coordinates for this chunk.
- Methods:
getBlock(int x, int y, int z),setBlock(int x, int y, int z)- Block access.getWorldX(),getWorldZ- Returns chunk world coordinates.getChunkMesh()- Getter for chunk mesh.
ChunkMesh
Generates and manages the mesh representation of a Chunk for rendering.
- Package:
-
com.bitwave.VoxelGameEngine.world
-
- Methods:
ChunkMesh(Chunk chunk)- Builds mesh from the chunk.getMesh()- Returns the mesh object.rebuild(Chunk chunk)- Regenerates the mesh data.cleanup()- Releases mesh resources.
- Inner Enum:
Direction- 3D directions (NORTH, SOUTH, EAST, WEST, UP, DOWN) with Normal vectors.
CubeFace
Utility for generating the vertex data for each face of a cube, used by chunk meshing.
- Package:
-
com.bitwave.VoxelGameEngine.world
-
- Methods:
getFace(ChunkMesh.Direction dir, float x, float y, float z)- Returns the 4 vertices of a cube face in a given direction