{"id":20120875,"url":"https://github.com/nthnn/goblin3d","last_synced_at":"2025-05-06T14:33:28.654Z","repository":{"id":252664489,"uuid":"841059851","full_name":"nthnn/goblin3d","owner":"nthnn","description":"Graphics engine for rendering 3D wireframe on monochromatic displays and TFT LCDs without any dependency required for Arduino platform.","archived":false,"fork":false,"pushed_at":"2024-08-18T16:07:17.000Z","size":29934,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-09T14:06:02.409Z","etag":null,"topics":["3d-engine","3d-graphics","3d-renderer","3d-wireframe","arduino-display","arduino-library"],"latest_commit_sha":null,"homepage":"https://nthnn.github.io/goblin3d/","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nthnn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-11T14:20:41.000Z","updated_at":"2025-02-01T19:15:44.000Z","dependencies_parsed_at":"2024-08-18T17:27:07.074Z","dependency_job_id":null,"html_url":"https://github.com/nthnn/goblin3d","commit_stats":null,"previous_names":["nthnn/goblin3d"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nthnn%2Fgoblin3d","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nthnn%2Fgoblin3d/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nthnn%2Fgoblin3d/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nthnn%2Fgoblin3d/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nthnn","download_url":"https://codeload.github.com/nthnn/goblin3d/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252703478,"owners_count":21790891,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["3d-engine","3d-graphics","3d-renderer","3d-wireframe","arduino-display","arduino-library"],"created_at":"2024-11-13T19:23:42.838Z","updated_at":"2025-05-06T14:33:26.889Z","avatar_url":"https://github.com/nthnn.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n    \u003ch1\u003eGoblin3D\u003c/h1\u003e\n\u003c/div\u003e\n\n![Arduino CI](https://github.com/nthnn/goblin3d/actions/workflows/arduino_ci.yml/badge.svg)\n![Arduino Lint](https://github.com/nthnn/goblin3d/actions/workflows/arduino_lint.yml/badge.svg)\n![SDL2 Port CI](https://github.com/nthnn/goblin3d/actions/workflows/sdl2_ci.yml/badge.svg)\n![Arduino Release](https://img.shields.io/badge/Library%20Manager-v0.0.2-red?logo=Arduino)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/nthnn/goblin3d/blob/main/LICENSE)\n\n**Goblin3D** is a lightweight, dependency-free graphics engine designed for rendering 3D wireframes on monochromatic displays and TFT LCDs using the Arduino platform. Goblin3D is perfect for embedded systems where resources are limited but 3D rendering capabilities are desired.\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://github.com/nthnn/goblin3d/blob/main/assets/goblin3d_demo.gif?raw=true\" width=\"480\" alt=\"Goblin3D demo\"/\u003e\n    \u003cbr/\u003e\n    Goblin3D demo with ESP32 on TFT and OLED.\n\u003c/p\u003e\n\n\u003e [!NOTE]\n\u003e This library is also compatible with desktop environments.\n\n## Features\n\n- **3D Wireframe Rendering**: Render basic 3D shapes as wireframes on displays.\n- **Flexible Display Support**: Compatible with various display types, including OLEDs and TFT LCDs.\n- **No External Dependencies**: Goblin3D is a standalone library that does not require any additional libraries, making it easy to integrate into any Arduino project.\n- **Customizable Objects**: Easily define and manipulate custom 3D objects with your own vertices and edges.\n- **Rotation and Scaling**: Support for rotating and scaling objects in 3D space.\n- **Directly `*.obj` Rendering**: Goblin3D can render `*.obj` files made with Blender directly from SD card.\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/nthnn/goblin3d/main/assets/goblin3d_sdl2.png\" alt=\"Goblin3D port with SDL2\"/\u003e\n    \u003cbr/\u003e\n    Goblin3D port with SDL2\n\u003c/p\u003e\n\n## Installation\n\n### Arduino Library Manager\n\n1. Open the Arduino IDE.\n2. Go to **Sketch** \u003e **Include Library** \u003e **Manage Libraries...**\n3. Search for **Goblin3D**.\n4. Click **Install**.\n\n### Manual Installation\n\n1. Download the latest release from the [Releases](https://github.com/nthnn/goblin3d/releases) page.\n2. Unzip the downloaded file.\n3. Move the `Goblin3D` folder to your Arduino libraries directory (typically `~/Documents/Arduino/libraries/` on Windows and Linux, `~/Documents/Arduino/libraries/` on macOS).\n4. Restart the Arduino IDE.\n\n## Getting Started\n\n### Quick Start\n\nGoblin3D SDL2 port example is availble on Docker to try it out.\n\n```bash\ndocker pull nthnn/goblin3d\ndocker run -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix goblin3d\n```\n\n### Basic Usage\n\nHere’s a simple example of how to use Goblin3D to load an `*.obj` file from SD card to TFT ILI9341 display.\n\n```cpp\n#include \u003cSPI.h\u003e                // Include the SPI library for SPI communication\n#include \u003cSD.h\u003e                 // Include the SD card library for loading files\n#include \u003cTFT_eSPI.h\u003e           // Include the TFT_eSPI for display driver\n#include \u003cgoblin3d.h\u003e           // Include the Goblin3D library for 3D rendering\n\n#define SD_CS      2            // SD card chip select pin\n#define SD_SCK     14           // SD card SPI clock pin\n#define SD_MOSI    13           // SD card SPI MOSI pin\n#define SD_MISO    12           // SD card SPI MISO pin\n\nTFT_eSPI tft = TFT_eSPI(320, 240);   // Initialize the TFT display with 320x240 resolution\nSPIClass sdSpi(HSPI);                // SPI instance for SD card\ngoblin3d_obj_t obj;                  // Declare a 3D object using the Goblin3D structure\n\n/*\n * This function will be passed to Goblin3D's\n * render function to draw edges between 3D\n * points onto the 2D display.\n */\nvoid drawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) {\n    tft.drawLine(x1, y1, x2, y2, TFT_WHITE);  // Draw a white line between the given coordinates\n}\n\nvoid setup() {\n    // Initialize SD card\n    sdSpi.begin(SD_SCK, SD_MISO, SD_MOSI, SD_CS);\n    if(!SD.begin(SD_CS, sdSpi, 80000000)) {\n        Serial.begin(115200);                           // Start serial communication for debugging\n        Serial.println(\"Card mount failed.\");           // Print error message if initialization fails\n\n        while(true); // Halt execution if initialization fails\n    }\n\n    // Load the /monkey.obj file as Goblin3D object\n    if(!goblin3d_parse_obj_file(\"/monkey.obj\", \u0026obj)) {\n        Serial.begin(115200);                           // Start serial communication for debugging\n        Serial.println(\"Failed to initialize object.\"); // Print error message if initialization fails\n\n        while(true); // Halt execution if initialization fails\n    }\n\n    // Set the scaling factor for the 3D object\n    obj.scale_size = 230.0;\n    // Set the initial X and Y offset to center the object on the display\n    obj.x_offset = 160;\n    obj.y_offset = 120;\n\n    // Initialize the TFT display with black background color\n    tft.init();\n    tft.fillScreen(ILI9341_BLACK);\n}\n\nvoid loop() {\n    // Continuously update the rotation angles for a rotating effect\n    obj.x_angle_deg = fmod(obj.x_angle_deg + 1.0, 360.0);  // Increment X rotation\n    obj.y_angle_deg = fmod(obj.y_angle_deg + 1.0, 360.0);  // Increment Y rotation\n    obj.z_angle_deg = fmod(obj.z_angle_deg + 1.0, 360.0);  // Increment Z rotation\n\n    goblin3d_precalculate(\u0026obj);       // Perform rendition pre-calculations\n\n    tft.startWrite();                   // Start the rendition SPI transaction\n    tft.fillScreen(ILI9341_BLACK);      // Clear the display before drawing the new frame\n    goblin3d_render(\u0026obj, \u0026drawLine);  // Render the object on the TFT display\n    tft.endWrite();                     // End the SPI transaction\n\n    delay(10);                          // Sleep after ending the transaction\n}\n```\n\n## Exporting from Blender\n\nFollow these steps to export a 3D scene from Blender in a format compatible with Goblin3D:\n\n1. **Open the Export Menu**\n\n    In Blender, navigate to the top menu bar and select `File \u003e Export \u003e Wavefront (.obj)`. This will allow you to export your 3D scene in the OBJ format, which Goblin3D can read and render as a wireframe.\n\n    \u003cp align=\"center\"\u003e\n        \u003cimg alt=\"Exporting to Blender 1\" src=\"assets/screenshot_1.png\" /\u003e\n    \u003c/p\u003e\n\n2. **Configure the Export Settings**\n\n    Before saving the file, ensure that the `Vertex Groups` option is selected. This will export the vertex information needed for wireframe rendering.\n\n    Optionally, you can check the `Triangulate Faces` option to convert all faces into triangles, which is commonly used in wireframe rendering to ensure consistent results across different models.\n\n    \u003cp align=\"center\"\u003e\n        \u003cimg alt=\"Exporting to Blender 1\" src=\"assets/screenshot_2.png\" /\u003e\n    \u003c/p\u003e\n\n3. **Save the OBJ File**\n\n    When saving, you do not need to include the Material File (*.mtl) since Goblin3D only renders the wireframe, and materials are not required for this purpose. Simply save the OBJ file, and it's ready for use with Goblin3D.\n\n## Use Cases\n\n1. **Low-Power Displays**\n\n    Goblin3D can be used for rendering 3D wireframe graphics on low-power, monochrome displays (e.g., OLEDs, TFTs) in embedded systems, which often lack the resources for full shading or texture mapping.\n\n2. **Wearable Devices**\n\n    It can be integrated into wearable tech with small displays, such as smartwatches, where simple 3D visualizations like fitness progress or notifications might be shown in wireframe.\n\n3. **3D Modeling Previews**\n\n    Designers can use Goblin3D to quickly preview 3D models in a wireframe format, providing a sense of object geometry before moving to a more detailed rendering process.\n\n4. **Retro 3D Games**\n\n    Goblin3D can be used to develop retro-style 3D games on resource-constrained devices, where wireframe graphics give a nostalgic feel while minimizing resource usage.\n\n## Contribution and Feedback\n\nContributions and feedback are all welcome to enhance this library. If you encounter any issues, have suggestions for improvements, or would like to contribute code, please do so.\n\n## License\n\nCopyright 2024 - Nathanne Isip\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnthnn%2Fgoblin3d","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnthnn%2Fgoblin3d","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnthnn%2Fgoblin3d/lists"}