GithubHelp home page GithubHelp logo

keelus / 3d-viewer Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 1.54 MB

A simple application to visualize 3D .obj files.

License: MIT License

Go 100.00%
3d-graphics 3d-models 3d-viewer go-app golang golang-app obj-format obj-loader sdl2

3d-viewer's Introduction

3d-viewer

MIT License stars

ℹ️ Description

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 uses SDL2 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.

✨ Features

  • 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).

🐛 Known errors

  • 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.

📸 Screenshots


🔨 Requirements

To use and/or compile the application, you will need to have SDL2 and SDL2_TTF installed correctly in your system.

⬇️ Install & run it

The project is compatible with Windows, Linux and macOS, when requeriments are installed.

To use it, simply download the latest release binary file and execute it (unzip and execute on Windows).

🐧 Linux & macOS

To make the downloaded binary executable, run:

chmod +x 3d_viewer-<rest of the file>

In newer versions of macOS, you might need to run xattr -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>

Compile

To compile the project, you will need SDL2 and SDL2_TTF properly installed in your system. Also, a C compiler could be needed (such as GCC). If you encounter any issues while compiling, please check go-sdl2 compiling guide.

🪟 Windows

To compile the app, just run:

go mod tidy
go build -o 3d_viewer.exe -ldflags "-s -w -H windowsgui"

Make sure to have SDL2.dll and SDL2_ttf.dll files in the same place of the .exe.

🐧 Linux or macOS

To compile the app, just run:

go mod tidy
go build -o 3d_viewer -ldflags "-s -w"

⚠️ Disclaimer

The 3D models that are shown in the screenshots are for demonstration purposes only, I don't own the models.

⚖️ License

This project is open source under the terms of the MIT License


Made by keelus ✌️

](https://github.com/libsdl-org/SDL_ttf/releases/latest)https://github.com/libsdl-org/SDL_ttf/releases/latest

3d-viewer's People

Contributors

keelus avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.