https://github.com/cloudofoz/raylib-gizmo
A clean and customizable 3D gizmo tool for raylib. Designed with an Immediate Mode style for simplicity, it requires just a single function call to draw and interact. Supports global, local, and view-based axis orientations. Enables seamless translation, rotation, scaling, or any combination thereof, managed with intuitive bitwise flags.
https://github.com/cloudofoz/raylib-gizmo
3d game-development gizmo graphics raylib tools transforms
Last synced: 12 months ago
JSON representation
A clean and customizable 3D gizmo tool for raylib. Designed with an Immediate Mode style for simplicity, it requires just a single function call to draw and interact. Supports global, local, and view-based axis orientations. Enables seamless translation, rotation, scaling, or any combination thereof, managed with intuitive bitwise flags.
- Host: GitHub
- URL: https://github.com/cloudofoz/raylib-gizmo
- Owner: cloudofoz
- License: zlib
- Created: 2024-12-08T12:17:49.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-08T17:10:58.000Z (about 1 year ago)
- Last Synced: 2024-12-08T18:19:56.632Z (about 1 year ago)
- Topics: 3d, game-development, gizmo, graphics, raylib, tools, transforms
- Language: C
- Homepage:
- Size: 143 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
  
> **Note**: This library is in **beta**. Your feedback and support in enhancing its quality are greatly appreciated!
## Introduction
**raylib-gizmo** is a clean and customizable 3D gizmo tool for raylib. Designed with an **Immediate Mode style** for simplicity, it requires just a single function call to draw and interact.
No dependencies other than raylib: just include `raygizmo.c/.h` in your project, and you're ready to go!
## Table of Contents
- [Core Features](#core-features)
- [Minimal Usage](#minimal-usage)
- [Code Examples](#code-examples)
- [License](#license)
- [Current Limitations](#current-limitations)
- [Credits](#credits)
## Core Features
- **Portable Code:** No dependencies other than raylib.
- **Ease of Use:** Simple and customizable.
- **Flexible Transformations:** Translate, rotate, scale, or any combination of these three together.
- **Orientation Support:** Works with global, local, and view orientations.
- **Immediate-Mode Style:** Just one function call to draw and interact with the gizmo.
- **Camera Independence:** Gizmo size remains consistent regardless of camera movement.
- **raylib Integration:** Leverages raylib's `Transform` structure, eliminating the need for additional data structures.
## Minimal Usage
```c
#include
int main(...) {
Model model;
...
// Initialize a Transform for the gizmo.
// This Transform stores translation, rotation, and scaling values,
// and will be dynamically updated by the gizmo during the program.
Transform gizmoTransform = GizmoIdentity();
while (...) {
...
// Update the model's transform matrix using the gizmo's Transform.
model.transform = GizmoToMatrix(gizmoTransform);
// Draw the model with the updated transformation matrix.
DrawModel(model, Vector3Zero(), 1.0f, WHITE);
// Render a translation + rotation gizmo and handle user input.
// The gizmoTransform will be directly updated by this gizmo.
DrawGizmo3D(GIZMO_TRANSLATE | GIZMO_ROTATE, &gizmoTransform);
...
}
}
```
---
## Code Examples
**[`1) example_01_getting_started.c`](https://github.com/cloudofoz/raylib-gizmo/blob/main/examples/gizmo/example_01_getting_started.c)**
> *Description:* Demonstrates how to integrate and interact with a simple, globally oriented, 3D translation gizmo in a raylib scene.
**[`2) example_02_gizmo_types.c`](https://github.com/cloudofoz/raylib-gizmo/blob/main/examples/gizmo/example_02_gizmo_types.c)**
> *Description:* Demonstrates multiple gizmo modes (translate, rotate, scale, and all combined) with fixed configurations for simplicity.
---
## License
This project is licensed under the **Zlib** License. See the [LICENSE](LICENSE.md) file for details.
---
## Current Limitations
| Operation | Global | Local | View |
|------------|--------|-------|-------|
| Translate | Yes | Yes | Yes |
| Rotate | Yes | Yes | Yes |
| Scale | No | Yes | No |
For now, every gizmo with a scaling component will operate in local axis orientation. This means that an object will always be scaled as if no other transforms are applied.
---
## Credits
Although many gizmos share a similar appearance, this project drew visual inspiration from the Blender 3D editor. Interacting with Blender's gizmo provided key insights into designing my tool.