Skip to content

Commit

Permalink
Added documentation pages Introduction and Examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriySalnikov committed Dec 21, 2023
1 parent 8580817 commit de997c0
Show file tree
Hide file tree
Showing 52 changed files with 317 additions and 199 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ src/gen/*
addons/debug_draw_3d/libs/~*
addons/debug_draw_3d/csharp/*
clang_rt.asan_*
docs/images/temp/
docs/images/classes/temp/
48 changes: 26 additions & 22 deletions Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,32 @@ PROJECT_LOGO = images/icon_3d_64.png

OUTPUT_DIRECTORY = obj/doxygen

# The INPUT tag is used to specify the files and/or directories that contain
# documented source files. You may enter file names like myfile.cpp or
# directories like /usr/src/myproject. Separate the files or directories with
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched.

INPUT = docs/Introduction.md \
docs/Examples.md \
src/debug_draw_manager.h \
src/2d/debug_draw_2d.h \
src/2d/config_2d.h \
src/2d/graphs.h \
src/2d/stats_2d.h \
src/3d/debug_draw_3d.h \
src/3d/config_scope_3d.h \
src/3d/config_3d.h \
src/3d/stats_3d.h \

# The IMAGE_PATH tag can be used to specify one or more files or directories
# that contain images that are to be included in the documentation (see the
# \image command).

IMAGE_PATH = docs/images \
docs/images/classes \
images

# If the CREATE_SUBDIRS tag is set to YES then doxygen will create up to 4096
# sub-directories (in 2 levels) under the output directory of each output format
# and will distribute the generated files over these directories. Enabling this
Expand Down Expand Up @@ -937,22 +963,6 @@ WARN_LOGFILE =
# Configuration options related to the input files
#---------------------------------------------------------------------------

# The INPUT tag is used to specify the files and/or directories that contain
# documented source files. You may enter file names like myfile.cpp or
# directories like /usr/src/myproject. Separate the files or directories with
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched.

INPUT = ./src/debug_draw_manager.h \
./src/2d/debug_draw_2d.h \
./src/2d/config_2d.h \
./src/2d/graphs.h \
./src/2d/stats_2d.h \
./src/3d/debug_draw_3d.h \
./src/3d/config_scoped_3d.h \
./src/3d/config_3d.h \
./src/3d/stats_3d.h \

# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
# libiconv (or the iconv built into libc) for the transcoding. See the libiconv
Expand Down Expand Up @@ -1097,12 +1107,6 @@ EXAMPLE_PATTERNS = *

EXAMPLE_RECURSIVE = NO

# The IMAGE_PATH tag can be used to specify one or more files or directories
# that contain images that are to be included in the documentation (see the
# \image command).

IMAGE_PATH = docs/images

# The INPUT_FILTER tag can be used to specify a program that doxygen should
# invoke to filter for each input file. Doxygen will invoke the filter program
# by executing (via popen()) the command:
Expand Down
4 changes: 2 additions & 2 deletions addons/debug_draw_3d/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ Based on my previous addon, which was developed [only for C#](https://github.com

Your support adds motivation to develop my public projects.

[<img src="https://static.boosty.to/assets/images/boostyDomainLogo.5Vlxt.svg" alt="Boosty" width=120px/>](https://boosty.to/dmitriysalnikov/donate)
<a href="https://boosty.to/dmitriysalnikov/donate"><img src="https://static.boosty.to/assets/images/boostyDomainLogo.5Vlxt.svg" alt="Boosty" width=120px/></a>

[<img src="https://upload.wikimedia.org/wikipedia/commons/8/8f/QIWI_logo.svg" alt="qiwi" width=90px/>](https://qiwi.com/n/DMITRIYSALNIKOV)
<a href="https://qiwi.com/n/DMITRIYSALNIKOV"><img src="https://upload.wikimedia.org/wikipedia/commons/8/8f/QIWI_logo.svg" alt="qiwi" width=90px/></a>

## Features

Expand Down
70 changes: 70 additions & 0 deletions docs/Examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Examples

More examples can be found in the `examples_dd3d/` folder.

Simple test:

```python
func _process(delta: float) -> void:
var _time = Time.get_ticks_msec() / 1000.0
var box_pos = Vector3(0, sin(_time * 4), 0)
var line_begin = Vector3(-1, sin(_time * 4), 0)
var line_end = Vector3(1, cos(_time * 4), 0)

DebugDraw3D.draw_box(box_pos, Vector3(1, 2, 1), Color(0, 1, 0))
DebugDraw3D.draw_line(line_begin, line_end, Color(1, 1, 0))
DebugDraw2D.set_text("Time", _time)
DebugDraw2D.set_text("Frames drawn", Engine.get_frames_drawn())
DebugDraw2D.set_text("FPS", Engine.get_frames_per_second())
DebugDraw2D.set_text("delta", delta)
```

## CSharp

When you start the engine for the first time, bindings for `C#` will be generated automatically. If this does not happen, you can manually generate them through the `Project - Tools - Debug Draw` menu.

![](/images/project_tools_menu.png)

```csharp
public override void _Process(float delta)
{
var _time = Time.GetTicksMsec() / 1000.0f;
var box_pos = new Vector3(0, Mathf.Sin(_time * 4f), 0);
var line_begin = new Vector3(-1, Mathf.Sin(_time * 4f), 0);
var line_end = new Vector3(1, Mathf.Cos(_time * 4f), 0);

DebugDraw3D.DrawBox(box_pos, new Vector3(1, 2, 1), new Color(0, 1, 0));
DebugDraw3D.DrawLine(line_begin, line_end, new Color(1, 1, 0));
DebugDraw2D.SetText("Time", _time);
DebugDraw2D.SetText("Frames drawn", Engine.GetFramesDrawn());
DebugDraw2D.SetText("FPS", Engine.GetFramesPerSecond());
DebugDraw2D.SetText("delta", delta);
}
```

@warning
C# bindings work using ClassDB, which greatly decreases its performance and it can run slower than GDScript. There is currently no way to fix this.

## Aliases

If you don't want to write `DebugDraw3D`/`DebugDraw2D` every time, so you can use aliases for these singletons.

```python
var _s = Dbg3.new_scope_config().set_thickness(0.025).set_center_brightness(0.7)
Dbg3.draw_grid_xf(%Grid.global_transform, Vector2i(10,10), Color.LIGHT_GRAY)
Dbg2.set_text("Frametime", delta)
```

There is more information in the description of DebugDrawManager.

## Scope configs

When using DebugDraw3D, you will probably want to use the scope configurations DebugDraw3DScopeConfig. With this class you will be able to change the thickness of the geometry, the brightness of the volumetric shapes, the density of the sphere mesh and possibly other parameters in the future.

![](images/classes/LineThickness.webp)

## Project Settings

You can also explore other project settings in `debug_draw_3d/settings`.

![](images/project_settings.png)
65 changes: 65 additions & 0 deletions docs/Introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Introduction

This is an add-on for debug drawing in 3D and for some 2D overlays, which is written in `C++` and can be used with `GDScript` or `C#`.

## Screenshots

`DebugDrawDemoScene.tscn` in editor
![screenshot_2](/images/screenshot_2.png)

`DebugDrawDemoScene.tscn` in play mode
![screenshot_3](/images/screenshot_3.png)

## Features

3D:

* Arrow
* Billboard opaque square
* Box
* Camera Frustum
* Cylinder
* Gizmo
* Grid
* Line
* Line Path
* Line with Arrow
* Points
* Position 3D (3 crossing axes)
* Sphere

2D:

* **[Work in progress]**

Overlay:

* Text (with grouping and coloring)
* FPS Graph
* Custom Graphs

Precompiled for:

* Windows
* Linux
* macOS
* Android
* Web (WebAssembly)

## Download

To download, use the [Godot Asset Library](https://godotengine.org/asset-library/asset/1766) or download the archive from the [GithHub](https://github.com/DmitriySalnikov/godot_debug_draw_3d) page by clicking the button at the top of the repository page: `Code -> Download ZIP`, then unzip it to your project folder. Or use one of the stable versions from the [GitHub Releases](https://github.com/DmitriySalnikov/godot_debug_draw_3d/releases) page (just download one of the `Source Codes` in assets).

* Close editor
* Copy `addons/debug_draw_3d` to your `addons` folder, create it if the folder doesn't exist
* Launch editor

## Support me

Your support adds motivation to develop my public projects.

<a href="https://boosty.to/dmitriysalnikov/donate"><img src="https://static.boosty.to/assets/images/boostyDomainLogo.5Vlxt.svg" alt="Boosty" width=120px/></a>

## Next step

[Examples](Examples.md)
26 changes: 13 additions & 13 deletions docs/image_generator/preview_generator.gd
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func _process(delta):
%AnimationPlayer.advance(delta)

# Default 3D
var _s_def = DebugDraw3D.new_scoped_config().set_thickness(0.05)
var _s_def = DebugDraw3D.new_scope_config().set_thickness(0.05)

# Default 2D
DebugDraw2D.custom_canvas = $Control/PanelContainer
Expand All @@ -270,40 +270,40 @@ func _process(delta):

# Grid
if true:
var _s = DebugDraw3D.new_scoped_config().set_thickness(0.025).set_center_brightness(0.7)
var _s = DebugDraw3D.new_scope_config().set_thickness(0.025).set_center_brightness(0.7)
DebugDraw3D.draw_grid_xf(%Grid.global_transform, Vector2i(10,10), Color.LIGHT_GRAY)

var up_vec = $OriginUpVector.global_position - $OriginUpVector/Up.global_position

match preview_case:
PreviewCase.LineThickness:
var _s = DebugDraw3D.new_scoped_config().set_thickness(anim_value_1)
var _s = DebugDraw3D.new_scope_config().set_thickness(anim_value_1)
DebugDraw3D.draw_line(%OriginLine/A.global_position, %OriginLine/B.global_position, Color.DARK_SLATE_BLUE)
PreviewCase.LineCenterBrightness:
var _s = DebugDraw3D.new_scoped_config().set_center_brightness(anim_value_1).set_thickness(0.2)
var _s = DebugDraw3D.new_scope_config().set_center_brightness(anim_value_1).set_thickness(0.2)
DebugDraw3D.draw_line(%OriginLine/A.global_position, %OriginLine/B.global_position, Color.DARK_SLATE_BLUE)
PreviewCase.LineBevel:
var _s = DebugDraw3D.new_scoped_config().set_center_brightness(0.7).set_thickness(0.2)
var _s = DebugDraw3D.new_scope_config().set_center_brightness(0.7).set_thickness(0.2)
DebugDraw3D.draw_line(%OriginLine/A.global_position, %OriginLine/B.global_position, Color.FIREBRICK)
PreviewCase.SphereDensity:
var _s = DebugDraw3D.new_scoped_config().set_thickness(0.02).set_hd_sphere(anim_value_1 == 1)
var _s = DebugDraw3D.new_scope_config().set_thickness(0.02).set_hd_sphere(anim_value_1 == 1)
DebugDraw3D.draw_sphere_xf(%OriginInstances.global_transform, Color.INDIAN_RED)
PreviewCase.IcoSphere:
var _s = DebugDraw3D.new_scoped_config().set_thickness(0.02)
var _s = DebugDraw3D.new_scope_config().set_thickness(0.02)
DebugDraw3D.draw_sphere_xf(%OriginInstances.global_transform, Color.INDIAN_RED)

PreviewCase.Line:
var _s = DebugDraw3D.new_scoped_config().set_center_brightness(0.7).set_thickness(0.2)
var _s = DebugDraw3D.new_scope_config().set_center_brightness(0.7).set_thickness(0.2)
DebugDraw3D.draw_line(%OriginLine/A.global_position, %OriginLine/B.global_position, Color.FIREBRICK)
PreviewCase.Arrow:
var _s = DebugDraw3D.new_scoped_config().set_center_brightness(0.7).set_thickness(0.05)
var _s = DebugDraw3D.new_scope_config().set_center_brightness(0.7).set_thickness(0.05)
DebugDraw3D.draw_arrow(%OriginInstances/A.global_position, %OriginInstances/B.global_position, Color.FIREBRICK, 0.2)

PreviewCase.DrawSphere:
var _s = DebugDraw3D.new_scoped_config().set_thickness(0.03)
var _s = DebugDraw3D.new_scope_config().set_thickness(0.03)
DebugDraw3D.draw_sphere_xf(%OriginInstances.global_transform.scaled_local(Vector3.ONE * 1.1), Color.INDIAN_RED)
PreviewCase.DrawSphereXf:
var _s = DebugDraw3D.new_scoped_config().set_thickness(0.03)
var _s = DebugDraw3D.new_scope_config().set_thickness(0.03)
DebugDraw3D.draw_sphere_xf(%OriginInstances.global_transform.scaled_local(Vector3(0.8, 1.1, 0.8)))
PreviewCase.DrawCylinder:
DebugDraw3D.draw_cylinder(%OriginInstances.global_transform.scaled_local(Vector3(0.5, 1, 0.5)), Color.LIGHT_SALMON)
Expand Down Expand Up @@ -333,7 +333,7 @@ func _process(delta):
PreviewCase.DrawPointsPath:
DebugDraw3D.draw_point_path(path, DebugDraw3D.POINT_TYPE_SQUARE, 0.15, Color.SLATE_BLUE)
PreviewCase.DrawPointsPathSpheres:
var _s = DebugDraw3D.new_scoped_config().set_thickness(0.015)
var _s = DebugDraw3D.new_scope_config().set_thickness(0.015)
DebugDraw3D.draw_point_path(path, DebugDraw3D.POINT_TYPE_SPHERE, 0.15, Color.SLATE_BLUE)
PreviewCase.DrawPoints:
DebugDraw3D.draw_points(path, DebugDraw3D.POINT_TYPE_SQUARE, 0.15, Color.SLATE_BLUE)
Expand All @@ -348,7 +348,7 @@ func _process(delta):
var xf: Transform3D = %OriginInstances.global_transform
DebugDraw3D.draw_grid(xf.origin, xf.basis.x.rotated(xf.basis.z.normalized(), deg_to_rad(45)), xf.basis.y.rotated(xf.basis.z.normalized(), deg_to_rad(45)), Vector2i(2,2), Color.YELLOW_GREEN, true)
PreviewCase.DrawFrustum:
var _s = DebugDraw3D.new_scoped_config().set_thickness(0.015)
var _s = DebugDraw3D.new_scope_config().set_thickness(0.015)
DebugDraw3D.draw_camera_frustum($OriginCameraFrustum/Camera3D, Color.CORAL)


Expand Down
2 changes: 1 addition & 1 deletion docs/image_generator/preview_generator.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -2406,7 +2406,7 @@ grow_vertical = 2
script = ExtResource("1_1iqys")
preview_case = 4
anim_value_1 = 0.1
metadata/movie_file = "C:/My/Projects/GE/Addons/godot_debug_draw_3d/docs/images/temp/_.png"
metadata/movie_file = "C:/My/Projects/GE/Addons/godot_debug_draw_3d/docs/images/classes/temp/_.png"

[node name="FakeCamera" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -23, 0, -23)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added docs/images/project_settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 8 additions & 8 deletions examples_dd3d/DebugDrawDemoScene.gd
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ func main_update(delta: float) -> void:

DebugDraw3D.scoped_config().set_thickness(debug_thickness).set_center_brightness(debug_center_brightness)
if false: #test
var _s11 = DebugDraw3D.new_scoped_config().set_thickness(1)
var _s11 = DebugDraw3D.new_scope_config().set_thickness(1)
if true:
pass
var _s13 = DebugDraw3D.new_scoped_config()
var _s13 = DebugDraw3D.new_scope_config()
_s13.set_thickness(3)

_update_keys_just_press()
Expand Down Expand Up @@ -176,13 +176,13 @@ func main_update(delta: float) -> void:
# Spheres
DebugDraw3D.draw_sphere_xf($Spheres/SphereTransform.global_transform, Color.CRIMSON)
if true:
var _shd = DebugDraw3D.new_scoped_config().set_hd_sphere(true)
var _shd = DebugDraw3D.new_scope_config().set_hd_sphere(true)
DebugDraw3D.draw_sphere_xf($Spheres/SphereHDTransform.global_transform, Color.ORANGE_RED)

# Delayed spheres
if timer_1 < 0:
DebugDraw3D.draw_sphere($Spheres/SpherePosition.global_position, 2.0, Color.BLUE_VIOLET, 2.0)
var _shd = DebugDraw3D.new_scoped_config().set_hd_sphere(true)
var _shd = DebugDraw3D.new_scope_config().set_hd_sphere(true)
DebugDraw3D.draw_sphere($Spheres/SpherePosition.global_position + Vector3.FORWARD * 4, 2.0, Color.CORNFLOWER_BLUE, 2.0)
timer_1 = 2

Expand Down Expand Up @@ -261,11 +261,11 @@ func main_update(delta: float) -> void:
# Misc
if true:
#for i in 1000:
var _a11 = DebugDraw3D.new_scoped_config().set_thickness(0)
var _a11 = DebugDraw3D.new_scope_config().set_thickness(0)
DebugDraw3D.draw_camera_frustum($Camera, Color.DARK_ORANGE)

if true:
var _s123 = DebugDraw3D.new_scoped_config().set_center_brightness(0.1)
var _s123 = DebugDraw3D.new_scope_config().set_center_brightness(0.1)
DebugDraw3D.draw_arrowhead($Misc/Arrow.global_transform, Color.YELLOW_GREEN)

DebugDraw3D.draw_square($Misc/Billboard.global_position, 0.5, Color.GREEN)
Expand All @@ -275,7 +275,7 @@ func main_update(delta: float) -> void:
DebugDraw3D.draw_gizmo($Misc/GizmoTransform.global_transform, DebugDraw3D.empty_color, true)
DebugDraw3D.draw_gizmo($Misc/GizmoOneColor.global_transform, Color.BROWN, true)
if true:
var _s123 = DebugDraw3D.new_scoped_config().set_center_brightness(0.5)
var _s123 = DebugDraw3D.new_scope_config().set_center_brightness(0.5)
DebugDraw3D.draw_gizmo($Misc/GizmoNormal.global_transform.orthonormalized(), DebugDraw3D.empty_color, false)

var tg : Transform3D = $Grids/Grid.global_transform
Expand Down Expand Up @@ -398,7 +398,7 @@ func _more_tests():

# Delayed line render
if true:
var _a12 = DebugDraw3D.new_scoped_config().set_thickness(0.035)
var _a12 = DebugDraw3D.new_scope_config().set_thickness(0.035)
DebugDraw3D.draw_line($LagTest.global_position + Vector3.UP, $LagTest.global_position + Vector3(0,3,sin(Time.get_ticks_msec() / 50.0)), DebugDraw3D.empty_color, 0.5)


Expand Down
Loading

0 comments on commit de997c0

Please sign in to comment.