Skip to content

A project from 42, which is about 3d Visualization of a Wireframe inside a window

Notifications You must be signed in to change notification settings

floktl/WireframeVisualizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wireframe Visualizer- a 42 Project

A Porgram to display wireframe maps!


🌟 About the Project

This project is a 3D wireframe visualizer that demonstrates rendering and manipulating 3D maps, including zooming, shifting functionalities or window resize management.

screenshot Screenshot 2024-07-12 at 14 15 37 Screenshot 2024-07-12 at 14 18 25

It highlights efficient coding practices and custom solutions, providing a solid foundation for exploring computer graphics and 3D visualization.

🏃 Getting Started

Clone the project

  git clone https://github.com/floktl/WireframeVisualizer

Go to the project directory and compile

  cd WireframeVisualizer && make

running the executable with a map (choose map from test_map directory)

  ./fdf 42.fdf

🌟 Usage

You can zoom the map with the scroll wheel Or shift the map with left mouse button clicked

Press I for the full manual

fdf_mapzoom fdf_mapshift

🌟 Code details

Here are some examples that showcase why the code in this project is safe and easy to read:

Safe and Clean Memory Management

All dynamically allocated memory is properly freed to avoid memory leaks.

int32_t	***free_map_data(int32_t ***map, char **collumn, int row)
{
	map[row] = NULL;
	free_two_dimensional_array(collumn);
	free_map(map);
	return (NULL);
}

Clear and Descriptive Function Names

Function names are descriptive, making it easy to understand what each function does.

void	remove_manual_from_window(t_window *window);
void	set_map_to_middle(t_window *window);
void	print_manual(t_window *window);

Robust Error Handling

The code includes checks to handle errors gracefully.

//	function to assign the coordinate data from the map into 3-dimensional array
int	assign_map_values(int32_t ***map_x_axis, char **collumn, int line)
{
	char	*color;
	int		x;

	x = 0;
	while (collumn[x] != NULL)
	{
		(*map_x_axis)[x] = malloc(2 * sizeof(int));
		if (!(*map_x_axis)[x])
			return (EXIT_FAILURE); // returns an Error if there is a mallocation error

Custom functions

To prove my mathematical skills, i didn't us the math.h library, so i created my own math functions

for example a sqrt() replacement-function:

//	replace function for square root, why not, Math is fun!
//	Newton-Raphson Method
double	ft_sqrt(double a)
{
	double	x;
	double	next;

	x = a;
	while (1)
	{
		next = 0.5 * (x + a / x);
		if ((next - x) * (next - x) < EPSILON * EPSILON)
			break ;
		x = next;
	}
	return (x);
}

🤝 Contact

Florian Keitel - https://www.linkedin.com/in/fkeitel/ - [email protected]

Project Link: https://github.com/floktl/WireframeVisualizer)]

💎 Acknowledgements

About

A project from 42, which is about 3d Visualization of a Wireframe inside a window

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published