Cube3D is a captivating 3D cube simulation built entirely in C, utilizing the Codam 42MinilibX for graphics rendering.
This project showcases advanced graphics programming concepts, including camera orientation, collision detection, and real-time minimap functionality.
Developed for Linux, Cube3D demonstrates the power of C programming and the flexibility of the MinilibX library in creating interactive 3D environments.
- 3D Cube Rendering: Real-time rendering of a 3D cube with smooth rotations and transformations.
- Camera Orientation via Mouse Control: Provides intuitive camera movement by capturing mouse input, allowing users to freely explore the 3D environment.
- Wall Collision Detection: Prevents the camera from passing through the cube's walls, creating a more immersive and realistic experience.
- Minimap with Direction and Impact Point: A dynamic minimap that displays the player’s orientation and the exact point where the camera’s view intersects with the environment.
- Game Icon in Toolbar: A custom game icon appears in the Linux toolbar, enhancing the user interface and overall experience.
To get started with 4Cube3D, follow the steps below:
- A Linux-based system
- GCC compiler
- Clone the repository:
git clone https://github.com/BorisMichaelRandebrock/cube3D.git
cd 42s_Cube3D- Compile the program using the provided Makefile:
makeTo run the program, use:
make runor
./bin/cub3D ./res/level_peninsula.cubyou can also load any other map.cub you create (or have)....
- Move the mouse right or left to change the camera orientation.
- Explore the 3D cube environment by rotating the camera.
- Click the x to exit the program.
W,A,S,Dto move forward, strafe-left, backward, and strafe-right, respectively.QandEto rotate the camera left and right.- Right and Left arrow keys to rotate the camera.
Escto exit the program.
- The minimap in the left top corner of the screen displays the players current situation & orientation.
- It also shows the impact point of your view when it intersects with the environment.
This feature allows for a more immersive experience by enabling smooth camera movement using the mouse. You can explore the 3D environment intuitively by simply moving the mouse right or left, making navigation within the cube seamless and responsive.
The cube environment includes realistic wall collision detection. The camera will stop when it encounters a wall, preventing the user from passing through the cube's surfaces. This adds a layer of realism and enhances the overall user experience.
The minimap is a standout feature that not only shows your current orientation within the 3D space but also displays the exact point where your camera's view intersects with the cube's environment. This is especially useful for navigation and adds depth to the user interaction.
- Rendering: The 3D cube is rendered using basic graphics primitives provided by the Codam 42MinilibX.
- Camera Control: Implemented by capturing mouse movement and translating it into camera orientation changes within the 3D space.
- Collision Detection: Achieved through mathematical checks that determine if the camera's position intersects with the cube's surfaces.
- Minimap: A 2D representation of the 3D environment, updated in real-time to reflect the camera's orientation and view impact points.
This project is a testament to the power and simplicity of the C programming language and the Codam 42MinilibX. Special thanks to the 42 Network for providing an innovative and inspiring learning environment that encourages creative and technical growth.