GithubHelp home page GithubHelp logo

stefanjohnsen / triangulateobj-app Goto Github PK

View Code? Open in Web Editor NEW
6.0 1.0 0.0 3.5 MB

Triangulation of polygons in obj files

License: GNU General Public License v3.0

CMake 2.97% C++ 94.36% Lua 2.67%
console-application cpp11 obj polygon triangulation wavefront wavefront-obj cpp ear-clipping-algorithm earcut

triangulateobj-app's Introduction

Triangulate obj files

A lightweight console application designed to convert all polygons in a Wavefront OBJ file to triangles. The result is written to a new file with minimal modifications from the original. This console application is built upon the functionalities provided by the header-only file found in the TriangulateOBJ repository. It demonstrates the practical applications and integrations of the TriangulateOBJ.h.


         ---------------------------------------------------
         lego.triangulated.obj 13MB    (+3MB)
         ---------------------------------------------------
         Vertices              :    101.306
         ---------------------------------------------------
         Triangles             :     10.780
         Polygons              :     97.374
         ---------------------------------------------------
         Triangles    (after)  :    213.252     (+202.472)
         Polygons     (after)  :          0
         ---------------------------------------------------
         Execution time        : 371 milliseconds
         ---------------------------------------------------



New Release 1.1.0

In this latest release, we've made significant advancements in our polygon triangulation capabilities. The previous version was primarily reliant on the fan triangulation algorithm, which was efficient for convex polygons but fell short when applied to concave polygons.

To address this, the new update introduces the integration of the "Ear Cut" algorithm, significantly expanding the tool's versatility. This innovative approach ensures accurate triangulation of both convex and concave polygons, marking a substantial improvement in the algorithm's robustness and application range.



Intended Users

  1. Game Developers: Optimized models are key to performance in game development. Triangular polygons are computationally less intensive and are often preferred. With this tool, developers can easily ensure their 3D assets are optimized for real-time rendering.
  2. CAD Professionals: Triangular polygons often provide smoother transitions when transitioning from CAD to visualization tools or VR platforms. This tool offers an easy step in the conversion process.
  3. 3D Printing Enthusiasts: Some 3D printing software may require models to be triangulated for accurate print outputs. Using this application, enthusiasts can ensure their models are ready for printing.
  4. Educators and Students: Those teaching or learning about 3D modelling, graphics, or computer graphics algorithms can benefit from a lightweight tool to quickly triangulate models, helping in understanding the principles of 3D geometry.
  5. Software Developers: For those integrating 3D features in their applications or looking to modify Wavefront OBJ files programmatically, this utility provides a no-fuss, dependency-free method to ensure models are triangulated.
  6. 3D Artists and Designers: Often, designers create complex models with various polygon types, but some rendering or game engines might only accept triangular polygons. This tool aids in preparing models to be compatible with such systems without the need for heavy-duty software.



Binary releases

Download prebuilt from releases



Building in Windows (Visual Studio)

Clone the git repo

git clone https://github.com/StefanJohnsen/TriangulateOBJ-App.git
cd TriangulateOBJ-App
mkdir build
cd build
cmake ..
premake5 vs2022   # replace 'vs2022' with your version of Visual Studio

Open build\TriangulateOBJ.sln file in Visual Studio and build the solution.



Building in Linux and MacOS

Clone the git repo

git clone https://github.com/StefanJohnsen/TriangulateOBJ-App.git
cd TriangulateOBJ
mkdir build
cd build
cmake ..
make
premake5 gmake2
make



Building with CMake Project in Visual Studio

Use Visual Studio's CMake support to build and debug on Windows and Linux

  • Visual Studio 2017 or newer. Ensure you've installed the "Desktop development with C++" workload and enabled "C++ CMake tools for Windows" during installation. Visual Studio has integrated CMake support from version 2017 onwards.
  • (Optional) Windows Subsystem for Linux (WSL) with a Linux distribution (e.g., Ubuntu) for those wishing to build and test in a Linux environment.

Open TriangulateOBJ-App folder in Visual Studio and build the solution. Remember to right-click main.cpp file in Solution Explorer, select Set as Startup Item in the menu and push F5 to build and run.



Running the App from the Command Prompt (Windows)

  1. Copy the compiled or pre-compiled TriangulatedOBJ.exe to the .\TriangulateOBJ-App directory.

  2. Navigate to the .\TriangulateOBJ-App directory using the Command Prompt and run the following command:


TriangulateObj ObjFiles\lego.obj

On successful execution, you'll see an output similar to:

ObjFiles\lego.obj has been triangulated

---------------------------------------------------
lego.triangulated.obj 13MB    (+3MB)
---------------------------------------------------
Vertices              :    101.306
---------------------------------------------------
Triangles             :     10.780
Polygons              :     97.374
---------------------------------------------------
Triangles    (after)  :    213.252     (+202.472)
Polygons     (after)  :          0
---------------------------------------------------
Execution time        : 371 milliseconds
---------------------------------------------------

This command will triangulate the specified OBJ file and provide a summary of the operation.



License

This software is released under the GNU General Public License v3.0 terms.
Details and terms of this license can be found at: https://www.gnu.org/licenses/gpl-3.0.html

For those who require the freedom to operate without the constraints of the GPL,
a commercial license can be obtained by contacting the author at [email protected]

triangulateobj-app's People

Contributors

stefancognite avatar stefanjohnsen avatar

Stargazers

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