- Notifications
You must be signed in to change notification settings - Fork0
A simple application to visualize 3D .obj files.
License
keelus/3d-viewer
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A simple application to preview 3D models (currently .OBJ supported), where you can move the model around, flip normals, etc. It's implemented in Golang, and usesSDL2 to show the window, handle user's input, and write pixels into the screen buffer.
I made it from scratch to learn 3D rendering concepts, mathematics and algorithms involved to display a 3D textured mesh into the screen.
- Fast 3D .obj file loading.
- Fast and smooth rendering.
- Simple camera system to move and rotate the object around.
- Buttons to change the resolution (to gain performance for more complex objects)
- Support for .obj 3D files and .mtl material files (with PNG and JPEG texture formats).
- In very specific cases where the Z position of the camera is exactly 0, and rotation is default, some triangles might not be displayed correctly. This can be corrected by just moving or rotating the camera by a few pixels.
- May occasionally fail to update the text information of the new loaded mesh due to some strange SDL2_ttf error while rendering the text.
To use and/or compile the application, you will need to haveSDL2 andSDL2_TTF installed correctly in your system.
The project is compatible with Windows, Linux and macOS, when requeriments are installed.
To use it, simply download thelatest release binary file and execute it (unzip and execute on Windows).
To make the downloaded binary executable, run:
chmod +x 3d_viewer-<rest of the file>
In newer versions of macOS, you might need to runxattr -c 3d_viewer-<rest of the filename>
if you get an error message while opening the app.
Then, you can open it running:
./3d_viewer-<rest of the file>
To compile the project, you will need SDL2 and SDL2_TTF properly installed in your system. Also, a C compiler could be needed (such asGCC).If you encounter any issues while compiling, please checkgo-sdl2 compiling guide.
To compile the app, just run:
go mod tidy
go build -o 3d_viewer.exe -ldflags"-s -w -H windowsgui"
Make sure to haveSDL2.dll
andSDL2_ttf.dll
files in the same place of the.exe
.
To compile the app, just run:
go mod tidy
go build -o 3d_viewer -ldflags"-s -w"
The 3D models that are shown in the screenshots are for demonstration purposes only, I don't own the models.
This project is open source under the terms of theMIT License
Made bykeelus ✌️
About
A simple application to visualize 3D .obj files.